int main(int argc, char *argv[]) { option_flags oflags = 0; int exit_status = 0; char *json_file = NULL; FILE *input = NULL; while (1) { static struct option long_options[] = { // Flag options {"debug", no_argument, &debug_flag, 1}, {"help", no_argument, &help_flag, 1}, {"recurse", no_argument, &recurse_flag, 1}, {"silent", no_argument, &silent_flag, 1}, {"unbuffered", no_argument, &unbuffered_flag, 1}, {"unsafe", no_argument, &unsafe_flag, 1}, {"verbose", no_argument, &verbose_flag, 1}, {"version", no_argument, &version_flag, 1}, // Indexed options {"file", required_argument, NULL, 'f'}, {0, 0, 0, 0} }; int option_index = 0; int c = getopt_long_only(argc, argv, "f:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 'f': json_file = optarg; break; case '?': // getopt_long already printed an error message break; default: // Ignore break; } } const char *help = "Name\n" " baton-chmod\n" "\n" "Synopsis\n" "\n" " baton-chmod [--file <json file>] [--recurse] [--silent]\n" " [--unbuffered] [--unsafe] [--verbose]\n" " [--version]\n" "\n" "Description\n" " Set permissions on collections and data objects\n" "described in a JSON input file.\n" "\n" " --file The JSON file describing the data objects.\n" " Optional, defaults to STDIN.\n" " --recurse Modify collection permissions recursively.\n" " Optional, defaults to false.\n" " --silent Silence error messages.\n" " --unbuffered Flush print operations for each JSON object.\n" " --unsafe Permit unsafe relative iRODS paths.\n" " --verbose Print verbose messages to STDERR.\n" " --version Print the version number and exit.\n"; if (help_flag) { printf("%s\n",help); exit(0); } if (version_flag) { printf("%s\n", VERSION); exit(0); } if (unsafe_flag) oflags = oflags | UNSAFE_RESOLVE; if (debug_flag) set_log_threshold(DEBUG); if (verbose_flag) set_log_threshold(NOTICE); if (silent_flag) set_log_threshold(FATAL); declare_client_name(argv[0]); input = maybe_stdin(json_file); int status; if (recurse_flag) { status = do_modify_permissions(input, RECURSE, oflags); } else { status = do_modify_permissions(input, NO_RECURSE, oflags); } if (status != 0) exit_status = 5; exit(exit_status); }
int main(int argc, char *argv[]) { option_flags oflags = SEARCH_COLLECTIONS | SEARCH_OBJECTS; int exit_status = 0; char *zone_name = NULL; char *json_file = NULL; FILE *input = NULL; while (1) { static struct option long_options[] = { // Flag options {"acl", no_argument, &acl_flag, 1}, {"avu", no_argument, &avu_flag, 1}, {"checksum", no_argument, &checksum_flag, 1}, {"coll", no_argument, &coll_flag, 1}, {"debug", no_argument, &debug_flag, 1}, {"help", no_argument, &help_flag, 1}, {"obj", no_argument, &obj_flag, 1}, {"replicate", no_argument, &replicate_flag, 1}, {"silent", no_argument, &silent_flag, 1}, {"size", no_argument, &size_flag, 1}, {"timestamp", no_argument, ×tamp_flag, 1}, {"unbuffered", no_argument, &unbuffered_flag, 1}, {"unsafe", no_argument, &unsafe_flag, 1}, {"verbose", no_argument, &verbose_flag, 1}, {"version", no_argument, &version_flag, 1}, // Indexed options {"file", required_argument, NULL, 'f'}, {"zone", required_argument, NULL, 'z'}, {0, 0, 0, 0} }; int option_index = 0; int c = getopt_long_only(argc, argv, "f:z:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 'f': json_file = optarg; break; case 'z': zone_name = optarg; break; case '?': // getopt_long already printed an error message break; default: // Ignore break; } } if (coll_flag && !obj_flag) { oflags = oflags ^ SEARCH_OBJECTS; } else if (obj_flag && !coll_flag) { oflags = oflags ^ SEARCH_COLLECTIONS; } if (acl_flag) oflags = oflags | PRINT_ACL; if (avu_flag) oflags = oflags | PRINT_AVU; if (checksum_flag) oflags = oflags | PRINT_CHECKSUM; if (replicate_flag) oflags = oflags | PRINT_REPLICATE; if (size_flag) oflags = oflags | PRINT_SIZE; if (timestamp_flag) oflags = oflags | PRINT_TIMESTAMP; if (unsafe_flag) oflags = oflags | UNSAFE_RESOLVE; const char *help = "Name\n" " baton-metaquery\n" "\n" "Synopsis\n" "\n" " baton-metaquery [--acl] [--avu] [--checksum] [--coll]\n" " [--file <JSON file>]\n" " [--obj ] [--replicate] [--silent] [--size]\n" " [--timestamp] [--unbuffered] [--unsafe]\n" " [--verbose] [--version] [--zone <name>]\n" "\n" "Description\n" " Finds items in iRODS by AVU, given a query constructed\n" "from a JSON input file.\n" "\n" " --acl Print access control lists in output.\n" " --avu Print AVU lists in output.\n" " --checksum Print data object checksums in output.\n" " --coll Limit search to collection metadata only.\n" " --file The JSON file describing the query. Optional,\n" " defaults to STDIN.\n" " --obj Limit search to data object metadata only.\n" " --replicate Report data object replicates.\n" " --silent Silence error messages.\n" " --timestamp Print timestamps in output.\n" " --unbuffered Flush print operations for each JSON object.\n" " --unsafe Permit unsafe relative iRODS paths.\n" " --verbose Print verbose messages to STDERR.\n" " --version Print the version number and exit.\n" " --zone The zone to search. Optional.\n"; if (help_flag) { printf("%s\n",help); exit(0); } if (version_flag) { printf("%s\n", VERSION); exit(0); } if (debug_flag) set_log_threshold(DEBUG); if (verbose_flag) set_log_threshold(NOTICE); if (silent_flag) set_log_threshold(FATAL); declare_client_name(argv[0]); input = maybe_stdin(json_file); int status = do_search_metadata(input, zone_name, oflags); if (status != 0) exit_status = 5; exit(exit_status); }
int main(int argc, char *argv[]) { print_flags pflags = PRINT_DEFAULT; int exit_status = 0; char *json_file = NULL; FILE *input = NULL; while (1) { static struct option long_options[] = { // Flag options {"acl", no_argument, &acl_flag, 1}, {"avu", no_argument, &avu_flag, 1}, {"debug", no_argument, &debug_flag, 1}, {"help", no_argument, &help_flag, 1}, {"timestamp", no_argument, ×tamp_flag, 1}, {"unbuffered", no_argument, &unbuffered_flag, 1}, {"verbose", no_argument, &verbose_flag, 1}, {"version", no_argument, &version_flag, 1}, // Indexed options {"file", required_argument, NULL, 'f'}, {0, 0, 0, 0} }; int option_index = 0; int c = getopt_long_only(argc, argv, "f:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 'f': json_file = optarg; break; case '?': // getopt_long already printed an error message break; default: // Ignore break; } } if (acl_flag) pflags = pflags | PRINT_ACL; if (avu_flag) pflags = pflags | PRINT_AVU; if (timestamp_flag) pflags = pflags | PRINT_TIMESTAMP; if (help_flag) { puts("Name"); puts(" json-list"); puts(""); puts("Synopsis"); puts(""); puts(" json-list [--acl] [--avu] [--file <json file>]"); puts(""); puts("Description"); puts(" Lists data objects and collections described in a JSON "); puts(" input file."); puts(""); puts(" --acl Print access control lists in output."); puts(" --avu Print AVU lists in output."); puts(" --file The JSON file describing the data objects and"); puts(" collections. Optional, defaults to STDIN."); puts(" --timestamp Print timestamps in output."); puts(" --unbuffered Flush print operations for each JSON object."); puts(" --verbose Print verbose messages to STDERR."); puts(""); exit(0); } if (version_flag) { printf("%s\n", VERSION); exit(0); } if (debug_flag) set_log_threshold(DEBUG); if (verbose_flag) set_log_threshold(NOTICE); declare_client_name(argv[0]); input = maybe_stdin(json_file); int status = do_list_paths(input, pflags); if (status != 0) exit_status = 5; exit(exit_status); }
int main(int argc, char *argv[]) { option_flags oflags = 0; int exit_status = 0; metadata_op meta_op = -1; char *json_file = NULL; FILE *input = NULL; while (1) { static struct option long_options[] = { // Flag options {"debug", no_argument, &debug_flag, 1}, {"help", no_argument, &help_flag, 1}, {"silent", no_argument, &silent_flag, 1}, {"unbuffered", no_argument, &unbuffered_flag, 1}, {"unsafe", no_argument, &unsafe_flag, 1}, {"verbose", no_argument, &verbose_flag, 1}, {"version", no_argument, &version_flag, 1}, // Indexed options {"file", required_argument, NULL, 'f'}, {"operation", required_argument, NULL, 'o'}, {0, 0, 0, 0} }; int option_index = 0; int c = getopt_long_only(argc, argv, "f:o:", long_options, &option_index); /* Detect the end of the options. */ if (c == -1) break; switch (c) { case 'f': json_file = optarg; break; case 'o': if (strcmp("add", optarg) == 0) { meta_op = META_ADD; } if (strcmp("rem", optarg) == 0) { meta_op = META_REM; } break; case '?': // getopt_long already printed an error message break; default: // Ignore break; } } const char *help = "Name\n" " baton-metamod\n" "\n" "Synopsis\n" "\n" " baton-metamod [--file <JSON file>] --operation <operation>\n" " [--silent] [--unbuffered] [--unsafe]\n" " [--verbose] [--version]\n" "\n" "Description\n" " Modifies metadata AVUs on collections and data objects\n" "described in a JSON input file.\n" "\n" " --file The JSON file describing the data objects and\n" " collections. Optional, defaults to STDIN.\n" " --operation Operation to perform. One of [add, rem].\n" " Required.\n" " --silent Silence error messages.\n" " --unbuffered Flush print operations for each JSON object.\n" " --unsafe Permit unsafe relative iRODS paths.\n" " --verbose Print verbose messages to STDERR.\n" " --version Print the version number and exit.\n"; if (help_flag) { printf("%s\n", help); exit(0); } if (version_flag) { printf("%s\n", VERSION); exit(0); } if (unsafe_flag) oflags = oflags | UNSAFE_RESOLVE; if (debug_flag) set_log_threshold(DEBUG); if (verbose_flag) set_log_threshold(NOTICE); if (silent_flag) set_log_threshold(FATAL); declare_client_name(argv[0]); switch (meta_op) { case META_ADD: case META_REM: input = maybe_stdin(json_file); int status = do_modify_metadata(input, meta_op, oflags); if (status != 0) exit_status = 5; break; default: fprintf(stderr, "No valid operation was specified; valid " "operations are: [add rem]\n"); goto args_error; } exit(exit_status); args_error: exit_status = 4; exit(exit_status); }