~ubuntu-branches/ubuntu/saucy/slurm-llnl/saucy

« back to all changes in this revision

Viewing changes to src/sacctmgr/txn_functions.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2008-12-03 11:56:28 UTC
  • mfrom: (1.1.8 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20081203115628-93t417da6wkazmo5
Tags: 1.3.11-1
New upstream release 

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
{
47
47
        int i, end = 0;
48
48
        int set = 0;
 
49
        int command_len = 0;
 
50
        int option = 0;
49
51
 
50
52
        for (i=(*start); i<argc; i++) {
51
53
                end = parse_option_end(argv[i]);
52
 
                if(!end && !strncasecmp(argv[i], "where", 5)) {
 
54
                if(!end)
 
55
                        command_len=strlen(argv[i]);
 
56
                else {
 
57
                        command_len=end-1;
 
58
                        if(argv[i][end] == '=') {
 
59
                                option = (int)argv[i][end-1];
 
60
                                end++;
 
61
                        }
 
62
                }
 
63
 
 
64
                if(!end && !strncasecmp(argv[i], "where",
 
65
                                        MAX(command_len, 5))) {
53
66
                        continue;
54
 
                } if(!end && !strncasecmp(argv[i], "withassocinfo", 5)) {
 
67
                } if(!end && !strncasecmp(argv[i], "withassocinfo",
 
68
                                          MAX(command_len, 5))) {
55
69
                        txn_cond->with_assoc_info = 1;
56
70
                        set = 1;
57
71
                } else if(!end
58
 
                          || (!strncasecmp (argv[i], "Id", 1))
59
 
                          || (!strncasecmp (argv[i], "Txn", 1))) {
 
72
                          || (!strncasecmp (argv[i], "Id",
 
73
                                            MAX(command_len, 1)))
 
74
                          || (!strncasecmp (argv[i], "Txn",
 
75
                                            MAX(command_len, 1)))) {
 
76
                        ListIterator itr = NULL;
 
77
                        char *temp = NULL;
 
78
                        uint32_t id = 0;
 
79
 
60
80
                        if(!txn_cond->id_list)
61
81
                                txn_cond->id_list = 
62
82
                                        list_create(slurm_destroy_char);
64
84
                        if(slurm_addto_char_list(txn_cond->id_list, 
65
85
                                                 argv[i]+end))
66
86
                                set = 1;
67
 
                } else if (!strncasecmp (argv[i], "Accounts", 3)) {
 
87
 
 
88
                        /* check to make sure user gave ints here */
 
89
                        itr = list_iterator_create(txn_cond->id_list);
 
90
                        while ((temp = list_next(itr))) {
 
91
                                if (get_uint(temp, &id, "Transaction ID")
 
92
                                    != SLURM_SUCCESS) {
 
93
                                        exit_code = 1;
 
94
                                        list_delete_item(itr);
 
95
                                }
 
96
                        }
 
97
                        list_iterator_destroy(itr);
 
98
                } else if (!strncasecmp (argv[i], "Accounts",
 
99
                                         MAX(command_len, 3))) {
68
100
                        if(!txn_cond->acct_list)
69
101
                                txn_cond->acct_list =
70
102
                                        list_create(slurm_destroy_char);
71
103
                        if(slurm_addto_char_list(txn_cond->acct_list,
72
104
                                                 argv[i]+end))
73
105
                                set = 1;
74
 
                } else if (!strncasecmp (argv[i], "Action", 4)) {
 
106
                } else if (!strncasecmp (argv[i], "Action",
 
107
                                         MAX(command_len, 4))) {
75
108
                        if(!txn_cond->action_list)
76
109
                                txn_cond->action_list =
77
110
                                        list_create(slurm_destroy_char);
81
114
                                set = 1;
82
115
                        else
83
116
                                exit_code=1;
84
 
                } else if (!strncasecmp (argv[i], "Actors", 4)) {
 
117
                } else if (!strncasecmp (argv[i], "Actors",
 
118
                                         MAX(command_len, 4))) {
85
119
                        if(!txn_cond->actor_list)
86
120
                                txn_cond->actor_list =
87
121
                                        list_create(slurm_destroy_char);
88
122
                        if(slurm_addto_char_list(txn_cond->actor_list,
89
123
                                                 argv[i]+end))
90
124
                                set = 1;
91
 
                } else if (!strncasecmp (argv[i], "Clusters", 3)) {
 
125
                } else if (!strncasecmp (argv[i], "Clusters",
 
126
                                         MAX(command_len, 3))) {
92
127
                        if(!txn_cond->cluster_list)
93
128
                                txn_cond->cluster_list =
94
129
                                        list_create(slurm_destroy_char);
95
130
                        if(slurm_addto_char_list(txn_cond->cluster_list,
96
131
                                                 argv[i]+end))
97
132
                                set = 1;
98
 
                } else if (!strncasecmp (argv[i], "End", 1)) {
 
133
                } else if (!strncasecmp (argv[i], "End", MAX(command_len, 1))) {
99
134
                        txn_cond->time_end = parse_time(argv[i]+end, 1);
100
135
                        set = 1;
101
 
                } else if (!strncasecmp (argv[i], "Format", 1)) {
 
136
                } else if (!strncasecmp (argv[i], "Format",
 
137
                                         MAX(command_len, 1))) {
102
138
                        if(format_list)
103
139
                                slurm_addto_char_list(format_list, argv[i]+end);
104
 
                } else if (!strncasecmp (argv[i], "Start", 1)) {
 
140
                } else if (!strncasecmp (argv[i], "Start", 
 
141
                                         MAX(command_len, 1))) {
105
142
                        txn_cond->time_start = parse_time(argv[i]+end, 1);
106
143
                        set = 1;
107
 
                } else if (!strncasecmp (argv[i], "User", 1)) {
 
144
                } else if (!strncasecmp (argv[i], "User",
 
145
                                         MAX(command_len, 1))) {
108
146
                        if(!txn_cond->user_list)
109
147
                                txn_cond->user_list =
110
148
                                        list_create(slurm_destroy_char);
171
209
        itr = list_iterator_create(format_list);
172
210
        while((object = list_next(itr))) {
173
211
                char *tmp_char = NULL;
 
212
                int command_len = strlen(object);
 
213
 
174
214
                field = xmalloc(sizeof(print_field_t));
175
 
                if(!strncasecmp("Accounts", object, 3)) {
 
215
                if(!strncasecmp("Accounts", object, MAX(command_len, 3))) {
176
216
                        field->type = PRINT_ACCT;
177
217
                        field->name = xstrdup("Accounts");
178
218
                        field->len = 20;
179
219
                        field->print_routine = print_fields_str;
180
 
                } else if(!strncasecmp("Action", object, 4)) {
 
220
                } else if(!strncasecmp("Action", object, MAX(command_len, 4))) {
181
221
                        field->type = PRINT_ACTION;
182
222
                        field->name = xstrdup("Action");
183
223
                        field->len = 20;
184
224
                        field->print_routine = print_fields_str;
185
 
                } else if(!strncasecmp("Actor", object, 4)) {
 
225
                } else if(!strncasecmp("Actor", object,
 
226
                                       MAX(command_len, 4))) {
186
227
                        field->type = PRINT_ACTOR;
187
228
                        field->name = xstrdup("Actor");
188
229
                        field->len = 10;
189
230
                        field->print_routine = print_fields_str;
190
 
                } else if(!strncasecmp("Clusters", object, 4)) {
 
231
                } else if(!strncasecmp("Clusters", object, 
 
232
                                       MAX(command_len, 4))) {
191
233
                        field->type = PRINT_CLUSTER;
192
234
                        field->name = xstrdup("Clusters");
193
235
                        field->len = 20;
194
236
                        field->print_routine = print_fields_str;
195
 
                } else if(!strncasecmp("ID", object, 2)) {
 
237
                } else if(!strncasecmp("ID", object, MAX(command_len, 2))) {
196
238
                        field->type = PRINT_ID;
197
239
                        field->name = xstrdup("ID");
198
240
                        field->len = 6;
199
241
                        field->print_routine = print_fields_uint;
200
 
                } else if(!strncasecmp("Info", object, 2)) {
 
242
                } else if(!strncasecmp("Info", object, MAX(command_len, 2))) {
201
243
                        field->type = PRINT_INFO;
202
244
                        field->name = xstrdup("Info");
203
245
                        field->len = 20;
204
246
                        field->print_routine = print_fields_str;
205
 
                } else if(!strncasecmp("TimeStamp", object, 1)) {
 
247
                } else if(!strncasecmp("TimeStamp", object, 
 
248
                                       MAX(command_len, 1))) {
206
249
                        field->type = PRINT_TS;
207
250
                        field->name = xstrdup("Time");
208
251
                        field->len = 15;
209
252
                        field->print_routine = print_fields_date;
210
 
                } else if(!strncasecmp("Users", object, 4)) {
 
253
                } else if(!strncasecmp("Users", object, MAX(command_len, 4))) {
211
254
                        field->type = PRINT_USER;
212
255
                        field->name = xstrdup("Users");
213
256
                        field->len = 20;
214
257
                        field->print_routine = print_fields_str;
215
 
                } else if(!strncasecmp("Where", object, 1)) {
 
258
                } else if(!strncasecmp("Where", object, MAX(command_len, 1))) {
216
259
                        field->type = PRINT_WHERE;
217
260
                        field->name = xstrdup("Where");
218
261
                        field->len = 20;