char * generate_syntax (const struct ks_one_sample *rd) { gchar *text; GString *string = g_string_new ("NPAR TEST"); if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->cb[CB_NORMAL]))) append_fragment (string, "NORMAL", PSPPIRE_VAR_VIEW (rd->variables)); if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->cb[CB_UNIFORM]))) append_fragment (string, "UNIFORM", PSPPIRE_VAR_VIEW (rd->variables)); if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->cb[CB_POISSON]))) append_fragment (string, "POISSON", PSPPIRE_VAR_VIEW (rd->variables)); if ( gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (rd->cb[CB_EXPONENTIAL]))) append_fragment (string, "EXPONENTIAL", PSPPIRE_VAR_VIEW (rd->variables)); g_string_append (string, ".\n"); text = string->str; g_string_free (string, FALSE); return text; }
/* Append a live binary buffer that we should translate into the * format configured earlier by the user for this script. * Takes ownership of the malloc-allocated buffer and frees it. */ static void append_data(struct code_state *code, enum code_data_t data_type, void *data_buffer, int data_len) { struct code_data *data = data_new(); data->buffer = data_buffer; data->type = data_type; data->len = data_len; struct code_fragment *fragment = fragment_new(); fragment->type = FRAGMENT_DATA; fragment->contents.data = data; append_fragment(code, fragment); }
/* Append a literal ASCII text code snippet that we should emit. * Takes ownership of the malloc-allocated text memory and frees it. */ static void append_text(struct code_state *code, const char *file_name, int line_number, char *text_buffer) { struct code_text *text = text_new(); text->text = text_buffer; text->file_name = strdup(file_name); text->line_number = line_number; struct code_fragment *fragment = fragment_new(); fragment->type = FRAGMENT_TEXT; fragment->contents.text = text; append_fragment(code, fragment); }