annotate src/util.c @ 185:fed1334d766b noffle

[svn] * src/client.c: Change variable only used on constant to 'const'. * src/filter.c: Add a couple of 'return's after ASSERT() to remove compiler warnings about functions needing returns. * NEWS,TODO,configure,configure.in,noffle.conf.example,docs/NOTES, docs/noffle.conf.5,src/client.c,src/configfile.c,src/content.c, src/control.c,src/database.c,src/fetch.c,src/fetchlist.c,src/filter.c, src/group.c,src/lock.c,src/log.c,src/log.h,src/noffle.c,src/outgoing.c, src/post.c,src/protocol.c,src/request.c,src/server.c,src/util.c: Debug logging is always compiled and selected via noffle.conf. All debug logs are classified as all, none, config, control, expire, fetch, filter, newsbase, noffle, post, protocol, requests and server.
author bears
date Sun, 05 Aug 2001 09:24:22 +0100
parents 94f2e5607772
children 7d1f26e7c728
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
1 /*
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
2 util.c
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
3
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 164
diff changeset
4 $Id: util.c 300 2001-08-05 08:24:22Z bears $
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
5 */
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
6
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
7 #if HAVE_CONFIG_H
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
8 #include <config.h>
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
9 #endif
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
10
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
11 #if TIME_WITH_SYS_TIME
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
12 #include <sys/time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
13 #include <time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
14 #else
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
15 #if HAVE_SYS_TIME_H
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
16 #include <sys/time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
17 #else
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
18 #include <time.h>
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
19 #endif
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
20 #endif
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
21
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
22 #include "util.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
23 #include <errno.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
24 #include <ctype.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
25 #include <sys/types.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 #include <sys/stat.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
27 #include <fcntl.h>
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
28 #include <stdlib.h>
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
29 #include <unistd.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
30 #include "configfile.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
31 #include "log.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
32 #include "wildmat.h"
54
125d79c9e586 [svn] * src/client.c, src/configfile.c, src/content.c, src/control.c,
uh1763
parents: 45
diff changeset
33 #include "portable.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
34
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
35 #if defined(UTIL_TEST)
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
36 #define Log_err printf
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
37 #endif
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
38
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
39 static const char *
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
40 nextWhiteSpace( const char *p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
41 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
42 while ( *p && ! isspace( *p ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
43 ++p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
44 return p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
45 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
46
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
47 static const char *
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
48 nextNonWhiteSpace( const char *p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
49 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
50 while ( *p && isspace( *p ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
51 ++p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
52 return p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
53 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
54
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
55 const char *
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
56 Utl_restOfLn( const char *line, unsigned int token )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
57 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
58 unsigned int i;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
59 const char *p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
60
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
61 p = line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
62 for ( i = 0; i < token; ++i )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
63 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
64 p = nextNonWhiteSpace( p );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
65 p = nextWhiteSpace( p );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
66 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
67 p = nextNonWhiteSpace( p );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
68 return p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
69 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
70
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
71 const char *
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
72 Utl_getLn( Str result, const char *pos )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
73 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
74 int len = 0;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
75 const char *p = pos;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
76
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
77 if ( ! p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
78 return NULL;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
79 while ( *p != '\n' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
80 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
81 if ( *p == '\0' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
82 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
83 if ( len > 0 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
84 Log_err( "Line not terminated by newline: '%s'", pos );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
85 return NULL;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
86 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
87 *(result++) = *(p++);
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
88 ++len;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
89 if ( len >= MAXCHAR - 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
90 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
91 *result = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
92 Log_err( "Utl_getLn: line too long: %s", result );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
93 return ++p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
94 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
95 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
96 *result = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
97 return ++p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
98
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
99 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
100
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
101 const char *
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
102 Utl_ungetLn( const char *str, const char *p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
103 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
104 if ( str == p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
105 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
106 --p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
107 if ( *p != '\n' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
108 {
185
fed1334d766b [svn] * src/client.c: Change variable only used on constant to 'const'.
bears
parents: 164
diff changeset
109 Log_err( "Utl_ungetLn: not at beginning of line" );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
110 return NULL;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
111 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
112 --p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
113 while ( TRUE )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
114 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
115 if ( p == str )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
116 return p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
117 if ( *p == '\n' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
118 return p + 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
119 --p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
120 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
121 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
122
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
123 const char *
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
124 Utl_getHeaderLn( Str result, const char *p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
125 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
126 const char * res = Utl_getLn( result, p );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
127
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
128 /* Look for followon line if this isn't a blank line. */
109
2bedacfe1ba7 [svn] Fix header line reading buf
bears
parents: 91
diff changeset
129 if ( res != NULL && result[ 0 ] != '\0' && ! isspace( result[ 0 ] ) )
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
130 for(;;)
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
131 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
132 Str nextLine;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
133 const char *here;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
134
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
135 here = res;
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
136 nextLine[ 0 ] = '\0';
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
137 res = Utl_getLn( nextLine, res );
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
138 if ( res == NULL || nextLine[ 0 ] == '\0'
109
2bedacfe1ba7 [svn] Fix header line reading buf
bears
parents: 91
diff changeset
139 || ! isspace( nextLine[ 0 ] ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
140 {
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
141 res = here;
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
142 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
143 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
144 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
145 {
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
146 Utl_catStr( result, "\n" );
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
147 Utl_catStr( result, nextLine );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
148 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
149 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
150
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
151 return res;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
152 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
153
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
154 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
155 Utl_toLower( Str line )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
156 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
157 char *p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
158
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
159 p = line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
160 while ( *p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
161 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
162 *p = tolower( *p );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
163 ++p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
164 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
165 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
166
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
167 char *
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
168 Utl_stripWhiteSpace( char *line )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
169 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
170 char *p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
171
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
172 while ( isspace( *line ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
173 ++line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
174 p = line + strlen( line ) - 1;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
175 while ( isspace( *p ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
176 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
177 *p = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
178 --p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
179 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
180 return line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
181 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
182
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
183 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
184 Utl_stripComment( char *line )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
185 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
186 for ( ; *line != '\0'; line++ )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
187 if ( *line =='#' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
188 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
189 *line = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
190 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
191 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
192 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
193
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
194 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
195 Utl_cpyStr( Str dst, const char *src )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
196 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
197 dst[ 0 ] = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
198 strncat( dst, src, MAXCHAR );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
199 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
200
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
201 void
59
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
202 Utl_cpyStrN( Str dst, const char *src, int n )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
203 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
204 if ( n > MAXCHAR )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
205 n = MAXCHAR;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
206 dst[ 0 ] = '\0';
59
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
207 strncat( dst, src, (size_t)n );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
208 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
209
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
210 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
211 Utl_catStr( Str dst, const char *src )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
212 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
213 strncat( dst, src, MAXCHAR - strlen( dst ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
214 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
215
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
216 void
59
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
217 Utl_catStrN( Str dst, const char *src, int n )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
218 {
59
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
219 size_t un;
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
220
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
221 ASSERT( n >= 0 );
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
222 un = (size_t)n;
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
223 if ( un > MAXCHAR - strlen( dst ) )
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
224 un = MAXCHAR - strlen( dst );
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
225 strncat( dst, src, un );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
226 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
227
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
228 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229 Utl_stamp( Str file )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
230 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
231 FILE *f;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
232 time_t t;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
233
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
234 time( &t );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
235 if ( ! ( f = fopen( file, "w" ) ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
236 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
237 Log_err( "Could not open %s for writing (%s)",
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
238 file, strerror( errno ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
239 return;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
240 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
241 fprintf( f, "%lu\n", t );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
242 fclose( f );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
243 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
244
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
245 Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
246 Utl_getStamp( time_t *result, Str file )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
247 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
248 FILE *f;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
249
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
250 if ( ! ( f = fopen( file, "r" ) ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
251 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
252 if ( fscanf( f, "%lu", result ) != 1 )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
253 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
254 Log_err( "File %s corrupted", file );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
255 fclose( f );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
256 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
257 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
258 fclose( f );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
259 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
260 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
261
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
262 static const char *DOTW[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
263 "Sat", NULL };
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
264 static const char *MON[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
265 "Aug", "Sep", "Oct", "Nov", "Dec", NULL };
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
266
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
267 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
268 * Calculate the difference between local time and GMT. This is INN's
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
269 * 'always-works' method. It assumes the time differences is < 24hrs.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
270 * Sounds reasonable to me. It also assumes it can ignore seconds.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
271 * Returns GMT - localtime minutes. It will also trash the localtime/
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
272 * gmtime/etc. static buffer.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
273 */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
274 static int
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
275 tzDiff( void )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
276 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
277 time_t now;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
278 struct tm local, gmt, *tm;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
279 static time_t nextCalc = 0;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
280 static int res = 0;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
281
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
282 now = time( NULL );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
283 if ( now < nextCalc )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
284 return res;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
285
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
286 tm = localtime( &now );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
287 if ( tm == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
288 return 0;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
289 local = *tm;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
290 tm = gmtime( &now );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
291 if ( tm == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
292 return 0;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
293 gmt = *tm;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
294
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
295 res = gmt.tm_yday - local.tm_yday;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
296 if ( res < -1 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
297 res = -1; /* Year rollover? */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
298 else if ( res > 1 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
299 res = 1;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
300
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
301 res *= 24;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
302 res += gmt.tm_hour - local.tm_hour;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
303 res *= 60;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
304 res += gmt.tm_min - local.tm_min;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
305
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
306 /* Need to recalc at start of next hour */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
307 nextCalc = now + ( 60 - local.tm_sec ) + 60 * ( 59 - local.tm_min );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
308
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
309 return res;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
310 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
311
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
312 void
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
313 Utl_newsDate( time_t t, Str res )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
314 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
315 struct tm *local;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
316 long tzdiff, hoffset, moffset;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
317
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
318 tzdiff = - tzDiff();
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
319
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
320 local = localtime( &t );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
321 if ( local == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
322 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
323 Utl_cpyStr( res, "** localtime failure **" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
324 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
325 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
326
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
327 hoffset = tzdiff / 60;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
328 moffset = tzdiff % 60;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
329 if ( moffset < 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
330 moffset = - moffset;
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
331
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
332 sprintf( res, "%s, %d %s %4d %02d:%02d:%02d %+03ld%02ld",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
333 DOTW[local->tm_wday], local->tm_mday,
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
334 MON[local->tm_mon], local->tm_year + 1900,
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
335 local->tm_hour, local->tm_min, local->tm_sec,
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
336 hoffset, moffset );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
337 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
338
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
339 time_t
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
340 Utl_parseNewsDate( const char *s )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
341 {
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
342 struct tm tm;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
343 int wday, offset, tzoffset;
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
344 char *p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
345 time_t res;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
346
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
347 memset( &tm, 0, sizeof( tm ) );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
348 wday = -1;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
349 tm.tm_isdst = -1;
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
350
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
351 s = nextNonWhiteSpace( s );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
352
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
353 /* Is this the day number, or a weekday? */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
354 if ( ! isdigit( *s ) )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
355 {
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
356 if ( strlen( s ) < 4 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
357 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
358
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
359 for ( wday = 0; DOTW[ wday ] != NULL; wday++ )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
360 if ( strncmp( DOTW[ wday ], s, 3 ) == 0 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
361 break;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
362
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
363 if( DOTW[ wday ] == NULL || s[3] != ',' )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
364 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
365
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
366 s += 4;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
367 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
368
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
369 /* Get the day number */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
370 tm.tm_mday = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
371 if ( p == s )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
372 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
373 s = p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
374
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
375 /* Look for month name */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
376 s = nextNonWhiteSpace( s );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
377 if ( strlen( s ) < 4 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
378 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
379 for ( tm.tm_mon = 0; MON[ tm.tm_mon ] != NULL; tm.tm_mon++ )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
380 if ( strncmp( MON[ tm.tm_mon ], s, 3 ) == 0 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
381 break;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
382
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
383 if ( MON[ tm.tm_mon ] == NULL )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
384 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
385 s += 3;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
386
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
387 /* Year next */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
388 tm.tm_year = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
389 if ( p == s || ( tm.tm_year >= 100 && tm.tm_year < 1900 ) )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
390 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
391 if ( tm.tm_year >= 1900 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
392 tm.tm_year -= 1900;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
393 s = p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
394
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
395 /* Hours */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
396 tm.tm_hour = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
397 if ( p == s || *p != ':' )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
398 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
399 s = ++p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
400
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
401 /* Minutes */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
402 tm.tm_min = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
403 if ( p == s || ( *p != ':' && *p != ' ' ) )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
404 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
405 s = p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
406
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
407 /* Seconds */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
408 if ( *s == ':' )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
409 {
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
410 s++;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
411 tm.tm_sec = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
412 if ( p == s )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
413 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
414 s = p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
415 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
416
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
417 /* GMT/UT or timezone offset */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
418 tzoffset = 0;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
419 while ( isspace( *s ) )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
420 s++;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
421 if ( strncmp( s, "GMT", 3) == 0 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
422 s += 3;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
423 else if ( strncmp( s, "UT", 2 ) == 0 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
424 s += 2;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
425 else
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
426 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
427 offset = (int) strtol( s, &p, 10 );
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
428 s = p;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
429 tzoffset = ( offset / 100 ) * 60 + ( offset % 100 );
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
430 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
431
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
432 /* Check for following junk */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
433 if ( *s != '\0' && ! isspace( *s ) )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
434 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
435
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
436 res = mktime( &tm );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
437 if ( res == (time_t) -1 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
438 return res;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
439
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
440 if ( wday >= 0 && wday != tm.tm_wday )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
441 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
442
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
443 /* Remove local time diff from res to give time as if GMT */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
444 res -= tzDiff() * 60;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
445
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
446 /* And now adjust for tzoffset */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
447 res -= tzoffset * 60;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
448
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
449 return res;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
450 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
451
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
452 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
453 Utl_allocAndCpy( char **dst, const char *src )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
454 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
455 int len = strlen( src );
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
456 if ( ! ( *dst = malloc( (size_t)len + 1 ) ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
457 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
458 Log_err( "Cannot allocate string with length %lu", strlen( src ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
459 exit( EXIT_FAILURE );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
460 }
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
461 memcpy( *dst, src, (size_t)len + 1 );
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
462 }
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
463
164
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
464 sig_t
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
465 Utl_installSignalHandler( int sig, sig_t handler )
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
466 {
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
467 struct sigaction act, oldAct;
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
468
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
469 act.sa_handler = handler;
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
470 sigemptyset( &act.sa_mask );
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
471 act.sa_flags = 0;
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
472 if ( sig != SIGALRM )
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
473 act.sa_flags |= SA_RESTART;
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
474 if ( sigaction( sig, &act, &oldAct ) < 0 )
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
475 return SIG_ERR;
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
476 return oldAct.sa_handler;
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
477 }
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
478
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
479 #if defined(UTIL_TEST)
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
480
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
481 /* Test code borrowed from wildmat.c. Yep, still uses gets(). */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
482 extern char *gets();
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
483
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
484 int
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
485 main()
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
486 {
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
487 Str line;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
488 time_t t;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
489
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
490 printf( "Util date tester. Enter date to test.\n" );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
491 printf( "A blank line exits the program.\n" );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
492
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
493 for ( ; ; )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
494 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
495 t = time( NULL );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
496 Utl_newsDate( t, line );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
497 printf( "\n(%s) Enter date: ", line );
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
498 (void) fflush( stdout );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
499 if ( gets( line ) == NULL || line[0] == '\0' )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
500 break;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
501
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
502 t = Utl_parseNewsDate( line );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
503 if ( t == (time_t) -1 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
504 printf( "Date parse failed\n" );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
505 else
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
506 {
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
507 Utl_newsDate( t, line );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
508 printf( "Utl_newsDate -> '%s'\n", line );
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
509 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
510 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
511
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
512 exit(0);
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
513 /* NOTREACHED */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
514 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
515 #endif