static void free_request(request* reqP) { /*if (reqP->filename != NULL) { free(reqP->filename); reqP->filename = NULL; }*/ init_request(reqP); }
void dino_process_request(dino_http_site_t *dino_site, int socket) { dino_handle_t dhandle; init_request(&dhandle); if (-1 == socket) { log_error("accept", __FUNCTION__, __LINE__); } else { dhandle.http.socket = socket; accept_request(dino_site, &dhandle); } // Clear the cache memory... // This assumes that there is no memory allocations // that will be presisted across calls. // memory_cache_clear(); // Free DHANDLE // free_request(&dhandle); // Close Socket // close(socket); }
NSS_STATUS winbindd_send_request(int req_type, struct winbindd_request *request) { struct winbindd_request lrequest; /* Check for our tricky environment variable */ if (winbind_env_set()) { return NSS_STATUS_NOTFOUND; } if (!request) { ZERO_STRUCT(lrequest); request = &lrequest; } /* Fill in request and send down pipe */ init_request(request, req_type); if (write_sock(request, sizeof(*request), request->flags & WBFLAG_RECURSE) == -1) { return NSS_STATUS_UNAVAIL; } if ((request->extra_len != 0) && (write_sock(request->extra_data.data, request->extra_len, request->flags & WBFLAG_RECURSE) == -1)) { return NSS_STATUS_UNAVAIL; } return NSS_STATUS_SUCCESS; }
void h2o_http1_accept(h2o_accept_ctx_t *ctx, h2o_socket_t *sock, struct timeval connected_at) { static const h2o_conn_callbacks_t callbacks = { get_sockname, /* stringify address */ get_peername, /* ditto */ NULL, /* push */ {{ {log_protocol_version, log_session_reused, log_cipher, log_cipher_bits}, /* ssl */ {log_request_index}, /* http1 */ {} /* http2 */ }}}; struct st_h2o_http1_conn_t *conn = (void *)h2o_create_connection(sizeof(*conn), ctx->ctx, ctx->hosts, connected_at, &callbacks); /* zero-fill all properties expect req */ memset((char *)conn + sizeof(conn->super), 0, offsetof(struct st_h2o_http1_conn_t, req) - sizeof(conn->super)); /* init properties that need to be non-zero */ conn->super.ctx = ctx->ctx; conn->super.hosts = ctx->hosts; conn->super.connected_at = connected_at; conn->super.callbacks = &callbacks; conn->sock = sock; sock->data = conn; h2o_linklist_insert(&ctx->ctx->http1._conns, &conn->_conns); init_request(conn, 0); reqread_start(conn); }
/****************************************************************************** * * * Function: get_value_db * * * * Purpose: retrieve data from database * * * * Parameters: item - item we are interested in * * * * Return value: SUCCEED - data successfully retrieved and stored in result * * NOTSUPPORTED - requested item is not supported * * * * Author: Eugene Grigorjev * * * ******************************************************************************/ int get_value_db(DC_ITEM *item, AGENT_RESULT *result) { const char *__function_name = "get_value_db"; AGENT_REQUEST request; int ret = NOTSUPPORTED; zabbix_log(LOG_LEVEL_DEBUG, "In %s() key_orig:'%s'", __function_name, item->key_orig); init_request(&request); if (SUCCEED == parse_item_key(item->key, &request)) { if (0 == strcmp(request.key, "db.odbc.select")) ret = db_odbc_select(item, &request, result); else if (0 == strcmp(request.key, "db.odbc.discovery")) ret = db_odbc_discovery(item, &request, result); else SET_MSG_RESULT(result, zbx_strdup(NULL, "Unsupported item key for this item type.")); } else SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid item parameter format.")); free_request(&request); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(ret)); return ret; }
static void free_request(request* reqP) { if (reqP->authen == 1) update_conn_fd(reqP->usr->username, -1); close(reqP->conn_fd); free(reqP->usr); init_request(reqP); }
static int lua_aio_file_info(lua_State *L) { if (!( lua_isstring (L, -2) && ( lua_type(L, -1) == LUA_TTABLE || lua_isnil(L, -1) ) //TODO handle if attributes are a single string without ',' )) { printf("Invalid arguments"); //TODO use luaL_typerror return 0; } /* Discards extra arguments */ lua_settop(L, 2); //TODO add for all other methods //TODO handle if the arg is missing const char *path = lua_tostring(L, -2); attributes_list_t *first_node = helper_parse_attributes(L, -1); lua_pop(L, 2); request_t *r = aio_file_info(path, first_node); init_request(L, r); lua_pushlightuserdata(L, r); return 1; }
static ssize_t avdtp_get_caps(int sk, int seid) { struct seid_req req; char buffer[1024]; struct getcap_resp *caps = (void *) buffer; ssize_t ret; memset(&req, 0, sizeof(req)); init_request(&req.header, AVDTP_GET_CAPABILITIES); req.acp_seid = seid; ret = avdtp_send(sk, &req, sizeof(req)); if (ret < 0) return ret; memset(&buffer, 0, sizeof(buffer)); ret = avdtp_receive(sk, caps, sizeof(buffer)); if (ret < 0) return ret; if ((size_t) ret < (sizeof(struct getcap_resp) + 4 + sizeof(struct avdtp_media_codec_capability))) { printf("Invalid capabilities\n"); return -1; } print_caps(caps, ret); return 0; }
/** * Initializes the connection state by clearing out the data structures */ static void init_connection(connection_state_t* conn_state) { conn_state->state = STATE_WAITING; init_request(&conn_state->request); init_response(&conn_state->response); }
static ssize_t avdtp_discover(int sk) { struct avdtp_header req; char buffer[256]; struct discover_resp *discover = (void *) buffer; int seps, i; ssize_t ret; memset(&req, 0, sizeof(req)); init_request(&req, AVDTP_DISCOVER); ret = avdtp_send(sk, &req, sizeof(req)); if (ret < 0) return ret; memset(&buffer, 0, sizeof(buffer)); ret = avdtp_receive(sk, discover, sizeof(buffer)); if (ret < 0) return ret; seps = (ret - sizeof(struct avdtp_header)) / sizeof(struct seid_info); for (i = 0; i < seps; i++) { const char *type, *media; switch (discover->seps[i].type) { case AVDTP_SEP_TYPE_SOURCE: type = "Source"; break; case AVDTP_SEP_TYPE_SINK: type = "Sink"; break; default: type = "Invalid"; } switch (discover->seps[i].media_type) { case AVDTP_MEDIA_TYPE_AUDIO: media = "Audio"; break; case AVDTP_MEDIA_TYPE_VIDEO: media = "Video"; break; case AVDTP_MEDIA_TYPE_MULTIMEDIA: media = "Multimedia"; break; default: media = "Invalid"; } printf("Stream End-Point #%d: %s %s %s\n", discover->seps[i].seid, media, type, discover->seps[i].inuse ? "*" : ""); avdtp_get_caps(sk, discover->seps[i].seid); } return 0; }
static void free_request( request* reqP ) { if ( reqP->buf != NULL ) { free( reqP->buf ); reqP->buf = NULL; } init_request( reqP ); }
PyObject *init_guava(void) { PyObject *guava_module = NULL; PyObject *request_module = NULL; PyObject *server_module = NULL; PyObject *handler_module = NULL; PyObject *controller_module = NULL; PyObject *router_module = NULL; PyObject *session_module = NULL; PyObject *cookie_module = NULL; PyEval_InitThreads(); guava_module = Py_InitModule("guava", NULL); request_module = init_request(); if (!register_module(guava_module, "request", request_module)) { return NULL; } server_module = init_server(); if (!register_module(guava_module, "server", server_module)) { return NULL; } handler_module = init_handler(); if (!register_module(guava_module, "handler", handler_module)) { return NULL; } router_module = init_router(); if (!register_module(guava_module, "router", router_module)) { return NULL; } controller_module = init_controller(); if (!register_module(guava_module, "controller", controller_module)) { return NULL; } session_module = init_session(); if (!register_module(guava_module, "session", session_module)) { return NULL; } cookie_module = init_cookie(); if (!register_module(guava_module, "cookie", cookie_module)) { return NULL; } PyModule_AddStringConstant(guava_module, "version", GUAVA_VERSION); return guava_module; }
static void init_connection(struct connection *cn) { cn->header_input.state = 0; cn->output.start = cn->output.end = cn->output.floor; init_request(cn->r); cn->keepalive = 0; cn->nread = 0; cn->nwritten = 0; cn->left = 0; cn->havefile = 0; gettimeofday(&cn->itv, 0); }
int get_value_simple(DC_ITEM *item, AGENT_RESULT *result) { const char *__function_name = "get_value_simple"; AGENT_REQUEST request; vmfunc_t vmfunc; int ret = NOTSUPPORTED; zabbix_log(LOG_LEVEL_DEBUG, "In %s() key_orig:'%s' addr:'%s'", __function_name, item->key_orig, item->interface.addr); init_request(&request); parse_item_key(item->key, &request); request.lastlogsize = item->lastlogsize; if (0 == strcmp(request.key, "net.tcp.service")) { if (SYSINFO_RET_OK == check_service(&request, item->interface.addr, result, 0)) ret = SUCCEED; } else if (0 == strcmp(request.key, "net.tcp.service.perf")) { if (SYSINFO_RET_OK == check_service(&request, item->interface.addr, result, 1)) ret = SUCCEED; } else if (SUCCEED == get_vmware_function(request.key, &vmfunc)) { if (NULL != vmfunc) { if (SYSINFO_RET_OK == vmfunc(&request, item->username, item->password, result)) ret = SUCCEED; } else SET_MSG_RESULT(result, zbx_strdup(NULL, "Support for VMware checks was not compiled in.")); } else { /* it will execute item from a loadable module if any */ if (SUCCEED == process(item->key, PROCESS_MODULE_COMMAND, result)) ret = SUCCEED; } if (NOTSUPPORTED == ret && !ISSET_MSG(result)) SET_MSG_RESULT(result, zbx_strdup(NULL, "Simple check is not supported.")); free_request(&request); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(ret)); return ret; }
static int lua_aio_load_file(lua_State *L) { const char *path = lua_tostring(L, -1); lua_pop(L, 1); request_t *r = aio_load_file(path); init_request(L, r); lua_pushlightuserdata(L, r); return 1; }
int get_value_ssh(DC_ITEM *item, AGENT_RESULT *result) { AGENT_REQUEST request; int ret = NOTSUPPORTED; const char *port, *encoding, *dns; init_request(&request); if (SUCCEED != parse_item_key(item->key, &request)) { SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid item key format.")); goto out; } if (0 != strcmp(SSH_RUN_KEY, get_rkey(&request))) { SET_MSG_RESULT(result, zbx_strdup(NULL, "Unsupported item key for this item type.")); goto out; } if (4 < get_rparams_num(&request)) { SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters.")); goto out; } if (NULL != (dns = get_rparam(&request, 1)) && '\0' != *dns) { strscpy(item->interface.dns_orig, dns); item->interface.addr = item->interface.dns_orig; } if (NULL != (port = get_rparam(&request, 2)) && '\0' != *port) { if (FAIL == is_ushort(port, &item->interface.port)) { SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid third parameter.")); goto out; } } else item->interface.port = ZBX_DEFAULT_SSH_PORT; encoding = get_rparam(&request, 3); ret = ssh_run(item, result, ZBX_NULL2EMPTY_STR(encoding)); out: free_request(&request); return ret; }
static int lua_aio_file_write(lua_State *L) { const char *path = lua_tostring(L, -2); const char *content = lua_tostring(L, -1); lua_pop(L, 2); request_t *r = aio_file_write(path, content, strlen(content)); init_request(L, r); lua_pushlightuserdata(L, r); return 1; }
static int lua_aio_watch_gfile(lua_State *L) { const char *path = lua_tostring(L, -2); const int type = lua_tonumber(L, -1); lua_pop(L, 2); request_t *r = aio_watch_gfile(path, type); init_request(L, r); lua_pushlightuserdata(L, r); return 1; }
/* Process HTTP request */ void process_request(int conn_fd) { request req; vprintf("Initializing request struct\n"); init_request(&req); vprintf("About to parse_request()...\n"); if (parse_request(conn_fd, &req) == -1) { perror("parse_request"); exit(EXIT_FAILURE); } dispatch(conn_fd, req); }
void init_reg_requests() { init_request("rr", remove_reg); init_request("nr", define_number_reg); init_request("af", alter_format); init_request("aln", alias_reg); init_request("rnn", rename_reg); init_request("pnr", print_number_regs); }
static int lua_aio_file_icon(lua_State *L) { const char *path = lua_tostring (L, -3); const int size = lua_tonumber (L, -2); const int symbolic = lua_toboolean(L, -1); lua_pop(L, 3); request_t *r = aio_file_icon(path, size, symbolic); init_request(L, r); lua_pushlightuserdata(L, r); return 1; }
bool WebTools::DownloadFile(const ssi_char_t *url, const ssi_char_t *pathOnDisk, const ssi_char_t *pathToCertificate, bool showProgress) { bool result = false; init_curl(); CURL *curl = curl_easy_init(); if (url_exists(curl, url, pathToCertificate)) { curl_easy_reset(curl); init_request(curl, url, pathToCertificate, showProgress); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); FILE *file = fopen(pathOnDisk, "wb"); if (file) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, file); CURLcode code = curl_easy_perform(curl); fclose(file); if (code != CURLE_OK) { ssi_wrn(curl_easy_strerror(code)); ssi_remove(pathOnDisk); } else { result = true; } } else { ssi_wrn("could not create file '%s'", pathOnDisk); } } else { ssi_wrn("url does not exist '%s'", url); } curl_easy_cleanup(curl); return result; }
void init_column_requests() { the_column = new column; init_request("cols", column_start); init_request("colo", column_output); init_request("colj", column_justify); init_request("colr", column_reset); init_request("colt", column_trim); init_request("nvj", no_vjustify); init_request("rvj", restore_vjustify); number_reg_dictionary.define(".colb", new column_bottom_reg); number_reg_dictionary.define(".colx", new column_extra_space_reg); number_reg_dictionary.define(".cola", new column_active_reg); number_reg_dictionary.define(".nvj", new constant_int_reg(&no_vjustify_mode)); }
static int ioctl_send_broadcast_request(struct client *client, void *buffer) { struct fw_cdev_send_request *request = buffer; switch (request->tcode) { case TCODE_WRITE_QUADLET_REQUEST: case TCODE_WRITE_BLOCK_REQUEST: break; default: return -EINVAL; } /* Security policy: Only allow accesses to Units Space. */ if (request->offset < CSR_REGISTER_BASE + CSR_CONFIG_ROM_END) return -EACCES; return init_request(client, request, LOCAL_BUS | 0x3f, SCODE_100); }
void h2o_http1_accept(h2o_accept_ctx_t *ctx, h2o_socket_t *sock, struct timeval connected_at) { static const h2o_conn_callbacks_t callbacks = {get_sockname, get_peername}; struct st_h2o_http1_conn_t *conn = h2o_mem_alloc(sizeof(*conn)); /* zero-fill all properties expect req */ memset(conn, 0, offsetof(struct st_h2o_http1_conn_t, req)); /* init properties that need to be non-zero */ conn->super.ctx = ctx->ctx; conn->super.hosts = ctx->hosts; conn->super.connected_at = connected_at; conn->super.callbacks = &callbacks; conn->sock = sock; sock->data = conn; init_request(conn, 0); reqread_start(conn); }
void h2o_http1_accept(h2o_context_t *ctx, h2o_socket_t *sock) { h2o_http1_conn_t *conn = h2o_mem_alloc(sizeof(*conn)); /* zero-fill all properties expect req */ memset(conn, 0, offsetof(h2o_http1_conn_t, req)); /* init properties that need to be non-zero */ conn->super.ctx = ctx; if (sock->peername.len != 0) { conn->super.peername.addr = (void*)&sock->peername.addr; conn->super.peername.len = sock->peername.len; } conn->sock = sock; sock->data = conn; init_request(conn, 0); reqread_start(conn); }
static void on_send_complete(h2o_socket_t *sock, int status) { struct st_h2o_http1_conn_t *conn = sock->data; assert(conn->req._ostr_top == &conn->_ostr_final.super); if (!conn->req.http1_is_persistent) { /* TODO use lingering close */ close_connection(conn); return; } /* handle next request */ init_request(conn, 1); h2o_buffer_consume(&conn->sock->input, conn->_reqsize); conn->_prevreqlen = 0; conn->_reqsize = 0; reqread_start(conn); }
/****************************************************************************** * * * Function: zbx_itemkey_extract_global_regexps * * * * Purpose: extract global regular expression names from item key * * * * Parameters: key - [IN] the item key to parse * * regexps - [OUT] the extracted regular expression names * * * ******************************************************************************/ static void zbx_itemkey_extract_global_regexps(const char *key, zbx_vector_str_t *regexps) { #define ZBX_KEY_LOG 1 #define ZBX_KEY_EVENTLOG 2 AGENT_REQUEST request; int item_key; const char *param; if (0 == strncmp(key, "log[", 4) || 0 == strncmp(key, "logrt[", 6)) item_key = ZBX_KEY_LOG; else if (0 == strncmp(key, "eventlog[", 9)) item_key = ZBX_KEY_EVENTLOG; else return; init_request(&request); if(SUCCEED != parse_item_key(key, &request)) goto out; /* "params" parameter */ if (NULL != (param = get_rparam(&request, 1)) && '@' == *param) zbx_vector_str_append_uniq(regexps, param + 1); if (ZBX_KEY_EVENTLOG == item_key) { /* "severity" parameter */ if (NULL != (param = get_rparam(&request, 2)) && '@' == *param) zbx_vector_str_append_uniq(regexps, param + 1); /* "source" parameter */ if (NULL != (param = get_rparam(&request, 3)) && '@' == *param) zbx_vector_str_append_uniq(regexps, param + 1); /* "logeventid" parameter */ if (NULL != (param = get_rparam(&request, 4)) && '@' == *param) zbx_vector_str_append_uniq(regexps, param + 1); } out: free_request(&request); }
bool WebTools::url_exists(void *handle, const ssi_char_t *url, const ssi_char_t *pathToCertificate) { CURL *curl = (CURL *)handle; init_request(curl, url, pathToCertificate, false); curl_easy_setopt(curl, CURLOPT_HEADER, 1); curl_easy_setopt(curl, CURLOPT_NOBODY, 1); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); #if _WIN32|_WIN64 FILE *null_device = std::fopen("nul", "w"); #else FILE *null_device = std::fopen("/dev/null", "w"); #endif curl_easy_setopt(curl, CURLOPT_WRITEDATA, null_device); return curl_easy_perform(curl) == CURLE_OK; }
static int lua_aio_load_icon(lua_State *L) { const char *name = lua_tostring (L, -3); const int size = lua_tonumber (L, -2); const int symbolic = lua_toboolean(L, -1); lua_pop(L, 3); const char *names[2] = {NULL, NULL}; names[0] = name; request_t *r = aio_icon_load(names, size, symbolic); init_request(L, r); lua_pushlightuserdata(L, r); return 1; }