annotate src/util.c @ 202:027608dbd16b noffle

[svn] fixed SIGSEGV in Utl_getHeaderLn(); minor bugfix at Utl_parseNewsDate(). mliss
author mirkol
date Sun, 11 Nov 2001 03:53:07 +0000
parents 24d4cd032da5
children eb2589384836
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
202
mirkol
parents: 197
diff changeset
4 $Id: util.c 321 2001-11-11 03:53:07Z mirkol $
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 <errno.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
23 #include <ctype.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
24 #include <sys/types.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
25 #include <sys/stat.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
26 #include <fcntl.h>
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
27 #include <stdlib.h>
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
28 #include <unistd.h>
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
29 #include "configfile.h"
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
30 #include "log.h"
197
24d4cd032da5 [svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents: 186
diff changeset
31 #include "portable.h"
24d4cd032da5 [svn] * AUTHORS,INSTALL,NEWS,README,TODO,docs/NOTES,src/client.c,src/protocol.c,
bears
parents: 186
diff changeset
32 #include "util.h"
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
33 #include "wildmat.h"
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 );
202
mirkol
parents: 197
diff changeset
127 Bool not_too_long_header = TRUE;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
128
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
129 /* Look for followon line if this isn't a blank line. */
109
2bedacfe1ba7 [svn] Fix header line reading buf
bears
parents: 91
diff changeset
130 if ( res != NULL && result[ 0 ] != '\0' && ! isspace( result[ 0 ] ) )
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
131 for(;;)
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
132 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
133 Str nextLine;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
134 const char *here;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
135
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
136 here = res;
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
137 nextLine[ 0 ] = '\0';
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
138 res = Utl_getLn( nextLine, res );
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
139 if ( res == NULL || nextLine[ 0 ] == '\0'
109
2bedacfe1ba7 [svn] Fix header line reading buf
bears
parents: 91
diff changeset
140 || ! isspace( nextLine[ 0 ] ) )
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
141 {
87
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
142 res = here;
bf8c97460fd7 [svn] Preserve newslines and spaces in header lines
bears
parents: 59
diff changeset
143 break;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
144 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
145 else
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
146 {
202
mirkol
parents: 197
diff changeset
147 if ( not_too_long_header &&
mirkol
parents: 197
diff changeset
148 ( MAXCHAR > ( strlen( result ) + strlen( nextLine ) + 1 ) ) )
mirkol
parents: 197
diff changeset
149 {
mirkol
parents: 197
diff changeset
150 Utl_catStr( result, "\n" );
mirkol
parents: 197
diff changeset
151 Utl_catStr( result, nextLine );
mirkol
parents: 197
diff changeset
152 }
mirkol
parents: 197
diff changeset
153 else
mirkol
parents: 197
diff changeset
154 {
mirkol
parents: 197
diff changeset
155 Log_err( "Utl_getHeaderLn: skipped continued header: %s", nextLine );
mirkol
parents: 197
diff changeset
156 not_too_long_header = FALSE;
mirkol
parents: 197
diff changeset
157 /* Now let poor little noffle skip the header continuations. */
mirkol
parents: 197
diff changeset
158 /* We really need to up the size limit of headers much */
mirkol
parents: 197
diff changeset
159 /* higher than MAXCHAR = 2048. mliss */
mirkol
parents: 197
diff changeset
160 }
43
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 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
163
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
164 return res;
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 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
168 Utl_toLower( Str 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 p = line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
173 while ( *p )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
174 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
175 *p = tolower( *p );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
176 ++p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
177 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
178 }
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 char *
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
181 Utl_stripWhiteSpace( char *line )
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 char *p;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
184
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
185 while ( isspace( *line ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
186 ++line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
187 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
188 while ( isspace( *p ) )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
189 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
190 *p = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
191 --p;
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 return line;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
194 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
195
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
196 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
197 Utl_stripComment( char *line )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
198 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
199 for ( ; *line != '\0'; line++ )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
200 if ( *line =='#' )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
201 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
202 *line = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
203 break;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
204 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
205 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
206
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
207 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
208 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
209 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
210 dst[ 0 ] = '\0';
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
211 strncat( dst, src, MAXCHAR );
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
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
214 void
59
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
215 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
216 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
217 if ( n > MAXCHAR )
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
218 n = MAXCHAR;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
219 dst[ 0 ] = '\0';
59
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
220 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
221 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
222
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
223 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
224 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
225 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
226 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
227 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
228
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
229 void
59
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
230 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
231 {
59
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
232 size_t un;
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
233
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
234 ASSERT( n >= 0 );
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
235 un = (size_t)n;
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
236 if ( un > MAXCHAR - strlen( dst ) )
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
237 un = MAXCHAR - strlen( dst );
e612b263934f [svn] Changed some variable types and used some casts to avoid compiler
enz
parents: 54
diff changeset
238 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
239 }
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 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
242 Utl_stamp( Str file )
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 FILE *f;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
245 time_t t;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
246
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
247 time( &t );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
248 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
249 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
250 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
251 file, strerror( errno ) );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
252 return;
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 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
255 fclose( f );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
256 }
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 Bool
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
259 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
260 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
261 FILE *f;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
262
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
263 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
264 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
265 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
266 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
267 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
268 fclose( f );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
269 return FALSE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
270 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
271 fclose( f );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
272 return TRUE;
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
273 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
274
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
275 static const char *DOTW[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri",
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
276 "Sat", NULL };
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
277 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
278 "Aug", "Sep", "Oct", "Nov", "Dec", NULL };
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
279
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
280 /*
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
281 * Calculate the difference between local time and GMT. This is INN's
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
282 * 'always-works' method. It assumes the time differences is < 24hrs.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
283 * Sounds reasonable to me. It also assumes it can ignore seconds.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
284 * Returns GMT - localtime minutes. It will also trash the localtime/
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
285 * gmtime/etc. static buffer.
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
286 */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
287 static int
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
288 tzDiff( void )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
289 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
290 time_t now;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
291 struct tm local, gmt, *tm;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
292 static time_t nextCalc = 0;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
293 static int res = 0;
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 now = time( NULL );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
296 if ( now < nextCalc )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
297 return res;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
298
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
299 tm = localtime( &now );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
300 if ( tm == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
301 return 0;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
302 local = *tm;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
303 tm = gmtime( &now );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
304 if ( tm == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
305 return 0;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
306 gmt = *tm;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
307
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
308 res = gmt.tm_yday - local.tm_yday;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
309 if ( res < -1 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
310 res = -1; /* Year rollover? */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
311 else if ( res > 1 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
312 res = 1;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
313
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
314 res *= 24;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
315 res += gmt.tm_hour - local.tm_hour;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
316 res *= 60;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
317 res += gmt.tm_min - local.tm_min;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
318
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
319 /* Need to recalc at start of next hour */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
320 nextCalc = now + ( 60 - local.tm_sec ) + 60 * ( 59 - local.tm_min );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
321
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
322 return res;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
323 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
324
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
325 void
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
326 Utl_newsDate( time_t t, Str res )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
327 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
328 struct tm *local;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
329 long tzdiff, hoffset, moffset;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
330
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
331 tzdiff = - tzDiff();
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
332
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
333 local = localtime( &t );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
334 if ( local == NULL )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
335 {
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
336 Utl_cpyStr( res, "** localtime failure **" );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
337 return;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
338 }
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
339
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
340 hoffset = tzdiff / 60;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
341 moffset = tzdiff % 60;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
342 if ( moffset < 0 )
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
343 moffset = - moffset;
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
344
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
345 sprintf( res, "%s, %d %s %4d %02d:%02d:%02d %+03ld%02ld",
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
346 DOTW[local->tm_wday], local->tm_mday,
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
347 MON[local->tm_mon], local->tm_year + 1900,
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
348 local->tm_hour, local->tm_min, local->tm_sec,
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
349 hoffset, moffset );
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
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
352 time_t
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
353 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
354 {
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
355 struct tm tm;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
356 int wday, offset, tzoffset;
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
357 char *p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
358 time_t res;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
359
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
360 memset( &tm, 0, sizeof( tm ) );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
361 wday = -1;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
362 tm.tm_isdst = -1;
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
363
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
364 s = nextNonWhiteSpace( s );
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 /* Is this the day number, or a weekday? */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
367 if ( ! isdigit( *s ) )
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 if ( strlen( s ) < 4 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
370 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
371
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
372 for ( wday = 0; DOTW[ wday ] != NULL; wday++ )
186
7d1f26e7c728 [svn] Remove case sensitivity in date parse.
bears
parents: 185
diff changeset
373 if ( strncasecmp( DOTW[ wday ], s, 3 ) == 0 )
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
374 break;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
375
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
376 if( DOTW[ wday ] == NULL || s[3] != ',' )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
377 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
378
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
379 s += 4;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
380 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
381
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
382 /* Get the day number */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
383 tm.tm_mday = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
384 if ( p == s )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
385 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
386 s = p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
387
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
388 /* Look for month name */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
389 s = nextNonWhiteSpace( s );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
390 if ( strlen( s ) < 4 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
391 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
392 for ( tm.tm_mon = 0; MON[ tm.tm_mon ] != NULL; tm.tm_mon++ )
186
7d1f26e7c728 [svn] Remove case sensitivity in date parse.
bears
parents: 185
diff changeset
393 if ( strncasecmp( MON[ tm.tm_mon ], s, 3 ) == 0 )
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
394 break;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
395
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
396 if ( MON[ tm.tm_mon ] == NULL )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
397 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
398 s += 3;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
399
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
400 /* Year next */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
401 tm.tm_year = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
402 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
403 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
404 if ( tm.tm_year >= 1900 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
405 tm.tm_year -= 1900;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
406 s = p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
407
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
408 /* Hours */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
409 tm.tm_hour = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
410 if ( p == s || *p != ':' )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
411 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
412 s = ++p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
413
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
414 /* Minutes */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
415 tm.tm_min = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
416 if ( p == s || ( *p != ':' && *p != ' ' ) )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
417 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
418 s = p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
419
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
420 /* Seconds */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
421 if ( *s == ':' )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
422 {
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
423 s++;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
424 tm.tm_sec = (int) strtol( s, &p, 10 );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
425 if ( p == s )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
426 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
427 s = p;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
428 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
429
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
430 /* GMT/UT or timezone offset */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
431 tzoffset = 0;
202
mirkol
parents: 197
diff changeset
432 s = nextNonWhiteSpace( s );
186
7d1f26e7c728 [svn] Remove case sensitivity in date parse.
bears
parents: 185
diff changeset
433 if ( strncasecmp( s, "GMT", 3) == 0 )
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
434 s += 3;
186
7d1f26e7c728 [svn] Remove case sensitivity in date parse.
bears
parents: 185
diff changeset
435 else if ( strncasecmp( s, "UT", 2 ) == 0 )
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
436 s += 2;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
437 else
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
438 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
439 offset = (int) strtol( s, &p, 10 );
202
mirkol
parents: 197
diff changeset
440 if ( p == s )
mirkol
parents: 197
diff changeset
441 return (time_t) -1;
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
442 s = p;
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
443 tzoffset = ( offset / 100 ) * 60 + ( offset % 100 );
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
444 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
445
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
446 /* Check for following junk */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
447 if ( *s != '\0' && ! isspace( *s ) )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
448 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
449
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
450 res = mktime( &tm );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
451 if ( res == (time_t) -1 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
452 return res;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
453
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
454 if ( wday >= 0 && wday != tm.tm_wday )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
455 return (time_t) -1;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
456
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
457 /* Remove local time diff from res to give time as if GMT */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
458 res -= tzDiff() * 60;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
459
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
460 /* And now adjust for tzoffset */
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
461 res -= tzoffset * 60;
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
462
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
463 return res;
43
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
464 }
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
465
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
466 void
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
467 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
468 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
469 int len = strlen( src );
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
470 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
471 {
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
472 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
473 exit( EXIT_FAILURE );
2842f50feb55 [svn] * client.c, client.h, common.h, config.c, config.h, content.c, content.h,
uh1763
parents:
diff changeset
474 }
45
32ba1198c6fa [svn] * Makefile.in, configure, configure.in, docs/Makefile.in, src/Makefile.in:
uh1763
parents: 43
diff changeset
475 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
476 }
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
477
164
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
478 sig_t
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
479 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
480 {
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
481 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
482
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
483 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
484 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
485 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
486 if ( sig != SIGALRM )
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
487 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
488 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
489 return SIG_ERR;
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
490 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
491 }
94f2e5607772 [svn] * src/client.c,src/protocol.c,src/util.h,src/util.c: Common up
bears
parents: 127
diff changeset
492
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
493 #if defined(UTIL_TEST)
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
494
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
495 /* Test code borrowed from wildmat.c. Yep, still uses gets(). */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
496 extern char *gets();
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
497
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
498 int
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
499 main()
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
500 {
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
501 Str line;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
502 time_t t;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
503
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
504 printf( "Util date tester. Enter date to test.\n" );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
505 printf( "A blank line exits the program.\n" );
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 for ( ; ; )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
508 {
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
509 t = time( NULL );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
510 Utl_newsDate( t, line );
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
511 printf( "\n(%s) Enter date: ", line );
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
512 (void) fflush( stdout );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
513 if ( gets( line ) == NULL || line[0] == '\0' )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
514 break;
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
515
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
516 t = Utl_parseNewsDate( line );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
517 if ( t == (time_t) -1 )
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
518 printf( "Date parse failed\n" );
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
519 else
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
520 {
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
521 Utl_newsDate( t, line );
127
3c71e28c8eef [svn] Release-1-0 mergedocs/NOTES
bears
parents: 109
diff changeset
522 printf( "Utl_newsDate -> '%s'\n", line );
91
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
523 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
524 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
525
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
526 exit(0);
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
527 /* NOTREACHED */
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
528 }
93cc929329eb [svn] Date output change and now date parsing
bears
parents: 87
diff changeset
529 #endif