[PATCH] backport lprng_time parsing to appl-head

Martin Pool mbp at samba.org
Fri Apr 19 00:51:09 GMT 2002


This patch backports LPRng_time() from HEAD to APPLIANCE_HEAD without
modification.  As the comment says, it allows Samba to parse LPRng
output that supplies either just a time, or a date and time.

(I believe this fixes HP CR 594, because the lpr on that box supplies
a date.)

I'm not committing this directly because I want to be really careful
about that branch.  Could Tim, Jerry or jra let me know if you think
it's OK?

Thanks,
-- 
Martin



--- lpq_parse.c.~1.2.4.6.~	Fri Apr 19 17:13:30 2002
+++ lpq_parse.c	Fri Apr 19 17:34:24 2002
@@ -180,20 +180,39 @@ the lpq output.  The lpq time looks like
 
 <allan at umich.edu> June 30, 1998.
 Modified to work with the re-written parse_lpq_lprng routine.
+
+<J.P.M.v.Itegem at tue.nl> Dec 17,1999
+Modified to work with lprng 3.16
+With lprng 3.16 The lpq time looks like
+                       "23:15:07"
+                       "23:15:07.100"
+                       "1999-12-16-23:15:07"
+                       "1999-12-16-23:15:07.100"
+
 */
 static time_t LPRng_time(char *time_string)
 {
-  time_t jobtime;
-  struct tm *t;
+	time_t jobtime;
+	struct tm t;
+
+	jobtime = time(NULL);         /* default case: take current time */
+	t = *localtime(&jobtime);
 
-  jobtime = time(NULL);         /* default case: take current time */
-  t = localtime(&jobtime);
-  t->tm_hour = atoi(time_string);
-  t->tm_min = atoi(time_string+3);
-  t->tm_sec = atoi(time_string+6);
-  jobtime = mktime(t);
+	if ( atoi(time_string) < 24 ){
+		t.tm_hour = atoi(time_string);
+		t.tm_min = atoi(time_string+3);
+		t.tm_sec = atoi(time_string+6);
+	} else {
+		t.tm_year = atoi(time_string)-1900;
+		t.tm_mon = atoi(time_string+5)-1;
+		t.tm_mday = atoi(time_string+8);
+		t.tm_hour = atoi(time_string+11);
+		t.tm_min = atoi(time_string+14);
+		t.tm_sec = atoi(time_string+17);
+	}    
+	jobtime = mktime(&t);
 
-  return jobtime;
+	return jobtime;
 }
 
 




More information about the samba-technical mailing list