@@ -59,16 +59,16 @@ int check_max_len_valid(const char *s, int max)
5959
6060int find_ticket_by_name (const char * ticket , struct ticket_config * * found )
6161{
62+ struct ticket_config * tk ;
6263 int i ;
6364
6465 if (found )
6566 * found = NULL ;
6667
67- for (i = 0 ; i < booth_conf -> ticket_count ; i ++ ) {
68- if (!strncmp (booth_conf -> ticket [i ].name , ticket ,
69- sizeof (booth_conf -> ticket [i ].name ))) {
68+ FOREACH_TICKET (i , tk ) {
69+ if (!strncmp (tk -> name , ticket , sizeof (tk -> name ))) {
7070 if (found )
71- * found = booth_conf -> ticket + i ;
71+ * found = tk ;
7272 return 1 ;
7373 }
7474 }
@@ -392,6 +392,7 @@ int do_revoke_ticket(struct ticket_config *tk)
392392int list_ticket (char * * pdata , unsigned int * len )
393393{
394394 struct ticket_config * tk ;
395+ struct booth_site * site ;
395396 char timeout_str [64 ];
396397 char pending_str [64 ];
397398 char * data , * cp ;
@@ -405,7 +406,7 @@ int list_ticket(char **pdata, unsigned int *len)
405406
406407 alloc = booth_conf -> ticket_count * (BOOTH_NAME_LEN * 2 + 128 + 16 );
407408
408- foreach_ticket (i , tk ) {
409+ FOREACH_TICKET (i , tk ) {
409410 multiple_grant_warning_length = number_sites_marked_as_granted (tk );
410411
411412 if (multiple_grant_warning_length > 1 ) {
@@ -419,7 +420,7 @@ int list_ticket(char **pdata, unsigned int *len)
419420 return - ENOMEM ;
420421
421422 cp = data ;
422- foreach_ticket (i , tk ) {
423+ FOREACH_TICKET (i , tk ) {
423424 if ((!is_manual (tk )) && is_time_set (& tk -> term_expires )) {
424425 /* Manual tickets doesn't have term_expires defined */
425426 ts = wall_ts (& tk -> term_expires );
@@ -467,7 +468,7 @@ int list_ticket(char **pdata, unsigned int *len)
467468 }
468469 }
469470
470- foreach_ticket (i , tk ) {
471+ FOREACH_TICKET (i , tk ) {
471472 multiple_grant_warning_length = number_sites_marked_as_granted (tk );
472473
473474 if (multiple_grant_warning_length > 1 ) {
@@ -476,12 +477,12 @@ int list_ticket(char **pdata, unsigned int *len)
476477 "\nWARNING: The ticket %s is granted to multiple sites: " , // ~55 characters
477478 tk -> name );
478479
479- for (site_index = 0 ; site_index < booth_conf -> site_count ; ++ site_index ) {
480+ FOREACH_NODE (site_index , site ) {
480481 if (tk -> sites_where_granted [site_index ] > 0 ) {
481482 cp += snprintf (cp ,
482483 alloc - (cp - data ),
483484 "%s" ,
484- site_string (& ( booth_conf -> site [ site_index ]) ));
485+ site_string (site ));
485486
486487 if (-- multiple_grant_warning_length > 0 ) {
487488 cp += snprintf (cp ,
@@ -632,7 +633,7 @@ int setup_ticket(void)
632633 struct ticket_config * tk ;
633634 int i ;
634635
635- foreach_ticket (i , tk ) {
636+ FOREACH_TICKET (i , tk ) {
636637 reset_ticket (tk );
637638
638639 if (local -> type == SITE ) {
@@ -859,8 +860,7 @@ static void log_lost_servers(struct ticket_config *tk)
859860 */
860861 return ;
861862
862- for (i = 0 ; i < booth_conf -> site_count ; i ++ ) {
863- n = booth_conf -> site + i ;
863+ FOREACH_NODE (i , n ) {
864864 if (!(tk -> acks_received & n -> bitmask )) {
865865 tk_log_warn ("%s %s didn't acknowledge our %s, "
866866 "will retry %d times" ,
@@ -880,8 +880,7 @@ static void resend_msg(struct ticket_config *tk)
880880 if (!(tk -> acks_received ^ local -> bitmask )) {
881881 ticket_broadcast (tk , tk -> last_request , 0 , RLT_SUCCESS , 0 );
882882 } else {
883- for (i = 0 ; i < booth_conf -> site_count ; i ++ ) {
884- n = booth_conf -> site + i ;
883+ FOREACH_NODE (i , n ) {
885884 if (!(tk -> acks_received & n -> bitmask )) {
886885 n -> resend_cnt ++ ;
887886 tk_log_debug ("resending %s to %s" ,
@@ -1145,7 +1144,7 @@ void process_tickets(void)
11451144 int i ;
11461145 timetype last_cron ;
11471146
1148- foreach_ticket (i , tk ) {
1147+ FOREACH_TICKET (i , tk ) {
11491148 if (!has_extprog_exited (tk ) &&
11501149 is_time_set (& tk -> next_cron ) && !is_past (& tk -> next_cron ))
11511150 continue ;
@@ -1169,7 +1168,7 @@ void tickets_log_info(void)
11691168 int i ;
11701169 time_t ts ;
11711170
1172- foreach_ticket (i , tk ) {
1171+ FOREACH_TICKET (i , tk ) {
11731172 ts = wall_ts (& tk -> term_expires );
11741173 tk_log_info ("state '%s' "
11751174 "term %d "
@@ -1365,8 +1364,9 @@ int is_manual(struct ticket_config *tk)
13651364int number_sites_marked_as_granted (struct ticket_config * tk )
13661365{
13671366 int i , result = 0 ;
1367+ struct booth_site * ignored __attribute__((unused ));
13681368
1369- for ( i = 0 ; i < booth_conf -> site_count ; ++ i ) {
1369+ FOREACH_NODE ( i , ignored ) {
13701370 result += tk -> sites_where_granted [i ];
13711371 }
13721372
0 commit comments