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; }
void on_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) { Evas_Object *object = (Evas_Object*)data; int col, row; char buf[4]; if(password) eina_strbuf_reset(password); else password = eina_strbuf_new(); col = atoi(edje_object_data_get(object, "col")); row = atoi(edje_object_data_get(object, "row")); snprintf(buf, 4, "%dx%d", col, row); eina_strbuf_append(password, buf); mouse_down=EINA_TRUE; printf(_("Mouse down on %dx%d\n"), col, row); printf(_("Password is '%s'\n"), eina_strbuf_string_get(password)); }
static int _append_section(const char *desc, int ind, int curl, Eina_Strbuf *buf, Eina_Strbuf *wbuf, Eina_Bool use_legacy) { while (*desc) { eina_strbuf_reset(wbuf); while (*desc && isspace(*desc) && (*desc != '\n')) eina_strbuf_append_char(wbuf, *desc++); if (*desc == '\\') { desc++; if ((*desc != '@') && (*desc != '$')) eina_strbuf_append_char(wbuf, '\\'); eina_strbuf_append_char(wbuf, *desc++); } else if (*desc == '@') { const char *ref = ++desc; if (isalpha(*desc) || (*desc == '_')) { eina_strbuf_append(wbuf, "@ref "); while (isalnum(*desc) || (*desc == '.') || (*desc == '_')) ++desc; if (*(desc - 1) == '.') --desc; Eina_Stringshare *refn = eina_stringshare_add_length(ref, desc - ref); _generate_ref(refn, wbuf, use_legacy); eina_stringshare_del(refn); } else eina_strbuf_append_char(wbuf, '@'); } else if (*desc == '$') { desc++; if (isalpha(*desc)) eina_strbuf_append(wbuf, "@c "); else eina_strbuf_append_char(wbuf, '$'); } while (*desc && !isspace(*desc)) eina_strbuf_append_char(wbuf, *desc++); int limit = DOC_LIMIT(ind); int wlen = eina_strbuf_length_get(wbuf); if ((int)(curl + wlen) > limit) { curl = 3; eina_strbuf_append_char(buf, '\n'); curl += _indent_line(buf, ind); eina_strbuf_append(buf, " * "); if (*eina_strbuf_string_get(wbuf) == ' ') eina_strbuf_remove(wbuf, 0, 1); } curl += eina_strbuf_length_get(wbuf); eina_strbuf_append(buf, eina_strbuf_string_get(wbuf)); if (*desc == '\n') { desc++; eina_strbuf_append_char(buf, '\n'); while (*desc == '\n') { _indent_line(buf, ind); eina_strbuf_append(buf, " *\n"); desc++; } curl = _indent_line(buf, ind) + 3; eina_strbuf_append(buf, " * "); } } return curl; }
static int _append_section(const Eolian_State *state, const char *desc, int ind, int curl, Eina_Strbuf *buf, Eina_Strbuf *wbuf) { Eina_Bool try_note = EINA_TRUE; while (*desc) { eina_strbuf_reset(wbuf); while (*desc && isspace(*desc) && (*desc != '\n')) eina_strbuf_append_char(wbuf, *desc++); if (try_note) { #define CHECK_NOTE(str) !strncmp(desc, str ": ", sizeof(str ":")) if (CHECK_NOTE("Note")) { eina_strbuf_append(wbuf, "@note "); desc += sizeof("Note:"); } else if (CHECK_NOTE("Warning")) { eina_strbuf_append(wbuf, "@warning "); desc += sizeof("Warning:"); } else if (CHECK_NOTE("Remark")) { eina_strbuf_append(wbuf, "@remark "); desc += sizeof("Remark:"); } else if (CHECK_NOTE("TODO")) { eina_strbuf_append(wbuf, "@todo "); desc += sizeof("TODO:"); } #undef CHECK_NOTE try_note = EINA_FALSE; } if (*desc == '\\') { desc++; if ((*desc != '@') && (*desc != '$')) eina_strbuf_append_char(wbuf, '\\'); eina_strbuf_append_char(wbuf, *desc++); } else if (*desc == '@') { const char *ref = ++desc; if (isalpha(*desc) || (*desc == '_')) { eina_strbuf_append(wbuf, "@ref "); while (isalnum(*desc) || (*desc == '.') || (*desc == '_')) ++desc; if (*(desc - 1) == '.') --desc; Eina_Stringshare *refn = eina_stringshare_add_length(ref, desc - ref); _generate_ref(state, refn, wbuf); eina_stringshare_del(refn); } else eina_strbuf_append_char(wbuf, '@'); } else if (*desc == '$') { desc++; if (isalpha(*desc)) eina_strbuf_append(wbuf, "@c "); else eina_strbuf_append_char(wbuf, '$'); } while (*desc && !isspace(*desc)) eina_strbuf_append_char(wbuf, *desc++); int limit = DOC_LIMIT(ind); int wlen = eina_strbuf_length_get(wbuf); if ((int)(curl + wlen) > limit) { curl = 3; eina_strbuf_append_char(buf, '\n'); curl += _indent_line(buf, ind); eina_strbuf_append(buf, " * "); if (*eina_strbuf_string_get(wbuf) == ' ') eina_strbuf_remove(wbuf, 0, 1); } curl += eina_strbuf_length_get(wbuf); eina_strbuf_append(buf, eina_strbuf_string_get(wbuf)); if (*desc == '\n') { desc++; eina_strbuf_append_char(buf, '\n'); while (*desc == '\n') { _indent_line(buf, ind); eina_strbuf_append(buf, " *\n"); desc++; try_note = EINA_TRUE; } curl = _indent_line(buf, ind) + 3; eina_strbuf_append(buf, " * "); } } return curl; }