/** * @brief Send arbitrary data to a connected server * * This function is used to send arbitrary data to a connected server using @p client through HTTP PUT. * It relies on the user to set required headers by operating on the client's #Azy_Net object. * @param client The client (NOT NULL) * @param send_data The data+length to send (NOT NULL) * @param data Optional data to pass to associated callbacks * @return The #Azy_Client_Call_Id of the transmission, to be used with azy_client_callback_set, * or 0 on failure * @see azy_net_header_set */ Azy_Client_Call_Id azy_client_put(Azy_Client *client, const Azy_Net_Data *send_data, void *data) { Eina_Strbuf *msg; Azy_Client_Handler_Data *hd; if (!AZY_MAGIC_CHECK(client, AZY_MAGIC_CLIENT)) { AZY_MAGIC_FAIL(client, AZY_MAGIC_CLIENT); return 0; } EINA_SAFETY_ON_NULL_RETURN_VAL(send_data, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(send_data->data, 0); azy_net_message_length_set(client->net, send_data->size); azy_net_type_set(client->net, AZY_NET_TYPE_PUT); msg = azy_net_header_create(client->net); EINA_SAFETY_ON_NULL_GOTO(msg, error); #ifdef ISCOMFITOR DBG("\nSENDING >>>>>>>>>>>>>>>>>>>>>>>>\n%.*s%.*s\n>>>>>>>>>>>>>>>>>>>>>>>>", eina_strbuf_length_get(msg), eina_strbuf_string_get(msg), (int)send_data->size, send_data->data); #endif EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_server_send(client->net->conn, eina_strbuf_string_get(msg), eina_strbuf_length_get(msg)), error); INFO("Send [1/2] complete! %zi bytes queued for sending.", eina_strbuf_length_get(msg)); eina_strbuf_free(msg); msg = NULL; EINA_SAFETY_ON_TRUE_GOTO(!ecore_con_server_send(client->net->conn, send_data->data, send_data->size), error); INFO("Send [2/2] complete! %" PRIi64 " bytes queued for sending.", send_data->size); ecore_con_server_flush(client->net->conn); EINA_SAFETY_ON_TRUE_RETURN_VAL(!(hd = calloc(1, sizeof(Azy_Client_Handler_Data))), 0); if (!client->conns) { client->recv = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb)_azy_client_handler_data, hd); ecore_con_server_data_set(client->net->conn, client); } hd->client = client; hd->content_data = data; hd->type = AZY_NET_TYPE_PUT; AZY_MAGIC_SET(hd, AZY_MAGIC_CLIENT_DATA_HANDLER); while (++azy_client_send_id__ < 1) ; hd->id = azy_client_send_id__; client->conns = eina_list_append(client->conns, hd); return azy_client_send_id__; error: if (msg) eina_strbuf_free(msg); return 0; }
EAPI Eina_Stringshare * eolian_expression_value_to_literal(const Eolian_Value *val) { EINA_SAFETY_ON_NULL_RETURN_VAL(val, NULL); switch (val->type) { case EOLIAN_EXPR_BOOL: return eina_stringshare_add(val->value.b ? "EINA_TRUE" : "EINA_FALSE"); case EOLIAN_EXPR_NULL: return eina_stringshare_add("NULL"); case EOLIAN_EXPR_CHAR: { char c = val->value.c; Eina_Strbuf *buf = eina_strbuf_new(); const char *ret; eina_strbuf_append_char(buf, '\''); _append_char_escaped(buf, c); eina_strbuf_append_char(buf, '\''); ret = eina_stringshare_add(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return ret; } case EOLIAN_EXPR_STRING: { const char *ret; char *c = (char*)val->value.s; Eina_Strbuf *buf = eina_strbuf_new(); eina_strbuf_append_char(buf, '\"'); while (*c) _append_char_escaped(buf, *(c++)); eina_strbuf_append_char(buf, '\"'); ret = eina_stringshare_add(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return ret; } case EOLIAN_EXPR_INT: case EOLIAN_EXPR_UINT: case EOLIAN_EXPR_LONG: case EOLIAN_EXPR_ULONG: case EOLIAN_EXPR_LLONG: case EOLIAN_EXPR_ULLONG: case EOLIAN_EXPR_FLOAT: case EOLIAN_EXPR_DOUBLE: { const char *ret; Eina_Strbuf *buf = eina_strbuf_new(); _number_to_str(val, buf); ret = eina_stringshare_add(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return ret; } default: return NULL; } }
EAPI Eina_Stringshare * eolian_expression_serialize(const Eolian_Expression *expr) { EINA_SAFETY_ON_NULL_RETURN_VAL(expr, NULL); Eina_Strbuf *buf = eina_strbuf_new(); if (!_expr_serialize(expr, buf, EINA_TRUE)) { eina_strbuf_free(buf); return NULL; } const char *ret = eina_stringshare_add(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return ret; }
static void _gen_doc_full(const Eolian_State *state, const char *summary, const char *description, const char *since, const char *group, const char *el, int indent, Eina_Strbuf *buf) { int curl = 0; Eina_Strbuf *wbuf = eina_strbuf_new(); if (indent) eina_strbuf_append(buf, "/**<\n"); else eina_strbuf_append(buf, "/**\n"); curl += _indent_line(buf, indent); eina_strbuf_append(buf, " * @brief "); curl += sizeof(" * @brief ") - 1; _append_section(state, summary, indent, curl, buf, wbuf); eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); eina_strbuf_append(buf, " *\n"); curl = _indent_line(buf, indent); eina_strbuf_append(buf, " * "); _append_section(state, description, indent, curl + 3, buf, wbuf); curl = _append_extra(el, indent, curl, EINA_TRUE, buf); curl = _append_since(since, indent, curl, buf); eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); char *sgrp = _sanitize_group(group); if (sgrp) { eina_strbuf_append(buf, " *\n"); _indent_line(buf, indent); } _append_group(buf, sgrp, indent); eina_strbuf_append(buf, " */"); eina_strbuf_free(wbuf); }
static char * evas_gl_common_shader_glsl_get(unsigned int flags, const char *base) { Eina_Strbuf *s = eina_strbuf_new(); unsigned int k; char *str; /* This is an env var to use for debugging purposes only */ static const char *evas_gl_shader_glsl_version = NULL; if (!evas_gl_shader_glsl_version) { evas_gl_shader_glsl_version = getenv("EVAS_GL_SHADER_GLSL_VERSION"); if (!evas_gl_shader_glsl_version) evas_gl_shader_glsl_version = ""; else WRN("Using GLSL version tag: '%s'", evas_gl_shader_glsl_version); } if (*evas_gl_shader_glsl_version) eina_strbuf_append_printf(s, "#version %s\n", evas_gl_shader_glsl_version); for (k = 0; k < SHADER_FLAG_COUNT; k++) { if (flags & (1 << k)) eina_strbuf_append_printf(s, "#define SHD_%s\n", _shader_flags[k]); } eina_strbuf_append(s, base); str = eina_strbuf_string_steal(s); eina_strbuf_free(s); return str; }
static void _gen_doc_full(const char *summary, const char *description, const char *since, const char *group, int indent, Eina_Strbuf *buf, Eina_Bool use_legacy) { int curl = 0; Eina_Strbuf *wbuf = eina_strbuf_new(); eina_strbuf_append(buf, "/**\n"); curl += _indent_line(buf, indent); eina_strbuf_append(buf, " * @brief "); curl += sizeof(" * @brief ") - 1; _append_section(summary, indent, curl, buf, wbuf, use_legacy); eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); eina_strbuf_append(buf, " *\n"); curl = _indent_line(buf, indent); eina_strbuf_append(buf, " * "); _append_section(description, indent, curl + 3, buf, wbuf, use_legacy); curl = _append_since(since, indent, curl, buf); eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); char *sgrp = _sanitize_group(group); if (sgrp) { eina_strbuf_append(buf, " *\n"); _indent_line(buf, indent); } _append_group(buf, sgrp, indent); eina_strbuf_append(buf, " */"); eina_strbuf_free(wbuf); }
void shotgun_disconnect(Shotgun_Auth *auth) { if (!auth) return; if (auth->svr_name) ecore_event_add(SHOTGUN_EVENT_DISCONNECT, auth, shotgun_fake_free, NULL); if (auth->ev_add) ecore_event_handler_del(auth->ev_add); if (auth->ev_del) ecore_event_handler_del(auth->ev_del); if (auth->ev_data) ecore_event_handler_del(auth->ev_data); if (auth->ev_error) ecore_event_handler_del(auth->ev_error); if (auth->ev_upgrade) ecore_event_handler_del(auth->ev_upgrade); if (auth->ev_write) ecore_event_handler_del(auth->ev_write); if (auth->svr) ecore_con_server_del(auth->svr); if (auth->keepalive) ecore_timer_del(auth->keepalive); if (auth->et_ping) ecore_timer_del(auth->et_ping); if (auth->et_ping_timeout) ecore_timer_del(auth->et_ping_timeout); if (auth->buf) eina_strbuf_free(auth->buf); auth->keepalive = NULL; auth->ev_add = NULL; auth->ev_del = NULL; auth->ev_data = NULL; auth->ev_error = NULL; auth->ev_upgrade = NULL; auth->ev_write = NULL; auth->svr = NULL; auth->state = 0; auth->et_ping = NULL; auth->et_ping_timeout = NULL; auth->buf = NULL; memset(&auth->features, 0, sizeof(auth->features)); auth->pending_ping = 0; }
static void _gc_shutdown(E_Gadcon_Client *gcc) { Instance *inst; Forecasts *w; inst = gcc->data; w = inst->forecasts; if (inst->popup) _forecasts_popup_destroy(inst); if (inst->check_timer) ecore_timer_del(inst->check_timer); if (inst->add_handler) ecore_event_handler_del(inst->add_handler); if (inst->data_handler) ecore_event_handler_del(inst->data_handler); if (inst->del_handler) ecore_event_handler_del(inst->del_handler); if (inst->server) ecore_con_server_del(inst->server); if (inst->area) eina_stringshare_del(inst->area); eina_strbuf_free(inst->buffer); inst->server = NULL; forecasts_config->instances = eina_list_remove(forecasts_config->instances, inst); evas_object_event_callback_del(w->forecasts_obj, EVAS_CALLBACK_MOUSE_DOWN, _forecasts_cb_mouse_down); _forecasts_free(w); E_FREE(inst); }
static char * _get_abbreviated_name(const char *prefix, const char *fname) { Eina_Strbuf *buf = eina_strbuf_new(); const char *last_p = strrchr(prefix, '_'); last_p = (last_p) ? (last_p + 1) : prefix; const char *tmp = strstr(fname, last_p); int len = strlen(last_p); if ((tmp) && ((tmp == fname) || (*(tmp - 1) == '_')) && ((*(tmp + len) == '\0') || (*(tmp + len) == '_'))) { int plen = strlen(prefix); len += (tmp - fname); if ((plen >= len) && !strncmp(prefix + plen - len, fname, len)) { eina_strbuf_append_n(buf, prefix, plen - len); } } if (eina_strbuf_length_get(buf) == 0) eina_strbuf_append_printf(buf, "%s_", prefix); eina_strbuf_append(buf, fname); char *ret = eina_strbuf_string_steal(buf); eina_strbuf_free(buf); return ret; }
static void _gen_doc_brief(const char *summary, const char *since, const char *group, int indent, Eina_Strbuf *buf, Eina_Bool use_legacy) { int curl = 4 + indent; Eina_Strbuf *wbuf = eina_strbuf_new(); eina_strbuf_append(buf, "/** "); curl = _append_section(summary, indent, curl, buf, wbuf, use_legacy); eina_strbuf_free(wbuf); curl = _append_since(since, indent, curl, buf); char *sgrp = _sanitize_group(group); if (((curl + 3) > DOC_LIMIT(indent)) || sgrp) { eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); if (sgrp) eina_strbuf_append(buf, " *"); } if (sgrp) { eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); } _append_group(buf, sgrp, indent); eina_strbuf_append(buf, " */"); }
static void _gen_doc_brief(const Eolian_State *state, const char *summary, const char *since, const char *group, const char *el, int indent, Eina_Strbuf *buf) { int curl = 4 + indent; Eina_Strbuf *wbuf = eina_strbuf_new(); if (indent) eina_strbuf_append(buf, "/**< "); else eina_strbuf_append(buf, "/** "); curl = _append_section(state, summary, indent, curl, buf, wbuf); eina_strbuf_free(wbuf); curl = _append_extra(el, indent, curl, EINA_FALSE, buf); curl = _append_since(since, indent, curl, buf); char *sgrp = _sanitize_group(group); if (((curl + 3) > DOC_LIMIT(indent)) || sgrp) { eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); if (sgrp) eina_strbuf_append(buf, " *"); } if (sgrp) { eina_strbuf_append_char(buf, '\n'); _indent_line(buf, indent); } _append_group(buf, sgrp, indent); eina_strbuf_append(buf, " */"); }
Eina_Bool alert_command_run(void *data) { Module_Alert_Command *mac = data; #define _EV(_a, _b, _c, _d) _a = ecore_event_handler_add(ECORE_EXE_EVENT_##_b, _c, _d) _EV(mac->ev.data, DATA, _alert_command_data, mac); EINA_SAFETY_ON_NULL_RETURN_VAL(mac->ev.data, EINA_TRUE); _EV(mac->ev.del, DEL, _alert_command_del, mac); EINA_SAFETY_ON_NULL_GOTO(mac->ev.del, del_data); _EV(mac->ev.error, ERROR, _alert_command_error, mac); EINA_SAFETY_ON_NULL_GOTO(mac->ev.error, del_del); #undef _EV mac->buf = eina_strbuf_new(); EINA_SAFETY_ON_NULL_GOTO(mac->buf, del_error); mac->exe = ecore_exe_pipe_run(mac->command->command, ECORE_EXE_PIPE_READ, mac); EINA_SAFETY_ON_NULL_GOTO(mac->exe, free_buf); ecore_exe_data_set(mac->exe, mac); return EINA_TRUE; free_buf: eina_strbuf_free(mac->buf); del_error: ecore_event_handler_del(mac->ev.error); del_del: ecore_event_handler_del(mac->ev.del); del_data: ecore_event_handler_del(mac->ev.data); return EINA_TRUE; }
char * url_from_user_input(const char *arg) { /* If it is already a URL, return the argument as is. */ if (has_scheme(arg) || !strcasecmp(arg, "about:blank")) return strdup(arg); Eina_Strbuf *buf = eina_strbuf_manage_new(eina_file_path_sanitize(arg)); /* Check if the path exists. */ if (ecore_file_exists(eina_strbuf_string_get(buf))) { /* File exists, convert local path to a URL. */ eina_strbuf_prepend(buf, "file://"); } else { /* The path does not exist, convert it to a URL by prepending http:// scheme: www.google.com -> http://www.google.com */ eina_strbuf_string_free(buf); eina_strbuf_append_printf(buf, "http://%s", arg); } char *url = eina_strbuf_string_steal(buf); eina_strbuf_free(buf); return url; }
static Eina_Error ret_cb(Azy_Client *cli, Azy_Content *content, Eina_Binbuf *data) { Eina_Strbuf *buf; if (azy_content_error_is_set(content)) printf("Error encountered: %s\n", azy_content_error_message_get(content)); else { const Eina_List *cookies; printf("Success!\n"); buf = eina_strbuf_new(); cookies = azy_net_cookie_set_list_get(azy_content_net_get(content)); if (cookies) azy_net_cookie_set_list_generate(buf, cookies); cookies = azy_net_cookie_send_list_get(azy_content_net_get(content)); if (cookies) azy_net_cookie_send_list_generate(buf, cookies); printf("%s\n", eina_strbuf_string_get(buf)); eina_strbuf_free(buf); } if (!azy_client_current(cli)) azy_client_close(cli); return AZY_ERROR_NONE; }
int main(int argc, char **argv) { Eina_Strbuf *buf; eina_init(); buf = eina_strbuf_new(); eina_strbuf_append_length(buf, "buffe", 5); eina_strbuf_append_char(buf, 'r'); printf("%s\n", eina_strbuf_string_get(buf)); eina_strbuf_insert_escaped(buf, "my ", 0); printf("%s\n", eina_strbuf_string_get(buf)); eina_strbuf_reset(buf); eina_strbuf_append_escaped(buf, "my buffer"); printf("%s\n", eina_strbuf_string_get(buf)); eina_strbuf_reset(buf); eina_strbuf_append_printf(buf, "%s%c", "buffe", 'r'); eina_strbuf_insert_printf(buf, " %s: %d", 6, "length", eina_strbuf_length_get(buf)); printf("%s\n", eina_strbuf_string_get(buf)); eina_strbuf_remove(buf, 0, 7); printf("%s\n", eina_strbuf_string_get(buf)); eina_strbuf_replace_all(buf, "length", "size"); printf("%s\n", eina_strbuf_string_get(buf)); eina_strbuf_free(buf); eina_shutdown(); return 0; }
char * dbus_name_to_c(const char *dbus) { char *str_cpy = strdup(dbus), *pch, *ret; Eina_Strbuf *buffer = eina_strbuf_new(); unsigned i; pch = strtok(str_cpy, "/."); if (!pch) { ret = strdup("root"); goto end; } eina_strbuf_append(buffer, pch); while ((pch = strtok(NULL, "/."))) eina_strbuf_append_printf(buffer, "_%s",pch); ret = strdup(eina_strbuf_string_get(buffer)); eina_strbuf_reset(buffer); for (i = 0; ret[i]; i++) { if (i > 0 && ret[i-1] != '_' && ret[i] > '@' && ret[i] < '[')//upper case eina_strbuf_append_printf(buffer, "_%c", tolower(ret[i])); else eina_strbuf_append_char(buffer, tolower(ret[i])); } free(ret); ret = strdup(eina_strbuf_string_get(buffer)); end: free(str_cpy); eina_strbuf_free(buffer); return ret; }
EAPI Eina_Stringshare * eolian_function_full_c_name_get(const Eolian_Function *foo_id, Eolian_Function_Type ftype) { char tbuf[512]; tbuf[0] = '\0'; const char *prefix = (ftype != EOLIAN_FUNCTION_POINTER) ? _get_eo_prefix(foo_id, tbuf): tbuf; if (!prefix) return NULL; const char *funcn = eolian_function_name_get(foo_id); Eina_Strbuf *buf = eina_strbuf_new(); Eina_Stringshare *ret; char *abbr = _get_abbreviated_name(prefix, funcn); eina_strbuf_append(buf, abbr); free(abbr); if ((ftype == EOLIAN_PROP_GET) || (ftype == EOLIAN_PROPERTY)) eina_strbuf_append(buf, "_get"); else if (ftype == EOLIAN_PROP_SET) eina_strbuf_append(buf, "_set"); ret = eina_stringshare_add(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return ret; }
/** * @brief Frees a Store_Add structure. * @param sa Store_Add structure to free. */ void store_add_free(Store_Add *sa) { if (sa->ec) ecore_con_url_free(sa->ec); if (sa->data.buf) eina_strbuf_free(sa->data.buf); if (sa->ev.ed) ecore_event_handler_del(sa->ev.ed); if (sa->ev.ec) ecore_event_handler_del(sa->ev.ec); free(sa); }
void _alert_command_clean(Module_Alert_Command *mac) { eina_strbuf_free(mac->buf); ecore_event_handler_del(mac->ev.data); ecore_event_handler_del(mac->ev.del); ecore_event_handler_del(mac->ev.error); }
static void indicator_battery_text_set(void *data, int value) { Eina_Strbuf *temp_buf = NULL; Eina_Strbuf *percent_buf = NULL; char *temp_str = NULL; retif(data == NULL, , "Invalid parameter!"); battery.type = INDICATOR_TXT_WITH_IMG_ICON; temp_buf = eina_strbuf_new(); percent_buf = eina_strbuf_new(); /* Set Label for percentage value */ eina_strbuf_append_printf(temp_buf, "%d", value); temp_str = eina_strbuf_string_steal(temp_buf); eina_strbuf_append_printf(percent_buf, "%s", indicator_util_icon_label_set (temp_str, NULL, NULL, BATTERY_VALUE_FONT_SIZE, data)); free(temp_str); /* Set Label for pecentage symbol */ eina_strbuf_append_printf(temp_buf, "%%"); temp_str = eina_strbuf_string_steal(temp_buf); eina_strbuf_append_printf(percent_buf, "%s", indicator_util_icon_label_set (temp_str, NULL, BATTERY_PERCENT_FONT_STYLE, BATTERY_PERCENT_FONT_SIZE, data)); free(temp_str); if (battery.txt_obj.data != NULL) free(battery.txt_obj.data); battery.txt_obj.data = eina_strbuf_string_steal(percent_buf); if (temp_buf != NULL) eina_strbuf_free(temp_buf); if (percent_buf != NULL) eina_strbuf_free(percent_buf); }
static Eina_Bool em_file_open(void *video, const char *file) { Emotion_Gstreamer_Video *ev = video; Eina_Strbuf *sbuf = NULL; const char *uri; if (!file) return EINA_FALSE; if (strstr(file, "://") == NULL) { sbuf = eina_strbuf_new(); eina_strbuf_append(sbuf, "file://"); if (strncmp(file, "./", 2) == 0) file += 2; if (strstr(file, ":/") != NULL) { /* We absolutely need file:///C:/ under Windows, so adding it here */ eina_strbuf_append(sbuf, "/"); } else if (*file != '/') { char tmp[PATH_MAX]; if (getcwd(tmp, PATH_MAX)) { eina_strbuf_append(sbuf, tmp); eina_strbuf_append(sbuf, "/"); } } eina_strbuf_append(sbuf, file); } ev->play_started = 0; ev->pipeline_parsed = 0; uri = sbuf ? eina_strbuf_string_get(sbuf) : file; DBG("setting file to '%s'", uri); ev->pipeline = gstreamer_video_sink_new(ev, ev->obj, uri); if (sbuf) eina_strbuf_free(sbuf); if (!ev->pipeline) return EINA_FALSE; ev->eos_bus = gst_pipeline_get_bus(GST_PIPELINE(ev->pipeline)); if (!ev->eos_bus) { ERR("could not get the bus"); return EINA_FALSE; } gst_bus_set_sync_handler(ev->eos_bus, _eos_sync_fct, ev); ev->position = 0.0; return 1; }
void enfeeble_free(Enfeeble *enf) { if (!enf) return; enfeeble_disconnect(enf); eina_stringshare_del(enf->user); eina_stringshare_del(enf->nick); eina_stringshare_del(enf->svr_name); if (enf->buf) eina_strbuf_free(enf->buf); free(enf); }
void _command_service_free(Command_Service *cs) { ecore_event_handler_del(cs->ev.error); ecore_event_handler_del(cs->ev.del); ecore_event_handler_del(cs->ev.data); eina_strbuf_free(cs->buf); free((char *)cs->jid); free(cs); }
EAPI Eina_Stringshare * eolian_typedecl_c_type_get(const Eolian_Typedecl *tp) { Eina_Stringshare *ret; Eina_Strbuf *buf; EINA_SAFETY_ON_NULL_RETURN_VAL(tp, NULL); buf = eina_strbuf_new(); database_typedecl_to_str(tp, buf); ret = eina_stringshare_add(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return ret; }
static void on_error(void *user_data, Evas_Object *webview, void *event_info) { Eina_Strbuf* buffer; const Ewk_Web_Error *error = (const Ewk_Web_Error *)event_info; buffer = eina_strbuf_new(); eina_strbuf_append_printf(buffer, "<html><body><div style=\"color:#ff0000\">ERROR!</div><br><div>Code: %d<br>Description: %s<br>URL: %s</div></body</html>", ewk_web_error_code_get(error), ewk_web_error_description_get(error), ewk_web_error_url_get(error)); ewk_view_html_string_load(webview, eina_strbuf_string_get(buffer), 0, ewk_web_error_url_get(error)); eina_strbuf_free(buffer); }
/* expand fname to full path name (so that PATH is ignored) plus turn * stuff into a command, and also verify whether the path exists */ static char * get_cmdline_from_argv(const char *fname, const char **argv) { Eina_Strbuf *buf; char *ret; char pbuf[PATH_MAX]; const char *arg = NULL; FILE *testf = fopen(fname, "rb"); if (!testf) return NULL; fclose(testf); /* for windows, we have realpath in evil, no need for GetFullPathName */ if (!realpath(fname, pbuf)) return NULL; buf = eina_strbuf_new(); eina_strbuf_append_char(buf, '"'); eina_strbuf_append(buf, pbuf); eina_strbuf_append_char(buf, '"'); while ((arg = *(argv++))) { char c; eina_strbuf_append_char(buf, ' '); eina_strbuf_append_char(buf, '"'); while ((c = *(arg++))) { #ifndef _WIN32 if (c == '"' || c == '$') eina_strbuf_append_char(buf, '\\'); eina_strbuf_append_char(buf, c); #else if (c == '"') eina_strbuf_append_char(buf, '\\'); else if (c == '%') eina_strbuf_append_char(buf, '"'); eina_strbuf_append_char(buf, c); if (c == '%') eina_strbuf_append_char(buf, '"'); #endif } eina_strbuf_append_char(buf, '"'); } ret = strdup(eina_strbuf_string_get(buf)); eina_strbuf_free(buf); return ret; }
char * replace_string(const char *string, const char *substr, const char *replacement) { char *str_cpy = strdup(string); char *pch; char *ret; Eina_Strbuf *buffer = eina_strbuf_new(); pch = strtok(str_cpy, substr); if (!pch) { eina_strbuf_free(buffer); return str_cpy; } eina_strbuf_append(buffer, pch); while ((pch = strtok(NULL, substr))) eina_strbuf_append_printf(buffer, "%s%s", replacement, pch); ret = eina_strbuf_string_steal(buffer); free(str_cpy); eina_strbuf_free(buffer); return ret; }
char * string_build(const char *fmt, ...) { va_list ap; Eina_Strbuf *buffer = eina_strbuf_new(); char *ret; va_start(ap, fmt); eina_strbuf_prepend_vprintf(buffer, fmt, ap); va_end(ap); ret = strdup(eina_strbuf_string_get(buffer)); eina_strbuf_free(buffer); return ret; }
EOLIAN static char* _efl_text_markup_util_text_to_markup(const char *text) { Eina_Strbuf *sbuf; char *str = NULL; if (!text) return NULL; sbuf = eina_strbuf_new(); _markup_get_text_utf8_append(sbuf, text); str = eina_strbuf_string_steal(sbuf); eina_strbuf_free(sbuf); return str; }
EAPI char * eina_simple_xml_node_dump(Eina_Simple_XML_Node *node, const char *indent) { Eina_Strbuf *buf; char *ret; if (!node) return NULL; buf = eina_strbuf_new(); if (!buf) return NULL; _eina_simple_xml_node_dump(buf, node, indent, 0); ret = eina_strbuf_string_steal(buf); eina_strbuf_free(buf); return ret; }