int smpd_hash(char *input, int input_length, char *output, int output_length) { /*int i;*/ unsigned char hash[MD5_DIGEST_LENGTH]; smpd_enter_fn(FCNAME); if (output_length < (MD5_DIGEST_LENGTH * 2 + 1)) { smpd_exit_fn(FCNAME); return SMPD_FAIL; } #ifdef HAVE_MD5_CALC md5_calc(hash, (unsigned char *)input, (unsigned int)input_length); #else MD5(input, input_length, hash); #endif /* for (i=0; i<MD5_DIGEST_LENGTH; i++) { sprintf(output, "%02x", hash[i]); output += 2; } */ sprintf(output, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7], hash[8], hash[9], hash[10], hash[11], hash[12], hash[13], hash[14], hash[15]); smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
int smpd_lock_smpd_data(void) { smpd_enter_fn(FCNAME); #ifdef HAVE_WINDOWS_H if (smpd_process.hSMPDDataMutex == NULL) { smpd_process.hSMPDDataMutex = CreateMutex(NULL, FALSE, SMPD_DATA_MUTEX_NAME); if (smpd_process.hSMPDDataMutex == NULL) { smpd_exit_fn(FCNAME); return SMPD_FAIL; } } if (WaitForSingleObject(smpd_process.hSMPDDataMutex, SMPD_SHORT_TIMEOUT*1000) != WAIT_OBJECT_0) { smpd_err_printf("lock_smpd_data failed\n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } #else /* No lock implemented for Unix systems */ #endif smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
int smpd_get_opt(int *argc, char ***argv, char * flag) { int i,j; smpd_enter_fn(FCNAME); if (flag == NULL) { smpd_exit_fn(FCNAME); return 0; } for (i=0; i<*argc; i++) { if (strcmp((*argv)[i], flag) == 0) { for (j=i; j<*argc; j++) { (*argv)[j] = (*argv)[j+1]; } *argc -= 1; smpd_exit_fn(FCNAME); return 1; } } smpd_exit_fn(FCNAME); return 0; }
int smpd_hpc_js_task_setenv(ISchedulerTask *ptask, char *proc_encoded_env) { char name[SMPD_MAX_ENV_LENGTH], equals[3], value[SMPD_MAX_ENV_LENGTH]; wchar_t namew[SMPD_MAX_ENV_LENGTH], valuew[SMPD_MAX_ENV_LENGTH]; HRESULT hr; smpd_enter_fn(FCNAME); if((ptask == NULL) || (proc_encoded_env == NULL)){ smpd_err_printf("Invalid ptr to task or proc environment\n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } for (;;){ name[0] = '\0'; equals[0] = '\0'; value[0] = '\0'; if (MPIU_Str_get_string(&proc_encoded_env, name, SMPD_MAX_ENV_LENGTH) != MPIU_STR_SUCCESS) break; if (name[0] == '\0') break; if (MPIU_Str_get_string(&proc_encoded_env, equals, 3) != MPIU_STR_SUCCESS) break; if (equals[0] == '\0') break; if (MPIU_Str_get_string(&proc_encoded_env, value, SMPD_MAX_ENV_LENGTH) != MPIU_STR_SUCCESS) break; smpd_dbg_printf("setting environment variable: <%s> = <%s>\n", name, value); mbstowcs(namew, name, SMPD_MAX_ENV_LENGTH); mbstowcs(valuew, value, SMPD_MAX_ENV_LENGTH); hr = ptask->SetHpcEnvironmentVariable(_bstr_t(namew), _bstr_t(valuew)); } smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
const char * smpd_get_string(const char *str, char *val, int maxlen, int *num_chars) { smpd_enter_fn(FCNAME); if (maxlen < 1) { *num_chars = 0; smpd_exit_fn(FCNAME); return NULL; } /* line up with the first token */ str = first_token(str); if (str == NULL) { *num_chars = 0; smpd_exit_fn(FCNAME); return NULL; } /* copy the token */ token_copy(str, val, maxlen); *num_chars = (int)strlen(val); /* move to the next token */ str = next_token(str); smpd_exit_fn(FCNAME); return str; }
int smpd_hpc_js_finalize(smpd_hpc_js_ctxt_t *pctxt) { int result; smpd_enter_fn(FCNAME); if(pctxt == NULL){ smpd_err_printf("ERROR: Invalid pointer to js ctxt\n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } if(*pctxt == NULL){ smpd_dbg_printf("Null js handle\n"); smpd_exit_fn(FCNAME); return SMPD_SUCCESS; } /* Release the job scheduler object */ if((*pctxt)->pscheduler){ ((*pctxt)->pscheduler)->Release(); (*pctxt)->pscheduler = NULL; } /* Free the job scheduler handle */ MPIU_Free(*pctxt); *pctxt = NULL; smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
int smpd_spn_list_finalize(smpd_spn_list_hnd_t *spn_list_hnd_p) { smpd_host_spn_node_t *spn_list_head, *cur_node; smpd_enter_fn(FCNAME); if(spn_list_hnd_p == NULL){ smpd_err_printf("Invalid pointer to spn list handle\n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } if(!SMPD_SPN_LIST_HND_IS_INIT(*spn_list_hnd_p)){ smpd_dbg_printf("Trying to finalize an uninitialized handle\n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } spn_list_head = **spn_list_hnd_p; while(spn_list_head != NULL){ cur_node = spn_list_head; spn_list_head = cur_node->next; MPIU_Free(cur_node); } /* Free contents of the spn handle */ MPIU_Free(*spn_list_hnd_p); *spn_list_hnd_p = NULL; smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
int smpd_get_opt_double(int *argc, char ***argv, char * flag, double *d) { int i,j; smpd_enter_fn(FCNAME); if (flag == NULL) { smpd_exit_fn(FCNAME); return 0; } for (i=0; i<*argc; i++) { if (strcmp((*argv)[i], flag) == 0) { if (i+1 == *argc) { smpd_exit_fn(FCNAME); return 0; } *d = atof((*argv)[i+1]); for (j=i; j<*argc-1; j++) { (*argv)[j] = (*argv)[j+2]; } *argc -= 2; smpd_exit_fn(FCNAME); return 1; } } smpd_exit_fn(FCNAME); return 0; }
int smpd_remove_from_dynamic_hosts(void) { #ifndef HAVE_WINDOWS_H char myhostname[SMPD_MAX_HOST_LENGTH]; char hosts[8192]; char hosts_less_me[8192]; char *host; #endif smpd_enter_fn(FCNAME); #ifndef HAVE_WINDOWS_H if (smpd_get_hostname(myhostname, SMPD_MAX_HOST_LENGTH) != 0) { smpd_err_printf("smpd_get_hostname failed, errno = %d\n", errno); smpd_exit_fn(FCNAME); return SMPD_FAIL; } smpd_lock_smpd_data(); hosts[0] = '\0'; if (smpd_get_smpd_data(SMPD_DYNAMIC_HOSTS_KEY, hosts, 8192) != SMPD_SUCCESS) { smpd_unlock_smpd_data(); smpd_dbg_printf("not removing host because "SMPD_DYNAMIC_HOSTS_KEY" does not exist\n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } /* create a new hosts lists without this host name in it */ hosts_less_me[0] = '\0'; host = strtok(hosts, " \t\r\n"); while (host) { if (strcmp(host, myhostname)) { if (hosts_less_me[0] != '\0') strcat(hosts_less_me, " "); strcat(hosts_less_me, host); } host = strtok(NULL, " \t\r\n"); } if (hosts_less_me[0] == '\0') { smpd_dbg_printf("removing "SMPD_DYNAMIC_HOSTS_KEY"\n"); smpd_delete_smpd_data(SMPD_DYNAMIC_HOSTS_KEY); } else { smpd_dbg_printf("setting new "SMPD_DYNAMIC_HOSTS_KEY": %s\n", hosts_less_me); smpd_set_smpd_data(SMPD_DYNAMIC_HOSTS_KEY, hosts_less_me); } smpd_unlock_smpd_data(); #endif smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
int smpd_get_smpd_data_default(const char *key, char *value, int value_len) { smpd_enter_fn(FCNAME); #ifdef HAVE_WINDOWS_H /* A default passphrase is only available for Windows */ if (strcmp(key, "phrase") == 0) { strncpy(value, SMPD_DEFAULT_PASSPHRASE, value_len); value[value_len-1] = '\0'; smpd_exit_fn(FCNAME); return SMPD_SUCCESS; } if(strcmp(key, "port") == 0) { snprintf(value, value_len, "%d", SMPD_LISTENER_PORT); smpd_exit_fn(FCNAME); return SMPD_SUCCESS; } #endif if (strcmp(key, "log") == 0) { strncpy(value, "no", value_len); value[value_len-1] = '\0'; } else if (strcmp(key, "prepend_rank") == 0) { strncpy(value, "yes", value_len); value[value_len-1] = '\0'; } else if (strcmp(key, "trace") == 0) { strncpy(value, "yes", value_len); value[value_len-1] = '\0'; } else if (strcmp(key, "noprompt") == 0) { strncpy(value, "no", value_len); value[value_len-1] = '\0'; } /* else if (strcmp(key, "hosts") == 0) { if (smpd_get_hostname(value, value_len) != 0) { smpd_exit_fn(FCNAME); return SMPD_FAIL; } } */ else { smpd_exit_fn(FCNAME); return SMPD_FAIL; } smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
SMPD_BOOL smpd_dbs_hasMoreKeys(smpd_dbsIter_t iter){ smpd_enter_fn(FCNAME); if(iter){ smpd_exit_fn(FCNAME); return SMPD_TRUE; } else{ smpd_exit_fn(FCNAME); return SMPD_FALSE; } }
int smpd_get_user_data(const char *key, char *value, int value_len) { #ifdef HAVE_WINDOWS_H HKEY tkey; DWORD len, result; char err_msg[512]; smpd_enter_fn(FCNAME); result = RegOpenKeyEx(HKEY_CURRENT_USER, SMPD_REGISTRY_KEY, 0, KEY_READ, &tkey); if (result != ERROR_SUCCESS) { smpd_translate_win_error(result, err_msg, 512, "Unable to open the HKEY_CURRENT_USER\\" SMPD_REGISTRY_KEY " registry key, error %d\n", result); smpd_dbg_printf("%s\n", err_msg); result = smpd_get_user_data_default(key, value, value_len); smpd_exit_fn(FCNAME); return result; } len = value_len; result = RegQueryValueEx(tkey, key, 0, NULL, (unsigned char *)value, &len); if (result != ERROR_SUCCESS) { smpd_translate_win_error(result, err_msg, 512, "Unable to read the smpd registry key '%s', error %d\n", key, result); smpd_dbg_printf("%s\n", err_msg); RegCloseKey(tkey); result = smpd_get_user_data_default(key, value, value_len); smpd_exit_fn(FCNAME); return result; } result = RegCloseKey(tkey); if (result != ERROR_SUCCESS) { smpd_translate_win_error(result, err_msg, 512, "Unable to close the HKEY_CURRENT_USER\\" SMPD_REGISTRY_KEY " registry key, error %d: ", result); smpd_err_printf("%s\n", err_msg); smpd_exit_fn(FCNAME); return SMPD_FAIL; } smpd_exit_fn(FCNAME); return SMPD_SUCCESS; #else int result; smpd_enter_fn(FCNAME); result = smpd_get_smpd_data(key, value, value_len); if (result != SMPD_SUCCESS) { result = smpd_get_user_data_default(key, value, value_len); } smpd_exit_fn(FCNAME); return result; #endif }
int smpd_hpc_js_init(smpd_hpc_js_ctxt_t *pctxt) { HRESULT hr; int result; smpd_enter_fn(FCNAME); if(pctxt == NULL){ smpd_err_printf("ERROR: Invalid pointer to js handle\n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } /* Alloc memory for scheduler object */ *pctxt = (smpd_hpc_js_ctxt_t )MPIU_Malloc(sizeof(smpd_hpc_js_ctxt_)); if(*pctxt == NULL){ smpd_err_printf("ERROR: Unable to allocate memory for js handle\n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } (*pctxt)->pscheduler = NULL; (*pctxt)->pnode_names = NULL; CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); /* Get an instance of the Scheduler object */ hr = CoCreateInstance( __uuidof(Scheduler), NULL, CLSCTX_INPROC_SERVER, __uuidof(IScheduler), reinterpret_cast<void **>(&((*pctxt)->pscheduler))); CoUninitialize(); if (FAILED(hr)){ smpd_err_printf("ERROR: CoCreateInstance(IScheduler) failed, 0x%x\n", hr); smpd_exit_fn(FCNAME); return SMPD_FAIL; } /* Connect to the head node */ result = smpd_hpc_js_connect_to_head_node(*pctxt, NULL); if(result != SMPD_SUCCESS){ smpd_err_printf("Unable to connect to head node \n"); smpd_exit_fn(FCNAME); return SMPD_FAIL; } smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
int smpd_dbs_put(const char *name, const char *key, const char *value) { smpd_database_node_t *pNode; smpd_database_element_t *pElement; smpd_enter_fn(FCNAME); #ifdef USE_WIN_MUTEX_PROTECT WaitForSingleObject(smpd_process.hDBSMutex, INFINITE); #endif pNode = smpd_process.pDatabase; while (pNode) { if (strcmp(pNode->pszName, name) == 0) { pElement = pNode->pData; while (pElement) { if (strcmp(pElement->pszKey, key) == 0) { strcpy(pElement->pszValue, value); #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_SUCCESS; } pElement = pElement->pNext; } pElement = (smpd_database_element_t*)MPIU_Malloc(sizeof(smpd_database_element_t)); pElement->pNext = pNode->pData; strcpy(pElement->pszKey, key); strcpy(pElement->pszValue, value); pNode->pData = pElement; #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_SUCCESS; } pNode = pNode->pNext; } #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_FAIL; }
int smpd_dbs_delete(const char *name, const char *key) { smpd_database_node_t *pNode; smpd_database_element_t *pElement, *pElementTrailer; smpd_enter_fn(FCNAME); #ifdef USE_WIN_MUTEX_PROTECT WaitForSingleObject(smpd_process.hDBSMutex, INFINITE); #endif pNode = smpd_process.pDatabase; while (pNode) { if (strcmp(pNode->pszName, name) == 0) { pElementTrailer = pElement = pNode->pData; while (pElement) { if (strcmp(pElement->pszKey, key) == 0) { if (pElementTrailer != pElement) pElementTrailer->pNext = pElement->pNext; else pNode->pData = pElement->pNext; MPIU_Free(pElement); #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_SUCCESS; } pElementTrailer = pElement; pElement = pElement->pNext; } #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_FAIL; } pNode = pNode->pNext; } #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_FAIL; }
static int quoted_printf(char *str, int maxlen, const char *val) { int count = 0; smpd_enter_fn(FCNAME); if (maxlen < 1) { smpd_exit_fn(FCNAME); return 0; } *str = SMPD_QUOTE_CHAR; str++; maxlen--; count++; while (maxlen) { if (*val == '\0') break; if (*val == SMPD_QUOTE_CHAR) { *str = SMPD_ESCAPE_CHAR; str++; maxlen--; count++; if (maxlen == 0) { smpd_exit_fn(FCNAME); return count; } } *str = *val; str++; maxlen--; count++; val++; } if (maxlen) { *str = SMPD_QUOTE_CHAR; str++; maxlen--; count++; if (maxlen == 0) { smpd_exit_fn(FCNAME); return count; } *str = '\0'; } smpd_exit_fn(FCNAME); return count; }
int smpd_get_int_arg(const char *str, const char *flag, int *val_ptr) { char int_str[12]; smpd_enter_fn(FCNAME); if (smpd_get_string_arg(str, flag, int_str, 12)) { *val_ptr = atoi(int_str); smpd_exit_fn(FCNAME); return SMPD_TRUE; } smpd_exit_fn(FCNAME); return SMPD_FALSE; }
int smpd_get_opt_long(int *argc, char ***argv, char * flag, long *n) { int i; smpd_enter_fn(FCNAME); if (smpd_get_opt_int(argc, argv, flag, &i)) { *n = (long)i; smpd_exit_fn(FCNAME); return 1; } smpd_exit_fn(FCNAME); return 0; }
int smpd_dbs_first(const char *name, char *key, char *value) { smpd_database_node_t *pNode; smpd_enter_fn(FCNAME); #ifdef USE_WIN_MUTEX_PROTECT WaitForSingleObject(smpd_process.hDBSMutex, INFINITE); #endif if (key != NULL) key[0] = '\0'; pNode = smpd_process.pDatabase; while (pNode) { if (strcmp(pNode->pszName, name) == 0) { if (key != NULL) { if (pNode->pData) { strcpy(key, pNode->pData->pszKey); strcpy(value, pNode->pData->pszValue); pNode->pIter = pNode->pData->pNext; } else key[0] = '\0'; } else { pNode->pIter = pNode->pData; } #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_SUCCESS; } pNode = pNode->pNext; } #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_FAIL; }
int smpd_dbs_nextdb(char *name) { smpd_enter_fn(FCNAME); #ifdef USE_WIN_MUTEX_PROTECT WaitForSingleObject(smpd_process.hDBSMutex, INFINITE); #endif if (smpd_process.pDatabaseIter == NULL) name[0] = '\0'; else { smpd_process.pDatabaseIter = smpd_process.pDatabaseIter->pNext; if (smpd_process.pDatabaseIter) strcpy(name, smpd_process.pDatabaseIter->pszName); else name[0] = '\0'; } #ifdef USE_WIN_MUTEX_PROTECT ReleaseMutex(smpd_process.hDBSMutex); #endif smpd_exit_fn(FCNAME); return SMPD_DBS_SUCCESS; }
/* This function formats the environment strings of the form, * foo1=bar1 foo2=bar2 foo3=bar3 * TO * "foo1=bar1" "foo2=bar2" "foo3=bar3" * and returns the length of the formatted string * Note: The formatted string contains a space in the front */ static int FmtEnvVarsForSSH(char *bEnv, char *fmtEnv, int fmtEnvLen) { char name[SMPD_MAX_ENV_LENGTH], equals[3], value[SMPD_MAX_ENV_LENGTH]; int curLen = 0, totLen = 0; smpd_enter_fn(FCNAME); if(fmtEnv && bEnv){ for (;;) { name[0] = '\0'; equals[0] = '\0'; value[0] = '\0'; if(fmtEnvLen <= 0) break; if (MPIU_Str_get_string(&bEnv, name, SMPD_MAX_ENV_LENGTH) != MPIU_STR_SUCCESS) break; if (name[0] == '\0') break; if (MPIU_Str_get_string(&bEnv, equals, 3) != MPIU_STR_SUCCESS) break; if (equals[0] == '\0') break; if (MPIU_Str_get_string(&bEnv, value, SMPD_MAX_ENV_LENGTH) != MPIU_STR_SUCCESS) break; MPIU_Snprintf(fmtEnv, fmtEnvLen, " \"%s=%s\"", name, value); curLen = strlen(fmtEnv); totLen += curLen; fmtEnv += curLen; fmtEnvLen -= curLen; } } smpd_exit_fn(FCNAME); return totLen; }
int smpd_free_sspi_client_context(smpd_sspi_client_context_t **context) { smpd_sspi_client_context_t *iter, *trailer; smpd_enter_fn(FCNAME); trailer = iter = smpd_process.sspi_context_list; while (iter) { if (iter == *context) { if (trailer != iter) { trailer->next = iter->next; } else { smpd_process.sspi_context_list = iter->next; } break; } if (trailer != iter) trailer = trailer->next; iter = iter->next; } if (iter == NULL) { smpd_dbg_printf("freeing a sspi_client_context not in the global list\n"); } /* FIXME: cleanup sspi structures */ MPIU_Free(*context); *context = NULL; smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
void smpd_get_password(char *password) { #ifdef HAVE_WINDOWS_H HANDLE hStdin; DWORD dwMode; #else struct termios terminal_settings, original_settings; #endif size_t len; smpd_enter_fn(FCNAME); #ifdef HAVE_WINDOWS_H hStdin = GetStdHandle(STD_INPUT_HANDLE); if (!GetConsoleMode(hStdin, &dwMode)) dwMode = ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT; SetConsoleMode(hStdin, dwMode & ~ENABLE_ECHO_INPUT); *password = '******'; fgets(password, 100, stdin); SetConsoleMode(hStdin, dwMode); fprintf(stderr, "\n"); #else /* save the current terminal settings */ tcgetattr(STDIN_FILENO, &terminal_settings); original_settings = terminal_settings; /* turn off echo */ terminal_settings.c_lflag &= ~ECHO; terminal_settings.c_lflag |= ECHONL; tcsetattr(STDIN_FILENO, TCSAFLUSH, &terminal_settings); /* check that echo is off */ tcgetattr(STDIN_FILENO, &terminal_settings); if (terminal_settings.c_lflag & ECHO) { smpd_err_printf("\nunable to turn off the terminal echo\n"); tcsetattr(STDIN_FILENO, TCSANOW, &original_settings); } fgets(password, 100, stdin); /* restore the original settings */ tcsetattr(STDIN_FILENO, TCSANOW, &original_settings); #endif while ((len = strlen(password)) > 0) { if (password[len-1] == '\r' || password[len-1] == '\n') password[len-1] = '\0'; else break; } smpd_exit_fn(FCNAME); }
int smpd_add_host_to_default_list(const char *hostname) { int result; smpd_enter_fn(FCNAME); result = smpd_add_extended_host_to_default_list(hostname, NULL, 1); smpd_exit_fn(FCNAME); return result; }
int smpd_get_smpd_password_from_parent(SMPDU_Sock_set_t set, SMPDU_Sock_t sock) { smpd_enter_fn(FCNAME); SMPD_UNREFERENCED_ARG(set); SMPD_UNREFERENCED_ARG(sock); smpd_exit_fn(FCNAME); return SMPD_FAIL; }
SMPD_BOOL smpd_option_on(const char *option) { char val[SMPD_MAX_VALUE_LENGTH]; smpd_enter_fn(FCNAME); if (smpd_get_smpd_data(option, val, SMPD_MAX_VALUE_LENGTH) == SMPD_SUCCESS) { if (smpd_is_affirmative(val) || (strcmp(val, "1") == 0)) { smpd_exit_fn(FCNAME); return SMPD_TRUE; } } smpd_exit_fn(FCNAME); return SMPD_FALSE; }
int smpd_watch_processes() { smpd_enter_fn(FCNAME); printf("Process watching not implemented under unix systems, exiting...\n"); fflush(stdout); smpd_exit_fn(FCNAME); return SMPD_SUCCESS; }
int smpd_dbsIter_finalize(smpd_dbsIter_t *pIter){ smpd_enter_fn(FCNAME); if(pIter){ *pIter = NULL; } smpd_exit_fn(FCNAME); return SMPD_DBS_SUCCESS; }
static const char * first_token(const char *str) { smpd_enter_fn(FCNAME); if (str == NULL) { smpd_exit_fn(FCNAME); return NULL; } while (isspace(*str)) str++; if (*str == '\0') { smpd_exit_fn(FCNAME); return NULL; } smpd_exit_fn(FCNAME); return str; }
int smpd_get_string_arg(const char *str, const char *flag, char *val, int maxlen) { smpd_enter_fn(FCNAME); if (maxlen < 1) { smpd_exit_fn(FCNAME); return SMPD_FALSE; } /* line up with the first token */ str = first_token(str); if (str == NULL) { smpd_exit_fn(FCNAME); return SMPD_FALSE; } /* This loop will match the first instance of "flag = value" in the string. */ do { if (compare_token(str, flag) == 0) { str = next_token(str); if (compare_token(str, SMPD_DELIM_STR) == 0) { str = next_token(str); if (str == NULL) { smpd_exit_fn(FCNAME); return SMPD_FALSE; } token_copy(str, val, maxlen); smpd_exit_fn(FCNAME); return SMPD_TRUE; } } else { str = next_token(str); } } while (str); smpd_exit_fn(FCNAME); return SMPD_FALSE; }