// dummy html parser to demonstrate parsing callback data. static sys_result app_handler_ondatareceive(uint8_t *data, uint32_t len) { sys_result result; #ifdef HTML_LOGCONTENT printf("app_handler_ondatareceive: %s\r\n", data); #endif char * ptr = NULL; result = parse_result(data, HTML_START, &ptr); if(result == SYS_OK) { printf("<!doctype html> start tag found\r\n"); return result; } result = parse_result(data, HTML_END, &ptr); if(result == SYS_OK) { printf("</html> end tag found\r\n"); return result; } return result; }
/* CURL Make the Request */ static int ov_curl(void *ov_msg_handle, int (*parse_result)(void*, char*, void*), void *parse_data) { ov_msg_t *ov_msg = (ov_msg_t*) ov_msg_handle; CURL *curl = ov_msg->curl; CURLcode res = CURLE_OK; curl_string_t s; assert(ov_msg->magic_no == OV_MSG_MAGIC_NO); ov_curl_string_init(&s); curl_easy_setopt(curl, CURLOPT_HTTPPOST, ov_msg->formpost); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ov_curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*) &s); /* Perform the request, res will get the return code */ switch ((res = curl_easy_perform(curl))) { case CURLE_OK: if (parse_result) { parse_result(ov_msg_handle, s.ptr, parse_data); } free(s.ptr); break; default: fprintf(stderr, "curl_easy_perform() failed <%d>: %s\n", res, curl_easy_strerror(res)); res = 1; } curl_easy_cleanup(curl); curl_global_cleanup(); return res; }
bool pge_ws_packet_begin() { AppMessageResult result = app_message_outbox_begin(&s_outbox_iter); if(result != APP_MSG_OK) { parse_result(result); return false; } else { return true; } }
bool pge_ws_packet_send() { AppMessageResult result = app_message_outbox_send(); if(result != APP_MSG_OK) { parse_result(result); return false; } else { s_outbox_iter = NULL; return true; } }
bool DDDG::build_initial_dddg(gzFile trace_file) { std::cerr << "-------------------------------" << std::endl; std::cerr << " Generating DDDG " << std::endl; std::cerr << "-------------------------------" << std::endl; char buffer[256]; std::string first_function; bool seen_first_line = false; bool first_function_returned = false; while (trace_file && !gzeof(trace_file)) { if (gzgets(trace_file, buffer, sizeof(buffer)) == NULL) { continue; } std::string wholeline(buffer); size_t pos_end_tag = wholeline.find(","); if (pos_end_tag == std::string::npos) { if (first_function_returned) break; continue; } std::string tag = wholeline.substr(0, pos_end_tag); std::string line_left = wholeline.substr(pos_end_tag + 1); if (tag.compare("0") == 0) { if (!seen_first_line) { seen_first_line = true; first_function = parse_function_name(line_left); } first_function_returned = is_function_returned(line_left, first_function); parse_instruction_line(line_left); } else if (tag.compare("r") == 0) { parse_result(line_left); } else if (tag.compare("f") == 0) { parse_forward(line_left); } else { parse_parameter(line_left, atoi(tag.c_str())); } } output_dddg(); std::cerr << "-------------------------------" << std::endl; std::cerr << "Num of Nodes: " << datapath->getNumOfNodes() << std::endl; std::cerr << "Num of Edges: " << datapath->getNumOfEdges() << std::endl; std::cerr << "Num of Reg Edges: " << num_of_register_dependency() << std::endl; std::cerr << "Num of MEM Edges: " << num_of_memory_dependency() << std::endl; std::cerr << "-------------------------------" << std::endl; return 0; }
JsonArray * gs_snapd_find (const gchar *macaroon, gchar **discharges, gchar **values, GCancellable *cancellable, GError **error) { g_autoptr(GString) path = NULL; g_autofree gchar *query = NULL; g_autofree gchar *escaped = NULL; guint status_code; g_autofree gchar *reason_phrase = NULL; g_autofree gchar *response_type = NULL; g_autofree gchar *response = NULL; g_autoptr(JsonParser) parser = NULL; JsonObject *root; JsonArray *result; path = g_string_new ("/v2/find?q="); query = g_strjoinv (" ", values); escaped = soup_uri_encode (query, NULL); g_string_append (path, escaped); if (!send_request ("GET", path->str, NULL, macaroon, discharges, &status_code, &reason_phrase, &response_type, &response, NULL, cancellable, error)) return NULL; if (status_code != SOUP_STATUS_OK) { g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "snapd returned status code %u: %s", status_code, reason_phrase); return NULL; } parser = parse_result (response, response_type, error); if (parser == NULL) return NULL; root = json_node_get_object (json_parser_get_root (parser)); result = json_object_get_array_member (root, "result"); if (result == NULL) { g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "snapd returned no result"); return NULL; } return json_array_ref (result); }
bool pge_ws_add_int(int key, int value) { if(!s_outbox_iter) { if(PGE_WS_LOGS) APP_LOG(APP_LOG_LEVEL_ERROR, "pge_ws_packet_begin() has not been called!"); return false; } AppMessageResult result = dict_write_int(s_outbox_iter, key, &value, sizeof(int), true); if(result != APP_MSG_OK) { parse_result(result); return false; } return true; }
binresult *get_result(apisock *sock){ unsigned char *data; binresult *res; uint32_t ressize; if (readall(sock, &ressize, sizeof(uint32_t))!=sizeof(uint32_t)) return NULL; data=(unsigned char *)malloc(ressize); if (readall(sock, data, ressize)!=ressize){ free(data); return NULL; } res=parse_result(data, ressize); free(data); return res; }
/* parses: cstring | list | tuple * Actually, this is more permissive and allows mixed tuples/lists */ static struct gdb_mi_value *parse_value(const gchar **p) { struct gdb_mi_value *val = g_malloc0(sizeof *val); if (**p == '"') { val->type = GDB_MI_VAL_STRING; val->string = parse_cstring(p); } else if (**p == '{' || **p == '[') { struct gdb_mi_result *prev = NULL; val->type = GDB_MI_VAL_LIST; gchar end = **p == '{' ? '}' : ']'; (*p)++; while (**p && **p != end) { struct gdb_mi_result *item = g_malloc0(sizeof *item); while (g_ascii_isspace(**p)) (*p)++; if ((item->val = parse_value(p)) || parse_result(item, p)) { if (prev) prev->next = item; else val->list = item; prev = item; } else { gdb_mi_result_free(item, TRUE); break; } while (g_ascii_isspace(**p)) (*p)++; if (**p != ',') break; (*p)++; } if (**p == end) (*p)++; } else { gdb_mi_value_free(val); val = NULL; } return val; }
static JsonObject * get_changes (const gchar *macaroon, gchar **discharges, const gchar *change_id, GCancellable *cancellable, GError **error) { g_autofree gchar *path = NULL; guint status_code; g_autofree gchar *reason_phrase = NULL; g_autofree gchar *response_type = NULL; g_autofree gchar *response = NULL; g_autoptr(JsonParser) parser = NULL; JsonObject *root, *result; path = g_strdup_printf ("/v2/changes/%s", change_id); if (!send_request ("GET", path, NULL, macaroon, discharges, &status_code, &reason_phrase, &response_type, &response, NULL, cancellable, error)) return NULL; if (status_code != SOUP_STATUS_OK) { g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "snapd returned status code %u: %s", status_code, reason_phrase); return NULL; } parser = parse_result (response, response_type, error); if (parser == NULL) return NULL; root = json_node_get_object (json_parser_get_root (parser)); result = json_object_get_object_member (root, "result"); if (result == NULL) { g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "snapd returned no result"); return NULL; } return json_object_ref (result); }
static void browse_cb (GUPnPServiceProxy *cds_proxy, GUPnPServiceProxyAction *action, gpointer user_data) { GError *error; char *result; char *container_id; error = NULL; if (!gupnp_service_proxy_end_action (cds_proxy, action, &error, "Result", G_TYPE_STRING, &result, NULL)) { g_critical ("Failed to browse root container: %s", error->message); g_error_free (error); application_exit (); return; } g_assert (result != NULL); container_id = parse_result (result); if (container_id == NULL) { g_critical ("Failed to find a suitable container for upload."); g_free (result); application_exit (); return; } else { container_found (container_id); g_free (container_id); } g_free (result); }
JsonArray * gs_snapd_list (const gchar *macaroon, gchar **discharges, GCancellable *cancellable, GError **error) { guint status_code; g_autofree gchar *reason_phrase = NULL; g_autofree gchar *response_type = NULL; g_autofree gchar *response = NULL; g_autoptr(JsonParser) parser = NULL; JsonObject *root; JsonArray *result; if (!send_request ("GET", "/v2/snaps", NULL, macaroon, discharges, &status_code, &reason_phrase, &response_type, &response, NULL, cancellable, error)) return NULL; if (status_code != SOUP_STATUS_OK) { g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "snapd returned status code %u: %s", status_code, reason_phrase); return NULL; } parser = parse_result (response, response_type, error); if (parser == NULL) return NULL; root = json_node_get_object (json_parser_get_root (parser)); result = json_object_get_array_member (root, "result"); if (result == NULL) { g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "snapd returned no result"); return NULL; } return json_array_ref (result); }
static void create_object_cb (GUPnPServiceProxy *cds_proxy, GUPnPServiceProxyAction *action, gpointer user_data) { GError *error; char *result; const char *import_uri; error = NULL; if (!gupnp_service_proxy_end_action (cds_proxy, action, &error, "Result", G_TYPE_STRING, &result, NULL)) { g_critical ("Failed to create new item on remote container: %s", error->message); g_error_free (error); item_created (NULL); return; } if (result == NULL) { g_critical ("Failed to create new item on remote container." "No reasons given by MediaServer."); item_created (NULL); return; } import_uri = parse_result (result); item_created (import_uri); g_free (result); }
void check_correctness() { const prb_t p(dims, dir, dt, tag, axis, group); char pstr[max_prb_len]; prb2str(&p, pstr); if (pattern && !match_regex(pstr, pattern)) return; print(1, "run: %s\n", pstr); res_t res{}; const int status = shuffle::doit(&p, &res); bool want_perf_report = false; parse_result(res, want_perf_report, allow_unimpl, status, pstr); if (want_perf_report && bench_mode & PERF) perf_report(&p, &res, pstr); benchdnn_stat.tests++; }
void check_correctness(const desc_t *c) { const prb_t p(*c, dir, cfg, alg, attr, mb); char pstr[max_prb_len]; prb2str(&p, pstr); if (pattern && !match_regex(pstr, pattern)) return; print(1, "run: %s\n", pstr); res_t res{}; const int status = conv::doit(&p, &res); (void)status; bool want_perf_report = false; parse_result(res, want_perf_report, allow_unimpl, status, pstr); if (want_perf_report && bench_mode & PERF) perf_report(&p, &res, pstr); benchdnn_stat.tests++; }
static int nis_servent(void *retval, void *mdata, va_list ap) { char *resultbuf, *lastkey; int resultbuflen; char buf[YPMAXRECORD + 2]; struct nis_state *st; int rv; enum nss_lookup_type how; char *name; char *proto; int port; struct servent *serv; char *buffer; size_t bufsize; int *errnop; name = NULL; proto = NULL; how = (enum nss_lookup_type)mdata; switch (how) { case nss_lt_name: name = va_arg(ap, char *); proto = va_arg(ap, char *); break; case nss_lt_id: port = va_arg(ap, int); proto = va_arg(ap, char *); break; case nss_lt_all: break; default: return NS_NOTFOUND; }; serv = va_arg(ap, struct servent *); buffer = va_arg(ap, char *); bufsize = va_arg(ap, size_t); errnop = va_arg(ap, int *); *errnop = nis_getstate(&st); if (*errnop != 0) return (NS_UNAVAIL); if (st->yp_domain[0] == '\0') { if (getdomainname(st->yp_domain, sizeof st->yp_domain)) { *errnop = errno; return (NS_UNAVAIL); } } do { switch (how) { case nss_lt_name: snprintf(buf, sizeof(buf), "%s/%s", name, proto); if (yp_match(st->yp_domain, "services.byname", buf, strlen(buf), &resultbuf, &resultbuflen)) { rv = NS_NOTFOUND; goto fin; } break; case nss_lt_id: snprintf(buf, sizeof(buf), "%d/%s", ntohs(port), proto); /* * We have to be a little flexible * here. Ideally you're supposed to have both * a services.byname and a services.byport * map, but some systems have only * services.byname. FreeBSD cheats a little by * putting the services.byport information in * the same map as services.byname so that * either case will work. We allow for both * possibilities here: if there is no * services.byport map, we try services.byname * instead. */ rv = yp_match(st->yp_domain, "services.byport", buf, strlen(buf), &resultbuf, &resultbuflen); if (rv) { if (rv == YPERR_MAP) { if (yp_match(st->yp_domain, "services.byname", buf, strlen(buf), &resultbuf, &resultbuflen)) { rv = NS_NOTFOUND; goto fin; } } else { rv = NS_NOTFOUND; goto fin; } } break; case nss_lt_all: if (!st->yp_stepping) { free(st->yp_key); rv = yp_first(st->yp_domain, "services.byname", &st->yp_key, &st->yp_keylen, &resultbuf, &resultbuflen); if (rv) { rv = NS_NOTFOUND; goto fin; } st->yp_stepping = 1; } else { lastkey = st->yp_key; rv = yp_next(st->yp_domain, "services.byname", st->yp_key, st->yp_keylen, &st->yp_key, &st->yp_keylen, &resultbuf, &resultbuflen); free(lastkey); if (rv) { st->yp_stepping = 0; rv = NS_NOTFOUND; goto fin; } } break; }; rv = parse_result(serv, buffer, bufsize, resultbuf, resultbuflen, errnop); free(resultbuf); } while (!(rv & NS_TERMINATE) && how == nss_lt_all); fin: if (rv == NS_SUCCESS && retval != NULL) *(struct servent **)retval = serv; return (rv); }
static int db_servent(void *retval, void *mdata, va_list ap) { char buf[BUFSIZ]; DBT key, data, *result; DB *db; struct db_state *st; int rv; int stayopen; enum nss_lookup_type how; char *name; char *proto; int port; struct servent *serv; char *buffer; size_t bufsize; int *errnop; name = NULL; proto = NULL; how = (enum nss_lookup_type)mdata; switch (how) { case nss_lt_name: name = va_arg(ap, char *); proto = va_arg(ap, char *); break; case nss_lt_id: port = va_arg(ap, int); proto = va_arg(ap, char *); break; case nss_lt_all: break; default: return NS_NOTFOUND; }; serv = va_arg(ap, struct servent *); buffer = va_arg(ap, char *); bufsize = va_arg(ap, size_t); errnop = va_arg(ap,int *); *errnop = db_getstate(&st); if (*errnop != 0) return (NS_UNAVAIL); if (how == nss_lt_all && st->keynum < 0) return (NS_NOTFOUND); if (st->db == NULL) { st->db = dbopen(_PATH_SERVICES_DB, O_RDONLY, 0, DB_HASH, NULL); if (st->db == NULL) { *errnop = errno; return (NS_UNAVAIL); } } stayopen = (how == nss_lt_all) ? 1 : st->stayopen; db = st->db; do { switch (how) { case nss_lt_name: key.data = buf; if (proto == NULL) key.size = snprintf(buf, sizeof(buf), "\376%s", name); else key.size = snprintf(buf, sizeof(buf), "\376%s/%s", name, proto); key.size++; if (db->get(db, &key, &data, 0) != 0 || db->get(db, &data, &key, 0) != 0) { rv = NS_NOTFOUND; goto db_fin; } result = &key; break; case nss_lt_id: key.data = buf; port = htons(port); if (proto == NULL) key.size = snprintf(buf, sizeof(buf), "\377%d", port); else key.size = snprintf(buf, sizeof(buf), "\377%d/%s", port, proto); key.size++; if (db->get(db, &key, &data, 0) != 0 || db->get(db, &data, &key, 0) != 0) { rv = NS_NOTFOUND; goto db_fin; } result = &key; break; case nss_lt_all: key.data = buf; key.size = snprintf(buf, sizeof(buf), "%d", st->keynum++); key.size++; if (db->get(db, &key, &data, 0) != 0) { st->keynum = -1; rv = NS_NOTFOUND; goto db_fin; } result = &data; break; } rv = parse_result(serv, buffer, bufsize, result->data, result->size - 1, errnop); } while (!(rv & NS_TERMINATE) && how == nss_lt_all); db_fin: if (!stayopen && st->db != NULL) { db->close(db); st->db = NULL; } if (rv == NS_SUCCESS && retval != NULL) *(struct servent **)retval = serv; return (rv); }
/* * compat structures. compat and files sources functionalities are almost * equal, so they all are managed by files_servent function */ static int files_servent(void *retval, void *mdata, va_list ap) { static const ns_src compat_src[] = { #ifdef YP { NSSRC_NIS, NS_SUCCESS }, #endif { NULL, 0 } }; ns_dtab compat_dtab[] = { { NSSRC_DB, db_servent, (void *)((struct servent_mdata *)mdata)->how }, #ifdef YP { NSSRC_NIS, nis_servent, (void *)((struct servent_mdata *)mdata)->how }, #endif { NULL, NULL, NULL } }; struct files_state *st; int rv; int stayopen; struct servent_mdata *serv_mdata; char *name; char *proto; int port; struct servent *serv; char *buffer; size_t bufsize; int *errnop; size_t linesize; char *line; char **cp; name = NULL; proto = NULL; serv_mdata = (struct servent_mdata *)mdata; switch (serv_mdata->how) { case nss_lt_name: name = va_arg(ap, char *); proto = va_arg(ap, char *); break; case nss_lt_id: port = va_arg(ap, int); proto = va_arg(ap, char *); break; case nss_lt_all: break; default: return NS_NOTFOUND; }; serv = va_arg(ap, struct servent *); buffer = va_arg(ap, char *); bufsize = va_arg(ap, size_t); errnop = va_arg(ap,int *); *errnop = files_getstate(&st); if (*errnop != 0) return (NS_UNAVAIL); if (st->fp == NULL) st->compat_mode_active = 0; if (st->fp == NULL && (st->fp = fopen(_PATH_SERVICES, "r")) == NULL) { *errnop = errno; return (NS_UNAVAIL); } if (serv_mdata->how == nss_lt_all) stayopen = 1; else { rewind(st->fp); stayopen = st->stayopen; } rv = NS_NOTFOUND; do { if (!st->compat_mode_active) { if ((line = fgetln(st->fp, &linesize)) == NULL) { *errnop = errno; rv = NS_RETURN; break; } if (*line=='+' && serv_mdata->compat_mode != 0) st->compat_mode_active = 1; } if (st->compat_mode_active != 0) { switch (serv_mdata->how) { case nss_lt_name: rv = nsdispatch(retval, compat_dtab, NSDB_SERVICES_COMPAT, "getservbyname_r", compat_src, name, proto, serv, buffer, bufsize, errnop); break; case nss_lt_id: rv = nsdispatch(retval, compat_dtab, NSDB_SERVICES_COMPAT, "getservbyport_r", compat_src, port, proto, serv, buffer, bufsize, errnop); break; case nss_lt_all: rv = nsdispatch(retval, compat_dtab, NSDB_SERVICES_COMPAT, "getservent_r", compat_src, serv, buffer, bufsize, errnop); break; } if (!(rv & NS_TERMINATE) || serv_mdata->how != nss_lt_all) st->compat_mode_active = 0; continue; } rv = parse_result(serv, buffer, bufsize, line, linesize, errnop); if (rv == NS_NOTFOUND) continue; if (rv == NS_RETURN) break; rv = NS_NOTFOUND; switch (serv_mdata->how) { case nss_lt_name: if (strcmp(name, serv->s_name) == 0) goto gotname; for (cp = serv->s_aliases; *cp; cp++) if (strcmp(name, *cp) == 0) goto gotname; continue; gotname: if (proto == 0 || strcmp(serv->s_proto, proto) == 0) rv = NS_SUCCESS; break; case nss_lt_id: if (port != serv->s_port) continue; if (proto == 0 || strcmp(serv->s_proto, proto) == 0) rv = NS_SUCCESS; break; case nss_lt_all: rv = NS_SUCCESS; break; } } while (!(rv & NS_TERMINATE)); if (!stayopen && st->fp != NULL) { fclose(st->fp); st->fp = NULL; } if ((rv == NS_SUCCESS) && (retval != NULL)) *(struct servent **)retval=serv; return (rv); }
static gboolean send_package_action (const gchar *macaroon, gchar **discharges, const gchar *name, const gchar *action, GsSnapdProgressCallback callback, gpointer user_data, GCancellable *cancellable, GError **error) { g_autofree gchar *content = NULL, *path = NULL; guint status_code; g_autofree gchar *reason_phrase = NULL; g_autofree gchar *response_type = NULL; g_autofree gchar *response = NULL; g_autofree gchar *status = NULL; g_autoptr(JsonParser) parser = NULL; JsonObject *root, *result; const gchar *type; content = g_strdup_printf ("{\"action\": \"%s\"}", action); path = g_strdup_printf ("/v2/snaps/%s", name); if (!send_request ("POST", path, content, macaroon, discharges, &status_code, &reason_phrase, &response_type, &response, NULL, cancellable, error)) return FALSE; if (status_code == SOUP_STATUS_UNAUTHORIZED) { g_set_error_literal (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_AUTH_REQUIRED, "Requires authentication with @snapd"); return FALSE; } if (status_code != SOUP_STATUS_ACCEPTED) { g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "snapd returned status code %u: %s", status_code, reason_phrase); return FALSE; } parser = parse_result (response, response_type, error); if (parser == NULL) return FALSE; root = json_node_get_object (json_parser_get_root (parser)); type = json_object_get_string_member (root, "type"); if (g_strcmp0 (type, "async") == 0) { const gchar *change_id; change_id = json_object_get_string_member (root, "change"); while (TRUE) { /* Wait for a little bit before polling */ g_usleep (100 * 1000); result = get_changes (macaroon, discharges, change_id, cancellable, error); if (result == NULL) return FALSE; status = g_strdup (json_object_get_string_member (result, "status")); if (g_strcmp0 (status, "Done") == 0) break; callback (result, user_data); } } if (g_strcmp0 (status, "Done") != 0) { g_set_error (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_NOT_SUPPORTED, "snapd operation finished with status %s", status); return FALSE; } return TRUE; }
void OPENLDAP::Book::refresh_result () { int result = LDAP_SUCCESS; int nbr = 0; struct timeval timeout = { 1, 0}; /* block 1s */ LDAPMessage *msg_entry = NULL; LDAPMessage *msg_result = NULL; gchar* c_status = NULL; result = ldap_result (ldap_context, LDAP_RES_ANY, LDAP_MSG_ALL, &timeout, &msg_entry); if (result <= 0) { if (patience == 3) { patience--; Ekiga::Runtime::run_in_main (boost::bind (&OPENLDAP::Book::refresh_result, this), 12); } else if (patience == 2) { patience--; Ekiga::Runtime::run_in_main (boost::bind (&OPENLDAP::Book::refresh_result, this), 21); } else if (patience == 1) { patience--; Ekiga::Runtime::run_in_main (boost::bind (&OPENLDAP::Book::refresh_result, this), 30); } else { // patience == 0 status = std::string (_("Could not search")); updated (this->shared_from_this ()); ldap_unbind_ext (ldap_context, NULL, NULL); ldap_context = NULL; } if (msg_entry != NULL) ldap_msgfree (msg_entry); return; } msg_result = ldap_first_message (ldap_context, msg_entry); do { if (ldap_msgtype (msg_result) == LDAP_RES_SEARCH_ENTRY) { ContactPtr contact = parse_result (msg_result); if (contact) { add_contact (contact); nbr++; } } msg_result = ldap_next_message (ldap_context, msg_result); } while (msg_result != NULL); // Do not count ekiga.net's first entry "Search Results ... 100 entries" if (bookinfo.uri_host == EKIGA_NET_URI) nbr--; c_status = g_strdup_printf (ngettext ("%d user found", "%d users found", nbr), nbr); status = c_status; g_free (c_status); updated (this->shared_from_this ()); (void)ldap_msgfree (msg_entry); ldap_unbind_ext (ldap_context, NULL, NULL); ldap_context = NULL; }
/* parses: async-record | stream-record | result-record * note: post-value data is ignored. * * FIXME: that's NOT exactly what the GDB docs call an output, and that's not * exactly what a line could be. The GDB docs state that a line can * contain more than one stream-record, as it's not terminated by a * newline, and as it defines: * * output ==> * ( out-of-band-record )* [ result-record ] "(gdb)" nl * out-of-band-record ==> * async-record | stream-record * stream-record ==> * console-stream-output | target-stream-output | log-stream-output * console-stream-output ==> * "~" c-string * target-stream-output ==> * "@" c-string * log-stream-output ==> * "&" c-string * * so as none of the stream-outputs are terminated by a newline, and the * parser here only extracts the first record it will fail with combined * records in one line. */ struct gdb_mi_record *gdb_mi_record_parse(const gchar *line) { struct gdb_mi_record *record = g_malloc0(sizeof *record); /* FIXME: prompt detection should not really be useful, especially not as a * special case, as the prompt should always follow an (optional) record */ if (is_prompt(line)) record->type = GDB_MI_TYPE_PROMPT; else { /* extract token */ const gchar *token_end = line; for (token_end = line; g_ascii_isdigit(*token_end); token_end++) ; if (token_end > line) { record->token = g_strndup(line, (gsize)(token_end - line)); line = token_end; while (g_ascii_isspace(*line)) line++; } /* extract record */ record->type = *line; if (*line) ++line; while (g_ascii_isspace(*line)) line++; switch (record->type) { case '~': case '@': case '&': /* FIXME: although the syntax description in the docs are clear, * the "GDB/MI Stream Records" section does not agree with it, * widening the input to: * * > [string-output] is either raw text (with an implicit new * > line) or a quoted C string (which does not contain an * > implicit newline). * * This adds "raw text" to "c-string"... so? */ record->klass = parse_cstring(&line); break; case '^': case '*': case '+': case '=': { struct gdb_mi_result *prev = NULL; record->klass = parse_string(&line); while (*line) { while (g_ascii_isspace(*line)) line++; if (*line != ',') break; else { struct gdb_mi_result *res = g_malloc0(sizeof *res); line++; while (g_ascii_isspace(*line)) line++; if (!parse_result(res, &line)) { g_warning("failed to parse result"); gdb_mi_result_free(res, TRUE); break; } if (prev) prev->next = res; else record->first = res; prev = res; } } break; } default: /* FIXME: what to do with invalid prefix? */ record->type = GDB_MI_TYPE_PROMPT; } } return record; }