From 8f0316bdbcba996d40ac152a9ac076a18b5dd7ec Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 28 Oct 1997 19:32:59 +0000 Subject: [PATCH] Adding Windows 95 printer driver code donated by Jean-Francois.Micouleau@utc.fr. New program, make_printerdef, plus two new parameters : [global] "printer driver file" [local] "printer driver location" Jeremy. (This used to be commit 9a5b42e6b3e7a35d56f81e9428fc747246e2fc5c) --- source3/.cvsignore | 1 + source3/include/proto.h | 3 + source3/param/loadparm.c | 8 +++ source3/smbd/ipc.c | 139 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 145 insertions(+), 6 deletions(-) diff --git a/source3/.cvsignore b/source3/.cvsignore index f6b77ee2f96..1e48a541752 100644 --- a/source3/.cvsignore +++ b/source3/.cvsignore @@ -2,6 +2,7 @@ Makefile.RPM makefile makefile.sunos5 make_smbcodepage +make_printerdef nmbd nmblookup smbclient diff --git a/source3/include/proto.h b/source3/include/proto.h index db8674a5a1c..9ebe15e99a8 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -159,6 +159,7 @@ struct in_addr *iface_ip(struct in_addr ip); /*The following definitions come from ipc.c */ +int get_printerdrivernumber(int snum); int reply_trans(char *inbuf,char *outbuf); /*The following definitions come from kanji.c */ @@ -203,6 +204,7 @@ char *lp_socket_address(void); char *lp_nis_home_map_name(void); char *lp_announce_version(void); char *lp_netbios_aliases(void); +char *lp_driverfile(void); char *lp_domain_sid(void); char *lp_domain_other_sids(void); char *lp_domain_groups(void); @@ -285,6 +287,7 @@ char *lp_volume(int ); char *lp_mangled_map(int ); char *lp_veto_files(int ); char *lp_hide_files(int ); +char *lp_driverlocation(int ); BOOL lp_alternate_permissions(int ); BOOL lp_revalidate(int ); BOOL lp_casesensitive(int ); diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 122e2f66492..db494711b6c 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -147,6 +147,7 @@ typedef struct char *szDomainSID; char *szDomainOtherSIDs; char *szDomainGroups; + char *szDriverFile; int max_log_size; int mangled_stack; int max_xmit; @@ -222,6 +223,7 @@ typedef struct char *szLpresumecommand; char *szPrintername; char *szPrinterDriver; + char *szPrinterDriverLocation; char *szDontdescend; char *szHostsallow; char *szHostsdeny; @@ -305,6 +307,7 @@ static service sDefault = NULL, /* szLpresumecommand */ NULL, /* szPrintername */ NULL, /* szPrinterDriver - this is set in init_globals() */ + NULL, /* szPrinterDriverLocation */ NULL, /* szDontdescend */ NULL, /* szHostsallow */ NULL, /* szHostsdeny */ @@ -494,6 +497,7 @@ struct parm_struct {"unix realname", P_BOOL, P_GLOBAL, &Globals.bUnixRealname, NULL}, {"NIS homedir", P_BOOL, P_GLOBAL, &Globals.bNISHomeMap, NULL}, {"time server", P_BOOL, P_GLOBAL, &Globals.bTimeServer, NULL}, + {"printer driver file", P_STRING, P_GLOBAL, &Globals.szDriverFile, NULL}, {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL}, {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL}, {"copy", P_STRING, P_LOCAL, &sDefault.szCopy, handle_copy}, @@ -576,6 +580,7 @@ struct parm_struct {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL}, {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL}, {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL}, + {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL}, {"hosts allow", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL}, {"allow hosts", P_STRING, P_LOCAL, &sDefault.szHostsallow, NULL}, {"hosts deny", P_STRING, P_LOCAL, &sDefault.szHostsdeny, NULL}, @@ -627,6 +632,7 @@ static void init_globals(void) string_set(&Globals.szWorkGroup, WORKGROUP); string_set(&Globals.szPasswdProgram, SMB_PASSWD); string_set(&Globals.szPrintcapname, PRINTCAP_NAME); + string_set(&Globals.szDriverFile, DRIVERFILE); string_set(&Globals.szLockDir, LOCKDIR); string_set(&Globals.szRootdir, "/"); string_set(&Globals.szSmbrun, SMBRUN); @@ -868,6 +874,7 @@ FN_GLOBAL_STRING(lp_socket_address,&Globals.szSocketAddress) FN_GLOBAL_STRING(lp_nis_home_map_name,&Globals.szNISHomeMapName) FN_GLOBAL_STRING(lp_announce_version,&Globals.szAnnounceVersion) FN_GLOBAL_STRING(lp_netbios_aliases,&Globals.szNetbiosAliases) +FN_GLOBAL_STRING(lp_driverfile,&Globals.szDriverFile) FN_GLOBAL_STRING(lp_domain_sid,&Globals.szDomainSID) FN_GLOBAL_STRING(lp_domain_other_sids,&Globals.szDomainOtherSIDs) @@ -954,6 +961,7 @@ FN_LOCAL_STRING(lp_volume,volume) FN_LOCAL_STRING(lp_mangled_map,szMangledMap) FN_LOCAL_STRING(lp_veto_files,szVetoFiles) FN_LOCAL_STRING(lp_hide_files,szHideFiles) +FN_LOCAL_STRING(lp_driverlocation,szPrinterDriverLocation) FN_LOCAL_BOOL(lp_alternate_permissions,bAlternatePerm) FN_LOCAL_BOOL(lp_revalidate,bRevalidate) diff --git a/source3/smbd/ipc.c b/source3/smbd/ipc.c index 0354b4ecbe8..65f85719ae4 100644 --- a/source3/smbd/ipc.c +++ b/source3/smbd/ipc.c @@ -462,6 +462,10 @@ static int check_printq_info(struct pack_desc* desc, case 5: desc->format = "z"; break; + case 52: + desc->format = "WzzzzzzzzN"; + desc->subformat = "z"; + break; default: return False; } if (strcmp(desc->format,id1) != 0) return False; @@ -521,11 +525,18 @@ static void fill_printq_info(int cnum, int snum, int uLevel, int count, print_queue_struct* queue, print_status_struct* status) { - if (uLevel < 3) { - PACKS(desc,"B13",SERVICE(snum)); - } else { - PACKS(desc,"z",Expand(cnum,snum,SERVICE(snum))); + switch (uLevel) { + case 1: + case 2: + PACKS(desc,"B13",SERVICE(snum)); + break; + case 3: + case 4: + case 5: + PACKS(desc,"z",Expand(cnum,snum,SERVICE(snum))); + break; } + if (uLevel == 1 || uLevel == 2) { PACKS(desc,"B",""); /* alignment */ PACKI(desc,"W",5); /* priority */ @@ -573,10 +584,119 @@ static void fill_printq_info(int cnum, int snum, int uLevel, for (i=0;i gave %d entries\n",SERVICE(snum),count)); } +/* This function returns the number of file for a given driver */ +int get_printerdrivernumber(int snum) +{ + int i=0,ok=0; + pstring tok; + char *p,*q; + FILE *f; + pstring fname; + + strcpy(fname,lp_driverfile()); + + DEBUG(4,("In get_printerdrivernumber: %s\n",fname)); + f=fopen(fname,"r"); + if (!f) { + DEBUG(0,("get_printerdrivernumber: Can't open %s - %s\n",fname,strerror(errno))); + return(0); + } + + p=(char *)malloc(8192*sizeof(char)); + q=p; /* need it to free memory because p change ! */ + + /* lookup the long printer driver name in the file description */ + while (!feof(f) && !ok) + { + fgets(p,8191,f); + next_token(&p,tok,":"); + if(!strncmp(tok,lp_printerdriver(snum),strlen(lp_printerdriver(snum)))) ok=1; + } + + if (ok) { + /* skip 2 fields */ + next_token(&p,tok,":"); /* short name */ + next_token(&p,tok,":"); /* driver name */ + /* count the number of files */ + while (next_token(&p,tok,",")) + i++; + } + fclose(f); + free(q); + + return(i); +} + static BOOL api_DosPrintQGetInfo(int cnum,uint16 vuid, char *param,char *data, int mdrcnt,int mprcnt, char **rdata,char **rparam, @@ -622,7 +742,14 @@ static BOOL api_DosPrintQGetInfo(int cnum,uint16 vuid, char *param,char *data, if (snum < 0 || !VALID_SNUM(snum)) return(False); - count = get_printqueue(snum,cnum,&queue,&status); + if (uLevel==52) + { + count = get_printerdrivernumber(snum); + DEBUG(3,("api_DosPrintQGetInfo: Driver files count: %d\n",count)); + } + else + count = get_printqueue(snum,cnum,&queue,&status); + if (mdrcnt > 0) *rdata = REALLOC(*rdata,mdrcnt); desc.base = *rdata; desc.buflen = mdrcnt;