int main(int argc, char *argv[argc]) { char *keystoreFile = NULL; char *keystorePassword = NULL; char *commandString = "/bin/date"; char *listenName = "lci:/Server"; /* options descriptor */ static struct option longopts[] = { { "identity", required_argument, NULL, 'f' }, { "password", required_argument, NULL, 'p' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'v' }, { NULL, 0, NULL, 0 } }; if (argc < 2) { usage(); exit(1); } int ch; while ((ch = getopt_long(argc, argv, "fphvc:", longopts, NULL)) != -1) { switch (ch) { case 'f': keystoreFile = optarg; break; case 'p': keystorePassword = optarg; break; case 'v': printf("%s\n", ccnxPortalServerAbout_Version()); return 0; case 'h': usage(); return 0; default: usage(); return -1; } } argc -= optind; argv += optind; if (argv[0] == NULL || keystoreFile == NULL || keystorePassword == NULL) { usage(); return -1; } listenName = argv[0]; commandString = argv[1]; argc += 2; PARCIdentityFile *identityFile = parcIdentityFile_Create(keystoreFile, keystorePassword); if (parcIdentityFile_Exists(identityFile) == false) { printf("Inaccessible keystore file '%s'.\n", keystoreFile); exit(1); } PARCIdentity *identity = parcIdentity_Create(identityFile, PARCIdentityFileAsPARCIdentity); parcIdentityFile_Release(&identityFile); CCNxName *name = ccnxName_CreateFromCString(listenName); int result = ccnServe(identity, name, commandString); ccnxName_Release(&name); return result; }
int main(int argc, char *argv[]) { int result; int ch; while ((ch = getopt_long(argc, argv, "a:f:p:hv", longopts, NULL)) != -1) { switch (ch) { case 'f': keystoreFile = optarg; break; case 'p': keystorePassword = optarg; break; case 'a': setenv(FORWARDER_CONNECTION_ENV, optarg, 1); break; case 'v': printf("%s\n", athenactlAbout_Version()); exit(0); case 'h': _usage(); athenactl_Usage(); exit(0); default: _usage(); exit(1); } } argc -= optind; argv += optind; KeystoreParams *keystoreParams; parcSecurity_Init(); if (keystorePassword == NULL) { keystorePassword = ccnxKeystoreUtilities_ReadPassword(); } keystoreParams = ccnxKeystoreUtilities_OpenFile(keystoreFile, keystorePassword); if (keystoreParams == NULL) { printf("Could not open or authenticate keystore\n"); exit(1); } PARCIdentityFile *identityFile = parcIdentityFile_Create(ccnxKeystoreUtilities_GetFileName(keystoreParams), ccnxKeystoreUtilities_GetPassword(keystoreParams)); if (parcIdentityFile_Exists(identityFile) == false) { printf("Inaccessible keystore file '%s'.\n", keystoreFile); exit(1); } PARCIdentity *identity = parcIdentity_Create(identityFile, PARCIdentityFileAsPARCIdentity); parcIdentityFile_Release(&identityFile); result = athenactl_Command(identity, argc, argv); parcIdentity_Release(&identity); keystoreParams_Destroy(&keystoreParams); parcSecurity_Fini(); return (result); }