Cleaned up all list iterations, added macro named LIST_FOREACH.
Previously you would have to do something like this:
for (type foo = (type) list_get_first(list); foo; foo = (type) list_get_next(list)
{
/* code */
}
Now, you can instead write this as:
LIST_FOREACH(type, foo, list,
{
/* code */
})
Basically, boilerplate stuff including the casting is gone.
This commit is contained in:
@@ -139,12 +139,11 @@ int route_flush_pipeline(struct hub_info* hub, struct hub_user* u)
|
||||
|
||||
int route_to_all(struct hub_info* hub, struct adc_message* command) /* iterate users */
|
||||
{
|
||||
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (user)
|
||||
struct hub_user* user;
|
||||
LIST_FOREACH(struct hub_user*, user, hub->users->list,
|
||||
{
|
||||
route_to_user(hub, user, command);
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -154,47 +153,38 @@ int route_to_subscribers(struct hub_info* hub, struct adc_message* command) /* i
|
||||
int do_send;
|
||||
char* tmp;
|
||||
|
||||
struct hub_user* user = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (user)
|
||||
struct hub_user* user;
|
||||
LIST_FOREACH(struct hub_user*, user, hub->users->list,
|
||||
{
|
||||
if (user->feature_cast)
|
||||
{
|
||||
do_send = 1;
|
||||
|
||||
tmp = list_get_first(command->feature_cast_include);
|
||||
while (tmp)
|
||||
|
||||
LIST_FOREACH(char*, tmp, command->feature_cast_include,
|
||||
{
|
||||
if (!user_have_feature_cast_support(user, tmp))
|
||||
{
|
||||
do_send = 0;
|
||||
break;
|
||||
}
|
||||
tmp = list_get_next(command->feature_cast_include);;
|
||||
}
|
||||
});
|
||||
|
||||
if (!do_send) {
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
if (!do_send)
|
||||
continue;
|
||||
}
|
||||
|
||||
tmp = list_get_first(command->feature_cast_exclude);
|
||||
while (tmp)
|
||||
LIST_FOREACH(char*, tmp, command->feature_cast_exclude,
|
||||
{
|
||||
if (user_have_feature_cast_support(user, tmp))
|
||||
{
|
||||
do_send = 0;
|
||||
break;
|
||||
}
|
||||
tmp = list_get_next(command->feature_cast_exclude);
|
||||
}
|
||||
});
|
||||
|
||||
if (do_send)
|
||||
{
|
||||
route_to_user(hub, user, command);
|
||||
}
|
||||
}
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -213,17 +203,14 @@ int route_info_message(struct hub_info* hub, struct hub_user* u)
|
||||
|
||||
adc_msg_remove_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR);
|
||||
adc_msg_add_named_argument(cmd, ADC_INF_FLAG_IPV4_ADDR, address);
|
||||
|
||||
user = (struct hub_user*) list_get_first(hub->users->list);
|
||||
while (user)
|
||||
|
||||
LIST_FOREACH(struct hub_user*, user, hub->users->list,
|
||||
{
|
||||
if (user_is_nat_override(user))
|
||||
route_to_user(hub, user, cmd);
|
||||
else
|
||||
route_to_user(hub, user, u->info);
|
||||
|
||||
user = (struct hub_user*) list_get_next(hub->users->list);
|
||||
}
|
||||
});
|
||||
adc_msg_free(cmd);
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user