예제 #1
0
파일: main.cpp 프로젝트: snowpardx/parser
void main(int argc, const char *argv[]){
	try{
		setlocale(LC_ALL,"Russian");
		//debug_begin
		/*TESTS();
		return;*/
		//debug_end
		if (argc<2) {std::cerr<<"\nВы ввели неверный исходный файл.\n"; return;}
		analisator a(argv[1]);
		a.start();
		std::ofstream file;
		if (argc>2)
			file.open(argv[2],std::ios::out);
		else file.open("out.txt");
		if(!file)
			throw not_open();
		file<<a;

		std::ofstream syntax_out("syntax_output.txt");
		syntax_analiser SA;
		SA.start(a.get_list_of_lexical_covolution());
		syntax_out<<SA;
		std::cout<<"Анализ завершен."<<std::endl;
	}
	catch(not_open){
		std::cerr<<"Файл невозможно открыть.";
	}
}
예제 #2
0
파일: fzp.c 프로젝트: vanElden/burp
int fzp_printf(struct fzp *fzp, const char *format, ...)
{
	static char buf[4096];
	int ret=-1;
	va_list ap;
	va_start(ap, format);
	vsnprintf(buf, sizeof(buf), format, ap);

	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			ret=fprintf(fzp->fp, "%s", buf);
			break;
		case FZP_COMPRESSED:
			ret=gzprintf(fzp->zp, "%s", buf);
			break;
		default:
			unknown_type(fzp->type, __func__);
			break;
	}
	else
		not_open(__func__);
	va_end(ap);
	return ret;
}
예제 #3
0
파일: gvccmd.c 프로젝트: 131/gsview
/* if not DSC document or not open, display error message and return true */
BOOL
not_dsc()
{
    if (not_open())
        return TRUE;
    if (psfile.dsc!=(CDSC *)NULL)
        return FALSE;
    gserror(IDS_NOPAGE, NULL, MB_ICONEXCLAMATION, SOUND_NONUMBER);
    return TRUE;
}
예제 #4
0
파일: fzp.c 프로젝트: vanElden/burp
char *fzp_gets(struct fzp *fzp, char *s, int size)
{
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			return fgets(s, size, fzp->fp);
		case FZP_COMPRESSED:
			return gzgets(fzp->zp, s, size);
		default:
			unknown_type(fzp->type, __func__);
			goto error;
	}
	not_open(__func__);
error:
	return NULL;
}
예제 #5
0
파일: fzp.c 프로젝트: vanElden/burp
off_t fzp_tell(struct fzp *fzp)
{
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			return ftello(fzp->fp);
		case FZP_COMPRESSED:
			return gztell(fzp->zp);
		default:
			unknown_type(fzp->type, __func__);
			goto error;
	}
	not_open(__func__);
error:
	return -1;
}
예제 #6
0
파일: fzp.c 프로젝트: vanElden/burp
int fzp_flush(struct fzp *fzp)
{
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			return fflush(fzp->fp);
		case FZP_COMPRESSED:
			return gzflush(fzp->zp, Z_FINISH);
		default:
			unknown_type(fzp->type, __func__);
			goto error;
	}
	not_open(__func__);
error:
	return EOF;
}
예제 #7
0
파일: fzp.c 프로젝트: vanElden/burp
size_t fzp_write(struct fzp *fzp, const void *ptr, size_t nmemb)
{
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			return fwrite(ptr, 1, nmemb, fzp->fp);
		case FZP_COMPRESSED:
			return gzwrite(fzp->zp, ptr, (unsigned)nmemb);
		default:
			unknown_type(fzp->type, __func__);
			goto error;
	}
	not_open(__func__);
error:
	return 0;
}
예제 #8
0
파일: fzp.c 프로젝트: vanElden/burp
extern int fzp_fileno(struct fzp *fzp)
{
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			return fileno(fzp->fp);
		case FZP_COMPRESSED:
			logp("gzfileno() does not exist in %s\n", __func__);
			goto error;
		default:
			unknown_type(fzp->type, __func__);
			goto error;
	}
	not_open(__func__);
error:
	return -1;
}
예제 #9
0
파일: fzp.c 프로젝트: vanElden/burp
int fzp_eof(struct fzp *fzp)
{
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			return feof(fzp->fp);
		case FZP_COMPRESSED:
			return gzeof(fzp->zp);
		default:
			unknown_type(fzp->type, __func__);
			goto error;
	}
	not_open(__func__);
error:
	// Non-zero means end of file. Should be OK to use -1 here.
	return -1;
}
예제 #10
0
파일: fzp.c 프로젝트: vanElden/burp
X509 *fzp_PEM_read_X509(struct fzp *fzp)
{
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			return PEM_read_X509(fzp->fp, NULL, NULL, NULL);
		case FZP_COMPRESSED:
			logp("PEM_read_X509() does not exist in %s\n",
				__func__);
			goto error;
		default:
			unknown_type(fzp->type, __func__);
			goto error;
	}
	not_open(__func__);
error:
	return NULL;
}
예제 #11
0
파일: fzp.c 프로젝트: vanElden/burp
void fzp_setlinebuf(struct fzp *fzp)
{
#ifndef HAVE_WIN32
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			setlinebuf(fzp->fp);
			return;
		case FZP_COMPRESSED:
			logp("gzsetlinebuf() does not exist in %s\n", __func__);
			return;
		default:
			unknown_type(fzp->type, __func__);
			return;
	}
	not_open(__func__);
#endif
}
예제 #12
0
파일: fzp.c 프로젝트: vanElden/burp
int fzp_seek(struct fzp *fzp, off_t offset, int whence)
{
	if(fzp) switch(fzp->type)
	{
		case FZP_FILE:
			return fseeko(fzp->fp, offset, whence);
		case FZP_COMPRESSED:
			// Notice that gzseek returns the new offset.
			if(gzseek(fzp->zp, offset, whence)==offset)
				return 0;
			goto error;
		default:
			unknown_type(fzp->type, __func__);
			goto error;
	}
	not_open(__func__);
error:
	return -1;
}
예제 #13
0
void initBoxCapacitated(std::vector<Box*> &vectorBox, Data &data, std::vector<int> & sorted_fac)
{
    // sorted_fac is sorted by decreasing capacities
    std::sort( sorted_fac.begin(), sorted_fac.end(), compare_capacity(data) );

    // Compute the total demand
    double dtotal( 0 );
    for ( unsigned int i = 0; i < data.getnbCustomer(); ++i )
    {
        dtotal += data.getCustomer(i).getDemand();
    }

    // Compute the minimum number of facilities to open (left).
    double qminsum( 0 );
    unsigned int minfac( 0 );
    while ( minfac < sorted_fac.size() && qminsum < dtotal )
    {
        qminsum += data.getFacility(sorted_fac[minfac]).getCapacity();
        ++minfac;
    }

    // Check if the problem can be feasible
    if ( qminsum < dtotal )
    {
        std::cerr << "The problem is infeasible !" << std::endl;
        return;
    }

    // Compute the minimum number of facilities to open (right).
    double qmaxsum( 0 );
    unsigned int maxfac( sorted_fac.size() );
    while ( maxfac >= 0 && qmaxsum < dtotal )
    {
        --maxfac;
        qmaxsum += data.getFacility(sorted_fac[maxfac]).getCapacity();
    }

    for ( int it = 0; it < Argument::paving_directions; ++it )
    {
        // GRASP
        std::vector<bool> facilityOpen(data.getnbFacility(), false);
        std::vector<int> not_open( sorted_fac );
        double qsum( 0 ), alpha( 0.5 ),
               dir( (double)it / (double)(Argument::paving_directions - 1.) );

        while ( qsum < dtotal )
        {
            std::vector<double> u( not_open.size() );
            std::vector<int> RCL;
            double umin( std::numeric_limits<double>::infinity() ),
                   umax( -std::numeric_limits<double>::infinity() ),
                   ulimit;

            // Build utility function
            for ( unsigned int j = 0; j < not_open.size(); ++j )
            {
                double cost( 0 );
                if ( data.getNbObjective() > 2 )
                {
                    for ( int k = 0; k < data.getNbObjective(); ++k )
                    {
                        cost += data.getFacility( not_open[j] ).getLocationObjCost( k );
                    }
                }
                else
                {
                    cost = dir * data.getFacility( not_open[j] ).getLocationObjCost( 0 )
                           + ( 1. - dir ) * data.getFacility( not_open[j] ).getLocationObjCost( 1 );
                }

                u[j] = data.getFacility( not_open[j] ).getCapacity() / cost;
                if ( u[j] < umin ) umin = u[j];
                if ( u[j] > umax ) umax = u[j];
            }
            ulimit = umin + alpha * ( umax - umin );

            // Build RCL
            for ( unsigned int j = 0; j < u.size(); ++j )
            {
                if ( u[j] >= ulimit )
                {
                    RCL.push_back( j );
                }
            }

            // Select a random facility
            int r = std::rand() % RCL.size();

            // Open it
            facilityOpen[not_open[RCL[r]]] = true;
            qsum += data.getFacility( not_open[RCL[r]] ).getCapacity();
            not_open.erase( not_open.begin() + RCL[r] );
        }
        vectorBox.push_back( new Box(data, facilityOpen) );
    }
}
예제 #14
0
파일: gvccmd.c 프로젝트: 131/gsview
/* gsview menu commands */
int
gsview_command(int command)
{
    switch (command) {
    case IDM_NEXTHOME:
    case IDM_NEXT:
    case IDM_NEXTSKIP:
    case IDM_REDISPLAY:
    case IDM_PREVHOME:
    case IDM_PREVSKIP:
    case IDM_PREV:
    case IDM_GOBACK:
    case IDM_GOFWD:
    case IDM_MAGPLUS:
    case IDM_MAGMINUS:
    case IDM_FITWIN:
    case IDM_ZOOM:
    case IDM_FULLSCREEN:
        /* These don't close the full screen window */
        break;
    default:
        gsview_fullscreen_end();
    }
    switch (command) {
    case IDM_FULLSCREEN:
        gsview_fullscreen();
        return 0;
    case IDM_OPEN:
        if (pending.psfile) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        gsview_display();
        return 0;
    case IDM_LASTFILE1:
    case IDM_LASTFILE2:
    case IDM_LASTFILE3:
    case IDM_LASTFILE4:
        if (pending.psfile) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        make_cwd(last_files[command-IDM_LASTFILE1]);
        gsview_displayfile(last_files[command-IDM_LASTFILE1]);
        return 0;
    case IDM_CLOSE:
        /* doesn't unload DLL */
        /* close file */
        if (gsdll.open && (gsdll.state != GS_UNINIT)) {
            PSFILE *tpsfile;
            if (pending.psfile) {
                play_sound(SOUND_BUSY);
                return 0;
            }
            tpsfile = (PSFILE *)malloc(sizeof(PSFILE));
            if (tpsfile == NULL)
                return 0;
            memset((char *)tpsfile, 0, sizeof(PSFILE));
            pending.psfile = tpsfile;
            pending.now = TRUE;
            if (psfile.name[0] && psfile.dsc==(CDSC *)NULL)
                pending.abort = TRUE;
        }
        else {
            /* DLL isn't loaded */
            if (psfile.file)
                dfclose();	/* just to make sure */
            psfile_free(&psfile);
            post_img_message(WM_GSTITLE, 0);
            info_wait(IDS_NOWAIT);
        }
        return 0;
    case IDM_CLOSE_DONE:
        if (selectname[0] != '\0') {
            /* pending IDM_SELECT */
            PSFILE *tpsfile;
            tpsfile = gsview_openfile(selectname);
            if (tpsfile) {
                psfile = *tpsfile;
                free(tpsfile);
            }
            selectname[0] = '\0';
            post_img_message(WM_GSTITLE, 0);
            info_wait(IDS_NOWAIT);
        }
        return 0;
    case IDM_NEXTHOME:
#ifdef UNIX
        set_scroll(-1, 0);
#else
#ifdef _Windows
        PostMessage(hwnd_image ,WM_VSCROLL,SB_TOP,0L);
#else
        WinPostMsg(hwnd_frame, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_TOP));
#endif
#endif
    /* fall thru */
    case IDM_NEXT:
        if (not_open())
            return 0;
        gs_page_skip(1);
        return 0;
    case IDM_NEXTSKIP:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        gs_page_skip(page_skip);
        return 0;
    case IDM_REDISPLAY:
        if (dfchanged()) {
            PSFILE *tpsfile;
            if (dfchanged() < 0) {
                gs_addmess("File has been deleted\n");
                gsview_command(IDM_CLOSE);
                pending.unload = TRUE;
                pending.now = FALSE;
                return 0;
            }
            if (pending.psfile)
                tpsfile = pending.psfile;	/* new file, old file deleted */
            else
                tpsfile = gsview_openfile(psfile.name);
            if (tpsfile) {
                tpsfile->pagenum = psfile.pagenum;
                request_mutex();
                pending.psfile = tpsfile;
                if ( gsdll.hmodule &&  (psfile.dsc==(CDSC *)NULL) &&
                        (gsdll.state != GS_IDLE) )
                    /* don't know where we are so close and reopen */
                    pending.abort = TRUE;
                pending.now = TRUE;
                release_mutex();
            }
        }

        if (not_open())
            return 0;
        if (psfile.dsc==(CDSC *)NULL) {
            /* don't know where we are so close and reopen */
            if (gsdll.state != GS_IDLE) {
                if (!pending.psfile) {
                    pending.psfile = (PSFILE *)malloc(sizeof(PSFILE));
                    if (pending.psfile)
                        *pending.psfile = psfile;
                }
                pending.psfile->pagenum = pending.pagenum = 1;
                pending.abort = TRUE;
                pending.now = TRUE;
            }
        }
        else {
            pending.pagenum = -1;  /* default page number is current page */
            if (psfile.dsc->page_order == CDSC_SPECIAL)
                pending.pagenum = 1;	/* restart */
        }
        gsview_unzoom();
        pending.now = TRUE;
        return 0;
    case IDM_PREVHOME:
#ifdef UNIX
        set_scroll(-1, 0);
#else
#ifdef _Windows
        PostMessage(hwnd_image ,WM_VSCROLL,SB_TOP,0L);
#else
        WinPostMsg(hwnd_frame, WM_VSCROLL, MPFROMLONG(0), MPFROM2SHORT(0, SB_TOP));
#endif
#endif
    /* fall thru */
    case IDM_PREV:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        gs_page_skip(-1);
        return 0;
    case IDM_PREVSKIP:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        gs_page_skip(-page_skip);
        return 0;
    case IDM_GOTO:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        if (psfile.dsc->page_count == 0) {
            gserror(IDS_NOPAGE, NULL, MB_ICONEXCLAMATION, SOUND_NONUMBER);
            return 0;
        }
        nHelpTopic = IDS_TOPICGOTO;
        {   int pagenum;
            pagenum = psfile.pagenum;
            if (get_page(&pagenum, FALSE, FALSE)) {
                gsview_goto_page(pagenum);
            }
        }
        return 0;
    case IDM_GOBACK:
        if (not_dsc())
            return 0;
        if (order_is_special())
            return 0;
        history_back();
        return 0;
    case IDM_GOFWD:
        if (not_open())
            return 0;
        if (psfile.dsc == (CDSC *)NULL)
            gsview_command(IDM_NEXT);
        else
            history_forward();
        return 0;
    case IDM_INFO:
        show_info();
        return 0;
    case IDM_SELECT:
        if (pending.psfile) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        gsview_select();
        return 0;
#ifndef VIEWONLY
    case IDM_PRINT:
    case IDM_PRINTTOFILE:
    case IDM_CONVERTFILE:
        if (psfile.name[0] == '\0')
            gsview_select();
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        if (dfreopen() != 0)
            return 0;
        if (command == IDM_PRINTTOFILE)
            option.print_to_file = TRUE;
        if (psfile.name[0] != '\0')
            gsview_print(command == IDM_CONVERTFILE);
        dfclose();
        return 0;
    case IDM_SPOOL:
        gsview_spool((char *)NULL, (char *)NULL);
        return 0;
    case IDM_SAVEAS:
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        if (psfile.name[0] == '\0')
            gsview_select();
        if (psfile.name[0] != '\0')
            gsview_saveas();
        return 0;
    case IDM_EXTRACT:
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        if (psfile.name[0] == '\0')
            gsview_select();
        if (order_is_special())
            return 0;
        if (psfile.name[0] != '\0')
            gsview_extract();
        return 0;
    case IDM_PSTOEDIT:
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        if (psfile.name[0] == '\0')
            gsview_select();
        (void)order_is_special();    /* warn, but allow it anyway */
        if (dfreopen() != 0)
            return 0;
        if (psfile.name[0] != '\0')
            gsview_pstoedit();
        dfclose();
        return 0;
    case IDM_TEXTEXTRACT:
        if (psfile.name[0] == '\0')
            gsview_select();
        if (psfile.name[0] != '\0')
            gsview_text_extract();
        return 0;
    case IDM_TEXTEXTRACT_SLOW:
        gsview_text_extract_slow();
        return 0;
    case IDM_TEXTFIND:
        gsview_text_find();
        return 0;
    case IDM_TEXTFINDNEXT:
        gsview_text_findnext();
        return 0;
    case IDM_COPYCLIP:
        copy_clipboard();
        return 0;
    case IDM_PASTETO:
        paste_to_file();
        return 0;
    case IDM_CONVERT:
        clip_convert();
        return 0;
    case IDM_MEASURE:
        if (gsdll.state == GS_BUSY) {
            play_sound(SOUND_BUSY);
            return 0;
        }
        measure_show();
        return 0;
#endif /* !VIEWONLY */
    case IDM_GSMESS:
        gs_showmess();	/* show messages from Ghostscript */
        return 0;
    case IDM_EXIT:
        if (print_count) {
            /* Still busy printing.  Warn user. */
            TCHAR buf[MAXSTR];
            load_string(IDS_BUSYPRINTING, buf,
                        sizeof(buf)/sizeof(TCHAR)-1);
            if (message_box(buf, MB_OKCANCEL) != IDOK)
                return 0;
        }
        post_img_message(WM_CLOSE, 0);
        return 0;
    case IDM_CFG:	/* Easy configure */
        config_wizard(TRUE);
        return 0;
    case IDM_GSCOMMAND:	/* Advanced configure */
        if (install_gsdll() && gsdll.open)
            pending.unload = TRUE;
        return 0;
    case IDM_UNITPT:
    case IDM_UNITMM:
    case IDM_UNITINCH:
        gsview_unit(command);
        return 0;
    case IDM_UNITFINE:
        option.unitfine = !option.unitfine;
        check_menu_item(IDM_UNITMENU, IDM_UNITFINE, option.unitfine);
        return 0;
    case IDM_LANGMENU+1:
    case IDM_LANGMENU+2:
    case IDM_LANGMENU+3:
    case IDM_LANGMENU+4:
    case IDM_LANGMENU+5:
    case IDM_LANGMENU+6:
    case IDM_LANGMENU+7:
    case IDM_LANGMENU+8:
    case IDM_LANGMENU+9:
    case IDM_LANGMENU+10:
    case IDM_LANGMENU+11:
    case IDM_LANGMENU+12:
    case IDM_LANGMENU+13:
    case IDM_LANGMENU+14:
    case IDM_LANGMENU+15:
    case IDM_LANGMENU+16:
    case IDM_LANGMENU+17:
    case IDM_LANGMENU+18:
    case IDM_LANGMENU+19:
        gsview_language(command);
        return 0;
    case IDM_SAFER:
        option.safer = !option.safer;
        check_menu_item(IDM_OPTIONMENU, IDM_SAFER, option.safer);
        return 0;
    case IDM_SAVEDIR:
        option.save_dir = !option.save_dir;
        check_menu_item(IDM_OPTIONMENU, IDM_SAVEDIR, option.save_dir);
        return 0;
    case IDM_BUTTONSHOW:
        option.button_show = !option.button_show;
        check_menu_item(IDM_OPTIONMENU, IDM_BUTTONSHOW, option.button_show);
        show_buttons();
        return 0;
    case IDM_FITPAGE:
        option.fit_page = !option.fit_page;
        check_menu_item(IDM_OPTIONMENU, IDM_FITPAGE, option.fit_page);
        /* should cause WM_SIZE message to be sent */
        return 0;
    case IDM_PSTOTEXTDIS:
    case IDM_PSTOTEXTNORM:
    case IDM_PSTOTEXTCORK:
        check_menu_item(IDM_PSTOTEXTMENU, option.pstotext + IDM_PSTOTEXTMENU + 1, FALSE);
        option.pstotext = command - IDM_PSTOTEXTMENU - 1;
        check_menu_item(IDM_PSTOTEXTMENU, option.pstotext + IDM_PSTOTEXTMENU + 1, TRUE);
        return 0;
    case IDM_AUTOREDISPLAY:
        option.redisplay = !option.redisplay;
        check_menu_item(IDM_OPTIONMENU, IDM_AUTOREDISPLAY, option.redisplay);
        return 0;
    case IDM_EPSFCLIP:
        option.epsf_clip = !option.epsf_clip;
        check_menu_item(IDM_OPTIONMENU, IDM_EPSFCLIP, option.epsf_clip);
        gs_resize();
        return 0;
    case IDM_EPSFWARN:
        option.epsf_warn = !option.epsf_warn;
        check_menu_item(IDM_OPTIONMENU, IDM_EPSFWARN, option.epsf_warn);
        return 0;
    case IDM_IGNOREDSC:
        option.ignore_dsc = !option.ignore_dsc;
        check_menu_item(IDM_OPTIONMENU, IDM_IGNOREDSC, option.ignore_dsc);
        if (psfile.name[0]) {
            if (option.redisplay)
                gsview_displayfile(psfile.name);
            else
                gsview_selectfile(psfile.name);
        }
        return 0;
    case IDM_SHOWBBOX:
        option.show_bbox = !option.show_bbox;
        check_menu_item(IDM_OPTIONMENU, IDM_SHOWBBOX, option.show_bbox);
#ifdef UNIX
        gtk_widget_draw(img, NULL);
#else
#ifdef _Windows
        PostMessage(hwndimg, WM_GSSYNC, 0, 0L);
#else
        if (!WinInvalidateRect(hwnd_bmp, (PRECTL)NULL, TRUE))
            error_message("error invalidating rect");
        if (!WinUpdateWindow(hwnd_bmp))
            error_message("error updating window");
#endif
#endif
        return 0;
#ifndef VIEWONLY
    case IDM_PSTOEPS:
        if (not_open())
            return 0;
        if (psfile.name[0] != '\0') {
            if (dfreopen() != 0)
                return 0;
            ps_to_eps();
            dfclose();
        }
        return 0;
    case IDM_MAKEEPSI:
        if ( (option.orientation == IDM_PORTRAIT) ||
                (option.auto_orientation == TRUE) ) {
            char epsname[MAXSTR];
            epsname[0] = '\0';
            if (dfreopen() != 0)
                return 0;
            if (!get_filename(epsname, TRUE, FILTER_EPS, 0,
                              IDS_TOPICPREVIEW)) {
                dfclose();
                return 0;
            }
            image_lock(view.img);
            make_eps_interchange(FALSE, epsname);
            image_unlock(view.img);
            dfclose();
        }
        else
            gserror(IDS_MUSTUSEPORTRAIT, 0, MB_ICONEXCLAMATION, 0);
        return 0;
    case IDM_MAKEEPST4:
    case IDM_MAKEEPST6U:
    case IDM_MAKEEPST6P:
        if ( (option.orientation == IDM_PORTRAIT) ||
                (option.auto_orientation == TRUE) ) {
            char epsname[MAXSTR];
            epsname[0] = '\0';
            if (dfreopen() != 0)
                return 0;
            if (!get_filename(epsname, TRUE, FILTER_EPS, 0,
                              IDS_TOPICPREVIEW)) {
                dfclose();
                return 0;
            }
            image_lock(view.img);
            make_eps_tiff(command, FALSE, epsname);
            image_unlock(view.img);
            dfclose();
        }
        else
            gserror(IDS_MUSTUSEPORTRAIT, 0, MB_ICONEXCLAMATION, 0);
        return 0;
    case IDM_MAKEEPSW:
        if ( (option.orientation == IDM_PORTRAIT) ||
                (option.auto_orientation == TRUE) ) {
            char epsname[MAXSTR];
            epsname[0] = '\0';
            if (dfreopen() != 0)
                return 0;
            if (!get_filename(epsname, TRUE, FILTER_EPS, 0,
                              IDS_TOPICPREVIEW)) {
                dfclose();
                return 0;
            }
            image_lock(view.img);
            make_eps_metafile(FALSE, epsname);
            image_unlock(view.img);
            dfclose();
        }
        else
            gserror(IDS_MUSTUSEPORTRAIT, 0, MB_ICONEXCLAMATION, 0);
        return 0;
    case IDM_MAKEEPSU:
        if (dfreopen() != 0)
            return 0;
        make_eps_user();
        dfclose();
        return 0;
    case IDM_EXTRACTPS:
    case IDM_EXTRACTPRE:
        if (dfreopen() != 0)
            return 0;
        extract_doseps(command);
        dfclose();
        return 0;
#endif
    case IDM_SETTINGS:
        write_profile();
        return 0;
    case IDM_SAVESETTINGS:
        option.settings = !option.settings;
        check_menu_item(IDM_OPTIONMENU, IDM_SAVESETTINGS, option.settings);
        {   char buf[MAXSTR];
            PROFILE *prf = profile_open(szIniFile);
            sprintf(buf, "%d", (int)option.settings);
            profile_write_string(prf, INISECTION, "SaveSettings", buf);
            profile_close(prf);
        }
        return 0;
    case IDM_SOUNDS:
        change_sounds();
        return 0;
    case IDM_AUTOORIENT:
    case IDM_PORTRAIT:
    case IDM_LANDSCAPE:
    case IDM_UPSIDEDOWN:
    case IDM_SEASCAPE:
    case IDM_SWAPLANDSCAPE:
        gsview_orientation(command);
        return 0;
    case IDM_DSC_OFF:
    case IDM_DSC_ERROR:
    case IDM_DSC_WARN:
    case IDM_DSC_INFO:
        check_menu_item(IDM_DSCMENU, option.dsc_warn, FALSE);
        option.dsc_warn = command;
        check_menu_item(IDM_DSCMENU, option.dsc_warn, TRUE);
        return 0;
    case IDM_ZOOM:		/* called indirectly from Right Mouse Button */
        if (not_dsc()) {
            zoom = FALSE;
            return 0;
        }
        if (order_is_special()) {
            zoom = FALSE;
            return 0;
        }
        if (! ((gsdll.state == GS_PAGE) || (gsdll.state == GS_IDLE)) ) {
            zoom = FALSE;
            gserror(IDS_NOZOOM, NULL, MB_ICONEXCLAMATION, SOUND_ERROR);
            return 0;
        }
        gs_resize();
        pending.pagenum = -1;  /* default page number is current page */
        pending.now = TRUE;
        return 0;
    case IDM_MAGPLUS:
        gs_magnify((float)1.2);
        return 0;
    case IDM_MAGMINUS:
        gs_magnify((float)0.8333);
        return 0;
    case IDM_FITWIN:
        /* fit media to size of current window */
        gsview_fitwin();
        return 0;
    case IDM_DISPLAYSETTINGS:
        display_settings();
        return 0;
    case IDM_MEDIAROTATE:
        option.media_rotate = !option.media_rotate;
        check_menu_item(IDM_MEDIAMENU, IDM_MEDIAROTATE,
                        option.media_rotate);
        zoom = FALSE;
        gs_resize();
        return 0;
    case IDM_11x17:
    case IDM_A3:
    case IDM_A4:
    case IDM_A5:
    case IDM_B4:
    case IDM_B5:
    case IDM_LEDGER:
    case IDM_LEGAL:
    case IDM_LETTER:
    case IDM_NOTE:
    case IDM_USERSIZE:
    case IDM_USERSIZE1:
    case IDM_USERSIZE2:
    case IDM_USERSIZE3:
    case IDM_USERSIZE4:
    case IDM_USERSIZE5:
    case IDM_USERSIZE6:
    case IDM_USERSIZE7:
    case IDM_USERSIZE8:
    case IDM_USERSIZE9:
    case IDM_USERSIZE10:
    case IDM_USERSIZE11:
    case IDM_USERSIZE12:
    case IDM_USERSIZE13:
        if (command == IDM_USERSIZE)
            if (!gsview_usersize())
                return 0;
        gsview_media(command);
        return 0;
    case IDM_HELPCONTENT:
#ifdef UNIX
        nHelpTopic = IDS_TOPICROOT;
        get_help();
#else
#ifdef _Windows
#ifdef USE_HTMLHELP
        nHelpTopic = IDS_TOPICROOT;
        get_help();
#else
        WinHelp(hwndimg,szHelpName,HELP_CONTENTS,(DWORD)NULL);
#endif
#else
        WinSendMsg(hwnd_help, HM_HELP_CONTENTS, 0L, 0L);
#endif
#endif
        return 0;
    case IDM_HELPSEARCH:
#ifdef UNIX
        gs_addmess("IDM_HELPSEARCH: not implemented\n");
#else
#ifdef _Windows
#ifdef USE_HTMLHELP
        HtmlHelp(hwndimg,szHelpName,HH_DISPLAY_INDEX, (DWORD)TEXT(""));
        gs_addmessf("HtmlHelp: %s HH_DISPLAY_INDEX\n", szHelpName);
#else
        WinHelp(hwndimg,szHelpName,HELP_PARTIALKEY,(DWORD)"");
#endif
#else
        WinSendMsg(hwnd_help, HM_HELP_INDEX, 0L, 0L);
#endif
#endif
        return 0;
    case IDM_HELPKEYS:
        nHelpTopic = IDS_TOPICKEYS;
        get_help();
        return 0;
    case IDM_ABOUT:
        show_about();
        return 0;
    case IDM_REGISTER:
        registration_nag();
        return 0;
    }
    return 0;
}