aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>1999-07-07 11:28:26 +0000
committerWerner Koch <[email protected]>1999-07-07 11:28:26 +0000
commitbd7298cf0dbeacbd415acdf814acace9aabb8455 (patch)
treeae235766ee42b77ba5ca19dfb1bf99e678154e3d /util
parentSee ChangeLog: Fri Jul 2 11:45:54 CEST 1999 Werner Koch (diff)
downloadgnupg-bd7298cf0dbeacbd415acdf814acace9aabb8455.tar.gz
gnupg-bd7298cf0dbeacbd415acdf814acace9aabb8455.zip
See ChangeLog: Wed Jul 7 13:23:40 CEST 1999 Werner Koch
Diffstat (limited to 'util')
-rw-r--r--util/ChangeLog12
-rw-r--r--util/Makefile.am9
-rw-r--r--util/logger.c23
-rw-r--r--util/memory.c9
-rw-r--r--util/miscutil.c44
5 files changed, 75 insertions, 22 deletions
diff --git a/util/ChangeLog b/util/ChangeLog
index e74bf851e..44c0f7f65 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,15 @@
+Wed Jul 7 13:08:40 CEST 1999 Werner Koch <[email protected]>
+
+
+ * memory.c (membug): Use if either M_DEBUG or M_GUARD is used.
+
+ * miscutil.c (scan_isodatestr): New.
+
+ * logger.c (g10_log_mpidump): Moved to ../mpi/mpicoder.c
+ (g10_log_print_prefix): Renamed from print_prefix and made global.
+
+ * Makefile.am: Support for libtool.
+
Thu Jul 1 12:47:31 CEST 1999 Werner Koch <[email protected]>
diff --git a/util/Makefile.am b/util/Makefile.am
index 5b0b99df2..75f9e8c18 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -2,12 +2,13 @@
INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/intl
-noinst_LIBRARIES = libutil.a
+noinst_LTLIBRARIES = libutil.la
-libutil_a_SOURCES = g10u.c logger.c fileutil.c miscutil.c strgutil.c \
- ttyio.c argparse.c memory.c secmem.c errors.c iobuf.c \
- dotlock.c http.c
+libutil_la_LDFLAGS =
+libutil_la_SOURCES = g10u.c logger.c fileutil.c miscutil.c strgutil.c \
+ ttyio.c argparse.c memory.c secmem.c errors.c iobuf.c \
+ dotlock.c http.c
http-test: http.c
diff --git a/util/logger.c b/util/logger.c
index 2573f5b63..a1fb1f3d7 100644
--- a/util/logger.c
+++ b/util/logger.c
@@ -102,8 +102,8 @@ log_get_errorcount( int clear)
}
-static void
-print_prefix(const char *text)
+void
+g10_log_print_prefix(const char *text)
{
if( !logfp )
logfp = stderr;
@@ -129,7 +129,7 @@ g10_log_info( const char *fmt, ... )
{
va_list arg_ptr ;
- print_prefix("");
+ g10_log_print_prefix("");
va_start( arg_ptr, fmt ) ;
vfprintf(logfp,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -151,7 +151,7 @@ g10_log_error( const char *fmt, ... )
{
va_list arg_ptr ;
- print_prefix("");
+ g10_log_print_prefix("");
va_start( arg_ptr, fmt ) ;
vfprintf(logfp,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -175,7 +175,7 @@ g10_log_fatal( const char *fmt, ... )
{
va_list arg_ptr ;
- print_prefix("fatal: ");
+ g10_log_print_prefix("fatal: ");
va_start( arg_ptr, fmt ) ;
vfprintf(logfp,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -202,7 +202,7 @@ g10_log_bug( const char *fmt, ... )
va_list arg_ptr ;
putc('\n', stderr );
- print_prefix("Ohhhh jeeee: ");
+ g10_log_print_prefix("Ohhhh jeeee: ");
va_start( arg_ptr, fmt ) ;
vfprintf(stderr,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -230,7 +230,7 @@ g10_log_debug( const char *fmt, ... )
{
va_list arg_ptr ;
- print_prefix("DBG: ");
+ g10_log_print_prefix("DBG: ");
va_start( arg_ptr, fmt ) ;
vfprintf(logfp,fmt,arg_ptr) ;
va_end(arg_ptr);
@@ -254,18 +254,11 @@ g10_log_hexdump( const char *text, const char *buf, size_t len )
{
int i;
- print_prefix(text);
+ g10_log_print_prefix(text);
for(i=0; i < len; i++ )
fprintf(logfp, " %02X", ((const byte*)buf)[i] );
fputc('\n', logfp);
}
-void
-g10_log_mpidump( const char *text, MPI a )
-{
- print_prefix(text);
- mpi_print(logfp, a, 1 );
- fputc('\n', logfp);
-}
diff --git a/util/memory.c b/util/memory.c
index 40784375d..af79cd0cb 100644
--- a/util/memory.c
+++ b/util/memory.c
@@ -48,9 +48,11 @@
#define EXTRA_ALIGN 0
#endif
+#if defined(M_DEBUG) || defined(M_GUARD)
+ static void membug( const char *fmt, ... );
+#endif
#ifdef M_DEBUG
- static void membug( const char *fmt, ... );
#ifndef M_GUARD
#define M_GUARD 1
@@ -319,7 +321,9 @@ check_allmem( const char *info )
check_mem(e->user_p-4-EXTRA_ALIGN, info);
}
+#endif /* M_DEBUG */
+#if defined(M_DEBUG) || defined(M_GUARD)
static void
membug( const char *fmt, ... )
{
@@ -336,8 +340,7 @@ membug( const char *fmt, ... )
#endif
abort();
}
-
-#endif /* M_DEBUG */
+#endif
void
m_print_stats( const char *prefix )
diff --git a/util/miscutil.c b/util/miscutil.c
index 4244ccce0..b0a6410e8 100644
--- a/util/miscutil.c
+++ b/util/miscutil.c
@@ -19,6 +19,7 @@
*/
#include <config.h>
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
@@ -30,12 +31,55 @@
#include "util.h"
#include "i18n.h"
+/****************
+ * I know that the OpenPGP protocol has a Y2106 problem ;-)
+ */
u32
make_timestamp()
{
return time(NULL);
}
+/****************
+ * Scan a date string and return a timestamp.
+ * The only supported format is "yyyy-mm-dd"
+ * Returns 0 for an invalid date.
+ */
+u32
+scan_isodatestr( const char *string )
+{
+ int year, month, day;
+ struct tm tmbuf;
+ time_t stamp;
+ int i;
+
+ if( strlen(string) != 10 || string[4] != '-' || string[7] != '-' )
+ return 0;
+ for( i=0; i < 4; i++ )
+ if( !isdigit(string[i]) )
+ return 0;
+ if( !isdigit(string[5]) || !isdigit(string[6]) )
+ return 0;
+ if( !isdigit(string[8]) || !isdigit(string[9]) )
+ return 0;
+ year = atoi(string);
+ month = atoi(string+5);
+ day = atoi(string+8);
+ /* some basic checks */
+ if( year < 1970 || month < 1 || month > 12 || day < 1 || day > 31 )
+ return 0;
+ memset( &tmbuf, 0, sizeof tmbuf );
+ tmbuf.tm_mday = day;
+ tmbuf.tm_mon = month-1;
+ tmbuf.tm_year = year - 1900;
+ tmbuf.tm_isdst = -1;
+ stamp = mktime( &tmbuf );
+ if( stamp == (time_t)-1 )
+ return 0;
+ return stamp;
+}
+
+
u32
add_days_to_timestamp( u32 stamp, u16 days )
{