int main(int argc, char *argv[]) { /* Declarations */ int c, option_index = 0; struct option long_options[] = { {"interface", required_argument, 0, 'i'}, {"target-property", required_argument, 0, 't'}, {"profile", required_argument, 0, 'p'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} }; char *interface = NULL; char *target_property = NULL; char *profile = NULL; /* Parse command-line options */ while((c = getopt_long(argc, argv, "p:hv", long_options, &option_index)) != -1) { switch(c) { case 'i': interface = optarg; break; case 't': target_property = optarg; break; case 'p': profile = optarg; break; case 'h': case '?': print_usage(argv[0]); return 0; case 'v': print_version(argv[0]); return 0; } } /* Validate options */ interface = check_interface_option(interface); target_property = check_target_property_option(target_property); profile = check_profile_option(profile); if(optind >= argc) { fprintf(stderr, "An infrastructure Nix expression has to be specified!\n"); return 1; } else return query_installed(interface, target_property, argv[optind], profile); /* Execute query operation */ }
int main(int argc, char *argv[]) { /* Declarations */ int c, option_index = 0; struct option long_options[] = { {"unlock", no_argument, 0, 'u'}, {"coordinator-profile-path", required_argument, 0, 'P'}, {"profile", required_argument, 0, 'p'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} }; char *profile = NULL; int lock = TRUE; char *coordinator_profile_path = NULL; char *manifest_file; /* Parse command-line options */ while((c = getopt_long(argc, argv, "up:hv", long_options, &option_index)) != -1) { switch(c) { case 'u': lock = FALSE; break; case 'P': coordinator_profile_path = optarg; break; case 'p': profile = optarg; break; case 'h': case '?': print_usage(argv[0]); return 0; case 'v': print_version(argv[0]); return 0; } } /* Validate options */ profile = check_profile_option(profile); if(optind >= argc) manifest_file = NULL; else manifest_file = argv[optind]; return lock_or_unlock(lock, manifest_file, coordinator_profile_path, profile); /* Execute lock or unlock operation */ }
int main(int argc, char *argv[]) { /* Declarations */ int c, option_index = 0; struct option long_options[] = { {"container", required_argument, 0, DISNIX_OPTION_CONTAINER}, {"component", required_argument, 0, DISNIX_OPTION_COMPONENT}, {"coordinator-profile-path", required_argument, 0, DISNIX_OPTION_COORDINATOR_PROFILE_PATH}, {"profile", required_argument, 0, DISNIX_OPTION_PROFILE}, {"old-manifest", required_argument, 0, DISNIX_OPTION_OLD_MANIFEST}, {"no-upgrade", no_argument, 0, DISNIX_OPTION_NO_UPGRADE}, {"delete-state", no_argument, 0, DISNIX_OPTION_DELETE_STATE}, {"transfer-only", no_argument, 0, DISNIX_OPTION_TRANSFER_ONLY}, {"depth-first", no_argument, 0, DISNIX_OPTION_DEPTH_FIRST}, {"all", no_argument, 0, DISNIX_OPTION_ALL}, {"keep", required_argument, 0, DISNIX_OPTION_KEEP}, {"max-concurrent-transfers", required_argument, 0, DISNIX_OPTION_MAX_CONCURRENT_TRANSFERS}, {"help", no_argument, 0, DISNIX_OPTION_HELP}, {"version", no_argument, 0, DISNIX_OPTION_VERSION}, {0, 0, 0, 0} }; unsigned int max_concurrent_transfers = DISNIX_DEFAULT_MAX_NUM_OF_CONCURRENT_TRANSFERS; unsigned int flags = 0; int keep = DISNIX_DEFAULT_KEEP; char *manifest_file; char *old_manifest = NULL; char *profile = NULL; char *coordinator_profile_path = NULL; char *container = NULL; char *component = NULL; /* Parse command-line options */ while((c = getopt_long(argc, argv, "c:C:m:o:p:hv", long_options, &option_index)) != -1) { switch(c) { case DISNIX_OPTION_CONTAINER: container = optarg; break; case DISNIX_OPTION_COMPONENT: component = optarg; break; case DISNIX_OPTION_PROFILE: profile = optarg; break; case DISNIX_OPTION_COORDINATOR_PROFILE_PATH: coordinator_profile_path = optarg; break; case DISNIX_OPTION_OLD_MANIFEST: old_manifest = optarg; break; case DISNIX_OPTION_NO_UPGRADE: flags |= FLAG_NO_UPGRADE; break; case DISNIX_OPTION_DELETE_STATE: flags |= FLAG_DELETE_STATE; break; case DISNIX_OPTION_ALL: flags |= FLAG_ALL; break; case DISNIX_OPTION_KEEP: keep = atoi(optarg); break; case DISNIX_OPTION_TRANSFER_ONLY: flags |= FLAG_TRANSFER_ONLY; break; case DISNIX_OPTION_DEPTH_FIRST: flags |= FLAG_DEPTH_FIRST; break; case DISNIX_OPTION_MAX_CONCURRENT_TRANSFERS: max_concurrent_transfers = atoi(optarg); break; case DISNIX_OPTION_HELP: print_usage(argv[0]); return 0; case DISNIX_OPTION_VERSION: print_version(argv[0]); return 0; default: print_usage(argv[0]); return 1; } } /* Validate options */ profile = check_profile_option(profile); if(optind >= argc) manifest_file = NULL; else manifest_file = argv[optind]; if(check_global_delete_state()) flags |= FLAG_DELETE_STATE; return run_migrate(manifest_file, max_concurrent_transfers, flags, keep, old_manifest, coordinator_profile_path, profile, container, component); /* Execute migrate operation */ }
int main(int argc, char *argv[]) { /* Declarations */ int c, option_index = 0; struct option long_options[] = { {"container", required_argument, 0, 'c'}, {"component", required_argument, 0, 'C'}, {"coordinator-profile-path", required_argument, 0, 'P'}, {"profile", required_argument, 0, 'p'}, {"old-manifest", required_argument, 0, 'o'}, {"no-upgrade", no_argument, 0, 'u'}, {"transfer-only", no_argument, 0, 't'}, {"all", no_argument, 0, 'a'}, {"max-concurrent-transfers", required_argument, 0, 'm'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} }; unsigned int max_concurrent_transfers = 2; int transfer_only = FALSE; int all = FALSE; int no_upgrade = FALSE; char *manifest_file; char *old_manifest = NULL; char *profile = NULL; char *coordinator_profile_path = NULL; char *container = NULL; char *component = NULL; /* Parse command-line options */ while((c = getopt_long(argc, argv, "c:C:m:o:p:hv", long_options, &option_index)) != -1) { switch(c) { case 'c': container = optarg; break; case 'C': component = optarg; break; case 'p': profile = optarg; break; case 'P': coordinator_profile_path = optarg; break; case 'o': old_manifest = optarg; break; case 'u': no_upgrade = TRUE; break; case 'a': all = TRUE; break; case 't': transfer_only = TRUE; break; case 'm': max_concurrent_transfers = atoi(optarg); break; case 'h': case '?': print_usage(argv[0]); return 0; case 'v': print_version(argv[0]); return 0; } } /* Validate options */ profile = check_profile_option(profile); if(optind >= argc) manifest_file = NULL; else manifest_file = argv[optind]; return snapshot(manifest_file, max_concurrent_transfers, transfer_only, all, old_manifest, coordinator_profile_path, profile, no_upgrade, container, component); /* Execute snapshot operation */ }
int main(int argc, char *argv[]) { /* Declarations */ int c, option_index = 0; struct option long_options[] = { {"old-manifest", required_argument, 0, 'o'}, {"coordinator-profile-path", required_argument, 0, 'P'}, {"profile", required_argument, 0, 'p'}, {"no-upgrade", no_argument, 0, 'u'}, {"no-rollback", no_argument, 0, 'r'}, {"dry-run", no_argument, 0, 'd'}, {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} }; char *old_manifest = NULL; char *profile = NULL; char *coordinator_profile_path = NULL; int no_upgrade = FALSE; int no_rollback = FALSE; int dry_run = FALSE; /* Parse command-line options */ while((c = getopt_long(argc, argv, "o:p:hv", long_options, &option_index)) != -1) { switch(c) { case 'o': old_manifest = optarg; break; case 'p': profile = optarg; break; case 'P': coordinator_profile_path = optarg; break; case 'r': no_rollback = TRUE; break; case 'u': no_upgrade = TRUE; break; case 'd': dry_run = TRUE; break; case 'h': case '?': print_usage(argv[0]); return 0; case 'v': print_version(argv[0]); return 0; } } /* Validate options */ profile = check_profile_option(profile); if(optind >= argc) { fprintf(stderr, "A manifest file has to be specified!\n"); return 1; } else return activate_system(argv[optind], old_manifest, coordinator_profile_path, profile, no_upgrade, no_rollback, dry_run); /* Execute activation operation */ }