~serge-hallyn/ubuntu/quantal/lxc/lxc-fixapi

« back to all changes in this revision

Viewing changes to src/lxc/arguments.c

  • Committer: Bazaar Package Importer
  • Author(s): Guido Trotter
  • Date: 2010-06-28 10:15:48 UTC
  • mto: (1.1.4 upstream) (3.1.5 sid)
  • mto: This revision was merged to the branch mainline in revision 7.
  • Revision ID: james.westby@ubuntu.com-20100628101548-vexhggdo6x9cpwtk
ImportĀ upstreamĀ versionĀ 0.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
207
207
        char **argv;
208
208
        int opt, nbargs = args->argc + 2;
209
209
 
210
 
        if (args->log_file)
211
 
                nbargs += 2;
212
 
        if (args->log_priority)
213
 
                nbargs += 2;
214
210
        if (args->quiet)
215
211
                nbargs += 1;
216
212
 
222
218
 
223
219
        argv[nbargs++] = strdup(file);
224
220
 
225
 
        if (args->log_file) {
226
 
                argv[nbargs++] = "--logfile";
227
 
                argv[nbargs++] = strdup(args->log_file);
228
 
        }
229
 
 
230
 
        if (args->log_priority) {
231
 
                argv[nbargs++] = "--logpriority";
232
 
                argv[nbargs++] = strdup(args->log_priority);
233
 
        }
234
 
 
235
221
        if (args->quiet)
236
222
                argv[nbargs++] = "--quiet";
237
223
 
244
230
 
245
231
        return argv;
246
232
}
 
233
 
 
234
int lxc_arguments_str_to_int(struct lxc_arguments *args, const char *str)
 
235
{
 
236
        long val;
 
237
        char *endptr;
 
238
 
 
239
        errno = 0;
 
240
        val = strtol(str, &endptr, 10);
 
241
        if (errno) {
 
242
                lxc_error(args, "invalid statefd '%s' : %m", str);
 
243
                return -1;
 
244
        }
 
245
 
 
246
        if (*endptr) {
 
247
                lxc_error(args, "invalid digit for statefd '%s'", str);
 
248
                return -1;
 
249
        }
 
250
 
 
251
        return (int)val;
 
252
}