Skip to content

Commit f1b1390

Browse files
committed
Refactor: move find_ticket_by_name to config module, for a better fit
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
1 parent 07e88c5 commit f1b1390

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

src/config.c

+22
Original file line numberDiff line numberDiff line change
@@ -1040,3 +1040,25 @@ const char *type_to_string(int type)
10401040
}
10411041
return "??invalid-type??";
10421042
}
1043+
1044+
int find_ticket_by_name(struct booth_config *conf_ptr,
1045+
const char *ticket, struct ticket_config **found)
1046+
{
1047+
struct ticket_config *tk;
1048+
int i;
1049+
1050+
assert(conf_ptr != NULL);
1051+
1052+
if (found)
1053+
*found = NULL;
1054+
1055+
FOREACH_TICKET(conf_ptr, i, tk) {
1056+
if (!strncmp(tk->name, ticket, sizeof(tk->name))) {
1057+
if (found)
1058+
*found = tk;
1059+
return 1;
1060+
}
1061+
}
1062+
1063+
return 0;
1064+
}

src/config.h

+13
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,17 @@ int find_site_by_id(struct booth_config *conf_ptr, uint32_t site_id,
395395

396396
const char *type_to_string(int type);
397397

398+
/**
399+
* @internal
400+
* Pick a ticket structure based on given name
401+
*
402+
* @param[inout] conf_ptr config object to refer to
403+
* @param[in] ticket name of the ticket to search for
404+
* @param[out] found place the reference here when found
405+
*
406+
* @return see @list_ticket and @send_header_plus
407+
*/
408+
int find_ticket_by_name(struct booth_config *conf_ptr,
409+
const char *ticket, struct ticket_config **found);
410+
398411
#endif /* _CONFIG_H */

src/ticket.c

-22
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,6 @@
4747

4848
extern int TIME_RES;
4949

50-
int find_ticket_by_name(struct booth_config *conf_ptr,
51-
const char *ticket, struct ticket_config **found)
52-
{
53-
struct ticket_config *tk;
54-
int i;
55-
56-
assert(conf_ptr != NULL);
57-
58-
if (found)
59-
*found = NULL;
60-
61-
FOREACH_TICKET(conf_ptr, i, tk) {
62-
if (!strncmp(tk->name, ticket, sizeof(tk->name))) {
63-
if (found)
64-
*found = tk;
65-
return 1;
66-
}
67-
}
68-
69-
return 0;
70-
}
71-
7250
int check_ticket(struct booth_config *conf_ptr, const char *ticket,
7351
struct ticket_config **found)
7452
{

src/ticket.h

-13
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,6 @@ void update_ticket_state(struct booth_config *conf_ptr,
164164
*/
165165
int setup_ticket(struct booth_config *conf_ptr);
166166

167-
/**
168-
* @internal
169-
* Pick a ticket structure based on given name
170-
*
171-
* @param[inout] conf_ptr config object to refer to
172-
* @param[in] ticket name of the ticket to search for
173-
* @param[out] found place the reference here when found
174-
*
175-
* @return see @list_ticket and @send_header_plus
176-
*/
177-
int find_ticket_by_name(struct booth_config *conf_ptr,
178-
const char *ticket, struct ticket_config **found);
179-
180167
/**
181168
* @internal
182169
* Apply the next step with the ticket if possible.

0 commit comments

Comments
 (0)