Пример #1
0
/**
** Higher-level interface: Output Enhanced META File format (-m emf)
**/
int to_emf(const GEN_PAR * pg, const OUT_PAR * po)
{
	HANDLE outDC;
	int err = 0;
	if (!pg->quiet)
		Eprintf("\n\n- Writing emf code to \"%s\"\n",
			*po->outfile == '-' ? "stdout" : po->outfile);

	/* Init.  */

	if (*po->outfile != '-') {
		if ((outDC =
		     CreateEnhMetaFile(NULL, po->outfile, NULL,
				       "hp2xx\0\0")) == 0) {
			PError("hp2xx (emf)");
			return ERROR;
		}
	} else {
		PError("hp2xx (Cant send metafile to stdout emf)");
		return ERROR;
	}
	SetMapMode(outDC, MM_ANISOTROPIC);
	SetViewportExtEx(outDC, 10, -10, NULL);	// size mult
	err = plotit(outDC, pg, po);
	CloseEnhMetaFile(outDC);

	if (!pg->quiet) {
		Eprintf("\nlines=%d moves=%d", lines, moves);
		Eprintf("\n");
	}
	return err;
}
Пример #2
0
/* data printout to file plotargs */
void
com_write_simple(wordlist *wl)
{
    char *fname = NULL;
    bool tempf = FALSE;

    if (wl) {
        fname = wl->wl_word;
        wl = wl->wl_next;
    }

    if (!wl)
        return;

    if (cieq(fname, "temp") || cieq(fname, "tmp")) {
        fname = smktemp("gp"); /* Is this the correct name ? */
        tempf = TRUE;
    }

    (void) plotit(wl, fname, "writesimple");

    /* Leave temp file sitting around so gnuplot can grab it from
       background. */
    if (tempf)
        tfree(fname);
}
Пример #3
0
/**
** Higher-level interface: Windows  print it  (-m emp)
**/
int to_emp(const GEN_PAR * pg, const OUT_PAR * po)
{
	DEVMODE *dev;
	PRINTDLG pd;
	DOCINFO di = { 0 };

	int xpix, ypix;		//DPI

	int yprinter, xprinter, err;
	// Initialize PRINTDLG
	ZeroMemory(&pd, sizeof(PRINTDLG));
	pd.lStructSize = sizeof(PRINTDLG);
	pd.hwndOwner = NULL;
	pd.hDevMode = NULL;	// Don't forget to free or store hDevMode
	pd.hDevNames = NULL;	// Don't forget to free or store hDevNames
	pd.Flags = PD_RETURNDEFAULT;	// gives default printer
	pd.nCopies = 1;
	pd.nFromPage = 0xFFFF;
	pd.nToPage = 0xFFFF;
	pd.nMinPage = 1;
	pd.nMaxPage = 0xFFFF;

	PrintDlg(&pd);		// first call to fill devmode struct from default printer

	dev = GlobalLock(pd.hDevMode);

	//Auto orient paper
	if (fabs(po->xmax - po->xmin) < fabs(po->ymax - po->ymin))
		dev->dmOrientation = DMORIENT_PORTRAIT;
	else
		dev->dmOrientation = DMORIENT_LANDSCAPE;
	GlobalUnlock(pd.hDevMode);
	pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;

	// now check which printer he wants
	if (PrintDlg(&pd) != TRUE)
		return 0;

	Eprintf("\n\n- Printing it -\n");
	GlobalFree(pd.hDevMode);
	GlobalFree(pd.hDevNames);

	xprinter = GetDeviceCaps(pd.hDC, HORZRES);	// papper width in pixels
	yprinter = GetDeviceCaps(pd.hDC, VERTRES);	// height in pixels
	xpix = GetDeviceCaps(pd.hDC, LOGPIXELSX);	// DPI x to be checked
	ypix = GetDeviceCaps(pd.hDC, LOGPIXELSY);	// DPI y
	// the following code is an attempt to compensate for printers with different
	// X and y resolution ( Not tested !!!)
	if (xpix < ypix) {
		xprinter = (int) (xprinter * ((float) xpix) / ypix);
	} else if (xpix > ypix) {
		yprinter = (int) (yprinter * ((float) ypix) / xpix);
	}
	SetScale(pd.hDC, yprinter, xprinter, po);

	di.cbSize = sizeof(DOCINFO);
	di.lpszDocName = "HPGL File";

	// Begin a print job by calling the StartDoc function.
	StartDoc(pd.hDC, &di);

	// Inform the driver that the application is about to begin
	// sending data.
	StartPage(pd.hDC);

	err = plotit(pd.hDC, pg, po);
	EndPage(pd.hDC);
	EndDoc(pd.hDC);

	DeleteDC(pd.hDC);
	if (!pg->quiet) {
		Eprintf("\nlines=%d moves=%d", lines, moves);
		Eprintf("\n");
	}
	return err;
}
Пример #4
0
//*******************************************************************
// Mesage handler for Preview Dialog.
static INT_PTR CALLBACK
Preview(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	static const GEN_PAR *pg;
	static const OUT_PAR *po;
	static int first = 1;

	switch (message) {
	case WM_INITDIALOG:
		{
			HMENU meny;
			PGPO *p = (PGPO *) lParam;
			po = p->po;	// save them for print/draw later on
			pg = p->pg;
			SetWindowText(hDlg, "Preview Enter to close");
			meny = GetSystemMenu(hDlg, 0);
			// add print item to bottom of system menu
			InsertMenu(meny, (unsigned) -1, MF_BYPOSITION,
				   PRINT, "Print");
		}
		return TRUE;
	case WM_SIZE:
		InvalidateRect(hDlg, 0, TRUE);	// redraw all
		return TRUE;

	case WM_SYSCOMMAND:
		if (LOWORD(wParam) == PRINT) {
			reset_tmpfile();	//rewind so i can reuse the data  (in hpgl.c)
			to_emp(pg, po);
			return TRUE;
		}
		return FALSE;

	case WM_COMMAND:
		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) {
			EndDialog(hDlg, LOWORD(wParam));
			return TRUE;
		}
		break;
	case WM_PAINT:
		{
			RECT rt;
			PAINTSTRUCT ps;
			HDC dc;
			dc = BeginPaint(hDlg, &ps);
			GetClientRect(hDlg, &rt);
			SetScale(dc, rt.bottom, rt.right, po);

			reset_tmpfile();	//rewind so i can redraw it in hpgl.c
			plotit(dc, pg, po);
			EndPaint(hDlg, &ps);
			if (first) {
				Eprintf("\nWaiting for preview to end\n");
				first = 0;
			}
		}
		return TRUE;
	case WM_ERASEBKGND:	// fix white background
		{
			RECT rt;
			GetClientRect(hDlg, &rt);
			rt.bottom += 1;
			rt.right += 1;
			FillRect((HDC) wParam, &rt,
				 GetStockObject(WHITE_BRUSH));
		}
		return TRUE;
	}
	return FALSE;
}
Пример #5
0
void IO_GO(int sig){
 syslog(LOG_ERR, "SIG IO SIG IO!!!!!!"); //Log it
mainfd = open_port();

        struct sockaddr_in clientName = { 0 };
        int BuffCount;  // Got Count 
	char Buff[1024]; //Buffer size 
        bzero(Buff,sizeof(Buff)); //Zero out the buffer
	int simpleChildSocket = 0;
        int clientNameLength = sizeof(clientName);
	int flag=0;
	char endL[3];
	char TempBuff[256];
	int TempCount;
	int returnstatus;
	bzero(endL,sizeof(endL));
	//transbridgeon(mainfd);
	sprintf(endL,"%c%c",end,0x82);

        simpleChildSocket = accept(simpleSocket,(struct sockaddr *)&clientName, &clientNameLength);

        if (simpleChildSocket == -1) {

            syslog(LOG_ERR, "Cannot accept connections!\n");
            close(simpleSocket);
            exit(1);

        }
        BuffCount=read(simpleChildSocket, Buff, 3);
	TempCount=sprintf(TempBuff,"%d",BuffCount);
        syslog(LOG_WARNING, "I read %d : %s",BuffCount,Buff);
	//trying a switch case to select the begining mode of the sign protocoll
	switch(Buff[0]){
	case 'A':// Sign Type, Sign Addr (last bit)
	startc(mainfd,Buff[1],Buff[2]);
        TempCount=sprintf(TempBuff,"CASE A");
	write(simpleChildSocket, TempBuff, strlen(TempBuff) );
	bzero(Buff,sizeof(Buff));

	break;
	case 'B': //simple mode 
	starttext(mainfd,'Z','0','A');
        TempCount=sprintf(TempBuff," CASE B");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
	bzero(Buff,sizeof(Buff));

	break;
	case 'C': //set 2 line mem
        TempCount=sprintf(TempBuff,"CASE C");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
    	syslog(LOG_ERR, "CASE C Buff1=%c",Buff[1]);
    	setmem(mainfd,Buff[1]);

        bzero(Buff,sizeof(Buff));

	flag =1;	// skip loop
	break;
	case 'D': //Single line set memory
        TempCount=sprintf(TempBuff,"CASE D");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));

 syslog(LOG_ERR, "CASE D"); //Log it

	slsetmem(mainfd,Buff[1]);
	bzero(Buff,sizeof(Buff));
	 syslog(LOG_ERR, "End of Case D"); //Log it


	flag =1;
	break;
	case 'P': 
	plotit();
	flag=1;
	break;
	case 'X':
	 TempCount=sprintf(TempBuff,"CASE X");
        write(simpleChildSocket, TempBuff, strlen(TempBuff));
        bzero(Buff,sizeof(Buff));
	break;
	}
       while(flag != 1){

	BuffCount=read(simpleChildSocket, Buff, sizeof(Buff));
	if(DEBUG == 1)
	syslog(LOG_WARNING, "I read %d : %s",BuffCount,Buff);	
		if(endsearch(Buff)==1 )
		{
			flag=1;
		}
		if(BuffCount == 0){
			flag =1;
		}
        /* handle the new connection request  */
        /* write out our message to the client */

			write(mainfd,Buff,strlen(Buff));
			bzero(Buff,sizeof(Buff));
/* OLD CODE SNIPPIT
        write(simpleChildSocket, ACKMESSAGE, strlen(ACKMESSAGE));
        close(simpleChildSocket);
        transbridgeon(mainfd);
        write(mainfd,Buff,strlen(Buff));
        transbridgeoff(mainfd);

*/
	}
	//transbridgeoff(mainfd);
	        write(simpleChildSocket, ACKMESSAGE, strlen(ACKMESSAGE));

	close(simpleChildSocket);
	close(mainfd);
	flag = 0;
	usleep(250);


}