本文整理汇总了C++中smpd_enter_fn函数的典型用法代码示例。如果您正苦于以下问题:C++ smpd_enter_fn函数的具体用法?C++ smpd_enter_fn怎么用?C++ smpd_enter_fn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了smpd_enter_fn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: smpd_set_user_data
int smpd_set_user_data(const char *key, const char *value)
{
#ifdef HAVE_WINDOWS_H
HKEY tkey;
DWORD len, result;
char err_msg[512];
smpd_enter_fn(FCNAME);
if (key == NULL || value == NULL)
{
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
result = RegCreateKeyEx(HKEY_CURRENT_USER, SMPD_REGISTRY_KEY,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &tkey, NULL);
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: ", result);
smpd_err_printf("%s\n", err_msg);
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
len = (DWORD)(strlen(value)+1);
result = RegSetValueEx(tkey, key, 0, REG_SZ, (const BYTE *)value, len);
if (result != ERROR_SUCCESS)
{
smpd_translate_win_error(result, err_msg, 512, "Unable to write the user smpd registry value '%s:%s', error %d\n", key, value, result);
smpd_err_printf("%s\n", err_msg);
RegCloseKey(tkey);
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
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_set_smpd_data(key, value);
smpd_exit_fn(FCNAME);
return result;
#endif
}
示例2: smpd_get_user_data
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
}
示例3: smpd_delete_user_data
int smpd_delete_user_data(const char *key)
{
#ifdef HAVE_WINDOWS_H
HKEY tkey;
DWORD result;
char err_msg[512];
smpd_enter_fn(FCNAME);
if (key == NULL)
{
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
result = RegCreateKeyEx(HKEY_CURRENT_USER, SMPD_REGISTRY_KEY,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &tkey, NULL);
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: ", result);
smpd_err_printf("%s\n", err_msg);
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
result = RegDeleteValue(tkey, key);
if (result != ERROR_SUCCESS)
{
smpd_translate_win_error(result, err_msg, 512, "Unable to delete the user smpd registry value '%s', error %d: ", key, result);
smpd_err_printf("%s\n", err_msg);
RegCloseKey(tkey);
smpd_exit_fn(FCNAME);
return SMPD_FAIL;
}
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_delete_smpd_data(key);
smpd_exit_fn(FCNAME);
return result;
#endif
}
示例4: smpd_hash
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;
}
示例5: smpd_lock_smpd_data
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;
}
示例6: smpd_dbs_nextdb
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;
}
示例7: smpd_get_opt_double
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;
}
示例8: smpd_get_opt
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;
}
示例9: smpd_spn_list_finalize
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;
}
示例10: smpd_get_string
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;
}
示例11: smpd_free_sspi_client_context
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;
}
示例12: FmtEnvVarsForSSH
/* 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;
}
示例13: smpd_get_password
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 = '\0';
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);
}
示例14: smpd_watch_processes
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;
}
示例15: smpd_add_host_to_default_list
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;
}