Mercurial > noffle
diff src/server.c @ 61:adf0af5152f7 noffle
[svn] Renamed some variables and function names, because they caused compiler
warnings because of shadowing global variables from system include files
(index, stat, serv).
author | enz |
---|---|
date | Fri, 12 May 2000 18:19:38 +0100 |
parents | 125d79c9e586 |
children | 7250be163ec4 |
line wrap: on
line diff
--- a/src/server.c Fri May 12 17:52:58 2000 +0100 +++ b/src/server.c Fri May 12 18:19:38 2000 +0100 @@ -1,7 +1,7 @@ /* server.c - $Id: server.c 60 2000-05-09 22:28:38Z uh1763 $ + $Id: server.c 67 2000-05-12 17:19:38Z enz $ */ #if HAVE_CONFIG_H @@ -55,7 +55,7 @@ Bool running; int artPtr; Str grp; /* selected group, "" if none */ -} serv = { FALSE, 0, "" }; +} server = { FALSE, 0, "" }; typedef struct Cmd { @@ -122,11 +122,11 @@ { FetchMode mode; - Grp_setLastAccess( serv.grp, time( NULL ) ); - if ( ! Grp_local ( serv.grp ) && Cfg_autoSubscribe() && ! Online_true() ) + Grp_setLastAccess( server.grp, time( NULL ) ); + if ( ! Grp_local ( server.grp ) && Cfg_autoSubscribe() && ! Online_true() ) { Fetchlist_read(); - if ( ! Fetchlist_contains( serv.grp ) ) + if ( ! Fetchlist_contains( server.grp ) ) { if ( strcmp( Cfg_autoSubscribeMode(), "full" ) == 0 ) mode = FULL; @@ -134,7 +134,7 @@ mode = THREAD; else mode = OVER; - Fetchlist_add( serv.grp, mode ); + Fetchlist_add( server.grp, mode ); Fetchlist_write(); Pseudo_autoSubscribed(); } @@ -210,11 +210,11 @@ checkNewArts( const char *grp ) { if ( ! Online_true() - || strcmp( grp, serv.grp ) == 0 + || strcmp( grp, server.grp ) == 0 || Grp_local( grp ) - || time( NULL ) - Grp_lastAccess( serv.grp ) < 1800 ) + || time( NULL ) - Grp_lastAccess( server.grp ) < 1800 ) return; - if ( Fetch_init( Grp_serv( grp ) ) ) + if ( Fetch_init( Grp_server( grp ) ) ) { Fetch_getNewArts( grp, OVER ); Fetch_close(); @@ -224,11 +224,11 @@ static void postArts( void ) { - Str serv; + Str s; Cfg_beginServEnum(); - while ( Cfg_nextServ( serv ) ) - if ( Fetch_init( serv ) ) + while ( Cfg_nextServ( s ) ) + if ( Fetch_init( s ) ) { Fetch_postArts(); Fetch_close(); @@ -263,9 +263,9 @@ changeToGrp( const char *grp ) { checkNewArts( grp ); - Utl_cpyStr( serv.grp, grp ); + Utl_cpyStr( server.grp, grp ); readCont( grp ); - serv.artPtr = Cont_first(); + server.artPtr = Cont_first(); } static Bool @@ -296,7 +296,7 @@ static Bool testGrpSelected( void ) { - if ( *serv.grp == '\0' ) + if ( *server.grp == '\0' ) { putStat( STAT_NO_GRP_SELECTED, "No group selected" ); return FALSE; @@ -305,9 +305,9 @@ } static void -findServ( const char *msgId, Str result ) +findServer( const char *msgId, Str result ) { - const char *p, *pColon, *serv; + const char *p, *pColon, *srv; Str s, grp; Utl_cpyStr( result, "(unknown)" ); @@ -322,9 +322,9 @@ if ( pColon ) { Utl_cpyStrN( grp, p, pColon - p ); - serv = Grp_serv( grp ); - if ( Cfg_servIsPreferential( serv, result ) ) - Utl_cpyStr( result, serv ); + srv = Grp_server( grp ); + if ( Cfg_servIsPreferential( srv, result ) ) + Utl_cpyStr( result, srv ); } } while ( ( p = strtok( NULL, " \t" ) ) ); @@ -334,13 +334,13 @@ static Bool retrieveArt( const char *msgId ) { - Str serv; + Str s; - findServ( msgId, serv ); - if ( strcmp( serv, "(unknown)" ) == 0 - || strcmp( serv, GRP_LOCAL_SERVER_NAME ) == 0 ) + findServer( msgId, s ); + if ( strcmp( s, "(unknown)" ) == 0 + || strcmp( s, GRP_LOCAL_SERVER_NAME ) == 0 ) return FALSE; - if ( ! Client_connect( serv ) ) + if ( ! Client_connect( s ) ) return FALSE; Client_retrieveArt( msgId ); Client_disconnect(); @@ -374,18 +374,18 @@ { if ( ! checkNumb( n ) ) return FALSE; - serv.artPtr = n; + server.artPtr = n; ov = Cont_get( n ); *msgId = Ov_msgId( ov ); *numb = n; } else if ( strcmp( arg, "" ) == 0 ) { - if ( ! checkNumb( serv.artPtr ) ) + if ( ! checkNumb( server.artPtr ) ) return FALSE; - ov = Cont_get( serv.artPtr ); + ov = Cont_get( server.artPtr ); *msgId = Ov_msgId( ov ); - *numb = serv.artPtr; + *numb = server.artPtr; } else { @@ -403,9 +403,9 @@ static void touchArticle( const char *msgId ) { - int stat = Db_stat( msgId ); - stat |= DB_INTERESTING; - Db_setStat( msgId, stat ); + int status = Db_status( msgId ); + status |= DB_INTERESTING; + Db_setStatus( msgId, status ); Db_updateLastAccess( msgId ); } @@ -441,29 +441,29 @@ doBodyInDb( const char *msgId ) { int stat; - Str serv; + Str srv; touchArticle( msgId ); touchReferences( msgId ); - stat = Db_stat( msgId ); + stat = Db_status( msgId ); if ( Online_true() && ( stat & DB_NOT_DOWNLOADED ) ) { retrieveArt( msgId ); - stat = Db_stat( msgId ); + stat = Db_status( msgId ); } if ( stat & DB_RETRIEVING_FAILED ) { - Db_setStat( msgId, stat & ~DB_RETRIEVING_FAILED ); + Db_setStatus( msgId, stat & ~DB_RETRIEVING_FAILED ); putTxtBuf( Db_body( msgId ) ); } else if ( stat & DB_NOT_DOWNLOADED ) { - findServ( msgId, serv ); - if ( Req_contains( serv, msgId ) ) + findServer( msgId, srv ); + if ( Req_contains( srv, msgId ) ) putTxtBuf( Pseudo_alreadyMarkedBody() ); - else if ( strcmp( serv, "(unknown)" ) != 0 && - strcmp( serv, GRP_LOCAL_SERVER_NAME ) != 0 && - Req_add( serv, msgId ) ) + else if ( strcmp( srv, "(unknown)" ) != 0 && + strcmp( srv, GRP_LOCAL_SERVER_NAME ) != 0 && + Req_add( srv, msgId ) ) putTxtBuf( Pseudo_markedBody() ); else putTxtBuf( Pseudo_markingFailedBody() ); @@ -570,7 +570,7 @@ if ( testGrpSelected() ) { - n = serv.artPtr; + n = server.artPtr; if ( ! Cont_validNumb( n ) ) putStat( STAT_NO_ART_SELECTED, "No article selected" ); else @@ -582,7 +582,7 @@ { putStat( STAT_ART_RETRIEVED, "%ld %s selected", n, Ov_msgId( Cont_get( n ) ) ); - serv.artPtr = n; + server.artPtr = n; } } } @@ -876,7 +876,7 @@ if ( testGrpSelected() ) { - n = serv.artPtr; + n = server.artPtr; if ( ! Cont_validNumb( n ) ) putStat( STAT_NO_ART_SELECTED, "No article selected" ); else @@ -888,7 +888,7 @@ { putStat( STAT_ART_RETRIEVED, "%ld %s selected", n, Ov_msgId( Cont_get( n ) ) ); - serv.artPtr = n; + server.artPtr = n; } } } @@ -937,7 +937,7 @@ { if ( Grp_exists( grp ) && ! Grp_local( grp ) ) { - if ( ! Out_add( Grp_serv( grp ), msgId, art ) ) + if ( ! Out_add( Grp_server( grp ), msgId, art ) ) { Log_err( "Cannot add posted article to outgoing directory" ); err = TRUE; @@ -1002,7 +1002,7 @@ { if ( Grp_exists( grp ) && ! Grp_local( grp ) ) { - if ( ! Out_add( Grp_serv( grp ), msgId, art ) ) + if ( ! Out_add( Grp_server( grp ), msgId, art ) ) { Log_err( "Cannot add posted article to outgoing directory" ); err = TRUE; @@ -1221,8 +1221,8 @@ r = sscanf( p, "%d-%d", first, last ); if ( r < 1 ) { - *first = serv.artPtr; - *last = serv.artPtr; + *first = server.artPtr; + *last = server.artPtr; } else if ( r == 1 ) { @@ -1333,7 +1333,7 @@ case XREF: msgId = Ov_msgId( ov ); if ( Pseudo_isGeneralInfo( msgId ) ) - putTxtLn( "%lu %s:%lu", n, serv.grp, n ); + putTxtLn( "%lu %s:%lu", n, server.grp, n ); else putTxtLn( "%lu %s", n, Db_xref( msgId ) ); break; @@ -1460,7 +1460,7 @@ return TRUE; parseRange( arg, &first, &last, &n ); if ( n == 0 ) - first = last = serv.artPtr; + first = last = server.artPtr; putStat( STAT_OVERS_FOLLOW, "Overview %ld-%ld", first, last ); for ( i = first; i <= last; ++i ) if ( ( ov = Cont_get( i ) ) ) @@ -1526,25 +1526,25 @@ } static Bool -initServ( void ) +initServer( void ) { - ASSERT( ! serv.running ); + ASSERT( ! server.running ); if ( ! Lock_openDatabases() ) return FALSE; - serv.running = TRUE; + server.running = TRUE; return TRUE; } static void -closeServ( void ) +closeServer( void ) { - ASSERT( serv.running ); - serv.running = FALSE; + ASSERT( server.running ); + server.running = FALSE; Lock_closeDatabases(); } void -Serv_run( void ) +Server_run( void ) { Bool done; int r; @@ -1569,14 +1569,14 @@ done = TRUE; else if ( r == 0 ) { - if ( serv.running ) - closeServ(); + if ( server.running ) + closeServer(); } else /* ( r > 0 ) */ { - if ( ! serv.running ) + if ( ! server.running ) { - if ( ! initServ() ) + if ( ! initServer() ) { putFatal( "Cannot init server" ); done = TRUE; @@ -1591,6 +1591,6 @@ done = TRUE; } } - if ( serv.running ) - closeServ(); + if ( server.running ) + closeServer(); }