Mercurial > noffle
comparison src/server.c @ 155:22b81617d427 noffle
[svn] applied patch from Matija Nalis: better handling of inconsistent counters
at remote server; do not read overview on each group command
author | enz |
---|---|
date | Tue, 05 Dec 2000 19:50:09 +0000 |
parents | bfeea2bc09b6 |
children | 23a53c92d4d7 |
comparison
equal
deleted
inserted
replaced
154:b2a4f839affd | 155:22b81617d427 |
---|---|
1 /* | 1 /* |
2 server.c | 2 server.c |
3 | 3 |
4 $Id: server.c 225 2000-10-26 21:13:28Z bears $ | 4 $Id: server.c 236 2000-12-05 19:50:09Z enz $ |
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 |
55 time_t lastServerOpen; | 55 time_t lastServerOpen; |
56 int artPtr; | 56 int artPtr; |
57 Str grp; /* selected group, "" if none */ | 57 Str grp; /* selected group, "" if none */ |
58 DynStr *reply; | 58 DynStr *reply; |
59 Bool eotAfterReply; | 59 Bool eotAfterReply; |
60 } server = { FALSE, 0L, 0, "", NULL, FALSE }; | 60 Bool groupReady; |
61 } server = { FALSE, 0L, 0, "", NULL, FALSE, FALSE }; | |
61 | 62 |
62 typedef struct Cmd | 63 typedef struct Cmd |
63 { | 64 { |
64 const char *name; | 65 const char *name; |
65 const char *syntax; | 66 const char *syntax; |
305 { | 306 { |
306 checkNewArts( grp ); | 307 checkNewArts( grp ); |
307 Utl_cpyStr( server.grp, grp ); | 308 Utl_cpyStr( server.grp, grp ); |
308 readCont( grp ); | 309 readCont( grp ); |
309 server.artPtr = Cont_first(); | 310 server.artPtr = Cont_first(); |
311 server.groupReady = TRUE; | |
310 } | 312 } |
311 | 313 |
312 static Bool | 314 static Bool |
313 doGrp( char *arg, const Cmd *cmd ) | 315 doGrp( char *arg, const Cmd *cmd ) |
314 { | 316 { |
318 putSyntax( cmd ); | 320 putSyntax( cmd ); |
319 else if ( ! Grp_exists( arg ) ) | 321 else if ( ! Grp_exists( arg ) ) |
320 putStat( STAT_NO_SUCH_GRP, "No such group" ); | 322 putStat( STAT_NO_SUCH_GRP, "No such group" ); |
321 else | 323 else |
322 { | 324 { |
323 changeToGrp( arg ); | 325 Utl_cpyStr( server.grp, arg ); |
324 first = Cont_first(); | 326 server.groupReady = FALSE; |
325 last = Cont_last(); | 327 server.artPtr = Grp_first( arg ); |
328 first = server.artPtr; | |
329 last = Grp_last( arg ); | |
326 if ( ( first == 0 && last == 0 ) | 330 if ( ( first == 0 && last == 0 ) |
327 || first > last ) | 331 || first > last ) |
328 first = last = numb = 0; | 332 first = last = numb = 0; |
329 else | 333 else |
330 numb = last - first + 1; | 334 numb = last - first + 1; |
333 } | 337 } |
334 return TRUE; | 338 return TRUE; |
335 } | 339 } |
336 | 340 |
337 static Bool | 341 static Bool |
338 testGrpSelected( void ) | 342 loadGrpIfSelected( void ) |
339 { | 343 { |
344 Str group; | |
340 if ( *server.grp == '\0' ) | 345 if ( *server.grp == '\0' ) |
341 { | 346 { |
342 putStat( STAT_NO_GRP_SELECTED, "No group selected" ); | 347 putStat( STAT_NO_GRP_SELECTED, "No group selected" ); |
343 return FALSE; | 348 return FALSE; |
349 } | |
350 if ( ! server.groupReady ) | |
351 { | |
352 Utl_cpyStr( group, server.grp ); | |
353 changeToGrp( group ); | |
344 } | 354 } |
345 return TRUE; | 355 return TRUE; |
346 } | 356 } |
347 | 357 |
348 static void | 358 static void |
393 } | 403 } |
394 | 404 |
395 static Bool | 405 static Bool |
396 checkNumb( int numb ) | 406 checkNumb( int numb ) |
397 { | 407 { |
398 if ( ! testGrpSelected() ) | 408 if ( ! loadGrpIfSelected() ) |
399 return FALSE; | 409 return FALSE; |
400 if ( ! Cont_validNumb( numb ) ) | 410 if ( ! Cont_validNumb( numb ) ) |
401 { | 411 { |
402 putStat( STAT_NO_SUCH_NUMB, "No such article" ); | 412 putStat( STAT_NO_SUCH_NUMB, "No such article" ); |
403 return FALSE; | 413 return FALSE; |
626 int n; | 636 int n; |
627 | 637 |
628 UNUSED( arg ); | 638 UNUSED( arg ); |
629 UNUSED( cmd ); | 639 UNUSED( cmd ); |
630 | 640 |
631 if ( testGrpSelected() ) | 641 if ( loadGrpIfSelected() ) |
632 { | 642 { |
633 n = server.artPtr; | 643 n = server.artPtr; |
634 if ( ! Cont_validNumb( n ) ) | 644 if ( ! Cont_validNumb( n ) ) |
635 putStat( STAT_NO_ART_SELECTED, "No article selected" ); | 645 putStat( STAT_NO_ART_SELECTED, "No article selected" ); |
636 else | 646 else |
927 int n; | 937 int n; |
928 | 938 |
929 UNUSED(arg); | 939 UNUSED(arg); |
930 UNUSED(cmd); | 940 UNUSED(cmd); |
931 | 941 |
932 if ( testGrpSelected() ) | 942 if ( loadGrpIfSelected() ) |
933 { | 943 { |
934 n = server.artPtr; | 944 n = server.artPtr; |
935 if ( ! Cont_validNumb( n ) ) | 945 if ( ! Cont_validNumb( n ) ) |
936 putStat( STAT_NO_ART_SELECTED, "No article selected" ); | 946 putStat( STAT_NO_ART_SELECTED, "No article selected" ); |
937 else | 947 else |
1155 const Over * ov; | 1165 const Over * ov; |
1156 int first, last, i, n, numb; | 1166 int first, last, i, n, numb; |
1157 Str field; | 1167 Str field; |
1158 | 1168 |
1159 /* Argument is article no. or range */ | 1169 /* Argument is article no. or range */ |
1160 if ( ! testGrpSelected() ) | 1170 if ( ! loadGrpIfSelected() ) |
1161 return TRUE; | 1171 return TRUE; |
1162 parseRange( p, &first, &last, &numb ); | 1172 parseRange( p, &first, &last, &numb ); |
1163 if ( numb == 0 ) | 1173 if ( numb == 0 ) |
1164 { | 1174 { |
1165 putStat( STAT_NO_ART_SELECTED, "No articles selected" ); | 1175 putStat( STAT_NO_ART_SELECTED, "No articles selected" ); |
1220 const Over * ov; | 1230 const Over * ov; |
1221 Str field; | 1231 Str field; |
1222 int first, last, i, n, numb; | 1232 int first, last, i, n, numb; |
1223 | 1233 |
1224 /* Argument is article no. or range */ | 1234 /* Argument is article no. or range */ |
1225 if ( ! testGrpSelected() ) | 1235 if ( ! loadGrpIfSelected() ) |
1226 return TRUE; | 1236 return TRUE; |
1227 parseRange( articles, &first, &last, &numb ); | 1237 parseRange( articles, &first, &last, &numb ); |
1228 if ( numb == 0 ) | 1238 if ( numb == 0 ) |
1229 { | 1239 { |
1230 putStat( STAT_NO_ART_SELECTED, "No articles selected" ); | 1240 putStat( STAT_NO_ART_SELECTED, "No articles selected" ); |
1289 int first, last, i, n; | 1299 int first, last, i, n; |
1290 const Over *ov; | 1300 const Over *ov; |
1291 | 1301 |
1292 UNUSED( cmd ); | 1302 UNUSED( cmd ); |
1293 | 1303 |
1294 if ( ! testGrpSelected() ) | 1304 if ( ! loadGrpIfSelected() ) |
1295 return TRUE; | 1305 return TRUE; |
1296 parseRange( arg, &first, &last, &n ); | 1306 parseRange( arg, &first, &last, &n ); |
1297 if ( n == 0 ) | 1307 if ( n == 0 ) |
1298 first = last = server.artPtr; | 1308 first = last = server.artPtr; |
1299 putStat( STAT_OVERS_FOLLOW, "Overview %ld-%ld", first, last ); | 1309 putStat( STAT_OVERS_FOLLOW, "Overview %ld-%ld", first, last ); |