summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1997-10-28 19:32:59 +0000
committerJeremy Allison <jra@samba.org>1997-10-28 19:32:59 +0000
commit8f0316bdbcba996d40ac152a9ac076a18b5dd7ec (patch)
tree0e0a909076478b8771c5da1518d18cb67125ed83
parent3c214a8fa16826c8c404dab3bc14d66d7dc18ec6 (diff)
downloadsamba-8f0316bdbcba996d40ac152a9ac076a18b5dd7ec.tar.gz
samba-8f0316bdbcba996d40ac152a9ac076a18b5dd7ec.tar.bz2
samba-8f0316bdbcba996d40ac152a9ac076a18b5dd7ec.zip
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)
-rw-r--r--source3/.cvsignore1
-rw-r--r--source3/include/proto.h3
-rw-r--r--source3/param/loadparm.c8
-rw-r--r--source3/smbd/ipc.c139
4 files changed, 145 insertions, 6 deletions
diff --git a/source3/.cvsignore b/source3/.cvsignore
index f6b77ee2f9..1e48a54175 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 db8674a5a1..9ebe15e99a 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 122e2f6649..db494711b6 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 0354b4ecbe..65f85719ae 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<count;i++)
fill_printjob_info(cnum,snum,uLevel == 2 ? 1 : 2,desc,&queue[i],i);
}
-
+
+ if (uLevel==52) {
+ int i,ok=0;
+ pstring tok,driver,short_name;
+ char *p,*q;
+ FILE *f;
+ pstring fname;
+
+ strcpy(fname,lp_driverfile());
+
+ f=fopen(fname,"r");
+ if (!f) {
+ DEBUG(0,("fill_printq_info: Can't open %s - %s\n",fname,strerror(errno)));
+ }
+
+ p=(char *)malloc(8192*sizeof(char));
+ bzero(p, 8192*sizeof(char));
+ q=p;
+
+ /* lookup the long printer driver name in the file description */
+ while (f && !feof(f) && !ok)
+ {
+ fgets(p,8191,f);
+ p[strlen(p)-1]='\0';
+ next_token(&p,tok,":");
+ if(!strncmp(tok,lp_printerdriver(snum),strlen(lp_printerdriver(snum)))) ok=1;
+ }
+
+ fclose(f);
+
+ next_token(&p,short_name,":");
+ next_token(&p,driver,":");
+
+ PACKI(desc,"W",0x0400); /* don't know */
+ PACKS(desc,"z",lp_printerdriver(snum)); /* long printer name */
+
+ if (ok)
+ {
+ PACKS(desc,"z",driver); /* Driver Name */
+ PACKS(desc,"z",short_name); /* short printer name */
+ DEBUG(3,("Driver:%s:\n",driver));
+ DEBUG(3,("short name:%s:\n",short_name));
+ }
+ else
+ {
+ PACKS(desc,"z","");
+ PACKS(desc,"z","");
+ }
+
+ PACKS(desc,"z","");
+ PACKS(desc,"z",lp_driverlocation(snum)); /* share to retrieve files */
+ PACKS(desc,"z","EMF");
+ PACKS(desc,"z","");
+ if (ok)
+ PACKS(desc,"z",driver); /* driver name */
+ else
+ PACKS(desc,"z","");
+ PACKI(desc,"N",count); /* number of files to copy */
+ for (i=0;i<count;i++)
+ {
+ next_token(&p,tok,",");
+ PACKS(desc,"z",tok); /* driver files to copy */
+ DEBUG(3,("file:%s:\n",tok));
+ }
+ free(q);
+ }
+
DEBUG(3,("fill_printq_info on <%s> 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;