#include "wresource.h"#include "wcommon.h"#include "Messages.h"#include "Warnings.h"#include "Errors.h"#include "win_mem_alloc.h"Include dependency graph for gvwprn.c:

Go to the source code of this file.
Defines | |
| #define | MAXSTR 256 |
| #define | PORT_BUF_SIZE 4096 |
| #define | PRINT_BUF_SIZE 16384u |
Functions | |
| char * | GetPrinterName (void) |
| BOOL | get_queuename (HINSTANCE hInstance, HWND hwnd, char *portname, char *queue) |
| int | gp_printfile (HINSTANCE hInstance, HWND hwnd, char *filename, char *port) |
Variables | |
| char | printer_port [32] |
| #define PRINT_BUF_SIZE 16384u |
| BOOL get_queuename | ( | HINSTANCE | hInstance, | |
| HWND | hwnd, | |||
| char * | portname, | |||
| char * | queue | |||
| ) |
Definition at line 38 of file gvwprn.c.
References FALSE, FREE, GetPrinterName(), NULL, PrinterName, and TRUE.
Referenced by gp_printfile().
00039 { 00040 char *PrinterName=NULL; 00041 00042 PrinterName=GetPrinterName(); 00043 if (strcmp(PrinterName,"EMPTY")==0) return FALSE; 00044 wsprintf(portname, "\\\\spool\\%s",PrinterName); 00045 if (PrinterName) { FREE(PrinterName); PrinterName=NULL;} 00046 00047 return TRUE; 00048 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* GetPrinterName | ( | void | ) |
Definition at line 601 of file TextToPrint.c.
References MALLOC, NULL, and PrinterName.
Referenced by get_queuename().
00602 { 00603 char *ReturnPrinterName=NULL; 00604 00605 ReturnPrinterName=MALLOC(strlen(PrinterName)*sizeof(char)); 00606 wsprintf(ReturnPrinterName,"%s",PrinterName); 00607 00608 return ReturnPrinterName; 00609 }
Here is the caller graph for this function:

| int gp_printfile | ( | HINSTANCE | hInstance, | |
| HWND | hwnd, | |||
| char * | filename, | |||
| char * | port | |||
| ) |
Definition at line 54 of file gvwprn.c.
References buffer, count, f(), FALSE, FREE, get_queuename(), MALLOC, MAXSTR, MSG_ERROR71, MSG_ERROR72, MSG_ERROR73, MSG_ERROR74, NULL, PRINT_BUF_SIZE, printer, sciprint(), and TRUE.
00055 { 00056 DWORD count; 00057 char *buffer; 00058 char portname[MAXSTR]; 00059 FILE *f; 00060 HANDLE printer; 00061 DOC_INFO_1 di; 00062 DWORD written; 00063 00064 if (!get_queuename (hInstance, hwnd, portname, port)) return FALSE; 00065 port = portname + 8; /* skip over \\spool\ */ 00066 00067 if ((buffer = MALLOC (PRINT_BUF_SIZE)) == (char *) NULL) return FALSE; 00068 if (filename != (char *) 0) 00069 { 00070 if ((f = fopen (filename, "rb")) == (FILE *) NULL) 00071 { 00072 FREE (buffer); 00073 return FALSE; 00074 } 00075 } 00076 else 00077 f = stdin; 00078 00079 /* open a printer */ 00080 if (!OpenPrinter (port, &printer, NULL)) 00081 { 00082 sciprint (MSG_ERROR71, port, GetLastError ()); 00083 FREE (buffer); 00084 return FALSE; 00085 } 00086 /* from here until ClosePrinter, should AbortPrinter on error */ 00087 00088 di.pDocName = filename; 00089 di.pOutputFile = NULL; 00090 di.pDatatype = "RAW"; /* for available types see EnumPrintProcessorDatatypes */ 00091 if (!StartDocPrinter (printer, 1, (LPBYTE) & di)) 00092 { 00093 sciprint (MSG_ERROR72, GetLastError ()); 00094 AbortPrinter (printer); 00095 FREE (buffer); 00096 return FALSE; 00097 } 00098 00099 while ((count = fread (buffer, 1, PRINT_BUF_SIZE, f)) != 0) 00100 { 00101 if (!WritePrinter (printer, (LPVOID) buffer, count, &written)) 00102 { 00103 FREE (buffer); 00104 fclose (f); 00105 AbortPrinter (printer); 00106 return FALSE; 00107 } 00108 } 00109 fclose (f); 00110 FREE (buffer); 00111 00112 if (!EndDocPrinter (printer)) 00113 { 00114 sciprint (MSG_ERROR73, GetLastError ()); 00115 AbortPrinter (printer); 00116 return FALSE; 00117 } 00118 00119 if (!ClosePrinter (printer)) 00120 { 00121 sciprint (MSG_ERROR74, GetLastError ()); 00122 return FALSE; 00123 } 00124 return TRUE; 00125 }
Here is the call graph for this function:

| char printer_port[32] |
1.5.1