1997-10-29 02:58:31 +03:00
/*
Unix SMB / Netbios implementation .
Version 1.9 .
Create printer definition files .
1998-01-22 16:27:43 +03:00
Copyright ( C ) Jean - Francois . Micouleau @ utc . fr , 10 / 26 / 97 - 1998
1997-10-29 02:58:31 +03:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
/*
1998-01-01 16:55:28 +03:00
# define DEBUGIT
1997-10-29 02:58:31 +03:00
*/
1998-01-23 10:59:29 +03:00
1997-10-29 02:58:31 +03:00
char * files_to_copy ;
2000-02-15 22:36:47 +03:00
char * driverfile , * datafile , * helpfile , * languagemonitor , * datatype , * vendorsetup ;
1998-05-12 04:55:32 +04:00
char buffer [ 50 ] [ sizeof ( pstring ) ] ;
char sbuffer [ 50 ] [ sizeof ( pstring ) ] ;
char sub_dir [ 50 ] [ 2 ] [ sizeof ( pstring ) ] ;
1997-10-29 02:58:31 +03:00
1998-09-05 09:07:05 +04:00
static void usage ( char * name )
1997-10-29 02:58:31 +03:00
{
fprintf ( stderr , " %s: printer.def \" Printer Name \" \n " , name ) ;
}
1998-09-05 09:07:05 +04:00
static char * myfgets ( char * s , int n , FILE * stream )
1998-01-23 10:59:29 +03:00
{
char * LString1 ;
char * LString2 ;
char * temp ;
1998-05-12 04:55:32 +04:00
pstring String ;
pstring NewString ;
1998-01-23 10:59:29 +03:00
int i ;
fgets ( s , n , stream ) ;
1998-01-23 11:35:15 +03:00
while ( ( LString1 = strchr ( s , ' % ' ) ) ! = NULL ) {
1998-01-23 10:59:29 +03:00
if ( ! ( LString2 = strchr ( LString1 + 1 , ' % ' ) ) ) break ;
* LString2 = ' \0 ' ;
1998-05-12 04:55:32 +04:00
pstrcpy ( String , LString1 + 1 ) ;
1998-01-23 10:59:29 +03:00
i = 0 ;
while ( * sbuffer [ i ] ! = ' \0 ' ) {
if ( strncmp ( sbuffer [ i ] , String , strlen ( String ) ) = = 0 )
{
1998-05-12 04:55:32 +04:00
pstrcpy ( String , sbuffer [ i ] ) ;
1998-01-23 11:35:15 +03:00
if ( ( temp = strchr ( String , ' = ' ) ) ! = NULL ) + + temp ;
1998-05-12 04:55:32 +04:00
pstrcpy ( String , temp ) ;
1998-01-23 10:59:29 +03:00
break ;
}
i + + ;
}
* LString1 = ' \0 ' ;
1998-05-12 04:55:32 +04:00
pstrcpy ( NewString , s ) ;
pstrcat ( NewString , String ) ;
pstrcat ( NewString , LString2 + 1 ) ;
pstrcpy ( s , NewString ) ;
1998-01-23 10:59:29 +03:00
}
return ( s ) ;
}
1997-10-29 02:58:31 +03:00
/*
This function split a line in two parts
on both side of the equal sign
" entry=value "
*/
1998-09-05 09:07:05 +04:00
static char * scan ( char * chaine , char * * entry )
1997-10-29 02:58:31 +03:00
{
char * value ;
char * temp ;
int i = 0 ;
1998-05-12 04:55:32 +04:00
* entry = ( char * ) malloc ( sizeof ( pstring ) ) ;
value = ( char * ) malloc ( sizeof ( pstring ) ) ;
1998-09-29 03:55:09 +04:00
if ( * entry = = NULL | | value = = NULL ) {
fprintf ( stderr , " scan: malloc fail ! \n " ) ;
exit ( 1 ) ;
}
1998-05-12 04:55:32 +04:00
pstrcpy ( * entry , chaine ) ;
1997-10-29 02:58:31 +03:00
temp = chaine ;
while ( temp [ i ] ! = ' = ' & & temp [ i ] ! = ' \0 ' ) {
i + + ;
}
( * entry ) [ i ] = ' \0 ' ;
2000-02-15 22:36:47 +03:00
if ( temp [ i ] ! = ' \0 ' ) {
i + + ;
}
while ( temp [ i ] = = ' ' & & temp [ i ] ! = ' \0 ' ) {
i + + ;
}
pstrcpy ( value , temp + i ) ;
1997-10-29 02:58:31 +03:00
return ( value ) ;
}
1998-09-05 09:07:05 +04:00
static void build_subdir ( void )
1997-10-29 02:58:31 +03:00
{
int i = 0 ;
2000-02-15 22:36:47 +03:00
int j = 0 ;
1997-10-29 02:58:31 +03:00
char * entry ;
char * data ;
while ( * buffer [ i ] ! = ' \0 ' ) {
data = scan ( buffer [ i ] , & entry ) ;
1998-01-01 16:55:28 +03:00
# ifdef DEBUGIT
1997-10-29 02:58:31 +03:00
fprintf ( stderr , " \t entry=data %s:%s \n " , entry , data ) ;
# endif
2000-02-15 22:36:47 +03:00
j = strlen ( entry ) ;
while ( j ) {
if ( entry [ j - 1 ] ! = ' ' ) break ;
j - - ;
}
entry [ j ] = ' \0 ' ;
1997-10-29 02:58:31 +03:00
2000-02-15 22:36:47 +03:00
if ( strncmp ( data , " 11 " , 2 ) = = 0 ) {
1998-05-12 04:55:32 +04:00
pstrcpy ( sub_dir [ i ] [ 0 ] , entry ) ;
pstrcpy ( sub_dir [ i ] [ 1 ] , " " ) ;
1997-10-29 02:58:31 +03:00
}
2000-02-15 22:36:47 +03:00
if ( strncmp ( data , " 23 " , 2 ) = = 0 ) {
1998-05-12 04:55:32 +04:00
pstrcpy ( sub_dir [ i ] [ 0 ] , entry ) ;
pstrcpy ( sub_dir [ i ] [ 1 ] , " color \\ " ) ;
1997-10-29 02:58:31 +03:00
}
1998-01-01 16:55:28 +03:00
# ifdef DEBUGIT
1997-10-29 02:58:31 +03:00
fprintf ( stderr , " \t subdir %s:%s \n " , sub_dir [ i ] [ 0 ] , sub_dir [ i ] [ 1 ] ) ;
# endif
i + + ;
}
}
1998-01-23 10:59:29 +03:00
/*
Lockup Strings entry in a file
Return all the lines between the entry and the next one or the end of file
An entry is something between braces .
*/
1998-09-05 09:07:05 +04:00
static void lookup_strings ( FILE * fichier )
1998-01-23 10:59:29 +03:00
{
int found = 0 , pointeur = 0 , i = 0 ;
char * temp , * temp2 ;
1998-05-12 04:55:32 +04:00
temp = ( char * ) malloc ( sizeof ( pstring ) ) ;
temp2 = ( char * ) malloc ( sizeof ( pstring ) ) ;
1998-01-23 10:59:29 +03:00
1998-09-29 03:55:09 +04:00
if ( temp = = NULL | | temp2 = = NULL ) {
fprintf ( stderr , " lookup_strings: malloc fail ! \n " ) ;
exit ( 1 ) ;
}
1998-01-23 10:59:29 +03:00
* sbuffer [ 0 ] = ' \0 ' ;
1998-05-12 04:55:32 +04:00
pstrcpy ( temp2 , " [Strings] " ) ;
1998-01-23 10:59:29 +03:00
rewind ( fichier ) ;
# ifdef DEBUGIT
fprintf ( stderr , " \t Looking for Strings \n " ) ;
# endif
while ( ! feof ( fichier ) & & found = = 0 ) {
* temp = ' \0 ' ;
fgets ( temp , 255 , fichier ) ;
if ( strncmp ( temp , temp2 , strlen ( temp2 ) ) = = 0 ) found = 1 ;
}
while ( ! feof ( fichier ) & & found = = 1 ) {
* temp = ' \0 ' ;
fgets ( temp , 255 , fichier ) ;
if ( * temp = = ' [ ' ) {
found = 2 ;
* sbuffer [ pointeur ] = ' \0 ' ;
}
else {
1998-05-12 04:55:32 +04:00
pstrcpy ( sbuffer [ pointeur ] , temp ) ;
1998-01-23 10:59:29 +03:00
i = strlen ( sbuffer [ pointeur ] ) - 1 ;
while ( sbuffer [ pointeur ] [ i ] = = ' \r ' | | sbuffer [ pointeur ] [ i ] = = ' \n ' )
sbuffer [ pointeur ] [ i - - ] = ' \0 ' ;
pointeur + + ;
}
}
1999-12-13 16:27:58 +03:00
/* CCMRCF Mod, seg fault or worse if not found */
if ( pointeur = = 0 ) {
fprintf ( stderr , " Printer not found \t No [Strings] block in inf file \n " ) ;
exit ( 2 ) ;
}
1998-01-23 10:59:29 +03:00
# ifdef DEBUGIT
fprintf ( stderr , " \t \t Found %d entries \n " , pointeur - 1 ) ;
# endif
}
1997-10-29 02:58:31 +03:00
/*
Lockup an entry in a file
Return all the lines between the entry and the next one or the end of file
An entry is something between braces .
*/
1998-09-05 09:07:05 +04:00
static void lookup_entry ( FILE * fichier , char * chaine )
1997-10-29 02:58:31 +03:00
{
int found = 0 , pointeur = 0 , i = 0 ;
char * temp , * temp2 ;
1998-05-12 04:55:32 +04:00
temp = ( char * ) malloc ( sizeof ( pstring ) ) ;
temp2 = ( char * ) malloc ( sizeof ( pstring ) ) ;
1997-10-29 02:58:31 +03:00
1998-09-29 03:55:09 +04:00
if ( temp = = NULL | | temp2 = = NULL ) {
fprintf ( stderr , " lookup_entry: malloc fail ! \n " ) ;
exit ( 1 ) ;
}
1997-10-29 02:58:31 +03:00
* buffer [ 0 ] = ' \0 ' ;
1998-05-12 04:55:32 +04:00
pstrcpy ( temp2 , " [ " ) ;
pstrcat ( temp2 , chaine ) ;
pstrcat ( temp2 , " ] " ) ;
1997-10-29 02:58:31 +03:00
rewind ( fichier ) ;
1998-01-01 16:55:28 +03:00
# ifdef DEBUGIT
1997-10-29 02:58:31 +03:00
fprintf ( stderr , " \t Looking for %s \n " , chaine ) ;
# endif
while ( ! feof ( fichier ) & & found = = 0 ) {
* temp = ' \0 ' ;
1998-01-23 10:59:29 +03:00
myfgets ( temp , 255 , fichier ) ;
1997-10-29 02:58:31 +03:00
if ( strncmp ( temp , temp2 , strlen ( temp2 ) ) = = 0 ) found = 1 ;
}
while ( ! feof ( fichier ) & & found = = 1 ) {
* temp = ' \0 ' ;
1998-01-23 10:59:29 +03:00
myfgets ( temp , 255 , fichier ) ;
1997-10-29 02:58:31 +03:00
if ( * temp = = ' [ ' ) {
found = 2 ;
* buffer [ pointeur ] = ' \0 ' ;
}
else {
1998-05-12 04:55:32 +04:00
pstrcpy ( buffer [ pointeur ] , temp ) ;
1997-10-29 02:58:31 +03:00
i = strlen ( buffer [ pointeur ] ) - 1 ;
while ( buffer [ pointeur ] [ i ] = = ' \r ' | | buffer [ pointeur ] [ i ] = = ' \n ' )
buffer [ pointeur ] [ i - - ] = ' \0 ' ;
pointeur + + ;
}
}
1998-01-01 16:55:28 +03:00
# ifdef DEBUGIT
1997-10-29 02:58:31 +03:00
fprintf ( stderr , " \t \t Found %d entries \n " , pointeur - 1 ) ;
# endif
}
1998-09-05 09:07:05 +04:00
static char * find_desc ( FILE * fichier , char * text )
1997-10-29 02:58:31 +03:00
{
char * chaine ;
char * long_desc ;
char * short_desc ;
1997-11-17 22:16:38 +03:00
char * crap = NULL ;
1997-10-29 02:58:31 +03:00
char * p ;
int found = 0 ;
1998-05-12 04:55:32 +04:00
chaine = ( char * ) malloc ( sizeof ( pstring ) ) ;
long_desc = ( char * ) malloc ( sizeof ( pstring ) ) ;
short_desc = ( char * ) malloc ( sizeof ( pstring ) ) ;
1998-01-23 10:59:29 +03:00
if ( ! chaine | | ! long_desc | | ! short_desc ) {
1998-09-29 03:55:09 +04:00
fprintf ( stderr , " find_desc: Unable to malloc memory \n " ) ;
1998-01-23 10:59:29 +03:00
exit ( 1 ) ;
}
1997-10-29 02:58:31 +03:00
1998-01-23 10:59:29 +03:00
rewind ( fichier ) ;
1997-10-29 02:58:31 +03:00
while ( ! feof ( fichier ) & & found = = 0 )
{
1998-01-23 10:59:29 +03:00
myfgets ( chaine , 255 , fichier ) ;
1997-10-29 02:58:31 +03:00
long_desc = strtok ( chaine , " = " ) ;
1998-01-21 12:17:51 +03:00
crap = strtok ( NULL , " , \r " ) ;
1997-10-29 02:58:31 +03:00
p = long_desc ;
while ( * p ! = ' " ' & & * p ! = ' \0 ' )
p + + ;
if ( * p = = ' " ' & & * ( p + 1 ) ! = ' \0 ' ) p + + ;
long_desc = p ;
if ( * p ! = ' \0 ' )
{
p + + ;
while ( * p ! = ' \" ' )
p + + ;
* p = ' \0 ' ;
}
1998-01-01 16:55:28 +03:00
if ( ! strcmp ( text , long_desc ) )
found = 1 ;
1997-10-29 02:58:31 +03:00
}
free ( chaine ) ;
1998-01-01 16:55:28 +03:00
if ( ! found | | ! crap ) return ( NULL ) ;
1997-10-29 02:58:31 +03:00
while ( * crap = = ' ' ) crap + + ;
1998-05-12 04:55:32 +04:00
pstrcpy ( short_desc , crap ) ;
1998-01-01 16:55:28 +03:00
return ( short_desc ) ;
1997-10-29 02:58:31 +03:00
}
1998-09-05 09:07:05 +04:00
static void scan_copyfiles ( FILE * fichier , char * chaine )
1997-10-29 02:58:31 +03:00
{
char * part ;
1998-01-23 10:59:29 +03:00
char * mpart ;
1997-10-29 02:58:31 +03:00
int i ;
1998-05-12 04:55:32 +04:00
pstring direc ;
1998-01-01 16:55:28 +03:00
# ifdef DEBUGIT
1997-10-29 02:58:31 +03:00
fprintf ( stderr , " In scan_copyfiles Lookup up of %s \n " , chaine ) ;
# endif
1998-01-03 08:12:10 +03:00
fprintf ( stderr , " \n Copy the following files to your printer$ share location: \n " ) ;
1998-01-01 16:55:28 +03:00
part = strtok ( chaine , " , " ) ;
1997-10-29 02:58:31 +03:00
do {
/* If the entry start with a @ then it's a file to copy
else it ' s an entry refering to files to copy
the main difference is when it ' s an entry
you can have a directory to append before the file name
*/
if ( * part = = ' @ ' ) {
1998-01-01 16:55:28 +03:00
if ( strlen ( files_to_copy ) ! = 0 )
1998-05-12 04:55:32 +04:00
pstrcat ( files_to_copy , " , " ) ;
pstrcat ( files_to_copy , & part [ 1 ] ) ;
1998-01-03 08:12:10 +03:00
fprintf ( stderr , " %s \n " , & part [ 1 ] ) ;
1997-10-29 02:58:31 +03:00
} else {
lookup_entry ( fichier , part ) ;
i = 0 ;
1998-05-12 04:55:32 +04:00
pstrcpy ( direc , " " ) ;
1997-10-29 02:58:31 +03:00
while ( * sub_dir [ i ] [ 0 ] ! = ' \0 ' ) {
1998-01-01 16:55:28 +03:00
# ifdef DEBUGIT
1997-10-29 02:58:31 +03:00
fprintf ( stderr , " \t subdir %s:%s \n " , sub_dir [ i ] [ 0 ] , sub_dir [ i ] [ 1 ] ) ;
# endif
if ( strcmp ( sub_dir [ i ] [ 0 ] , part ) = = 0 )
2000-03-15 01:04:35 +03:00
pstrcpy ( direc , sub_dir [ i ] [ 1 ] ) ;
i + + ;
1997-10-29 02:58:31 +03:00
}
i = 0 ;
while ( * buffer [ i ] ! = ' \0 ' ) {
1998-01-23 10:59:29 +03:00
/*
* HP inf files have strange entries that this attempts to address
* Entries in the Copy sections normally have only a single file name
* on each line . I have seen the following format in various HP inf files :
*
* pscript . hlp = pscript . hl_
* hpdcmon . dll , hpdcmon . dl_
2000-03-15 01:04:35 +03:00
* MSVCRT . DLL , MSVCRT . DL_ , , 32
1998-01-23 10:59:29 +03:00
* ctl3dv2 . dll , ctl3dv2 . dl_ , ctl3dv2 . tmp
*
* In the first 2 cases you want the first file name - in the last case
* you only want the last file name ( at least that is what a Win95
2000-03-15 01:04:35 +03:00
* machine sent ) . In the third case you also want the first file name
* ( detect by the last component being just a number ? ) .
* This may still be wrong but at least I get the same list
1998-01-23 10:59:29 +03:00
* of files as seen on a printer test page .
*/
part = strchr ( buffer [ i ] , ' = ' ) ;
if ( part ) {
2000-03-15 01:04:35 +03:00
/*
* Case ( 1 ) eg . pscript . hlp = pscript . hl_ - chop after the first name .
*/
1998-01-23 10:59:29 +03:00
* part = ' \0 ' ;
2000-03-15 01:04:35 +03:00
/*
* Now move back to the start and print that .
*/
while ( - - part > buffer [ i ] ) {
if ( ( * part = = ' ' ) | | ( * part = = ' \t ' ) )
* part = ' \0 ' ;
else
break ;
}
} else {
part = strchr ( buffer [ i ] , ' , ' ) ;
if ( part ) {
/*
* Cases ( 2 - 4 )
*/
if ( ( mpart = strrchr ( part + 1 , ' , ' ) ) ! = NULL ) {
/*
* Second ' , ' - case 3 or 4.
* Check if the last part is just a number ,
* if so we need the first part .
*/
char * endptr = NULL ;
BOOL isnumber = False ;
mpart + + ;
( void ) strtol ( mpart , & endptr , 10 ) ;
isnumber = ( ( endptr > mpart ) & & isdigit ( * mpart ) ) ;
if ( ! isnumber )
pstrcpy ( buffer [ i ] , mpart + 1 ) ;
else
* part = ' \0 ' ;
} else {
* part = ' \0 ' ;
}
1998-01-23 10:59:29 +03:00
while ( - - part > buffer [ i ] )
if ( ( * part = = ' ' ) | | ( * part = = ' \t ' ) ) * part = ' \0 ' ;
else break ;
2000-03-15 01:04:35 +03:00
}
}
if ( * buffer [ i ] ! = ' ; ' ) {
2000-02-15 22:36:47 +03:00
if ( strlen ( files_to_copy ) ! = 0 )
pstrcat ( files_to_copy , " , " ) ;
2000-03-15 01:04:35 +03:00
pstrcat ( files_to_copy , direc ) ;
pstrcat ( files_to_copy , buffer [ i ] ) ;
fprintf ( stderr , " %s%s \n " , direc , buffer [ i ] ) ;
}
i + + ;
} /* end while */
1997-10-29 02:58:31 +03:00
}
1998-01-01 16:55:28 +03:00
part = strtok ( NULL , " , " ) ;
2000-03-15 01:04:35 +03:00
if ( part ) {
2000-02-15 22:36:47 +03:00
while ( * part = = ' ' & & * part ! = ' \0 ' ) {
2000-03-15 01:04:35 +03:00
part + + ;
2000-02-15 22:36:47 +03:00
}
2000-03-15 01:04:35 +03:00
}
} while ( part ! = NULL ) ;
1998-01-03 08:12:10 +03:00
fprintf ( stderr , " \n " ) ;
1997-10-29 02:58:31 +03:00
}
1998-09-05 09:07:05 +04:00
static void scan_short_desc ( FILE * fichier , char * short_desc )
1997-10-29 02:58:31 +03:00
{
int i = 0 ;
char * temp ;
1998-01-01 16:55:28 +03:00
char * copyfiles = 0 , * datasection = 0 ;
1997-10-29 02:58:31 +03:00
1998-01-01 16:55:28 +03:00
helpfile = 0 ;
languagemonitor = 0 ;
2000-02-15 22:36:47 +03:00
vendorsetup = 0 ;
1998-01-01 16:55:28 +03:00
datatype = " RAW " ;
1998-09-29 03:55:09 +04:00
if ( ( temp = ( char * ) malloc ( sizeof ( pstring ) ) ) = = NULL ) {
fprintf ( stderr , " scan_short_desc: malloc fail ! \n " ) ;
exit ( 1 ) ;
}
1997-10-29 02:58:31 +03:00
driverfile = short_desc ;
1998-01-01 16:55:28 +03:00
datafile = short_desc ;
1997-10-29 02:58:31 +03:00
lookup_entry ( fichier , short_desc ) ;
while ( * buffer [ i ] ! = ' \0 ' ) {
1998-01-01 16:55:28 +03:00
# ifdef DEBUGIT
1997-10-29 02:58:31 +03:00
fprintf ( stderr , " \t Lookup up of %s \n " , buffer [ i ] ) ;
# endif
1998-01-23 10:59:29 +03:00
if ( strncasecmp ( buffer [ i ] , " CopyFiles " , 9 ) = = 0 )
1998-01-01 16:55:28 +03:00
copyfiles = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " DataSection " , 11 ) = = 0 )
1998-01-01 16:55:28 +03:00
datasection = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " DataFile " , 8 ) = = 0 )
1998-01-01 16:55:28 +03:00
datafile = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " DriverFile " , 10 ) = = 0 )
1998-01-01 16:55:28 +03:00
driverfile = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " HelpFile " , 8 ) = = 0 )
1998-01-01 16:55:28 +03:00
helpfile = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " LanguageMonitor " , 15 ) = = 0 )
1998-01-01 16:55:28 +03:00
languagemonitor = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " DefaultDataType " , 15 ) = = 0 )
1998-01-01 16:55:28 +03:00
datatype = scan ( buffer [ i ] , & temp ) ;
2000-02-15 22:36:47 +03:00
else if ( strncasecmp ( buffer [ i ] , " VendorSetup " , 11 ) = = 0 )
vendorsetup = scan ( buffer [ i ] , & temp ) ;
1997-10-29 02:58:31 +03:00
i + + ;
}
1998-01-01 16:55:28 +03:00
if ( datasection ) {
lookup_entry ( fichier , datasection ) ;
i = 0 ;
while ( * buffer [ i ] ! = ' \0 ' ) {
# ifdef DEBUGIT
fprintf ( stderr , " \t Lookup up of %s \n " , buffer [ i ] ) ;
# endif
1998-01-23 10:59:29 +03:00
if ( strncasecmp ( buffer [ i ] , " CopyFiles " , 9 ) = = 0 )
1998-01-01 16:55:28 +03:00
copyfiles = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " DataSection " , 11 ) = = 0 )
1998-01-01 16:55:28 +03:00
datasection = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " DataFile " , 8 ) = = 0 )
1998-01-01 16:55:28 +03:00
datafile = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " DriverFile " , 10 ) = = 0 )
1998-01-01 16:55:28 +03:00
driverfile = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " HelpFile " , 8 ) = = 0 )
1998-01-01 16:55:28 +03:00
helpfile = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " LanguageMonitor " , 15 ) = = 0 )
1998-01-01 16:55:28 +03:00
languagemonitor = scan ( buffer [ i ] , & temp ) ;
1998-01-23 10:59:29 +03:00
else if ( strncasecmp ( buffer [ i ] , " DefaultDataType " , 15 ) = = 0 )
1998-01-01 16:55:28 +03:00
datatype = scan ( buffer [ i ] , & temp ) ;
2000-02-15 22:36:47 +03:00
else if ( strncasecmp ( buffer [ i ] , " VendorSetup " , 11 ) = = 0 )
vendorsetup = scan ( buffer [ i ] , & temp ) ;
1998-01-01 16:55:28 +03:00
i + + ;
}
}
1998-01-23 10:59:29 +03:00
if ( languagemonitor ) {
temp = strtok ( languagemonitor , " , " ) ;
1998-01-01 16:55:28 +03:00
if ( * temp = = ' " ' ) + + temp ;
1998-05-12 04:55:32 +04:00
pstrcpy ( languagemonitor , temp ) ;
1998-01-23 11:35:15 +03:00
if ( ( temp = strchr ( languagemonitor , ' " ' ) ) ! = NULL ) * temp = ' \0 ' ;
1998-01-01 16:55:28 +03:00
}
1997-10-29 02:58:31 +03:00
if ( i ) fprintf ( stderr , " End of section found \n " ) ;
1998-03-11 20:44:27 +03:00
fprintf ( stderr , " CopyFiles: %s \n " ,
copyfiles ? copyfiles : " (null) " ) ;
fprintf ( stderr , " Datasection: %s \n " ,
datasection ? datasection : " (null) " ) ;
fprintf ( stderr , " Datafile: %s \n " ,
datafile ? datafile : " (null) " ) ;
fprintf ( stderr , " Driverfile: %s \n " ,
driverfile ? driverfile : " (null) " ) ;
fprintf ( stderr , " Helpfile: %s \n " ,
helpfile ? helpfile : " (null) " ) ;
fprintf ( stderr , " LanguageMonitor: %s \n " ,
languagemonitor ? languagemonitor : " (null) " ) ;
2000-02-15 22:36:47 +03:00
fprintf ( stderr , " VendorSetup: %s \n " ,
vendorsetup ? vendorsetup : " (null) " ) ;
1997-10-29 02:58:31 +03:00
if ( copyfiles ) scan_copyfiles ( fichier , copyfiles ) ;
}
int main ( int argc , char * argv [ ] )
{
char * short_desc ;
FILE * inf_file ;
if ( argc ! = 3 )
{
usage ( argv [ 0 ] ) ;
return ( - 1 ) ;
}
1998-11-17 23:50:07 +03:00
inf_file = sys_fopen ( argv [ 1 ] , " r " ) ;
1997-10-29 02:58:31 +03:00
if ( ! inf_file )
{
fprintf ( stderr , " Description file not found, bye \n " ) ;
return ( - 1 ) ;
}
1998-01-23 10:59:29 +03:00
lookup_strings ( inf_file ) ;
1997-10-29 02:58:31 +03:00
short_desc = find_desc ( inf_file , argv [ 2 ] ) ;
if ( short_desc = = NULL )
{
fprintf ( stderr , " Printer not found \n " ) ;
return ( - 1 ) ;
}
else fprintf ( stderr , " Found:%s \n " , short_desc ) ;
lookup_entry ( inf_file , " DestinationDirs " ) ;
build_subdir ( ) ;
1998-09-29 03:55:09 +04:00
if ( ( files_to_copy = ( char * ) malloc ( 2048 * sizeof ( char ) ) ) = = NULL ) {
fprintf ( stderr , " %s: malloc fail. \n " , argv [ 0 ] ) ;
exit ( 1 ) ;
}
1998-01-01 16:55:28 +03:00
* files_to_copy = ' \0 ' ;
1997-10-29 02:58:31 +03:00
scan_short_desc ( inf_file , short_desc ) ;
1998-01-01 16:55:28 +03:00
fprintf ( stdout , " %s:%s:%s: " ,
argv [ 2 ] , driverfile , datafile ) ;
fprintf ( stdout , " %s: " ,
helpfile ? helpfile : " " ) ;
fprintf ( stdout , " %s: " ,
languagemonitor ? languagemonitor : " " ) ;
fprintf ( stdout , " %s: " , datatype ) ;
1997-10-29 02:58:31 +03:00
fprintf ( stdout , " %s \n " , files_to_copy ) ;
return 0 ;
}