ce0ae0f98a
cups-bjnp is a CUPS backend for Canon USB over IP protocol which adds functionality to some Canon printers to connect and print over the network. from maintainer Julian Andrej ok robert@
74 lines
1.9 KiB
Plaintext
74 lines
1.9 KiB
Plaintext
$OpenBSD: patch-bjnp-debug_c,v 1.1.1.1 2014/08/28 19:02:19 ajacoutot Exp $
|
|
--- bjnp-debug.c.orig Mon Jan 21 19:43:27 2013
|
|
+++ bjnp-debug.c Thu Aug 28 17:00:17 2014
|
|
@@ -19,7 +19,7 @@
|
|
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
-#include <sys/timeb.h>
|
|
+#include <sys/time.h>
|
|
#include <errno.h>
|
|
#include "bjnp.h"
|
|
|
|
@@ -59,7 +59,7 @@ static bjnp_loglevel_t debug_level = LOG_ERROR;
|
|
static int to_cups = 0;
|
|
static FILE *debug_file = NULL;
|
|
static time_t start_sec = 0;
|
|
-static int start_msec;
|
|
+static suseconds_t start_usec;
|
|
|
|
/*
|
|
* local functions
|
|
@@ -186,9 +186,9 @@ bjnp_debug (bjnp_loglevel_t level, const char *fmt, ..
|
|
{
|
|
va_list ap;
|
|
char printbuf[256];
|
|
- struct timeb timebuf;
|
|
+ struct timeval timebuf;
|
|
int sec;
|
|
- int msec;
|
|
+ suseconds_t usec;
|
|
|
|
/* print received data into a string */
|
|
va_start (ap, fmt);
|
|
@@ -204,15 +204,15 @@ bjnp_debug (bjnp_loglevel_t level, const char *fmt, ..
|
|
|
|
if ((level <= debug_level) && debug_file)
|
|
{
|
|
- ftime (&timebuf);
|
|
- if ((msec = timebuf.millitm - start_msec) < 0)
|
|
+ gettimeofday (&timebuf, NULL);
|
|
+ if ((usec = timebuf.tv_usec - start_usec) < 0)
|
|
{
|
|
- msec += 1000;
|
|
- timebuf.time -= 1;
|
|
+ usec += 1000000;
|
|
+ timebuf.tv_sec -= 1;
|
|
}
|
|
- sec = timebuf.time - start_sec;
|
|
+ sec = timebuf.tv_sec - start_sec;
|
|
|
|
- fprintf (debug_file, "%8s: %03d.%03d %s", level2str (level), sec, msec,
|
|
+ fprintf (debug_file, "%8s: %03d.%06ld %s", level2str (level), sec, usec,
|
|
printbuf);
|
|
}
|
|
}
|
|
@@ -224,13 +224,13 @@ bjnp_set_debug_level (const char *level)
|
|
* set debug level to level (string)
|
|
*/
|
|
|
|
- struct timeb timebuf;
|
|
+ struct timeval timebuf;
|
|
char loglevel[16];
|
|
char *separator;
|
|
|
|
- ftime (&timebuf);
|
|
- start_sec = timebuf.time;
|
|
- start_msec = timebuf.millitm;
|
|
+ gettimeofday (&timebuf, NULL);
|
|
+ start_sec = timebuf.tv_sec;
|
|
+ start_usec = timebuf.tv_usec;
|
|
|
|
/*
|
|
* Split string into loglevel and optional cupslog string
|