static void hb_export_qif_elt_acc(GIOChannel *io, Account *acc) { GString *elt; gchar *type; elt = g_string_sized_new(255); // account export //#987144 fixed account type switch(acc->type) { case ACC_TYPE_BANK : type = "Bank"; break; case ACC_TYPE_CASH : type = "Cash"; break; case ACC_TYPE_ASSET : type = "Oth A"; break; case ACC_TYPE_CREDITCARD : type = "CCard"; break; case ACC_TYPE_LIABILITY : type = "Oth L"; break; default : type = "Bank"; break; } g_string_assign(elt, "!Account\n"); g_string_append_printf (elt, "N%s\n", acc->name); g_string_append_printf (elt, "T%s\n", type); g_string_append (elt, "^\n"); g_string_append_printf (elt, "!Type:%s\n", type); g_io_channel_write_chars(io, elt->str, -1, NULL, NULL); g_string_free(elt, TRUE); }
/******************************************************* * csv_import_sep_cb * * call back for type of separartor required *******************************************************/ void csv_import_sep_cb (GtkWidget *radio, gpointer user_data ) { CsvImportInfo *info = user_data; const gchar *name; gchar *temp; if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radio))) { LEAVE("1st callback of pair. Defer to 2nd callback."); return; } name = gtk_buildable_get_name(GTK_BUILDABLE(radio)); if (g_strcmp0(name, g_strdup("radio_semi")) == 0) g_string_assign (info->regexp, "^(?<type>[^;]*);(?<full_name>[^;]*);(?<name>[^;]*);(?<code>[^;]*);?(?<description>[^;]*);?(?<color>[^;]*);?(?<notes>[^;]*);?(?<commoditym>[^;]*);?(?<commodityn>[^;]*);?(?<hidden>[^;]*);?(?<tax>[^;]*);?(?<place_holder>[^;]*)$"); if (g_strcmp0(name, g_strdup("radio_comma")) == 0) g_string_assign (info->regexp, "^(?<type>[^,]*),(?<full_name>[^,]*),(?<name>[^,]*),(?<code>[^,]*),?(?<description>[^,]*),?(?<color>[^,]*),?(?<notes>[^,]*),?(?<commoditym>[^,]*),?(?<commodityn>[^,]*),?(?<hidden>[^,]*),?(?<tax>[^,]*),?(?<place_holder>[^,]*)$"); if (g_strcmp0(name, g_strdup("radio_semiq")) == 0) g_string_assign (info->regexp, "^((?<type>[^\";]*)|\"(?<type>[^\"]*)\");((?<full_name>[^\";]*)|\"(?<full_name>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<code>[^\";]*)|\"(?<code>[^\"]*)\");((?<description>[^\";]*)|\"(?<description>[^\"]*)\");((?<color>[^\";]*)|\"(?<color>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<commoditym>[^\";]*)|\"(?<commoditym>[^\"]*)\");((?<commodityn>[^\";]*)|\"(?<commodityn>[^\"]*)\");((?<hidden>[^\";]*)|\"(?<hidden>[^\"]*)\");((?<tax>[^\";]*)|\"(?<tax>[^\"]*)\");((?<place_holder>[^\";]*)|\"(?<place_holder>[^\"]*)\")$"); if (g_strcmp0(name, g_strdup("radio_commaq")) == 0) g_string_assign (info->regexp, "^((?<type>[^\",]*)|\"(?<type>[^\"]*)\"),((?<full_name>[^\",]*)|\"(?<full_name>[^\"]*)\"),((?<name>[^\",]*)|\"(?<name>[^\"]*)\"),((?<code>[^\",]*)|\"(?<code>[^\"]*)\"),((?<description>[^\",]*)|\"(?<description>[^\"]*)\"),((?<color>[^\",]*)|\"(?<color>[^\"]*)\"),((?<notes>[^\",]*)|\"(?<notes>[^\"]*)\"),((?<commoditym>[^\",]*)|\"(?<commoditym>[^\"]*)\"),((?<commodityn>[^\",]*)|\"(?<commodityn>[^\"]*)\"),((?<hidden>[^\",]*)|\"(?<hidden>[^\"]*)\"),((?<tax>[^\",]*)|\"(?<tax>[^\"]*)\"),((?<place_holder>[^\",]*)|\"(?<place_holder>[^\"]*)\")$"); if (g_strcmp0(name, g_strdup("radio_custom")) == 0) { temp = gnc_input_dialog (0, _("Adjust regular expression used for import"), _("This regular expression is used to parse the import file. Modify according to your needs.\n"), info->regexp->str); if (temp) { g_string_assign (info->regexp, temp); g_free (temp); } } /* Generate preview */ gtk_list_store_clear (info->store); if (csv_import_read_file (info->file_name, info->regexp->str, info->store, 11 ) == MATCH_FOUND) gtk_widget_set_sensitive (info->header_row_spin, TRUE); else gtk_widget_set_sensitive (info->header_row_spin, FALSE); /* Reset Header spin to 0 */ gtk_spin_button_set_value( GTK_SPIN_BUTTON(info->header_row_spin), 0 ); }
gboolean read_subshell_prompt (void) { int rc = 0; ssize_t bytes = 0; struct timeval timeleft = { 0, 0 }; GString *p; gboolean prompt_was_reset = FALSE; fd_set tmp; FD_ZERO (&tmp); FD_SET (mc_global.tty.subshell_pty, &tmp); /* First time through */ if (subshell_prompt == NULL) subshell_prompt = g_string_sized_new (INITIAL_PROMPT_SIZE); p = g_string_sized_new (INITIAL_PROMPT_SIZE); while (subshell_alive && (rc = select (mc_global.tty.subshell_pty + 1, &tmp, NULL, NULL, &timeleft)) != 0) { ssize_t i; /* Check for 'select' errors */ if (rc == -1) { if (errno == EINTR) { if (mc_global.tty.winch_flag != 0) tty_change_screen_size (); continue; } fprintf (stderr, "select (FD_SETSIZE, &tmp...): %s\r\n", unix_error_string (errno)); exit (EXIT_FAILURE); } bytes = read (mc_global.tty.subshell_pty, pty_buffer, sizeof (pty_buffer)); /* Extract the prompt from the shell output */ for (i = 0; i < bytes; i++) if (pty_buffer[i] == '\n' || pty_buffer[i] == '\r') { g_string_set_size (p, 0); prompt_was_reset = TRUE; } else if (pty_buffer[i] != '\0') g_string_append_c (p, pty_buffer[i]); } if (p->len != 0 || prompt_was_reset) g_string_assign (subshell_prompt, p->str); g_string_free (p, TRUE); return (rc != 0 || bytes != 0); }
static GtkWidget* gwy_app_recent_file_list_filter_construct(Controls *controls) { GwyContainer *settings; GtkWidget *hbox, *label, *entry, *check, *button, *image; const guchar *glob; settings = gwy_app_settings_get(); hbox = gtk_hbox_new(FALSE, 0); label = gtk_label_new_with_mnemonic(_("_Filter:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 4); if (!controls->glob) controls->glob = g_string_new(NULL); if (gwy_container_gis_string_by_name(settings, "/app/file/recent/glob", &glob)) g_string_assign(controls->glob, glob); entry = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(entry), controls->glob->str); gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); gtk_label_set_mnemonic_widget(GTK_LABEL(label), entry); controls->filter_glob = entry; g_signal_connect(entry, "activate", G_CALLBACK(gwy_app_recent_file_list_filter_apply), controls); button = gtk_button_new(); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); g_signal_connect(button, "clicked", G_CALLBACK(gwy_app_recent_file_list_filter_clear), controls); image = gtk_image_new_from_stock(GTK_STOCK_CLEAR, GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_button_set_image(GTK_BUTTON(button), image); #ifdef G_OS_WIN32 controls->casesens = FALSE; #else controls->casesens = TRUE; #endif gwy_container_gis_boolean_by_name(settings, "/app/file/recent/case-sensitive", &controls->casesens); check = gtk_check_button_new_with_mnemonic(_("Case _sensitive")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), controls->casesens); gtk_box_pack_start(GTK_BOX(hbox), check, FALSE, FALSE, 4); controls->filter_case = check; g_signal_connect(check, "toggled", G_CALLBACK(gwy_app_recent_file_list_filter_case_changed), controls); return hbox; }
static void _set_file_name (gchar * name) { if (file_name == NULL) file_name = g_string_new (name); else g_string_assign (file_name, name); }
/** * z_transfer2_ps_iface_set_stacked_verdict: * @self: ZProxyStackIface instance * @verdict: verdict sent by the child proxy * @description: additional information about @decision * * This function is the virtual set_result method in the ZProxyStackIface * interface callable by child proxies. It simply stores the verdict sent * by the child proxy in self->stack_decision. * * NOTE: this function runs in the thread of the child proxy and there is no * synchronization between this and the main proxy thread except for the fact * that the child proxy should call this function before he sends anything * and HTTP will make use of this value when it first receives something, * thus there must be at least one context switch in between, and the HTTP * is possibly sleeping when this function is called. **/ static void z_transfer2_ps_iface_set_stacked_verdict(ZProxyStackIface *s, ZVerdict verdict, const gchar *description) { ZTransfer2PSIface *self = Z_CAST(s, ZTransfer2PSIface); g_string_assign(self->transfer->stack_info, description ? description : ""); self->transfer->stack_decision = verdict; }
void on_diff3_tool_selection_changed(GtkFileChooser* filechooser, gpointer user_data) { MODEL* m = (MODEL*)model; gchar* name = gtk_file_chooser_get_filename(filechooser); if(name != NULL) { g_string_assign(m->diff3_tool, name); } }
Fasta* load_fasta(const gchar* filename, GError** err_out) { GError* err = NULL; GIOChannel* ch = g_io_channel_new_file(filename, "r", &err); if (err != NULL){ *err_out = err; return NULL; } // Initialize Fasta Fasta* fasta = g_new(Fasta, 1); fasta->array = g_array_new(FALSE, FALSE, sizeof(Sequence*)); fasta->hash = g_hash_table_new(g_str_hash, g_str_equal); gchar* line; GString* seq = g_string_new(""); GString* seq_id = g_string_new(""); gboolean first = TRUE; while(g_io_channel_read_line(ch, &line, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) { //g_message("line='%s'", line); if (line[0] == '>'){ if (first){ first = FALSE; } else { got_sequence(fasta, seq_id->str, seq->str); } g_string_assign(seq_id, g_strstrip(line + 1)); g_string_assign(seq, ""); } else { g_string_append(seq, g_strstrip(line)); } g_free(line); } if (first){ return NULL; } else { got_sequence(fasta, seq_id->str, seq->str); } g_string_free(seq, TRUE); g_string_free(seq_id, TRUE); g_io_channel_unref(ch); return fasta; }
static void prefs_load_xml_start_element( GMarkupParseContext * context, const gchar * element, const gchar ** attribute_names, const gchar ** attribute_values, gpointer user_data, GError ** error) { struct prefs_parser_state * state = (struct prefs_parser_state*)user_data; if(!g_utf8_collate(element, "vqcc_gtk") && state->tag==PREFS_TAG_NO_TAG) { state->tag = PREFS_TAG_VQCC_GTK; } else if(!g_utf8_collate(element, "settings") && state->tag==PREFS_TAG_VQCC_GTK) { state->tag = PREFS_TAG_VQCC_GTK_SETTINGS; } else if(!g_utf8_collate(element, "pref") && state->tag==PREFS_TAG_VQCC_GTK_SETTINGS) { struct prefs_value * val; const gchar ** attr, ** value; const gchar * prefs_type_attr; state->tag = PREFS_TAG_VQCC_GTK_SETTINGS_PREF; /* fetch pref attributes */ g_string_assign(state->pref_name, ""); for(attr = attribute_names, value = attribute_values; *attr; attr++, value++) { if(!g_utf8_collate(*attr, "name")) g_string_assign(state->pref_name, *value); if(!g_utf8_collate(*attr, "type")) prefs_type_attr = *value; } /* check if we have a valid preference name and type */ state->pref_valid = FALSE; val = (struct prefs_value*)g_hash_table_lookup(prefs_hash, state->pref_name->str); if(val && prefs_get_type_by_name(prefs_type_attr, &state->pref_type)) { if(state->pref_type==val->type) state->pref_valid = TRUE; } } else if(!g_utf8_collate(element, "entry") && state->tag==PREFS_TAG_VQCC_GTK_SETTINGS_PREF) { state->tag = PREFS_TAG_VQCC_GTK_SETTINGS_PREF_ENTRY; } }
void gnc_bi_import_gui_option4_cb (GtkWidget *widget, gpointer data) { BillImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; g_string_assign (gui->regexp, "^((?<id>[^\",]*)|\"(?<id>[^\"]*)\"),((?<date_opened>[^\",]*)|\"(?<date_opened>[^\"]*)\"),((?<owner_id>[^\",]*)|\"(?<owner_id>[^\"]*)\"),((?<billing_id>[^\",]*)|\"(?<billing_id>[^\"]*)\"),((?<notes>[^\",]*)|\"(?<notes>[^\"]*)\"),((?<date>[^\",]*)|\"(?<date>[^\"]*)\"),((?<desc>[^\",]*)|\"(?<desc>[^\"]*)\"),((?<action>[^\",]*)|\"(?<action>[^\"]*)\"),((?<account>[^\",]*)|\"(?<account>[^\"]*)\"),((?<quantity>[^\",]*)|\"(?<quantity>[^\"]*)\"),((?<price>[^\",]*)|\"(?<price>[^\"]*)\"),((?<disc_type>[^\",]*)|\"(?<disc_type>[^\"]*)\"),((?<disc_how>[^\",]*)|\"(?<disc_how>[^\"]*)\"),((?<discount>[^\",]*)|\"(?<discount>[^\"]*)\"),((?<taxable>[^\",]*)|\"(?<taxable>[^\"]*)\"),((?<taxincluded>[^\",]*)|\"(?<taxincluded>[^\"]*)\"),((?<tax_table>[^\",]*)|\"(?<tax_table>[^\"]*)\"),((?<date_posted>[^\",]*)|\"(?<date_posted>[^\"]*)\"),((?<due_date>[^\",]*)|\"(?<due_date>[^\"]*)\"),((?<account_posted>[^\",]*)|\"(?<account_posted>[^\"]*)\"),((?<memo_posted>[^\",]*)|\"(?<memo_posted>[^\"]*)\"),((?<accu_splits>[^\",]*)|\"(?<accu_splits>[^\"]*)\")$"); gnc_bi_import_gui_filenameChanged_cb (gui->entryFilename, gui); }
void cd_do_select_previous_next_matching_icon (gboolean bNext) { GList *pMatchingElement = myData.pCurrentMatchingElement; do { if (!bNext) myData.pCurrentMatchingElement = cairo_dock_get_previous_element (myData.pCurrentMatchingElement, myData.pMatchingIcons); else myData.pCurrentMatchingElement = cairo_dock_get_next_element (myData.pCurrentMatchingElement, myData.pMatchingIcons); } while (myData.pCurrentMatchingElement != pMatchingElement && ((Icon*)myData.pCurrentMatchingElement->data)->image.pSurface == NULL); if (myData.pCurrentMatchingElement != pMatchingElement) // on complete le texte et on redessine. { Icon *pIcon = myData.pCurrentMatchingElement->data; if (pIcon->cCommand && *pIcon->cCommand != *myData.sCurrentText->str) // cas d'une commande avec un tiret. myData.iNbValidCaracters = 0; cd_do_delete_invalid_caracters (); if (pIcon->cBaseURI != NULL) { gchar *cFile = g_path_get_basename (pIcon->cCommand); g_string_assign (myData.sCurrentText, cFile); g_free (cFile); } else g_string_assign (myData.sCurrentText, pIcon->cCommand); cd_do_load_pending_caracters (); // on arme l'animation de decalage. myData.iMatchingGlideCount = 10; // on rembobine l'animation. myData.iPreviousMatchingOffset = myData.iCurrentMatchingOffset; // on part du point courant. int iWidth, iHeight; cairo_dock_get_icon_extent (pIcon, &iWidth, &iHeight); if (iHeight != 0) { double fZoom = (double) g_pMainDock->container.iHeight/2 / iHeight; myData.iMatchingAimPoint += (bNext ? 1 : -1) * iWidth * fZoom; // on cherche a atteindre le nouveau point. } // on repositionne les caracteres et on anime tout ca. cd_do_launch_appearance_animation (); cairo_dock_redraw_container (CAIRO_CONTAINER (g_pMainDock)); } }
// Comma separated. void gnc_customer_import_gui_option2_cb (GtkWidget *widget, gpointer data) { CustomerImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; g_string_assign (gui->regexp, "^(?<id>[^,]*),(?<company>[^,]*),(?<name>[^,]*),(?<addr1>[^,]*),?(?<addr2>[^,]*),?(?<addr3>[^,]*),?(?<addr4>[^,]*),?(?<phone>[^,]*),?(?<fax>[^,]*),?(?<email>[^,]*),?(?<notes>[^,]*),?(?<shipname>[^,]*),?(?<shipaddr1>[^,]*),?(?<shipaddr2>[^,]*),?(?<shipaddr3>[^,]*),?(?<shipaddr4>[^,]*),?(?<shipphone>[^,]*),(?<shipfax>[^,]*),(?<shipemail>[^,]*)"); //,(?<account_posted>[^,]*),(?<memo_posted>[^,]*),(?<accu_splits>[^,]*)$"); gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui); }
static void _add_app( const gchar *name, const gchar *path) { guint i; gboolean ok; qio_app_cb cb; GString *full_path = qev_buffer_get(); guint *magic_num = NULL; struct app *app = g_slice_alloc0(sizeof(*app)); app->name = g_strdup(name); if (strspn(path, PATH_STARTERS) == 0) { g_string_printf(full_path, "%s/%s", PATH_LIB_DIR, path); } else { g_string_assign(full_path, path); } app->mod = g_module_open(full_path->str, G_MODULE_BIND_LOCAL); ASSERT(app->mod != NULL, "Could not open app %s: %s", name, g_module_error()); /* * For config: unloading modules causes segfaults on exit because the * modules can be closed an removed from memory. Keep them in memory at * all times: not like they can be removed at runtime anyway. */ g_module_make_resident(app->mod); for (i = 0; i < _apps->len; i++) { struct app *oapp = g_ptr_array_index(_apps, i); ASSERT(app->mod != oapp->mod, "Duplicate app detected %s (%s).", name, full_path->str); } ok = g_module_symbol(app->mod, "__qio_is_app", (void*)&magic_num) && *magic_num == QIO_MAGIC_NUM; ASSERT(ok, "Loaded module is not a QuickIO app: %s (%s)", name, full_path->str) #define X(fn) \ ASSERT(g_module_symbol(app->mod, "__qio_app_" G_STRINGIFY(fn), (void*)&cb), \ "App missing default QuickIO function %s: %s (%s)", \ "__qio_app_" G_STRINGIFY(fn), name, full_path->str); \ app->fn = cb; CALLBACKS #undef X ASSERT(app->init(), "Could not initialize app (%s): init() failed", name); g_ptr_array_add(_apps, app); qev_buffer_put(full_path); }
// Semicolon separated with quoted strings. void gnc_customer_import_gui_option3_cb (GtkWidget *widget, gpointer data) { CustomerImportGui *gui = data; if (!gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(widget) )) return; //g_string_assign (gui->regexp, "^((?<id>[^\";]*)|\"(?<id>[^\"]*)\");((?<company>[^\";]*)|\"(?<company>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<addr1>[^\";]*)|\"(?<addr1>[^\"]*)\");((?<addr2>[^\";]*)|\"(?<addr2>[^\"]*)\");((?<addr3>[^\";]*)|\"(?<addr3>[^\"]*)\");((?<addr4>[^\";]*)|\"(?<addr4>[^\"]*)\");((?<phone>[^\";]*)|\"(?<phone>[^\"]*)\");((?<fax>[^\";]*)|\"(?<fax>[^\"]*)\");((?<email>[^\";]*)|\"(?<email>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<shipname>[^\";]*)|\"(?<shipname>[^\"]*)\");((?<shipaddr1>[^\";]*)|\"(?<shipaddr1>[^\"]*)\");((?<shipaddr2>[^\";]*)|\"(?<shipaddr2>[^\"]*)\");((?<shipaddr3>[^\";]*)|\"(?<shipaddr3>[^\"]*)\");((?<shipaddr4>[^\";]*)|\"(?<shipaddr4>[^\"]*)\");((?<shipphone>[^\";]*)|\"(?<shipphone>[^\"]*)\");((?<shipfax>[^\";]*)|\"(?<shipfax>[^\"]*)\");((?<shipmail>[^\";]*)|\"(?<shipemail>[^\"]*)\")$"); g_string_assign (gui->regexp, "^((?<id>[^\";]*)|\"(?<id>[^\"]*)\");((?<company>[^\";]*)|\"(?<company>[^\"]*)\");((?<name>[^\";]*)|\"(?<name>[^\"]*)\");((?<addr1>[^\";]*)|\"(?<addr1>[^\"]*)\");((?<addr2>[^\";]*)|\"(?<addr2>[^\"]*)\");((?<addr3>[^\";]*)|\"(?<addr3>[^\"]*)\");((?<addr4>[^\";]*)|\"(?<addr4>[^\"]*)\");((?<phone>[^\";]*)|\"(?<phone>[^\"]*)\");((?<fax>[^\";]*)|\"(?<fax>[^\"]*)\");((?<email>[^\";]*)|\"(?<email>[^\"]*)\");((?<notes>[^\";]*)|\"(?<notes>[^\"]*)\");((?<shipname>[^\";]*)|\"(?<shipname>[^\"]*)\");((?<shipaddr1>[^\";]*)|\"(?<shipaddr1>[^\"]*)\");((?<shipaddr2>[^\";]*)|\"(?<shipaddr2>[^\"]*)\");((?<shipaddr3>[^\";]*)|\"(?<shipaddr3>[^\"]*)\");((?<shipaddr4>[^\";]*)|\"(?<shipaddr4>[^\"]*)\");((?<shipphone>[^\";]*)|\"(?<shipphone>[^\"]*)\");((?<shipfax>[^\";]*)|\"(?<shipfax>[^\"]*)\");((?<shipemail>[^\";]*)|\"(?<shipemail>[^\"]*)\")$"); gnc_customer_import_gui_filenameChanged_cb (gui->entryFilename, gui); }
void test_control_connection(gsize transaction_size) { moc_connection = (ControlConnectionMoc *)control_connection_moc_new(&moc_server); g_string_assign(moc_connection->source_buffer->buffer,"test command\n"); moc_connection->transaction_size = transaction_size; control_connection_start_watches((ControlConnection *)moc_connection); assert_string(result_string->str, "OK\n.\n", "BAD Behaviour transaction_size: %d",transaction_size); }
static CsvToken csv_get_token (Csv *csv) { gboolean done; gint c; if (csv->prev_token != CSV_TOKEN_BEGIN_QUOTE) if (!csv_find_data (csv)) return CSV_TOKEN_NONE; c = getc (csv->fp); if (csv->prev_token == CSV_TOKEN_NEW_LINE && c == '\n') return CSV_TOKEN_NEW_LINE; if (csv->prev_token == CSV_TOKEN_DATA) { if (c == csv->delimiter) return CSV_TOKEN_DELIMITER; else if (c == '\n') return CSV_TOKEN_NEW_LINE; return CSV_TOKEN_ERROR; } if (c == '"' && !csv->quoted) { csv->quoted = TRUE; return CSV_TOKEN_BEGIN_QUOTE; } ungetc (c, csv->fp); g_string_assign (csv->data, ""); while (1) { c = getc (csv->fp); done = (c == EOF) || (c == csv->delimiter && !csv->quoted) || (c == '\n' && !csv->quoted); if (done) { ungetc (c, csv->fp); return CSV_TOKEN_DATA; } if (c == '"') { gint next = getc (csv->fp); if (next != '"') { ungetc (next, csv->fp); csv->quoted = FALSE; return CSV_TOKEN_DATA; } } g_string_append_c (csv->data, c); } }
static void tf_dirname(LogMessage *msg, gint argc, GString *argv[], GString *result) { gchar *dir; dir = g_path_get_dirname(argv[0]->str); g_string_assign(result, dir); g_free(dir); }
static void tf_basename(LogMessage *msg, gint argc, GString *argv[], GString *result) { gchar *base; base = g_path_get_basename(argv[0]->str); g_string_assign(result, base); g_free(base); }
void gwp_torpspec_set_name (GwpTorpSpec *self, gchar *name) { g_assert (GWP_IS_TORPSPEC(self)); g_assert (name != NULL); if (strlen(name) <= 20) { self->priv->name = g_string_assign (self->priv->name, name); } }
MotoVariation *moto_variation_new(const gchar *name) { MotoVariation *self = (MotoVariation *)g_object_new(MOTO_TYPE_VARIATION, NULL); MotoVariationPriv *priv = MOTO_VARIATION_GET_PRIVATE(self); g_string_assign(priv->name, name); return self; }
int ctf_text_sequence_write(struct bt_stream_pos *ppos, struct bt_definition *definition) { struct ctf_text_stream_pos *pos = ctf_text_pos(ppos); struct definition_sequence *sequence_definition = container_of(definition, struct definition_sequence, p); struct declaration_sequence *sequence_declaration = sequence_definition->declaration; struct bt_declaration *elem = sequence_declaration->elem; int field_nr_saved; int ret = 0; if (!print_field(definition)) return 0; if (!pos->dummy) { if (pos->field_nr++ != 0) fprintf(pos->fp, ","); fprintf(pos->fp, " "); if (pos->print_names) fprintf(pos->fp, "%s = ", rem_(g_quark_to_string(definition->name))); } if (elem->id == BT_CTF_TYPE_ID_INTEGER) { struct declaration_integer *integer_declaration = container_of(elem, struct declaration_integer, p); if (integer_declaration->encoding == CTF_STRING_UTF8 || integer_declaration->encoding == CTF_STRING_ASCII) { if (!(integer_declaration->len == CHAR_BIT && integer_declaration->p.alignment == CHAR_BIT)) { pos->string = sequence_definition->string; g_string_assign(sequence_definition->string, ""); ret = bt_sequence_rw(ppos, definition); pos->string = NULL; } fprintf(pos->fp, "\"%s\"", sequence_definition->string->str); return ret; } } if (!pos->dummy) { fprintf(pos->fp, "["); pos->depth++; } field_nr_saved = pos->field_nr; pos->field_nr = 0; ret = bt_sequence_rw(ppos, definition); if (!pos->dummy) { pos->depth--; fprintf(pos->fp, " ]"); } pos->field_nr = field_nr_saved; return ret; }
static gboolean _parse_value_by_incrementing_all_bytes(KVScanner *self) { gint i; g_string_assign(self->decoded_value, self->value->str); for (i = 0; i < self->decoded_value->len; i++) self->decoded_value->str[i]++; return TRUE; }
static char* getShortStatusString( const tr_stat * torStat ) { GString * gstr = g_string_new( NULL ); switch( torStat->activity ) { case TR_STATUS_STOPPED: g_string_assign( gstr, _( "Paused" ) ); break; case TR_STATUS_CHECK_WAIT: g_string_assign( gstr, _( "Waiting to verify local data" ) ); break; case TR_STATUS_CHECK: g_string_append_printf( gstr, _( "Verifying local data (%.1f%% tested)" ), torStat->recheckProgress * 100.0 ); break; case TR_STATUS_DOWNLOAD: case TR_STATUS_SEED: { char buf[128]; if( torStat->activity != TR_STATUS_DOWNLOAD ) { tr_strlratio( buf, torStat->ratio, sizeof( buf ) ); g_string_append_printf( gstr, _( "Ratio: %s" ), buf ); g_string_append( gstr, ", " ); } getShortTransferString( torStat, buf, sizeof( buf ) ); g_string_append( gstr, buf ); break; } default: break; } return g_string_free( gstr, FALSE ); }
void l_quvi_object_crypto_invalid_hexstr(lua_State *l, _quvi_t q, const gboolean croak_if_error) { g_string_assign(q->status.errmsg, "invalid hex string value"); q->status.rc = QUVI_ERROR_CALLBACK; if (croak_if_error ==TRUE) luaL_error(l, "%s", q->status.errmsg->str); }
static GString *gstr_replace_all(GString *text, const gchar* old_str, const gchar *new_str) { gchar *escaped_s1 = g_regex_escape_string (old_str, -1); GRegex *regex = g_regex_new (escaped_s1, 0, 0, NULL); gchar *new_string = g_regex_replace_literal(regex, text->str, -1, 0, new_str, 0, NULL); g_regex_unref(regex); g_free(escaped_s1); g_string_assign(text, new_string); g_free(new_string); return text; }
static void make_file_list(NautilusFileInfo *info, GString *str) { gchar *uri = nautilus_file_info_get_uri(info); if (!str->len) g_string_assign(str, uri); else g_string_append_printf(str, " %s", uri); g_free(uri); }
void gui_entry_set_text(const char *str) { g_return_if_fail(str != NULL); g_string_assign(entry, str); pos = entry->len; entry_screenpos(); entry_update(); }
void mbus_symbol_set( MObject * msymbol, const gchar * str ) { M_OBJECT_ASSERT( msymbol, MSYMBOL ); if ( mbus_symbol_is_valid( msymbol ) ) g_string_assign( M_SYMBOL( msymbol )->str, str ); else g_error( "invalid characters in symbol (not set)" ); }
//------------------------------------------------------------------------------ int general_settings_load_configuration (config_setting_t *setting) { config_setting_t *s = NULL ; init_general_settings() ; s = config_setting_get_member(setting, "path_1_wire_directory") ; if (s != NULL) { g_string_assign (path_1_wire_directory, config_setting_get_string(s)) ; } ; s = config_setting_get_member(setting, "path_data_directory") ; if (s != NULL) { g_string_assign (path_data_directory, config_setting_get_string(s)) ; } ; s = config_setting_get_member(setting, "write_samples_interval") ; if (s != NULL) write_samples_interval = config_setting_get_int(s) ; return 0 ; } ;
static const gchar * _get_formatted_key(KVParser *self, const gchar *key) { if (self->formatted_key->len > 0) g_string_truncate(self->formatted_key, self->prefix_len); else g_string_assign(self->formatted_key, self->prefix); g_string_append(self->formatted_key, key); return self->formatted_key->str; }