9 static int exec_lp_cmd(
const char *cmd,
int test_default )
11 int have_default =
TRUE;
14 FILE *fp = popen( cmd,
"r" );
16 while( !feof( fp ) ) {
17 if( !fgets(
lp_buf, 256, fp ) ) {
18 if( test_default && have_default && (strlen(
lp_buf ) > 2) )
25 result = pclose( fp ) >> 8;
27 if( test_default && !have_default )
48 devInfo->
iPort = iPort;
50 if( devInfo->
iPort==0 ) {
54 filename = alloca( strlen(pszDeviceRaw) + 64 );
57 if( lpt_proto->
name && *lpt_proto->
name )
60 strcpy(filename,
"lpstat -v \"");
61 strcat(filename, lpt_proto->
name);
62 strcat(filename,
"\" 2>&1 ");
71 strcpy(filename,
"lp ");
72 strcat(filename,
"-d \"");
73 strcat(filename, lpt_proto->
name);
74 strcat(filename,
"\" ");
79 strcpy(filename,
"lpstat -d 2>&1");
87 strcpy(filename,
"lp ");
91 if( *lpt_proto->
title )
93 strcat(filename,
"-t \"");
94 strcat(filename, lpt_proto->
title);
95 strcat(filename,
"\"");
99 strcat(filename,
"-t \"FreeBASIC document\"");
103 strcat(filename,
" -s -");
107 while ((ptr = strpbrk(ptr,
"`&;|>^$\\")) !=
NULL)
112 strcat(filename,
" &> /dev/null");
114 fp = popen( filename,
"w" );
128 filename = alloca( 16 );
129 sprintf(filename,
"/dev/lp%d", (devInfo->
iPort-1));
130 fp = fopen(filename,
"wb");
142 if( lpt_proto!=
NULL )
151 if( fwrite( data, length, 1, fp ) != 1 ) {
163 char *temp = alloca( chars * 4 + 1 );
169 if( fwrite( temp, bytes, 1, fp ) != 1 )
178 if( devInfo->
iPort == 0 )
181 int result = ( pclose( (FILE *) devInfo->
driver_opaque ) >> 8 );