blob: 325706ed2350490163ea4fbea754769e605796cf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#ifndef QUEUE_H_SENTRY
#define QUEUE_H_SENTRY
#define MAKE_QUEUE_INIT(NAME) \
void NAME ## _init(struct NAME *q) \
{ \
q->first = NULL; \
q->last = NULL; \
}
#define MAKE_QUEUE_PUSH(NAME, VALUE, TYPE) \
void NAME ## _push(struct NAME *q, TYPE VALUE) \
{ \
struct VALUE ## _item *tmp = malloc(sizeof(struct VALUE ## _item)); \
tmp-> VALUE = VALUE; \
tmp->next = NULL; \
if(!q->first) { \
q->first = tmp; \
q->last = q->first; \
} else { \
q->last->next = tmp; \
q->last = q->last->next; \
} \
}
struct word_item {
char *word;
struct word_item *next;
};
struct cmdline_item {
char **cmdline;
struct cmdline_item *next;
};
struct pid_item {
int pid;
struct pid_item *next;
};
struct w_queue {
struct word_item *first;
struct word_item *last;
};
struct c_queue {
struct cmdline_item *first;
struct cmdline_item *last;
struct cmdline_item *last_extracted_item;
};
struct p_queue {
struct pid_item *first;
struct pid_item *last;
};
void w_queue_clear(struct w_queue *q);
int w_queue_get_word_count(const struct w_queue *q);
void w_queue_copy_words_to_args(const struct w_queue *q, char **cmdline);
void c_queue_init(struct c_queue *q);
void c_queue_push(struct c_queue *q, char **cmdline);
char** c_queue_pop(struct c_queue *q);
void c_queue_clear(struct c_queue *q);
int c_queue_is_empty(struct c_queue *q);
int p_queue_find_pid(struct p_queue *q, int pid);
void p_queue_clear(struct p_queue *q);
int p_queue_get_process_quantity(struct p_queue *q);
#endif
|