Patch from Chris Maltby <chris@softway.com.au>. His comments follow:
authorJeremy Allison <jra@samba.org>
Thu, 2 Apr 1998 01:01:24 +0000 (01:01 +0000)
committerJeremy Allison <jra@samba.org>
Thu, 2 Apr 1998 01:01:24 +0000 (01:01 +0000)
  + improvement to smbtar to allow exclusion/inclusion of system and
    hidden files, and to generate a listing of what has been archived
    in a format useful for automated backup systems.

  + add the "Softq" spooling system to samba's printing capabilities.

  + I have "fixed" the intrusion of US style dates into samba reporting
    as well. The format yyyy/mm/dd is not only uunambiguous, but also
    has the benefit of making lexicographic sorts work correctly.

Jeremy.

source/client/clitar.c
source/include/smb.h
source/lib/time.c
source/param/loadparm.c
source/printing/printing.c

index ccaab486d0f6f4183031729650b60d17abe57b38..36cefeec557b1bf77fc70b8944b0d539ea1e1936 100644 (file)
@@ -48,6 +48,13 @@ BOOL tar_inc=False;
 BOOL tar_reset=False;
 /* Include / exclude mode (true=include, false=exclude) */
 BOOL tar_excl=True;
+/* Dump files with System attribute */
+BOOL tar_system=False;
+/* Dump files with Hidden attribute */
+BOOL tar_hidden=True;
+/* Be noisy - make a catalogue */
+BOOL tar_noisy=True;
+
 char tar_type='\0';
 static char **cliplist=NULL;
 static int clipn=0;
@@ -856,6 +863,16 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
       DEBUG(4, ("skipping %s - archive bit not set\n", finfo.name));
       shallitime=0;
     }
+  else if (!tar_system && (finfo.mode & aSYSTEM))
+    {
+      DEBUG(4, ("skipping %s - system bit is set\n", finfo.name));
+      shallitime=0;
+    }
+  else if (!tar_hidden && (finfo.mode & aHIDDEN))
+    {
+      DEBUG(4, ("skipping %s - hidden bit is set\n", finfo.name));
+      shallitime=0;
+    }
   else
     {
       if (SVAL(inbuf,smb_vwv0) == SMBreadX)
@@ -870,7 +887,7 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
          datalen = 0;
        }
 
-      DEBUG(1,("getting file %s of size %d bytes as a tar file %s",
+      DEBUG(2,("getting file %s of size %d bytes as a tar file %s",
               finfo.name,
               finfo.size,
               lname));
@@ -1135,9 +1152,16 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
       get_total_size += finfo.size;
 
       /* Thanks to Carel-Jan Engel (ease@mail.wirehub.nl) for this one */
-      DEBUG(1,("(%g kb/s) (average %g kb/s)\n",
+      DEBUG(2,("(%g kb/s) (average %g kb/s)\n",
               finfo.size / MAX(0.001, (1.024*this_time)),
               get_total_size / MAX(0.001, (1.024*get_total_time_ms))));
+      if (tar_noisy)
+       {
+         printf("%10d (%7.1f kb/s) %s\n",
+              finfo.size, finfo.size / MAX(0.001, (1.024*this_time)),
+               finfo.name);
+       }
+
     }
   
   free(inbuf);free(outbuf);
@@ -1456,7 +1480,7 @@ void cmd_block(void)
     }
 
   blocksize=block;
-  DEBUG(1,("blocksize is now %d\n", blocksize));
+  DEBUG(2,("blocksize is now %d\n", blocksize));
 }
 
 /****************************************************************************
@@ -1475,12 +1499,28 @@ void cmd_tarmode(void)
       tar_reset=True;
     else if (strequal(buf, "noreset"))
       tar_reset=False;
+    else if (strequal(buf, "system"))
+      tar_system=True;
+    else if (strequal(buf, "nosystem"))
+      tar_system=False;
+    else if (strequal(buf, "hidden"))
+      tar_hidden=True;
+    else if (strequal(buf, "nohidden"))
+      tar_hidden=False;
+    else if (strequal(buf, "verbose") || strequal(buf, "noquiet"))
+      tar_noisy=True;
+    else if (strequal(buf, "quiet") || strequal(buf, "noverbose"))
+      tar_noisy=False;
     else DEBUG(0, ("tarmode: unrecognised option %s\n", buf));
   }
 
-  DEBUG(0, ("tarmode is now %s, %s\n",
+  DEBUG(0, ("tarmode is now %s, %s, %s, %s, %s\n",
            tar_inc ? "incremental" : "full",
-           tar_reset ? "reset" : "noreset"));
+           tar_system ? "system" : "nosystem",
+           tar_hidden ? "hidden" : "nohidden",
+           tar_reset ? "reset" : "noreset",
+           tar_noisy ? "verbose" : "quiet"));
+
 }
 
 /****************************************************************************
@@ -1533,7 +1573,7 @@ void cmd_setmode(void)
       return;
     }
 
-  DEBUG(1, ("\nperm set %d %d\n", attra[ATTRSET], attra[ATTRRESET]));
+  DEBUG(2, ("\nperm set %d %d\n", attra[ATTRSET], attra[ATTRRESET]));
   (void) do_setrattr(fname, attra[ATTRSET], ATTRSET);
   (void) do_setrattr(fname, attra[ATTRRESET], ATTRRESET);
 }
index 0acc5cbfa340f79981fe8a7a8f80de20ec278186..88d9a9de0959ca385a261bb4dbcf3196064e98cc 100644 (file)
@@ -1064,7 +1064,7 @@ enum security_types {SEC_SHARE,SEC_USER,SEC_SERVER};
 
 /* printing types */
 enum printing_types {PRINT_BSD,PRINT_SYSV,PRINT_AIX,PRINT_HPUX,
-                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG};
+                    PRINT_QNX,PRINT_PLP,PRINT_LPRNG,PRINT_SOFTQ};
 
 /* Remote architectures we know about. */
 enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT, RA_SAMBA};
index 050b4725a79a40e7afb18ccd99a5a2c0de2ee416..716f5d62cc66db6cdda1960c8912f752371214e5 100644 (file)
@@ -478,19 +478,19 @@ char *timestring(void )
 #ifdef NO_STRFTIME
   fstrcpy(TimeBuf, asctime(tm));
 #elif defined(CLIX) || defined(CONVEX)
-  strftime(TimeBuf,100,"%m/%d/%Y %I:%M:%S %p",tm);
+  strftime(TimeBuf,100,"%Y/%m/%d %I:%M:%S %p",tm);
 #elif defined(AMPM)
-  strftime(TimeBuf,100,"%m/%d/%Y %r",tm);
+  strftime(TimeBuf,100,"%Y/%m/%d %r",tm);
 #elif defined(TZ_TIME)
   {
     int zone = TimeDiff(t);
     int absZoneMinutes = (zone<0 ? -zone : zone) / 60;
-    size_t len = strftime(TimeBuf,sizeof(TimeBuf)-6,"%m/%d/%Y %T",tm);
+    size_t len = strftime(TimeBuf,sizeof(TimeBuf)-6,"%Y/%m/%d %T",tm);
     sprintf(TimeBuf+len," %c%02d%02d",
            zone<0?'+':'-',absZoneMinutes/60,absZoneMinutes%60);
   }
 #else
-  strftime(TimeBuf,100,"%m/%d/%Y %T",tm);
+  strftime(TimeBuf,100,"%Y/%m/%d %T",tm);
 #endif
   return(TimeBuf);
 }
index 70f06065a31b6b596cb77cf0bf98654265996a3b..2527692bc5e9a9c4f4b2d843376b57c5a6be26d6 100644 (file)
@@ -407,7 +407,8 @@ static struct enum_list enum_security[] = {{SEC_SHARE, "SHARE"},  {SEC_USER, "US
 static struct enum_list enum_printing[] = {{PRINT_SYSV, "sysv"}, {PRINT_AIX, "aix"}, 
                                           {PRINT_HPUX, "hpux"}, {PRINT_BSD, "bsd"},
                                           {PRINT_QNX, "qnx"},   {PRINT_PLP, "plp"},
-                                          {PRINT_LPRNG, "lprng"}, {-1, NULL}};
+                                          {PRINT_LPRNG, "lprng"}, {PRINT_SOFTQ, "softq"},
+                                          {-1, NULL}};
 
 static struct enum_list enum_announce_as[] = {{ANNOUNCE_AS_NT, "NT"}, {ANNOUNCE_AS_WIN95, "win95"},
                                              {ANNOUNCE_AS_WFW, "WfW"}, {-1, NULL}};
@@ -821,6 +822,13 @@ static void init_locals(void)
       string_initial(&sDefault.szPrintcommand,"lp -r -P%p %s");
       break;
 
+    case PRINT_SOFTQ:
+      string_initial(&sDefault.szLpqcommand,"qstat -l -d%p");
+      string_initial(&sDefault.szLprmcommand,"qstat -s -j%j -c");
+      string_initial(&sDefault.szPrintcommand,"lp -d%p -s %s; rm %s");
+      string_initial(&sDefault.szLppausecommand,"qstat -s -j%j -h");
+      string_initial(&sDefault.szLpresumecommand,"qstat -s -j%j -r");
+      break;
       
     }
 }
index bf49a372030188f2c4fe9bcaa13f669f44908cb8..c7db5744e266949bd7df420ea36a27fee8576089 100644 (file)
@@ -846,6 +846,84 @@ static BOOL parse_lpq_plp(char *line,print_queue_struct *buf,BOOL first)
   return(True);
 }
 
+/****************************************************************************
+parse a qstat line
+
+here is an example of "qstat -l -d qms" output under softq
+
+Queue qms: 2 jobs; daemon active (313); enabled; accepting;
+ job-ID   submission-time     pri     size owner      title 
+205980: H 98/03/09 13:04:05     0    15733 stephenf   chap1.ps
+206086:>  98/03/12 17:24:40     0      659 chris      -
+206087:   98/03/12 17:24:45     0     4876 chris      -
+Total:      21268 bytes in queue
+
+
+****************************************************************************/
+static BOOL parse_lpq_softq(char *line,print_queue_struct *buf,BOOL first)
+{
+  string tok[10];
+  int count=0;
+
+  /* mung all the ":"s to spaces*/
+  string_sub(line,":"," ");
+  
+  for (count=0; count<10 && next_token(&line,tok[count],NULL); count++) ;
+
+  /* we must get 9 tokens */
+  if (count < 9)
+    return(False);
+
+  /* the 1st and 7th columns must be integer */
+  if (!isdigit(*tok[0]) || !isdigit(*tok[6]))  return(False);
+  /* if the 2nd column is either '>' or 'H' then the 7th and 8th must be
+   * integer, else it's the 6th and 7th that must be
+   */
+  if (*tok[1] == 'H' || *tok[1] == '>')
+    {
+      if (!isdigit(*tok[7]))
+        return(False);
+      buf->status = *tok[1] == '>' ? LPQ_PRINTING : LPQ_PAUSED;
+      count = 1;
+    }
+  else
+    {
+      if (!isdigit(*tok[5]))
+        return(False);
+      buf->status = LPQ_QUEUED;
+      count = 0;
+    }
+       
+
+  buf->job = atoi(tok[0]);
+  buf->size = atoi(tok[count+6]);
+  buf->priority = atoi(tok[count+5]);
+  StrnCpy(buf->user,tok[count+7],sizeof(buf->user)-1);
+  StrnCpy(buf->file,tok[count+8],sizeof(buf->file)-1);
+  buf->time = time(NULL);              /* default case: take current time */
+  {
+    time_t jobtime;
+    struct tm *t;
+
+    t = localtime(&buf->time);
+    t->tm_mday = atoi(tok[count+2]+6);
+    t->tm_mon  = atoi(tok[count+2]+3);
+    switch (*tok[count+2])
+    {
+    case 7: case 8: case 9: t->tm_year = atoi(tok[count+2]) + 1900; break;
+    default:                t->tm_year = atoi(tok[count+2]) + 2000; break;
+    }
+
+    t->tm_hour = atoi(tok[count+3]);
+    t->tm_min = atoi(tok[count+4]);
+    t->tm_sec = atoi(tok[count+5]);
+    jobtime = mktime(t);
+    if (jobtime != (time_t)-1)
+      buf->time = jobtime; 
+  }
+
+  return(True);
+}
 
 
 char *stat0_strings[] = { "enabled", "online", "idle", "no entries", "free", "ready", NULL };
@@ -881,6 +959,9 @@ static BOOL parse_lpq_entry(int snum,char *line,
     case PRINT_PLP:
       ret = parse_lpq_plp(line,buf,first);
       break;
+    case PRINT_SOFTQ:
+      ret = parse_lpq_softq(line,buf,first);
+      break;
     default:
       ret = parse_lpq_bsd(line,buf,first);
       break;