Mercurial > noffle
comparison src/client.c @ 271:3477050e8d10 noffle
[svn] * src/client.c,src/fetch.c,src/lock.c.src/protocol.c,src/util.h,src/util.c:
Define our own SignalHandler type rather than use the rather
Linux-specific (and potentially glibc version specific) sig_t.
* src/client.c,src/database.h,src/database.c,src/over.h,src/over.c,
src/pseudo.c,src/server.c: Ensure format string specifiers and passed
data types match. As part of this, change some uses of size_t as a
general data type to an appropriate base C type. Database status changes
from int to unsigned.
author | bears |
---|---|
date | Sun, 10 Nov 2002 11:32:17 +0000 |
parents | f049f8639dc0 |
children | 9c54bf672ca1 |
comparison
equal
deleted
inserted
replaced
270:d6fedc09b052 | 271:3477050e8d10 |
---|---|
1 /* | 1 /* |
2 client.c | 2 client.c |
3 | 3 |
4 $Id: client.c 400 2002-10-08 13:52:52Z bears $ | 4 $Id: client.c 403 2002-11-10 11:32:17Z bears $ |
5 */ | 5 */ |
6 | 6 |
7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
8 #include <config.h> | 8 #include <config.h> |
9 #endif | 9 #endif |
224 | 224 |
225 static Bool | 225 static Bool |
226 connectWithTimeout( int sock, const struct sockaddr *servAddr, | 226 connectWithTimeout( int sock, const struct sockaddr *servAddr, |
227 socklen_t addrLen ) | 227 socklen_t addrLen ) |
228 { | 228 { |
229 sig_t oldHandler; | 229 SignalHandler oldHandler; |
230 int r, to; | 230 int r, to; |
231 | 231 |
232 oldHandler = Utl_installSignalHandler( SIGALRM, connectAlarm ); | 232 oldHandler = Utl_installSignalHandler( SIGALRM, connectAlarm ); |
233 if ( oldHandler == SIG_ERR ) | 233 if ( oldHandler == (SignalHandler) SIG_ERR ) |
234 { | 234 { |
235 Log_err( "client.c:connectWithTimeout: signal failed." ); | 235 Log_err( "client.c:connectWithTimeout: signal failed." ); |
236 return FALSE; | 236 return FALSE; |
237 } | 237 } |
238 to = Cfg_connectTimeout(); | 238 to = Cfg_connectTimeout(); |
291 } | 291 } |
292 else | 292 else |
293 { | 293 { |
294 *pColon = '\0'; | 294 *pColon = '\0'; |
295 strcpy( host, pStart ); | 295 strcpy( host, pStart ); |
296 if ( sscanf( pColon + 1, "%hi", &port ) != 1 ) | 296 if ( sscanf( pColon + 1, "%hu", &port ) != 1 ) |
297 { | 297 { |
298 Log_err( "Syntax error in server name: '%s'", serv ); | 298 Log_err( "Syntax error in server name: '%s'", serv ); |
299 return FALSE;; | 299 return FALSE;; |
300 } | 300 } |
301 if ( port <= 0 || port > 65535 ) | 301 if ( port <= 0 || port > 65535 ) |
302 { | 302 { |
303 Log_err( "Invalid port number %hi. Must be in [1, 65535]", port ); | 303 Log_err( "Invalid port number %hu. Must be in [1, 65535]", port ); |
304 return FALSE;; | 304 return FALSE;; |
305 } | 305 } |
306 } | 306 } |
307 memset( (void *)&sIn, 0, sizeof( sIn ) ); | 307 memset( (void *)&sIn, 0, sizeof( sIn ) ); |
308 hp = gethostbyname( host ); | 308 hp = gethostbyname( host ); |
699 } | 699 } |
700 | 700 |
701 static const char * | 701 static const char * |
702 readField( Str result, const char *p ) | 702 readField( Str result, const char *p ) |
703 { | 703 { |
704 size_t len; | 704 int len; |
705 char *r; | 705 char *r; |
706 | 706 |
707 if ( ! p ) | 707 if ( ! p ) |
708 return NULL; | 708 return NULL; |
709 r = result; | 709 r = result; |
729 return ++p; | 729 return ++p; |
730 } | 730 } |
731 | 731 |
732 static Bool | 732 static Bool |
733 parseOvLn( Str line, int *numb, Str subj, Str from, | 733 parseOvLn( Str line, int *numb, Str subj, Str from, |
734 Str date, Str msgId, Str ref, size_t *bytes, size_t *lines ) | 734 Str date, Str msgId, Str ref, |
735 unsigned long *bytes, unsigned long *lines ) | |
735 { | 736 { |
736 const char *p; | 737 const char *p; |
737 Str t; | 738 Str t; |
738 | 739 |
739 p = readField( t, line ); | 740 p = readField( t, line ); |
745 p = readField( msgId, p ); | 746 p = readField( msgId, p ); |
746 p = readField( ref, p ); | 747 p = readField( ref, p ); |
747 p = readField( t, p ); | 748 p = readField( t, p ); |
748 *bytes = 0; | 749 *bytes = 0; |
749 *lines = 0; | 750 *lines = 0; |
750 if ( sscanf( t, "%d", bytes ) != 1 ) | 751 if ( sscanf( t, "%lu", bytes ) != 1 ) |
751 return TRUE; | 752 return TRUE; |
752 p = readField( t, p ); | 753 p = readField( t, p ); |
753 if ( sscanf( t, "%d", lines ) != 1 ) | 754 if ( sscanf( t, "%lu", lines ) != 1 ) |
754 return TRUE; | 755 return TRUE; |
755 return TRUE; | 756 return TRUE; |
756 } | 757 } |
757 | 758 |
758 static const char* | 759 static const char* |
787 static Bool | 788 static Bool |
788 needsMark( const char *ref ) | 789 needsMark( const char *ref ) |
789 { | 790 { |
790 Bool interesting, result; | 791 Bool interesting, result; |
791 const char *msgId; | 792 const char *msgId; |
792 int status; | 793 unsigned status; |
793 time_t lastAccess, nowTime; | 794 time_t lastAccess, nowTime; |
794 double threadFollowTime, maxTime, timeSinceLastAccess; | 795 double threadFollowTime, maxTime, timeSinceLastAccess; |
795 ItemList *itl; | 796 ItemList *itl; |
796 const double secPerDay = 24.0 * 3600.0; | 797 const double secPerDay = 24.0 * 3600.0; |
797 | 798 |
886 } | 887 } |
887 | 888 |
888 int | 889 int |
889 Client_getOver( const char *grp, int rmtFirst, int rmtLast, FetchMode mode ) | 890 Client_getOver( const char *grp, int rmtFirst, int rmtLast, FetchMode mode ) |
890 { | 891 { |
891 size_t nbytes, nlines; | 892 unsigned long nbytes, nlines; |
892 int rmtNumb, groupsNumb, oldLast, cntMarked; | 893 int rmtNumb, groupsNumb, oldLast, cntMarked; |
893 Over *ov; | 894 Over *ov; |
894 Str line, subj, from, date, msgId, ref, groups; | 895 Str line, subj, from, date, msgId, ref, groups; |
895 DynStr *response, *newsgroups; | 896 DynStr *response, *newsgroups; |
896 const char *lines, *groupLines; | 897 const char *lines, *groupLines; |
1022 } | 1023 } |
1023 | 1024 |
1024 static void | 1025 static void |
1025 retrievingFailed( const char* msgId, const char *reason ) | 1026 retrievingFailed( const char* msgId, const char *reason ) |
1026 { | 1027 { |
1027 int status; | 1028 unsigned status; |
1028 | 1029 |
1029 ASSERT( ! Lock_gotLock() ); | 1030 ASSERT( ! Lock_gotLock() ); |
1030 Log_err( "Retrieving of %s failed: %s", msgId, reason ); | 1031 Log_err( "Retrieving of %s failed: %s", msgId, reason ); |
1031 if ( ! Lock_openDatabases() ) | 1032 if ( ! Lock_openDatabases() ) |
1032 return; | 1033 return; |