/// Unset environment variable /// /// For systems where unsetenv() is not available the value will be set as an /// empty string int os_unsetenv(const char *name) { #ifdef HAVE_UNSETENV return unsetenv(name); #else return os_setenv(name, "", 1); #endif }
/// Initializes the module void server_init(void) { servers = pmap_new(cstr_t)(); if (!os_getenv(LISTEN_ADDRESS_ENV_VAR)) { char *listen_address = (char *)vim_tempname(); os_setenv(LISTEN_ADDRESS_ENV_VAR, listen_address, 1); free(listen_address); } server_start((char *)os_getenv(LISTEN_ADDRESS_ENV_VAR)); }
void server_init() { servers = pmap_new(cstr_t)(); if (!os_getenv("NEOVIM_LISTEN_ADDRESS")) { char *listen_address = (char *)vim_tempname('s'); os_setenv("NEOVIM_LISTEN_ADDRESS", listen_address, 1); free(listen_address); } server_start((char *)os_getenv("NEOVIM_LISTEN_ADDRESS")); }
int main(int argc, char *argv[]) { START(argc, argv, "obj_pool"); if (argc < 4) UT_FATAL("usage: %s op path layout [poolsize mode]", argv[0]); char *layout = NULL; size_t poolsize; unsigned mode; if (strcmp(argv[3], "EMPTY") == 0) layout = ""; else if (strcmp(argv[3], "NULL") != 0) layout = argv[3]; switch (argv[1][0]) { case 'c': poolsize = strtoull(argv[4], NULL, 0) * MB; /* in megabytes */ mode = strtoul(argv[5], NULL, 8); pool_create(argv[2], layout, poolsize, mode); break; case 'o': pool_open(argv[2], layout); break; case 'f': os_setenv("PMEMOBJ_CONF", "invalid-query", 1); pool_open(argv[2], layout); os_unsetenv("PMEMOBJ_CONF"); pool_open(argv[2], layout); break; case 't': poolsize = strtoull(argv[4], NULL, 0) * MB; /* in megabytes */ mode = strtoul(argv[5], NULL, 8); test_fault_injection(argv[2], layout, poolsize, mode); break; default: UT_FATAL("unknown operation"); } DONE(NULL); }
static void wpatalk_action_process(const char *msg) { const char *pos; char *copy = NULL, *id, *pos2; pos = msg; if (*pos == '<') { /* skip priority */ pos = os_strchr(pos, '>'); if (pos) pos++; else pos = msg; } if (str_match(pos, WPA_EVENT_CONNECTED)) { int new_id = -1; os_unsetenv("WPA_ID"); os_unsetenv("WPA_ID_STR"); os_unsetenv("WPA_CTRL_DIR"); pos = os_strstr(pos, "[id="); if (pos) copy = os_strdup(pos + 4); if (copy) { pos2 = id = copy; while (*pos2 && *pos2 != ' ') pos2++; *pos2++ = '\0'; new_id = atoi(id); os_setenv("WPA_ID", id, 1); while (*pos2 && *pos2 != '=') pos2++; if (*pos2 == '=') pos2++; id = pos2; while (*pos2 && *pos2 != ']') pos2++; *pos2 = '\0'; os_setenv("WPA_ID_STR", id, 1); os_free(copy); } os_setenv("WPA_CTRL_DIR", ctrl_iface_dir, 1); if (!wpatalk_connected || new_id != wpatalk_last_id) { wpatalk_connected = 1; wpatalk_last_id = new_id; } return; } if (str_match(pos, WPA_EVENT_DISCONNECTED)) { if (wpatalk_connected) { wpatalk_connected = 0; } return; } if (str_match(pos, WPA_EVENT_TERMINATING)) { wpatalk_error("daemon is terminating"); os_sleep(2,0); wpatalk_reconnect(); return; } /* WPS-related messages. * All WPS "jobs" send CTRL-REQ-WPS_JOB_DONE when done. * They first send CTRL-REQ-EAP-WPS-SUCCESS if successful. */ if (str_match(pos, "CTRL-REQ-EAP-WPS-SUCCESS")) { if (wpatalk_wps_pending) { wpatalk_wps_finish(1, pos); } return; } if (str_match(pos, "CTRL-REQ-WPS-JOB-DONE")) { /* If we didn't stop due to success, must be failure */ if (wpatalk_wps_pending) { wpatalk_wps_finish(0, pos); } return; } }
int OSPL_MAIN(int argc, const char *argv[]) { FILE *testDataFile; char testDataLine[128]; #ifdef _WIN32 char* oldSearchPath; char* newSearchPath; #endif DDS_DomainParticipantFactory domainParticipantFactory; DDS_DomainParticipant domainParticipant = DDS_OBJECT_NIL; os_result result = os_resultSuccess; /** A local configuration file is used : ospllog4cplugin.xml * and a DomainParticpant is created with this configuration */ os_setenv("OSPL_URI", "file://ospllog4cplugin.xml"); #ifdef _WIN32 /** * Iff the patform is windows, the plugin lib directory is added onto the * PATH so it can be loaded */ oldSearchPath = os_getenv(OS_LIB_LOAD_PATH_VAR); if (oldSearchPath == NULL) { oldSearchPath = ""; } newSearchPath = os_malloc(sizeof(".." "lib") + 2 + strlen(oldSearchPath)); sprintf(newSearchPath, "%s%c%s%c%s", "..", OS_FILESEPCHAR, "lib", OS_PATHSEPCHAR, oldSearchPath); os_setenv(OS_LIB_LOAD_PATH_VAR, newSearchPath); os_free(newSearchPath); #endif /** * A single process DomainParticipant is created. */ domainParticipantFactory = DDS_DomainParticipantFactory_get_instance(); if (domainParticipantFactory == NULL) { printf("Error: can't get the domain participant factory.\n"); return -1; } domainParticipant = DDS_DomainParticipantFactory_create_participant(domainParticipantFactory, DDS_DOMAIN_ID_DEFAULT, DDS_PARTICIPANT_QOS_DEFAULT, NULL, DDS_STATUS_MASK_NONE); if (domainParticipant == NULL) { printf("Error: can't create the domain participant. Please check the configuration & the contents of any error logs.\n"); return -1; } /** After a DomainParticipant has been created the log plug-in will have * been initialised and will be in use. Some test data is now loaded and * written as report messages. */ testDataFile = fopen("testdata.txt", "r"); if (testDataFile != NULL) { int i = 0; while (i < 1000 && result == os_resultSuccess) { if (fgets(testDataLine, sizeof(testDataLine), testDataFile) != NULL) { i++; testDataLine[strlen(testDataLine) - 1] = '\0'; OS_REPORT_3 ((os_reportType) (i % (OS_REPAIRED - OS_DEBUG + 1)), "OpenSplice log4c plug-in example", i, "Test data line %d: %s\t\t%s", i, testDataLine, os_reportTypeText[i % (OS_REPAIRED - OS_DEBUG + 1)] ); } else if (i == 0) { OS_REPORT(OS_FATAL, "OpenSplice log4c plug-in example", 0, "Data cannot be read from testsdata.txt."); result = os_resultFail; } else { fseek(testDataFile, 0, SEEK_SET); } } fclose(testDataFile); } DDS_DomainParticipantFactory_delete_participant(domainParticipantFactory, domainParticipant); return result; }
static void wpa_cli_action_process(const char *msg) { const char *pos; char *copy = NULL, *id, *pos2; pos = msg; if (*pos == '<') { /* skip priority */ pos = os_strchr(pos, '>'); if (pos) pos++; else pos = msg; } if (str_match(pos, WPA_EVENT_CONNECTED)) { int new_id = -1; os_unsetenv("WPA_ID"); os_unsetenv("WPA_ID_STR"); os_unsetenv("WPA_CTRL_DIR"); pos = os_strstr(pos, "[id="); if (pos) copy = os_strdup(pos + 4); if (copy) { pos2 = id = copy; while (*pos2 && *pos2 != ' ') pos2++; *pos2++ = '\0'; new_id = atoi(id); os_setenv("WPA_ID", id, 1); while (*pos2 && *pos2 != '=') pos2++; if (*pos2 == '=') pos2++; id = pos2; while (*pos2 && *pos2 != ']') pos2++; *pos2 = '\0'; os_setenv("WPA_ID_STR", id, 1); os_free(copy); } os_setenv("WPA_CTRL_DIR", ctrl_iface_dir, 1); if (!wpa_cli_connected || new_id != wpa_cli_last_id) { wpa_cli_connected = 1; wpa_cli_last_id = new_id; wpa_cli_exec(action_file, ctrl_ifname, "CONNECTED"); } } else if (str_match(pos, WPA_EVENT_DISCONNECTED)) { if (wpa_cli_connected) { wpa_cli_connected = 0; wpa_cli_exec(action_file, ctrl_ifname, "DISCONNECTED"); } } else if (str_match(pos, WPA_EVENT_TERMINATING)) { printf("wpa_supplicant is terminating - stop monitoring\n"); wpa_cli_quit = 1; } }