本文整理汇总了C++中cmd_free函数的典型用法代码示例。如果您正苦于以下问题:C++ cmd_free函数的具体用法?C++ cmd_free怎么用?C++ cmd_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cmd_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reply_and_free
void
reply_and_free (command_context * ctx, sbuf * reply)
{
command_manager *mgr = ctx->my_mgr;
// "delay" and "pgs_del" commands are not cancelable, because these commands
// have post action after receiving responses from workers. If cmd_cancel()
// function is called due to client disconnection, these commands with
// unable-to-cancel flag continue the execution and just swallow the reply
// after execution finishes and reply_and_free() is called.
if (ctx->swallow)
{
assert (ctx->unable_to_cancel);
cmd_free (ctx);
return;
}
ctx->reply_cb (reply, ctx->cbarg);
mgr->stat.numcommands++;
if (ctx->local)
{
mgr->stat.numcommands_local++;
}
cmd_free (ctx);
}
示例2: cmd_tcp_write
void
cmd_tcp_write(evutil_socket_t fd, short which, void *arg)
{
struct tcp_con *con = arg;
int len;
TRACE(fd, len = write(fd, con->readbuf, con->rlen));
if (len == -1) {
if (errno == EINTR || errno == EAGAIN)
goto again;
cmd_free(&con->cmd);
return;
} else if (len == 0) {
cmd_free(&con->cmd);
return;
}
memmove(con->readbuf, con->readbuf + len, con->rlen - len);
con->rlen -= len;
/* Shut down the connection if we received a FIN and sent all data */
if (con->rlen == 0 && con->cmd.fdgotfin)
TRACE(con->cmd_pfd, shutdown(con->cmd_pfd, SHUT_WR));
again:
cmd_trigger_write(&con->cmd, con->rlen);
}
示例3: bye
void bye(void)
{
cliLogCommand("End Session");
//Set flag for thread to terminate
terminate_cli_check_session_thread = ACD_TRUE;
//Reset EditLine (useful if el_gets() did not complete normally)
if (el != NULL)
el_end(el);
//Free dynamically-allocated data
cli_command_cleanup(CLEAR_STATIC_DATA);
cli_free_command_cleanup_arr();
//Kill session
if (session_id)
cli_delete_session();
//Free IPC handles
cmd_free(&cli_backend_handle);
cmd_free(&cli_check_session_thread_ipc_handle);
#ifdef ACCEDIAN_CONFIG_DISCOVERY_ENABLED
if (acd_cap_discovery())
{
discovery_module_cleanup();
}
#endif
}
示例4: compare
int __cdecl compare(const void *arg1,const void *arg2)
{
FileName * File1;
FileName * File2;
INT ret;
File1 = cmd_alloc(sizeof(FileName));
if (!File1)
return 0;
File2 = cmd_alloc(sizeof(FileName));
if (!File2)
{
cmd_free(File1);
return 0;
}
memcpy(File1,arg1,sizeof(FileName));
memcpy(File2,arg2,sizeof(FileName));
/* ret = _tcsicmp(File1->Name, File2->Name); */
ret = lstrcmpi(File1->Name, File2->Name);
cmd_free(File1);
cmd_free(File2);
return ret;
}
示例5: cmd_udp_write
void
cmd_udp_write(int fd, short which, void *arg)
{
struct udp_con *con = arg;
struct conbuffer *buf;
ssize_t len;
buf = TAILQ_FIRST(&con->incoming);
if (buf == NULL)
return;
TRACE(fd, len = write(fd, buf->buf, buf->len));
if (len == -1) {
if (errno == EINTR || errno == EAGAIN)
goto again;
cmd_free(&con->cmd);
return;
} else if (len == 0) {
cmd_free(&con->cmd);
return;
}
TAILQ_REMOVE(&con->incoming, buf, next);
con->nincoming--;
free(buf->buf);
free(buf);
again:
cmd_trigger_write(&con->cmd, TAILQ_FIRST(&con->incoming) != NULL);
}
示例6: del
static
VOID del(LPHIST_ENTRY item)
{
if (item==NULL || item==Top || item==Bottom)
{
TRACE ("del in " __FILE__ ": returning\n"
"item is 0x%08x (Bottom is0x%08x)\n",
item, Bottom);
return;
}
/*free string's mem*/
if (item->string)
cmd_free(item->string);
/*set links in prev and next item*/
item->next->prev=item->prev;
item->prev->next=item->next;
cmd_free(item);
size--;
}
示例7: CleanHistory
VOID CleanHistory(VOID)
{
while (Bottom->next!=Top)
del(Bottom->next);
cmd_free(Top);
cmd_free(Bottom);
}
示例8: PrintAllAssociations
static INT
PrintAllAssociations()
{
DWORD return_val = 0;
HKEY hKey = NULL;
DWORD numKeys = 0;
DWORD extLength = 0;
LPTSTR extName = NULL;
DWORD keyCtr = 0;
return_val = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Classes"), 0, KEY_READ, &hKey);
if (return_val != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return -1;
}
return_val = RegQueryInfoKey(hKey, NULL, NULL, NULL, &numKeys, &extLength, NULL, NULL, NULL, NULL, NULL, NULL);
if (return_val != ERROR_SUCCESS)
{
RegCloseKey(hKey);
return -2;
}
extLength++;
extName = cmd_alloc(extLength * sizeof(TCHAR));
for(keyCtr = 0; keyCtr < numKeys; keyCtr++)
{
DWORD buffer_size = extLength;
return_val = RegEnumKeyEx(hKey, keyCtr, extName, &buffer_size, NULL, NULL, NULL, NULL);
if (return_val == ERROR_SUCCESS || return_val == ERROR_MORE_DATA)
{
if (*extName == _T('.'))
PrintAssociation(extName);
}
else
{
cmd_free(extName);
RegCloseKey(hKey);
return -1;
}
}
RegCloseKey(hKey);
if (extName)
cmd_free(extName);
return numKeys;
}
示例9: ClearBatch
/*
* free the allocated memory of a batch file
*/
VOID ClearBatch()
{
TRACE ("ClearBatch mem = %08x free = %d\n", bc->mem, bc->memfree);
if (bc->mem && bc->memfree)
cmd_free(bc->mem);
if (bc->raw_params)
cmd_free(bc->raw_params);
if (bc->params)
cmd_free(bc->params);
}
示例10: cmd_wpas_parse_cipher
static int cmd_wpas_parse_cipher(const char *value)
{
int val = 0, last;
char *start, *end, *buf;
buf = cmd_strdup(value);
if (buf == NULL)
return -1;
start = buf;
while (*start != '\0') {
while (*start == ' ' || *start == '\t')
start++;
if (*start == '\0')
break;
end = start;
while (*end != ' ' && *end != '\t' && *end != '\0')
end++;
last = *end == '\0';
*end = '\0';
if (cmd_strcmp(start, "CCMP-256") == 0)
val |= WPA_CIPHER_CCMP_256;
else if (cmd_strcmp(start, "GCMP-256") == 0)
val |= WPA_CIPHER_GCMP_256;
else if (cmd_strcmp(start, "CCMP") == 0)
val |= WPA_CIPHER_CCMP;
else if (cmd_strcmp(start, "GCMP") == 0)
val |= WPA_CIPHER_GCMP;
else if (cmd_strcmp(start, "TKIP") == 0)
val |= WPA_CIPHER_TKIP;
else if (cmd_strcmp(start, "WEP104") == 0)
val |= WPA_CIPHER_WEP104;
else if (cmd_strcmp(start, "WEP40") == 0)
val |= WPA_CIPHER_WEP40;
else if (cmd_strcmp(start, "NONE") == 0)
val |= WPA_CIPHER_NONE;
else if (cmd_strcmp(start, "GTK_NOT_USED") == 0)
val |= WPA_CIPHER_GTK_NOT_USED;
else {
cmd_free(buf);
return -1;
}
if (last)
break;
start = end + 1;
}
cmd_free(buf);
return val;
}
示例11: cmd_free
void
cmd_free(command_t *cmd)
{
int i;
// It's OK to cmd_free(NULL).
if (!cmd)
return;
/* Your code here. */
cmd_free(cmd->subshell);
cmd_free(cmd->next);
free(cmd);
}
示例12: cmd_path
INT cmd_path (LPTSTR param)
{
if (!_tcsncmp (param, _T("/?"), 2))
{
ConOutResPaging(TRUE,STRING_PATH_HELP1);
return 0;
}
nErrorLevel = 0;
/* if param is empty, display the PATH environment variable */
if (!param || !*param)
{
DWORD dwBuffer;
LPTSTR pszBuffer;
pszBuffer = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
if (dwBuffer == 0)
{
cmd_free(pszBuffer);
ConOutResPrintf(STRING_VOL_HELP2, _T("PATH"));
return 0;
}
else if (dwBuffer > ENV_BUFFER_SIZE)
{
pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer);
}
ConOutPrintf (_T("PATH=%s\n"), pszBuffer);
cmd_free (pszBuffer);
return 0;
}
/* skip leading '=' */
if (*param == _T('='))
param++;
/* set PATH environment variable */
if (!SetEnvironmentVariable (_T("PATH"), param))
{
nErrorLevel = 1;
return 1;
}
return 0;
}
示例13: os_run
/*
* By Tuwei
* Here is big problem which is the father process cannot
* get the return value of the child process. so we cannot
* know the command itself is right or not.
*
* in the next version.we need to add the waitpid() function
* which can tell the result of the child process. but then
* we should use the multi-process technology.
*/
int
os_run(char* command)
{
int ret = -1;
char** p = cmd_getsegs(command);
if (p == NULL)
{
return -1;
}
signal(SIGCHLD, sig_handle);
pid_t pid = fork();
if (pid == 0)
{
if (execvp(p[0], p) == -1)
{
exit(-1);
}
}
else if (pid > 0)
{
ret = pid;
}
else
{
ret = -1;
}
cmd_free(p);
return ret;
}
示例14: cmd_tcp_connect_cb
void
cmd_tcp_connect_cb(evutil_socket_t fd, short which, void *arg)
{
struct tcp_con *con = arg;
int error = 0;
socklen_t errsz = sizeof(error);
/* Everything is ready */
cmd_ready_fd(&con->cmd, &cb_tcp, con);
if (which == EV_TIMEOUT)
goto out;
/* Check if the connection completed */
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &errsz) == -1) {
warn("%s: getsockopt for %d", __FUNCTION__, fd);
goto out;
}
if (error) {
warnx("%s: getsockopt: %s", __FUNCTION__, strerror(error));
goto out;
}
cmd_trigger_read(&con->cmd, con->psize - con->plen);
cmd_trigger_write(&con->cmd, con->rlen);
return;
out:
/* Connection failed, bring this down gracefully */
cmd_free(&con->cmd);
tcp_sendfin(con);
}
示例15: PrintAlias
static VOID
PrintAlias (VOID)
{
LPTSTR Aliases;
LPTSTR ptr;
DWORD len;
len = GetConsoleAliasesLength(_T("cmd.exe"));
if (len == 0)
return;
/* allocate memory for an extra \0 char to make parsing easier */
ptr = cmd_alloc(len + sizeof(TCHAR));
if (!ptr)
{
WARN("Cannot allocate memory for ptr!\n");
return;
}
Aliases = ptr;
ZeroMemory(Aliases, len + sizeof(TCHAR));
if (GetConsoleAliases(Aliases, len, _T("cmd.exe")) != 0)
{
while (*Aliases != '\0')
{
ConOutPrintf(_T("%s\n"), Aliases);
Aliases = Aliases + lstrlen(Aliases);
Aliases++;
}
}
cmd_free(ptr);
}