int main(int argc, char *argv[]) { extern char *optarg; int option_index = 0; int c; char *workdir = getenv("CFENGINE_TEST_OVERRIDE_WORKDIR"); snprintf(AVAILABLE_PACKAGES_FILE_NAME, 256, "%s/cfengine-mock-package-manager-available", workdir ? workdir : "/tmp"); snprintf(INSTALLED_PACKAGES_FILE_NAME, 256, "%s/cfengine-mock-package-manager-installed", workdir ? workdir : "/tmp"); while ((c = getopt_long(argc, argv, "", OPTIONS, &option_index)) != EOF) { PackagePattern *pattern = NULL; switch (c) { case 'c': ClearInstalledPackages(); break; case 'C': ClearAvailablePackages(); break; case 'l': { Rlist *installed_packages = ReadPackageEntries(INSTALLED_PACKAGES_FILE_NAME); ShowPackages(stdout, installed_packages); } break; case 'L': { Rlist *available_packages = ReadPackageEntries(AVAILABLE_PACKAGES_FILE_NAME); ShowPackages(stdout, available_packages); } break; case 'a': pattern = DeserializePackagePattern(optarg); AddPackage(pattern); break; case 'P': PopulateAvailable(optarg); break; /* case 'd': */ /* DeletePackage(pattern); */ /* break; */ /* case 'r': */ /* ReinstallPackage(pattern); */ /* break; */ /* case 'u': */ /* UpdatePackage(pattern); */ /* break; */ /* case 'U': */ /* AddUpdatePackage(pattern); */ /* break; */ /* case 'v': */ /* VerifyPackage(pattern); */ /* break; */ default: Syntax("mock-package-manager - pretend that you are managing packages!", OPTIONS, HINTS, ID, false); exit(1); } } return 0; }
int main(int argc, char *argv[]) { extern char *optarg; int option_index = 0; int c; #ifdef __MINGW32__ InitializeWindows(); #endif char *workdir = getenv("CFENGINE_TEST_OVERRIDE_WORKDIR"); char *tempdir = getenv("TEMP"); if (!workdir && !tempdir) { fprintf(stderr, "Please set either CFENGINE_TEST_OVERRIDE_WORKDIR or TEMP environment variables\n" "to a valid directory.\n"); return 2; } xsnprintf(AVAILABLE_PACKAGES_FILE_NAME, 256, "%s/cfengine-mock-package-manager-available", workdir ? workdir : tempdir); xsnprintf(INSTALLED_PACKAGES_FILE_NAME, 256, "%s/cfengine-mock-package-manager-installed", workdir ? workdir : tempdir); while ((c = getopt_long(argc, argv, "", OPTIONS, &option_index)) != EOF) { PackagePattern *pattern = NULL; switch (c) { case 'c': ClearInstalledPackages(); break; case 'C': ClearAvailablePackages(); break; case 'l': { Seq *installed_packages = ReadPackageEntries(INSTALLED_PACKAGES_FILE_NAME); ShowPackages(stdout, installed_packages); } break; case 'L': { Seq *available_packages = ReadPackageEntries(AVAILABLE_PACKAGES_FILE_NAME); ShowPackages(stdout, available_packages); } break; case 'a': pattern = DeserializePackagePattern(optarg); AddPackage(pattern); break; case 'P': PopulateAvailable(optarg); break; /* case 'd': */ /* DeletePackage(pattern); */ /* break; */ /* case 'r': */ /* ReinstallPackage(pattern); */ /* break; */ /* case 'u': */ /* UpdatePackage(pattern); */ /* break; */ /* case 'U': */ /* AddUpdatePackage(pattern); */ /* break; */ /* case 'v': */ /* VerifyPackage(pattern); */ /* break; */ default: { Writer *w = FileWriter(stdout); WriterWriteHelp(w, "mock-package-manager - pretend that you are managing packages!", OPTIONS, HINTS, false); FileWriterDetach(w); } exit(EXIT_FAILURE); } } return 0; }