+ int c;
+
+ input = stdin;
+ ctx = uci_alloc_context();
+ if (!ctx) {
+ fprintf(stderr, "Out of memory\n");
+ return 1;
+ }
+
+ while((c = getopt(argc, argv, "f:mnNp:P:sSq")) != -1) {
+ switch(c) {
+ case 'f':
+ input = fopen(optarg, "r");
+ if (!input) {
+ perror("uci");
+ return 1;
+ }
+ break;
+ case 'm':
+ flags |= CLI_FLAG_MERGE;
+ break;
+ case 's':
+ ctx->flags |= UCI_FLAG_STRICT;
+ break;
+ case 'S':
+ ctx->flags &= ~UCI_FLAG_STRICT;
+ ctx->flags |= UCI_FLAG_PERROR;
+ break;
+ case 'n':
+ ctx->flags |= UCI_FLAG_EXPORT_NAME;
+ break;
+ case 'N':
+ ctx->flags &= ~UCI_FLAG_EXPORT_NAME;
+ break;
+ case 'p':
+ uci_add_history_path(ctx, optarg);
+ break;
+ case 'P':
+ uci_add_history_path(ctx, ctx->savedir);
+ uci_set_savedir(ctx, optarg);
+ flags |= CLI_FLAG_NOCOMMIT;
+ break;
+ case 'q':
+ flags |= CLI_FLAG_QUIET;
+ break;
+ default:
+ uci_usage(argc, argv);
+ break;
+ }
+ }
+ if (optind > 1)
+ argv[optind - 1] = argv[0];
+ argv += optind - 1;
+ argc -= optind - 1;