Skip to content

Commit

Permalink
Refactor: move find_ticket_by_name to config module, for a better fit
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Pokorný <[email protected]>
  • Loading branch information
jnpkrn committed Jan 31, 2020
1 parent 1afa62f commit 0732349
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
22 changes: 22 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1038,3 +1038,25 @@ const char *type_to_string(int type)
}
return "??invalid-type??";
}

int find_ticket_by_name(struct booth_config *conf_ptr,
const char *ticket, struct ticket_config **found)
{
struct ticket_config *tk;
int i;

assert(conf_ptr != NULL);

if (found)
*found = NULL;

FOREACH_TICKET(conf_ptr, i, tk) {
if (!strncmp(tk->name, ticket, sizeof(tk->name))) {
if (found)
*found = tk;
return 1;
}
}

return 0;
}
13 changes: 13 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,17 @@ int find_site_by_id(struct booth_config *conf_ptr, uint32_t site_id,

const char *type_to_string(int type);

/**
* @internal
* Pick a ticket structure based on given name
*
* @param[inout] conf_ptr config object to refer to
* @param[in] ticket name of the ticket to search for
* @param[out] found place the reference here when found
*
* @return see @list_ticket and @send_header_plus
*/
int find_ticket_by_name(struct booth_config *conf_ptr,
const char *ticket, struct ticket_config **found);

#endif /* _CONFIG_H */
22 changes: 0 additions & 22 deletions src/ticket.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,6 @@

extern int TIME_RES;

int find_ticket_by_name(struct booth_config *conf_ptr,
const char *ticket, struct ticket_config **found)
{
struct ticket_config *tk;
int i;

assert(conf_ptr != NULL);

if (found)
*found = NULL;

FOREACH_TICKET(conf_ptr, i, tk) {
if (!strncmp(tk->name, ticket, sizeof(tk->name))) {
if (found)
*found = tk;
return 1;
}
}

return 0;
}

int check_ticket(struct booth_config *conf_ptr, const char *ticket,
struct ticket_config **found)
{
Expand Down
13 changes: 0 additions & 13 deletions src/ticket.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,6 @@ void update_ticket_state(struct booth_config *conf_ptr,
*/
int setup_ticket(struct booth_config *conf_ptr);

/**
* @internal
* Pick a ticket structure based on given name
*
* @param[inout] conf_ptr config object to refer to
* @param[in] ticket name of the ticket to search for
* @param[out] found place the reference here when found
*
* @return see @list_ticket and @send_header_plus
*/
int find_ticket_by_name(struct booth_config *conf_ptr,
const char *ticket, struct ticket_config **found);

/**
* @internal
* Apply the next step with the ticket if possible.
Expand Down

0 comments on commit 0732349

Please sign in to comment.