void acpi_add_table(GArray *table_offsets, GArray *table_data) { uint32_t offset = cpu_to_le32(table_data->len); g_array_append_val(table_offsets, offset); }
/* This function is taken from gtk+/tests/testtext.c */ static gint get_lines (GtkTextView *text_view, gint first_y, gint last_y, GArray *buffer_coords, GArray *line_heights, GArray *numbers, gint *countp, GtkTextIter *start, GtkTextIter *end) { GtkTextIter iter; gint count; gint last_line_num = -1; gint total_height = 0; g_array_set_size (buffer_coords, 0); g_array_set_size (numbers, 0); if (line_heights != NULL) { g_array_set_size (line_heights, 0); } /* Get iter at first y */ gtk_text_view_get_line_at_y (text_view, &iter, first_y, NULL); /* For each iter, get its location and add it to the arrays. * Stop when we pass last_y */ count = 0; *start = iter; while (!gtk_text_iter_is_end (&iter)) { gint y, height; gtk_text_view_get_line_yrange (text_view, &iter, &y, &height); g_array_append_val (buffer_coords, y); if (line_heights) { g_array_append_val (line_heights, height); } total_height += height; last_line_num = gtk_text_iter_get_line (&iter); g_array_append_val (numbers, last_line_num); ++count; if ((y + height) >= last_y) { break; } gtk_text_iter_forward_line (&iter); } if (gtk_text_iter_is_end (&iter)) { gint y, height; gint line_num; gtk_text_view_get_line_yrange (text_view, &iter, &y, &height); line_num = gtk_text_iter_get_line (&iter); if (line_num != last_line_num) { g_array_append_val (buffer_coords, y); if (line_heights) { g_array_append_val (line_heights, height); } total_height += height; g_array_append_val (numbers, line_num); ++count; } } *countp = count; if (count == 0) { gint y = 0; gint n = 0; gint height; *countp = 1; g_array_append_val (buffer_coords, y); g_array_append_val (numbers, n); if (line_heights) { gtk_text_view_get_line_yrange (text_view, &iter, &y, &height); g_array_append_val (line_heights, height); total_height += height; } } *end = iter; return total_height; }
int main( int argc, char * argv[]){ pinyin_option_t options = USE_TONE | USE_RESPLIT_TABLE | PINYIN_CORRECT_ALL | PINYIN_AMB_ALL; FacadeChewingTable largetable; MemoryChunk * chunk = new MemoryChunk; chunk->load("../../data/pinyin_index.bin"); largetable.load(options, chunk, NULL); FacadePhraseIndex phrase_index; if (!load_phrase_index(&phrase_index)) exit(ENOENT); Bigram system_bigram; system_bigram.attach("../../data/bigram.db", ATTACH_READONLY); Bigram user_bigram; user_bigram.attach(NULL, ATTACH_CREATE|ATTACH_READWRITE); PinyinLookup2 pinyin_lookup(options, &largetable, &phrase_index, &system_bigram, &user_bigram); /* prepare the prefixes for get_best_match. */ TokenVector prefixes = g_array_new (FALSE, FALSE, sizeof(phrase_token_t)); g_array_append_val(prefixes, sentence_start); CandidateConstraints constraints = g_array_new (TRUE, FALSE, sizeof(lookup_constraint_t)); MatchResults results = g_array_new(FALSE, FALSE, sizeof(phrase_token_t)); char* linebuf = NULL; size_t size = 0; ssize_t read; while( (read = getline(&linebuf, &size, stdin)) != -1 ){ if ( '\n' == linebuf[strlen(linebuf) - 1] ) { linebuf[strlen(linebuf) - 1] = '\0'; } if ( strcmp ( linebuf, "quit" ) == 0) break; FullPinyinParser2 parser; ChewingKeyVector keys = g_array_new(FALSE, FALSE, sizeof(ChewingKey)); ChewingKeyRestVector key_rests = g_array_new(FALSE, FALSE, sizeof(ChewingKeyRest)); parser.parse(options, keys, key_rests, linebuf, strlen(linebuf)); if ( 0 == keys->len ) /* invalid pinyin */ continue; /* initialize constraints. */ g_array_set_size(constraints, keys->len); for ( size_t i = 0; i < constraints->len; ++i){ lookup_constraint_t * constraint = &g_array_index(constraints, lookup_constraint_t, i); constraint->m_type = NO_CONSTRAINT; } guint32 start_time = record_time(); for ( size_t i = 0; i < bench_times; ++i) pinyin_lookup.get_best_match(prefixes, keys, constraints, results); print_time(start_time, bench_times); for ( size_t i = 0; i < results->len; ++i){ phrase_token_t * token = &g_array_index(results, phrase_token_t, i); if ( null_token == *token) continue; printf("pos:%ld,token:%d\t", i, *token); } printf("\n"); char * sentence = NULL; pinyin_lookup.convert_to_utf8(results, sentence); printf("%s\n", sentence); g_array_free(keys, TRUE); g_array_free(key_rests, TRUE); g_free(sentence); } g_array_free(prefixes, TRUE); g_array_free(constraints, TRUE); g_array_free(results, TRUE); free(linebuf); return 0; }
void convert(char *filename) { struct stat stats; if (stat (filename, &stats) == -1) { printf("file not exist!\n"); return; } gchar *basefilename = g_path_get_basename(filename); FILE *tabfile; tabfile = fopen(filename,"r"); gchar *buffer = (gchar *)g_malloc (stats.st_size + 1); size_t fread_size; fread_size = fread (buffer, 1, stats.st_size, tabfile); if (fread_size != (size_t)stats.st_size) { g_print("fread error!\n"); } fclose (tabfile); buffer[stats.st_size] = '\0'; GArray *array = g_array_sized_new(FALSE,FALSE, sizeof(struct _worditem),20000); gchar *p, *p1, *p2; p = buffer; struct _worditem worditem; std::string definition; glong linenum=1; while (1) { if (*p == '\0') { g_print("over\n"); break; } p2 = strchr(p,'\n'); if (p2) { *p2 = '\0'; } else { g_print("error! not end up new line found %ld\n", linenum); return; } #ifdef IS_en_ru_bars p1 = strstr(p, " "); #else p1 = strstr(p, " = "); #endif if (p1) { *p1 = '\0'; } else { g_print("error! not two space chars found! %ld\n", linenum); return; } worditem.word = p; #ifdef IS_en_ru_bars worditem.definition = p1+2; #else worditem.definition = p1+3; #endif g_strstrip(worditem.word); g_strstrip(worditem.definition); if (!worditem.word[0]) { g_print("%ld: %s, bad word! %s\n", linenum, basefilename, worditem.definition); return; } if (!worditem.definition[0]) { g_print("%s, bad definition!!!\n", basefilename); return; } if (!g_utf8_validate(worditem.word, -1,NULL)) { g_print("%s, word %s convert to utf8 error!\n", basefilename, worditem.word); return; } if (!g_utf8_validate(worditem.definition, -1,NULL)) { g_print("%s, definition %s convert to utf8 error!\n", basefilename, worditem.definition); return; } #ifdef IS_en_ru_bars gchar *pp, *pp1; pp = worditem.definition; if ((pp1 = strstr(pp, "2>"))) { definition.clear(); static char number_str[4]; static char tmp_char; for (int i=3; i<= 121+1; i++) { tmp_char = *pp1; *pp1 = '\0'; g_strstrip(pp); definition += pp; definition += "\n\n"; *pp1 = tmp_char; pp = pp1; sprintf(number_str, "%d>", i); pp1 = strstr(pp, number_str); if (!pp1) { //if (strchr(pp, '>')) //g_print("warning: %s\n", worditem.word); break; } } definition += pp; worditem.definition_need_free = true; worditem.definition = g_strdup(definition.c_str()); } else { worditem.definition_need_free = false; } #else worditem.definition_need_free = false; #endif g_array_append_val(array, worditem); p= p2+1; linenum++; } g_array_sort(array,comparefunc); gchar idxfilename[256]; gchar dicfilename[256]; sprintf(idxfilename, "%s.idx", basefilename); sprintf(dicfilename, "%s.dict", basefilename); FILE *idxfile = fopen(idxfilename,"w"); FILE *dicfile = fopen(dicfilename,"w"); glong tmpglong = 0; glong wordcount = array->len; long offset_old; const gchar *previous_word = ""; struct _worditem *pworditem; gulong i=0; glong thedatasize; const gchar *insert_word = "\n"; gboolean flag; pworditem = &g_array_index(array, struct _worditem, i); gint definition_len; while (i<array->len) { thedatasize = 0; offset_old = ftell(dicfile); flag = true; while (flag == true) { definition_len = strlen(pworditem->definition); fwrite(pworditem->definition, 1 ,definition_len,dicfile); thedatasize += definition_len; previous_word = pworditem->word; i++; if (i<array->len) { pworditem = &g_array_index(array, struct _worditem, i); if (strcmp(previous_word,pworditem->word)==0) { g_print("D! %s\n",previous_word); wordcount--; fwrite(insert_word,sizeof(gchar),strlen(insert_word),dicfile); thedatasize += strlen(insert_word); } else { flag = false; } } else flag = false; }
//====================================================== // create all the objects that are needed by the process void prepare(params_t *params) { // === initialize RNG === // init default generator params->rng = gsl_rng_alloc(gsl_rng_default); // seed the generator if (params->seed == 0) // draw a seed from /dev/urandom params->seed = rand(); printf("Seed = %d\n", params->seed); // set the seed gsl_rng_set(params->rng, params->seed); // initialize the mutation wheel int var; params->mwheel = g_array_new(FALSE, FALSE, sizeof(int)); if (params->m_beta) { var = M_BETA; g_array_append_val(params->mwheel, var); } if (params->m_kappa) { var = M_KAPPA; g_array_append_val(params->mwheel, var); } if (params->m_alpha) { var = M_ALPHA; g_array_append_val(params->mwheel, var); } // compute the optimal copy number params->cn_hat = sqrt(params->phi * params->lambda / params->gamma) - params->lambda; printf("Optimal CN is %.2f\n", params->cn_hat); // initialize the population params->cells = g_ptr_array_new(); // initialize array of daughter cells params->dcells = g_ptr_array_new(); // initialize the profile pool params->pool = pool_new(); // load the population from a file?? if (params->load_from) load_population_from_file(params); else initialize_population(params); // do we have a competition?? if (params->compete) { // set the number of contenders based on the pool's contents params->contenders = params->pool->size; printf("COMPETITION MODE : %d contenders found\n", params->contenders); // OK, we do -- now cancel all mutations g_array_set_size(params->mwheel, 0); } // adjust steps so that it is a multiple of fparts int steps = params->steps; while (params->steps % params->fparts > 0) ++ params->steps; if (steps != params->steps) printf("Adjusted simulation steps so that it is a multiple of FPARTS (old=%d, new=%d)\n", steps, params->steps); // initialize logger params->logger = logger_new(params); }
static XdgDirEntry * parse_xdg_dirs (const char *config_file) { GArray *array; char *config_file_free = NULL; XdgDirEntry dir; char *data; char **lines; char *p, *d; int i; char *type_start, *type_end; char *value, *unescaped; gboolean relative; array = g_array_new (TRUE, TRUE, sizeof (XdgDirEntry)); if (config_file == NULL) { config_file_free = g_build_filename (g_get_user_config_dir (), "user-dirs.dirs", NULL); config_file = (const char *)config_file_free; } if (g_file_get_contents (config_file, &data, NULL, NULL)) { lines = g_strsplit (data, "\n", 0); g_free (data); for (i = 0; lines[i] != NULL; i++) { p = lines[i]; while (g_ascii_isspace (*p)) p++; if (*p == '#') continue; value = strchr (p, '='); if (value == NULL) continue; *value++ = 0; g_strchug (g_strchomp (p)); if (!g_str_has_prefix (p, "XDG_")) continue; if (!g_str_has_suffix (p, "_DIR")) continue; type_start = p + 4; type_end = p + strlen (p) - 4; while (g_ascii_isspace (*value)) value++; if (*value != '"') continue; value++; relative = FALSE; if (g_str_has_prefix (value, "$HOME")) { relative = TRUE; value += 5; while (*value == '/') value++; } else if (*value != '/') continue; d = unescaped = g_malloc (strlen (value) + 1); while (*value && *value != '"') { if ((*value == '\\') && (*(value + 1) != 0)) value++; *d++ = *value++; } *d = 0; *type_end = 0; dir.type = g_strdup (type_start); if (relative) { dir.path = g_build_filename (g_get_home_dir (), unescaped, NULL); g_free (unescaped); } else dir.path = unescaped; g_array_append_val (array, dir); } g_strfreev (lines); } g_free (config_file_free); return (XdgDirEntry *)g_array_free (array, FALSE); }
static gboolean do_xmlrpc (SoupSession *session, const gchar *uri, const gchar *method, GError **error, GValue *retval, ...) { SoupMessage *msg; va_list args; GArray *params = g_array_sized_new(FALSE, FALSE, sizeof(GValue), 1); GError *err = NULL; char *body; GType type; GValue val; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); va_start (args, retval); //copy soup_value_array_from_args() in here and change datatypes respectivly while ((type = va_arg (args, GType)) != G_TYPE_INVALID) { SOUP_VALUE_SETV (&val, type, args); g_array_append_val (params, val); } va_end (args); body = soup_xmlrpc_build_method_call (method, (GValue*)params->data, params->len); g_array_unref (params); if (!body) { err = g_error_new (SOUP_XMLRPC_FAULT, SOUP_XMLRPC_FAULT_APPLICATION_ERROR, _("An error occurred when creating the XMLRPC" " request.")); g_propagate_error (error, err); return FALSE; } msg = soup_message_new ("POST", uri); soup_message_set_request (msg, "text/xml", SOUP_MEMORY_TAKE, body, strlen (body)); soup_session_send_message (session, msg); if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { TRACE ("Error during the XMLRPC exchange: %d %s\n", msg->status_code, msg->reason_phrase); err = g_error_new (SOUP_XMLRPC_FAULT, SOUP_XMLRPC_FAULT_TRANSPORT_ERROR, _("An error occurred when transferring the data" " to ZimageZ.")); g_propagate_error (error, err); g_object_unref (msg); return FALSE; } if (!soup_xmlrpc_parse_method_response (msg->response_body->data, msg->response_body->length, retval, &err)) { if (err) { TRACE ("Fault when parsing the response: %d %s\n", err->code, err->message); g_propagate_error (error, err); } else { TRACE ("Unable to parse the response, and no error..."); err = g_error_new (SOUP_XMLRPC_FAULT, SOUP_XMLRPC_FAULT_APPLICATION_ERROR, _("An error occurred when parsing the response" " from ZimageZ.")); g_propagate_error (error, err); } g_object_unref (msg); return FALSE; } g_object_unref (msg); return TRUE; }
GArray* json_parse(json_object * jobj) { GArray * hostgrouparray; Host* head=NULL; int i; struct json_object * new_obj ,* inner_jobj,*data_jobj,*label_obj; enum json_type type; HostGroup* hostgroup; hostgrouparray = g_array_new (TRUE, FALSE, sizeof (HostGroup*)); json_object_object_foreach(jobj, key, val) { type = json_object_get_type(val); switch (type) { case json_type_array: hostgroup = malloc(sizeof(HostGroup)); bzero((void*)hostgroup,sizeof(HostGroup)); sethostgroupcounterid(hostgroup); head=NULL; json_object_object_get_ex(jobj, "data",&data_jobj); int arraylen = json_object_array_length(data_jobj); for (i=0;i<arraylen;i++) { Host* newhost = create_host_linkedlist(data_jobj,i); if (newhost!=NULL) head=host_queue(head,newhost); } hostgroup->hostarray=head; g_array_append_val (hostgrouparray, hostgroup); break; case json_type_object: hostgroup = malloc(sizeof(HostGroup)); bzero((void*)hostgroup,sizeof(HostGroup)); hostgroup->title=g_strdup(key); json_object_object_get_ex(jobj, key,&inner_jobj); head=NULL; json_object_object_foreach(inner_jobj, key, val) { if (!strcmp(key,"label")) { struct json_object * lab_obj; json_object_object_get_ex(inner_jobj, key,&lab_obj); char* title=(char*)json_object_get_string(lab_obj); HostGroup* labelhostgroup = malloc(sizeof(HostGroup)); bzero((void*)labelhostgroup,sizeof(HostGroup)); sethostgroupcounterid(labelhostgroup); labelhostgroup->title=g_strdup((const gchar*)title); labelhostgroup->label=TRUE; g_array_append_val (hostgrouparray, labelhostgroup); } else { json_object_object_get_ex(inner_jobj, "data",&data_jobj); int arraylen = json_object_array_length(data_jobj); for (i=0;i<arraylen;i++) { Host* new_host = create_host_linkedlist(data_jobj,i); if (new_host!=NULL) head=host_queue(head,new_host); } // Set the open all row Host* all_host = (Host*) malloc(sizeof(Host)); bzero((void*)all_host,sizeof(Host)); sethostcounterid(all_host); all_host->menu_name=g_strdup((char*)"Open all"); all_host->group_head=head; head=host_queue(head,all_host); } } hostgroup->hostarray=head; g_array_append_val (hostgrouparray, hostgroup); break; } }
static void build_append_byte(GArray *array, uint8_t val) { g_array_append_val(array, val); }
gboolean download_cb(WebKitWebView *web_view, WebKitDownload *download, gpointer user_data) { (void) web_view; (void) user_data; /* get the URI being downloaded */ const gchar *uri = webkit_download_get_uri(download); if (uzbl.state.verbose) printf("Download requested -> %s\n", uri); if (!uzbl.behave.download_handler) { webkit_download_cancel(download); return FALSE; /* reject downloads when there's no download handler */ } /* get a reasonable suggestion for a filename */ const gchar *suggested_filename; g_object_get(download, "suggested-filename", &suggested_filename, NULL); /* get the mimetype of the download */ const gchar *content_type = NULL; WebKitNetworkResponse *r = webkit_download_get_network_response(download); /* downloads can be initiated from the context menu, in that case there is no network response yet and trying to get one would crash. */ if(WEBKIT_IS_NETWORK_RESPONSE(r)) { SoupMessage *m = webkit_network_response_get_message(r); SoupMessageHeaders *h = NULL; g_object_get(m, "response-headers", &h, NULL); if(h) /* some versions of libsoup don't have "response-headers" here */ content_type = soup_message_headers_get_one(h, "Content-Type"); } if(!content_type) content_type = "application/octet-stream"; /* get the filesize of the download, as given by the server. (this may be inaccurate, there's nothing we can do about that.) */ unsigned int total_size = webkit_download_get_total_size(download); GArray *a = g_array_new (TRUE, FALSE, sizeof(gchar*)); const CommandInfo *c = parse_command_parts(uzbl.behave.download_handler, a); if(!c) { webkit_download_cancel(download); g_array_free(a, TRUE); return FALSE; } g_array_append_val(a, uri); g_array_append_val(a, suggested_filename); g_array_append_val(a, content_type); gchar *total_size_s = g_strdup_printf("%d", total_size); g_array_append_val(a, total_size_s); GString *result = g_string_new (""); run_parsed_command(c, a, result); g_free(total_size_s); g_array_free(a, TRUE); /* no response, cancel the download */ if(result->len == 0) { webkit_download_cancel(download); return FALSE; } /* we got a response, it's the path we should download the file to */ gchar *destination_path = result->str; g_string_free(result, FALSE); /* presumably people don't need newlines in their filenames. */ char *p = strchr(destination_path, '\n'); if ( p != NULL ) *p = '\0'; /* set up progress callbacks */ g_signal_connect(download, "notify::status", G_CALLBACK(download_status_cb), NULL); g_signal_connect(download, "notify::progress", G_CALLBACK(download_progress_cb), NULL); /* convert relative path to absolute path */ if(destination_path[0] != '/') { gchar *rel_path = destination_path; gchar *cwd = g_get_current_dir(); destination_path = g_strconcat(cwd, "/", destination_path, NULL); g_free(cwd); g_free(rel_path); } send_event(DOWNLOAD_STARTED, NULL, TYPE_STR, destination_path, NULL); /* convert absolute path to file:// URI */ gchar *destination_uri = g_strconcat("file://", destination_path, NULL); g_free(destination_path); webkit_download_set_destination_uri(download, destination_uri); g_free(destination_uri); return TRUE; }
void summary_fill_in(capture_file *cf, summary_tally *st) { frame_data *first_frame, *cur_frame; guint32 framenum; wtapng_section_t* shb_inf; iface_options iface; guint i; wtapng_iface_descriptions_t* idb_info; wtapng_if_descr_t wtapng_if_descr; wtapng_if_stats_t *if_stats; st->packet_count_ts = 0; st->start_time = 0; st->stop_time = 0; st->bytes = 0; st->filtered_count = 0; st->filtered_count_ts = 0; st->filtered_start = 0; st->filtered_stop = 0; st->filtered_bytes = 0; st->marked_count = 0; st->marked_count_ts = 0; st->marked_start = 0; st->marked_stop = 0; st->marked_bytes = 0; st->ignored_count = 0; /* initialize the tally */ if (cf->count != 0) { first_frame = frame_data_sequence_find(cf->frames, 1); st->start_time = nstime_to_sec(&first_frame->abs_ts); st->stop_time = nstime_to_sec(&first_frame->abs_ts); for (framenum = 1; framenum <= cf->count; framenum++) { cur_frame = frame_data_sequence_find(cf->frames, framenum); tally_frame_data(cur_frame, st); } } st->filename = cf->filename; st->file_length = cf->f_datalen; st->file_type = cf->cd_t; st->iscompressed = cf->iscompressed; st->is_tempfile = cf->is_tempfile; st->file_encap_type = cf->lnk_t; st->packet_encap_types = cf->linktypes; st->has_snap = cf->has_snap; st->snap = cf->snap; st->elapsed_time = nstime_to_sec(&cf->elapsed_time); st->packet_count = cf->count; st->drops_known = cf->drops_known; st->drops = cf->drops; st->dfilter = cf->dfilter; /* Get info from SHB */ shb_inf = wtap_file_get_shb_info(cf->wth); if(shb_inf == NULL){ st->opt_comment = NULL; st->shb_hardware = NULL; st->shb_os = NULL; st->shb_user_appl = NULL; }else{ st->opt_comment = shb_inf->opt_comment; st->shb_hardware = shb_inf->shb_hardware; st->shb_os = shb_inf->shb_os; st->shb_user_appl = shb_inf->shb_user_appl; g_free(shb_inf); } st->ifaces = g_array_new(FALSE, FALSE, sizeof(iface_options)); idb_info = wtap_file_get_idb_info(cf->wth); for (i = 0; i < idb_info->number_of_interfaces; i++) { wtapng_if_descr = g_array_index(idb_info->interface_data, wtapng_if_descr_t, i); iface.cfilter = g_strdup(wtapng_if_descr.if_filter_str); iface.name = g_strdup(wtapng_if_descr.if_name); iface.descr = g_strdup(wtapng_if_descr.if_description); iface.drops_known = FALSE; iface.drops = 0; iface.snap = wtapng_if_descr.snap_len; iface.has_snap = (iface.snap != 65535); iface.encap_type = wtapng_if_descr.wtap_encap; if(wtapng_if_descr.num_stat_entries == 1){ /* dumpcap only writes one ISB, only handle that for now */ if_stats = &g_array_index(wtapng_if_descr.interface_statistics, wtapng_if_stats_t, 0); iface.drops_known = TRUE; iface.drops = if_stats->isb_ifdrop; iface.isb_comment = if_stats->opt_comment; } g_array_append_val(st->ifaces, iface); } g_free(idb_info); }
/** * nm_modem_get_connection_ip_type: * @self: the #NMModem * @connection: the #NMConnection to determine IP type to use * * Given a modem and a connection, determine which #NMModemIPTypes to use * when connecting. * * Returns: an array of #NMModemIpType values, in the order in which they * should be tried. */ GArray * nm_modem_get_connection_ip_type (NMModem *self, NMConnection *connection, GError **error) { NMModemPrivate *priv = NM_MODEM_GET_PRIVATE (self); NMSettingIPConfig *s_ip4, *s_ip6; const char *method; gboolean ip4 = TRUE, ip6 = TRUE; gboolean ip4_may_fail = TRUE, ip6_may_fail = TRUE; s_ip4 = nm_connection_get_setting_ip4_config (connection); if (s_ip4) { method = nm_setting_ip_config_get_method (s_ip4); if (g_strcmp0 (method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED) == 0) ip4 = FALSE; ip4_may_fail = nm_setting_ip_config_get_may_fail (s_ip4); } s_ip6 = nm_connection_get_setting_ip6_config (connection); if (s_ip6) { method = nm_setting_ip_config_get_method (s_ip6); if (g_strcmp0 (method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) ip6 = FALSE; ip6_may_fail = nm_setting_ip_config_get_may_fail (s_ip6); } if (ip4 && !ip6) { if (!(priv->ip_types & NM_MODEM_IP_TYPE_IPV4)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Connection requested IPv4 but IPv4 is " "unsupported by the modem."); return NULL; } return build_single_ip_type_array (NM_MODEM_IP_TYPE_IPV4); } if (ip6 && !ip4) { if (!(priv->ip_types & NM_MODEM_IP_TYPE_IPV6)) { g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Connection requested IPv6 but IPv6 is " "unsupported by the modem."); return NULL; } return build_single_ip_type_array (NM_MODEM_IP_TYPE_IPV6); } if (ip4 && ip6) { NMModemIPType type; GArray *out; out = g_array_sized_new (FALSE, FALSE, sizeof (NMModemIPType), 3); /* Modem supports dual-stack? */ if (priv->ip_types & NM_MODEM_IP_TYPE_IPV4V6) { type = NM_MODEM_IP_TYPE_IPV4V6; g_array_append_val (out, type); } /* If IPv6 may-fail=false, we should NOT try IPv4 as fallback */ if ((priv->ip_types & NM_MODEM_IP_TYPE_IPV4) && ip6_may_fail) { type = NM_MODEM_IP_TYPE_IPV4; g_array_append_val (out, type); } /* If IPv4 may-fail=false, we should NOT try IPv6 as fallback */ if ((priv->ip_types & NM_MODEM_IP_TYPE_IPV6) && ip4_may_fail) { type = NM_MODEM_IP_TYPE_IPV6; g_array_append_val (out, type); } if (out->len > 0) return out; /* Error... */ g_array_unref (out); g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Connection requested both IPv4 and IPv6 " "but dual-stack addressing is unsupported " "by the modem."); return NULL; } g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INCOMPATIBLE_CONNECTION, "Connection specified no IP configuration!"); return NULL; }
static GArray * build_single_ip_type_array (NMModemIPType type) { return g_array_append_val (g_array_sized_new (FALSE, FALSE, sizeof (NMModemIPType), 1), type); }
static void handle_player_info (G_GNUC_UNUSED SoupSession * session, SoupMessage * msg, AurClient * client) { SoupBuffer *buffer; if (msg->status_code < 200 || msg->status_code >= 300) return; buffer = soup_message_body_flatten (msg->response_body); if (json_parser_load_from_data (client->json, buffer->data, buffer->length, NULL)) { const GValue *v1; GArray *player_info = NULL; gsize i; JsonNode *root = json_parser_get_root (client->json); GstStructure *s1 = aur_json_to_gst_structure (root); if (s1 == NULL) return; /* Invalid chunk */ v1 = gst_structure_get_value (s1, "player-clients"); if (!GST_VALUE_HOLDS_ARRAY (v1)) goto failed; player_info = g_array_sized_new (TRUE, TRUE, sizeof (AurPlayerInfo), gst_value_array_get_size (v1)); for (i = 0; i < gst_value_array_get_size (v1); i++) { AurPlayerInfo info; const GValue *v2 = gst_value_array_get_value (v1, i); const GstStructure *s2; gint64 client_id; if (!GST_VALUE_HOLDS_STRUCTURE (v2)) goto failed; s2 = gst_value_get_structure (v2); if (!aur_json_structure_get_int64 (s2, "client-id", &client_id)) goto failed; info.id = client_id; if (!aur_json_structure_get_boolean (s2, "enabled", &info.enabled)) goto failed; if (!aur_json_structure_get_double (s2, "volume", &info.volume)) goto failed; if (!(info.host = g_strdup (gst_structure_get_string (s2, "host")))) goto failed; g_array_append_val (player_info, info); } free_player_info (client->player_info); client->player_info = player_info; player_info = NULL; g_signal_emit (client, signals[SIGNAL_PLAYER_INFO_CHANGED], 0); failed: if (player_info) free_player_info (player_info); gst_structure_free (s1); } }
static gboolean xmms_midsquash_init (xmms_xform_t *xform) { xmms_error_t error; xmms_midsquash_data_t *data; gulong track_len, len; gint32 ticks_per_quarter_note; const gchar *metakey; guchar buf[4096]; gint ret; guchar prev_event = 0; GArray *events = NULL; GArray *track_data = NULL; g_return_val_if_fail (xform, FALSE); data = g_new0 (xmms_midsquash_data_t, 1); xmms_xform_private_data_set (xform, data); data->midi0_data = NULL; if (!xmms_xform_auxdata_get_int (xform, "tempo", &ticks_per_quarter_note)) { XMMS_DBG ("MIDI xform missing 'tempo' auxdata value"); goto error_cleanup; } xmms_xform_auxdata_set_int (xform, "tempo", ticks_per_quarter_note); /* Load all the tracks */ events = g_array_new(FALSE, FALSE, sizeof(xmms_midsquash_event_t)); track_data = g_array_new(FALSE, FALSE, sizeof(GString *)); while (xmms_xform_read (xform, buf, 4, &error) == 4) { track_len = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; GString *t = g_string_sized_new(track_len); ret = xmms_xform_read (xform, t->str, track_len, &error); g_array_append_val(track_data, t); /* Run through the MIDI data in this track, and convert it to a list of * events in absolute ticks (instead of delta ticks.) */ gulong i = 0; gulong abs_ticks = 0; while (i < track_len) { abs_ticks += xmms_midisquash_read_midi_num(t->str, &i); xmms_midsquash_event_t event; gboolean ignore_event = FALSE; event.time = abs_ticks; event.offset = &t->str[i]; gulong i0 = i; /* Read MIDI event */ guchar midi_event = t->str[i]; if (!(midi_event & 0x80)) { /* This is a running-status byte */ midi_event = prev_event; event.running_status = prev_event; } else { if ((midi_event & 0xF0) != 0xF0) { /* Meta events (0xF0 through 0xFF) can appear in the middle of * running-status data without affecting the running status, so we * only update the 'last event' if this isn't a meta-event. */ prev_event = midi_event; } event.running_status = 0; i++; } switch (midi_event & 0xF0) { case 0x80: /* Note off (two bytes) */ i += 2; break; case 0x90: /* Note on (two bytes) */ i += 2; break; case 0xA0: /* Key pressure (two bytes) */ i += 2; break; case 0xB0: /* Controller change (two bytes) */ i += 2; break; case 0xC0: /* Instrument change (one byte) */ i += 1; break; case 0xD0: /* Channel pressure (one byte) */ i += 1; break; case 0xE0: /* Pitch bend (two bytes) */ i += 2; break; case 0xF0: { if (midi_event == 0xFF) { /* Meta-event */ if (t->str[i] == 0x2F) { /* This is an end-of-track event, so we need to ignore it * otherwise the song will end as soon as we encounter the end * of the shortest track (which could be quite early on.) */ ignore_event = TRUE; } i++; /* event type */ } /* else sysex */ len = xmms_midisquash_read_midi_num(t->str, &i); i += len; break; } default: XMMS_DBG ("Corrupted MIDI file (invalid event 0x%02X)", midi_event); goto error_cleanup; } event.length = i - i0; if (!ignore_event) g_array_append_val(events, event); } /* end loop: run through all the track's events */ } /* Now that all the events have been read in, in absolute time, sorting them * will put them all in playable order. */ g_array_sort(events, xmms_midsquash_sort_events); /* Now copy all the sorted events into a big array, which will be used as * the output data. */ data->midi0_data = g_string_new(""); gulong last_time = 0; guint64 playtime_us = 0; gulong us_per_quarter_note = 500000; gulong i, j; guchar val; for (i = 0; i < events->len; i++) { xmms_midsquash_event_t *e; e = &g_array_index(events, xmms_midsquash_event_t, i); /* Calculate the delta time and write it out in MIDI style */ gulong delta_ticks = e->time - last_time; if (delta_ticks & (0x7F << 21)) { val = ((delta_ticks >> 21) & 0x7F) | 0x80; g_string_append_len(data->midi0_data, (gchar *)&val, 1); } if (delta_ticks & ((0x7F << 21) | (0x7F << 14))) { val = ((delta_ticks >> 14) & 0x7F) | 0x80; g_string_append_len(data->midi0_data, (gchar *)&val, 1); }
static gboolean _ghwp_file_v3_parse_paragraph (GHWPDocument *doc) { g_return_val_if_fail (doc != NULL, FALSE); GInputStream *stream = GHWP_FILE_V3 (doc->file)->priv->stream; GHWPContextV3 *context = ghwp_context_v3_new (stream); /* 문단 정보 */ guint8 prev_paragraph_shape; guint16 n_chars; guint16 n_lines; guint8 char_shape_included; guint8 flag; int i; ghwp_context_v3_read_uint8 (context, &prev_paragraph_shape); ghwp_context_v3_read_uint16 (context, &n_chars); ghwp_context_v3_read_uint16 (context, &n_lines); ghwp_context_v3_read_uint8 (context, &char_shape_included); ghwp_context_v3_skip (context, 1 + 4 + 1 + 31); /* 여기까지 43 바이트 */ if (prev_paragraph_shape == 0 && n_chars > 0) { ghwp_context_v3_skip (context, 187); } /* 빈문단이면 FALSE 반환 */ if (n_chars == 0) return FALSE; /* 줄 정보 */ ghwp_context_v3_skip (context, n_lines * 14); /* 글자 모양 정보 */ if (char_shape_included != 0) { for (i = 0; i < n_chars; i++) { ghwp_context_v3_read_uint8 (context, &flag); if (flag != 1) { ghwp_context_v3_skip (context, 31); } } } GHWPParagraph *paragraph = ghwp_paragraph_new (); g_array_append_val (doc->paragraphs, paragraph); GString *string = g_string_new (NULL); /* 글자들 */ guint16 n_chars_read = 0; guint16 c; while (n_chars_read < n_chars) { ghwp_context_v3_read_uint16 (context, &c); n_chars_read += 1; if (c == 6) { n_chars_read += 3; ghwp_context_v3_skip (context, 6 + 34); continue; } else if (c == 9) { /* tab */ n_chars_read += 3; ghwp_context_v3_skip (context, 6); g_string_append (string, "\t"); continue; } else if (c == 10) { /* table */ n_chars_read += 3; ghwp_context_v3_skip (context, 6); /* 테이블 식별 정보 84 바이트 */ ghwp_context_v3_skip (context, 80); guint16 n_cells; ghwp_context_v3_read_uint16 (context, &n_cells); ghwp_context_v3_skip (context, 2); ghwp_context_v3_skip (context, 27 * n_cells); /* <셀 문단 리스트>+ */ for (i = 0; i < n_cells; i++) { /* <셀 문단 리스트> ::= <셀 문단>+ <빈문단> */ while(_ghwp_file_v3_parse_paragraph(doc)) { } } /* <캡션 문단 리스트> ::= <캡션 문단>+ <빈문단> */ while(_ghwp_file_v3_parse_paragraph(doc)) { } continue; } else if (c == 11) { n_chars_read += 3; ghwp_context_v3_skip (context, 6); guint32 len; ghwp_context_v3_read_uint32 (context, &len); ghwp_context_v3_skip (context, 344); ghwp_context_v3_skip (context, len); /* <캡션 문단 리스트> ::= <캡션 문단>+ <빈문단> */ while(_ghwp_file_v3_parse_paragraph(doc)) { } continue; } else if (c == 13) { /* 글자들 끝 */ g_string_append (string, "\n"); continue; } else if (c == 16) { n_chars_read += 3; ghwp_context_v3_skip (context, 6); ghwp_context_v3_skip (context, 10); /* <문단 리스트> ::= <문단>+ <빈문단> */ while(_ghwp_file_v3_parse_paragraph(doc)) { } continue; } else if (c == 17) { /* 각주/미주 */ n_chars_read += 3; ghwp_context_v3_skip (context, 6); ghwp_context_v3_skip (context, 14); while(_ghwp_file_v3_parse_paragraph(doc)) { } continue; } else if (c == 18 || c == 19 || c == 20 || c == 21) { n_chars_read += 3; ghwp_context_v3_skip (context, 6); continue; } else if (c == 23) { /*글자 겹침 */ n_chars_read += 4; ghwp_context_v3_skip (context, 8); continue; } else if (c == 24 || c == 25) { n_chars_read += 2; ghwp_context_v3_skip (context, 4); continue; } else if (c == 28) { /* 개요 모양/번호 */ n_chars_read += 31; ghwp_context_v3_skip (context, 62); continue; } else if (c == 30 || c == 31) { n_chars_read += 1; ghwp_context_v3_skip (context, 2); continue; } else if (c >= 0x0020 && c <= 0xffff) { gchar *tmp = hnchar_to_utf8 (c); g_string_append (string, tmp); g_free (tmp); continue; } else { g_warning ("special character: %04x", c); } /* if */ } /* while */ gchar *tmp = g_string_free(string, FALSE); GHWPText *ghwp_text = ghwp_text_new (tmp); g_free (tmp); ghwp_paragraph_set_ghwp_text (paragraph, ghwp_text); static gdouble y = 0.0; static guint len = 0; /* 높이 계산 */ len = g_utf8_strlen (ghwp_text->text, -1); y += 18.0 * ceil (len / 33.0); if (y > 842.0 - 80.0) { g_array_append_val (doc->pages, GHWP_FILE_V3 (doc->file)->page); GHWP_FILE_V3 (doc->file)->page = ghwp_page_new (); g_array_append_val (GHWP_FILE_V3 (doc->file)->page->paragraphs, paragraph); y = 0.0; } else { g_array_append_val (GHWP_FILE_V3 (doc->file)->page->paragraphs, paragraph); } /* if */ g_object_unref (context); return TRUE; }
/* returns an error message or NULL */ static DBusMessage * invoke_js_async_from_dbus(SeedContext ctx, DBusBusType bus_type, DBusMessage *method_call, SeedObject this_obj, SeedObject method_obj, SeedException *exception) { DBusMessage *reply; int argc; SeedValue *argv; DBusMessageIter arg_iter; GArray *values; SeedObject callback_object; SeedValue sender_string, signature_string; gboolean thrown; SeedValue ignored; const char *signature; reply = NULL; thrown = FALSE; argc = 0; argv = NULL; if (!seed_js_values_from_dbus(ctx, &arg_iter, &values, exception)) { if (!dbus_reply_from_exception(ctx, method_call, &reply, exception)) g_warning ("conversion of dbus method arg failed but no exception was set?"); return reply; } /* we will add an argument, the callback */ callback_object = seed_make_function(ctx, async_call_callback, "" /* anonymous */); g_assert(callback_object); g_array_append_val(values, callback_object); /* We attach the DBus sender and serial as properties to * callback, so we don't need to bother with memory managing them * if the callback is never called and just discarded.*/ sender_string = seed_value_from_string (ctx, dbus_message_get_sender (method_call), exception); if (!sender_string) { thrown = TRUE; goto out; } seed_object_set_property (ctx, callback_object, "_dbusSender", sender_string); seed_object_set_property (ctx, callback_object, "_dbusSerial", seed_value_from_int (ctx, dbus_message_get_serial (method_call), exception)); seed_object_set_property (ctx, callback_object, "_dbusBusType", seed_value_from_int (ctx, bus_type, exception)); if (!signature_from_method(ctx, method_obj, &signature, exception)) { thrown = TRUE; goto out; } signature_string = seed_value_from_string (ctx, signature, exception); if (!signature_string) { thrown = TRUE; goto out; } seed_object_set_property (ctx, callback_object, "_dbusOutSignature", signature_string); argc = values->len; argv = (SeedValue *)values->data; seed_object_call (ctx, method_obj, this_obj, argc, argv, &ignored); out: if (thrown) { if (!dbus_reply_from_exception(ctx, method_call, &reply, exception)) g_warning("conversion of dbus method arg failed but no exception was set?"); } g_array_free (values, TRUE); return reply; }
int main (int argc, char **argv) { gchar *srcdir = getenv ("srcdir"); gchar *testfile; gchar *contents; GError *error = NULL; gchar *p, *end; char *tmp; gint state = 0; gint line = 1; gint start_line = 0; /* Quiet GCC */ gchar *utf8 = NULL; /* Quiet GCC */ GArray *ucs4; Status status = VALID; /* Quiet GCC */ #ifdef SYMBIAN g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); g_set_print_handler(mrtPrintHandler); #endif /*SYMBIAN*/ if (!srcdir) srcdir = "c:"; testfile = g_strconcat (srcdir, G_DIR_SEPARATOR_S "utf8.txt", NULL); g_file_get_contents (testfile, &contents, NULL, &error); if (error) { croak ("Cannot open utf8.txt: %s", error->message); #ifdef SYMBIAN testResultXml("unicode-encoding"); #endif /* EMULATOR */ exit(1); } ucs4 = g_array_new (TRUE, FALSE, sizeof(gunichar)); p = contents; /* Loop over lines */ while (*p) { while (*p && (*p == ' ' || *p == '\t')) p++; end = p; while (*end && (*end != '\r' && *end != '\n')) end++; if (!*p || *p == '#' || *p == '\r' || *p == '\n') goto next_line; tmp = g_strstrip (g_strndup (p, end - p)); switch (state) { case 0: /* UTF-8 string */ start_line = line; utf8 = tmp; tmp = NULL; break; case 1: /* Status */ if (!strcmp (tmp, "VALID")) status = VALID; else if (!strcmp (tmp, "INCOMPLETE")) status = INCOMPLETE; else if (!strcmp (tmp, "NOTUNICODE")) status = NOTUNICODE; else if (!strcmp (tmp, "OVERLONG")) status = OVERLONG; else if (!strcmp (tmp, "MALFORMED")) status = MALFORMED; else croak ("Invalid status on line %d\n", line); if (status != VALID && status != NOTUNICODE) state++; /* No UCS-4 data */ break; case 2: /* UCS-4 version */ p = strtok (tmp, " \t"); while (p) { gchar *endptr; gunichar ch = strtoul (p, &endptr, 16); if (*endptr != '\0') croak ("Invalid UCS-4 character on line %d\n", line); g_array_append_val (ucs4, ch); p = strtok (NULL, " \t"); } break; } g_free (tmp); state = (state + 1) % 3; if (state == 0) { process (start_line, utf8, status, (gunichar *)ucs4->data, ucs4->len); g_array_set_size (ucs4, 0); g_free (utf8); } next_line: p = end; if (*p && *p == '\r') p++; if (*p && *p == '\n') p++; line++; } #ifdef SYMBIAN testResultXml("unicode-encoding"); #endif /* EMULATOR */ return exit_status; }
static JSBool setDash_func(JSContext *context, unsigned argc, jsval *vp) { jsval *argv = JS_ARGV(context, vp); JSObject *obj = JS_THIS_OBJECT(context, vp); guint i; cairo_t *cr; JSObject *dashes; double offset; JSBool retval = JS_FALSE; guint len; GArray *dashes_c = NULL; if (!gjs_parse_args(context, "setDash", "of", argc, argv, "dashes", &dashes, "offset", &offset)) return JS_FALSE; JS_AddObjectRoot(context, &dashes); if (!JS_IsArrayObject(context, dashes)) { gjs_throw(context, "dashes must be an array"); goto out; } if (!JS_GetArrayLength(context, dashes, &len)) { gjs_throw(context, "Can't get length of dashes"); goto out; } dashes_c = g_array_sized_new (FALSE, FALSE, sizeof(double), len); for (i = 0; i < len; ++i) { jsval elem; double b; elem = JSVAL_VOID; if (!JS_GetElement(context, dashes, i, &elem)) { goto out; } if (JSVAL_IS_VOID(elem)) continue; if (!JS_ValueToNumber(context, elem, &b)) goto out; if (b <= 0) { gjs_throw(context, "Dash value must be positive"); goto out; } g_array_append_val(dashes_c, b); } cr = gjs_cairo_context_get_context(context, obj); cairo_set_dash(cr, (double*)dashes_c->data, dashes_c->len, offset); JS_SET_RVAL(context, vp, JSVAL_VOID); retval = JS_TRUE; out: if (dashes_c != NULL) g_array_free (dashes_c, TRUE); JS_RemoveObjectRoot(context, &dashes); return retval; }
vol_err_t vol_getfileprops(vol_t handle) { struct volume* vhnd = handle; struct vfile *vfile; log_info("Fetching file properties array."); guint64 os; os = vhnd->footer.fileprops.offset; gint i; guint c; vol_err_t err; guint o; log_debug("Scraping array header."); for (i=0; i <=4; i++) { err = vol_getheader(handle, &vhnd->footer.fileprops.header, vhnd->footer.fileprops.offset + i); if (err) return err; /* Header verification * There might be a memory leak here */ if (memcmp("voli", vhnd->footer.fileprops.header.ident, 4)) { log_debug("Retrieved IDstring does not matched needed IDstring."); err = VOL_ERR_BADHEADER; } else { vhnd->footer.fileprops.offset += i; os += i; err = VOL_ERR_OK; break; } } if (err == VOL_ERR_BADHEADER) { log_critical("Array identity string not recognized."); err = VOL_ERR_OK; /* Not setting error here, at least not yet */ } if (vhnd->footer.fileprops.header.val != 0) { os +=sizeof(struct header); vhnd->footer.fileprops.data = g_array_new(FALSE, TRUE, sizeof(struct vval)); log_debug("Fetching array data."); for (i = 0; i < vhnd->footer.fileprops.header.val; i+=(sizeof(struct vval))) { struct vval *propset = g_malloc0(sizeof(struct vval)); vfile = g_ptr_array_index(vhnd->files, o); log_debug("Pulling file struct from %p", (gpointer)vfile); o++; log_debug("Pulling value set."); err = readinto(&vhnd->volio, (guint64)(os+i), (gsize)sizeof(struct vval), (gpointer)propset); if (err) return err; log_info("Scraping VBLK header."); for (c=0; c <=4; c++) { err = vol_getheader(handle, &vfile->data.header, propset->field_3 + c); if (err) return err; /* Header verification * There might be a memory leak here */ if (memcmp("VBLK", &vfile->data.header.ident, 4)) { log_debug("Retrieved IDstring does not matched needed IDstring."); err = VOL_ERR_BADHEADER; } else { propset->field_3 += c; err = VOL_ERR_OK; break; } } if (err == VOL_ERR_BADHEADER) { log_warning("Array identity string not recognized."); err = VOL_ERR_OK; /* Not setting error here, at least not yet */ } log_info("Values pulled:"); log_info("\t32-bit value 1: 0x%x\t(unknown)", propset->field_1); /* Not putting this one into the file struct until we know what * it's for */ log_info("\t32-bit value 2: 0x%x\t(filename array offset)", propset->field_2); vfile->n_offset = propset->field_2; log_info("\t32-bit value 3: 0x%x\t(file VBLK offset)", propset->field_3); vfile->b_offset = propset->field_3; log_info("\t32-bit value 4: 0x%x\t(uncompressed filesize)", propset->field_4); vfile->size = propset->field_4; log_info("\t8-bit value: 0x%x\t\t(compression)", propset->endcap); if(propset->endcap != 0) vfile->compressed = TRUE; else vfile->compressed = FALSE; log_info("\tVBLK 24-bit value: 0x%x\t(compressed filesize)", (vfile->data.header.val - 0x80000000)); vfile->packed_size = (vfile->data.header.val - 0x80000000); g_array_append_val(vhnd->footer.fileprops.data, (*propset)); g_free(propset); } } else { log_message("Array is empty. (No files in volume?)"); vhnd->footer.fileprops.data = NULL; } return err; }
/** * xdg_app_review_parse_ratings: */ static GArray * xdg_app_review_parse_ratings (const gchar *data, gsize data_len, GError **error) { GArray *ratings; JsonNode *json_root; JsonObject *json_item; guint i; g_autoptr(JsonParser) json_parser = NULL; const gchar *names[] = { "star0", "star1", "star2", "star3", "star4", "star5", NULL }; /* nothing */ if (data == NULL) { g_set_error_literal (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "server returned no data"); return NULL; } /* parse the data and find the success */ json_parser = json_parser_new (); if (!json_parser_load_from_data (json_parser, data, data_len, error)) return NULL; json_root = json_parser_get_root (json_parser); if (json_root == NULL) { g_set_error_literal (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "no error root"); return NULL; } if (json_node_get_node_type (json_root) != JSON_NODE_OBJECT) { g_set_error_literal (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "no error object"); return NULL; } json_item = json_node_get_object (json_root); if (json_item == NULL) { g_set_error_literal (error, GS_PLUGIN_ERROR, GS_PLUGIN_ERROR_FAILED, "no error object"); return NULL; } /* get data array */ ratings = g_array_sized_new (FALSE, TRUE, sizeof(guint32), 6); for (i = 0; names[i] != NULL; i++) { guint64 tmp; if (!json_object_has_member (json_item, names[i])) continue; tmp = json_object_get_int_member (json_item, names[i]); g_array_append_val (ratings, tmp); } return ratings; }
static void handle_method_call_perform_writeback (TrackerController *controller, GDBusMethodInvocation *invocation, GVariant *parameters) { TrackerControllerPrivate *priv; TrackerDBusRequest *request; const gchar *subject; GPtrArray *results = NULL; GHashTableIter iter; gpointer key, value; GVariantIter *iter1, *iter2, *iter3; GArray *rdf_types_array; GStrv rdf_types; gchar *rdf_type = NULL; GList *writeback_handlers = NULL; WritebackData *data; priv = controller->priv; results = g_ptr_array_new_with_free_func ((GDestroyNotify) g_strfreev); g_variant_get (parameters, "(&sasaas)", &subject, &iter1, &iter2); rdf_types_array = g_array_new (TRUE, TRUE, sizeof (gchar *)); while (g_variant_iter_loop (iter1, "&s", &rdf_type)) { g_array_append_val (rdf_types_array, rdf_type); } rdf_types = (GStrv) rdf_types_array->data; g_array_free (rdf_types_array, FALSE); while (g_variant_iter_loop (iter2, "as", &iter3)) { GArray *row_array = g_array_new (TRUE, TRUE, sizeof (gchar *)); gchar *cell = NULL; while (g_variant_iter_loop (iter3, "&s", &cell)) { g_array_append_val (row_array, cell); } g_ptr_array_add (results, row_array->data); g_array_free (row_array, FALSE); } g_variant_iter_free (iter1); g_variant_iter_free (iter2); reset_shutdown_timeout (controller); request = tracker_dbus_request_begin (NULL, "%s (%s)", __FUNCTION__, subject); g_hash_table_iter_init (&iter, priv->modules); while (g_hash_table_iter_next (&iter, &key, &value)) { TrackerWritebackModule *module; const gchar * const *module_types; module = value; module_types = tracker_writeback_module_get_rdf_types (module); if (sparql_rdf_types_match (module_types, (const gchar * const *) rdf_types)) { TrackerWriteback *writeback; g_message (" Updating metadata for subject:'%s' using module:'%s'", subject, module->name); writeback = tracker_writeback_module_create (module); writeback_handlers = g_list_prepend (writeback_handlers, writeback); } } if (writeback_handlers != NULL) { data = writeback_data_new (controller, writeback_handlers, priv->connection, subject, results, invocation, request); g_io_scheduler_push_job (io_writeback_job, data, NULL, 0, data->cancellable); } else { g_dbus_method_invocation_return_error (invocation, TRACKER_DBUS_ERROR, TRACKER_DBUS_ERROR_UNSUPPORTED, "No module for rdf types"); } g_free (rdf_types); }
void add_entry (char *key, char *value) { char *value1=0, *value2=0, *value3=0; /* Background and border */ if (strcmp (key, "rounded") == 0) { // 'rounded' is the first parameter => alloc a new background Background bg; bg.border.rounded = atoi(value); g_array_append_val(backgrounds, bg); } else if (strcmp (key, "border_width") == 0) { g_array_index(backgrounds, Background, backgrounds->len-1).border.width = atoi(value); } else if (strcmp (key, "background_color") == 0) { Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1); extract_values(value, &value1, &value2, &value3); get_color (value1, bg->back.color); if (value2) bg->back.alpha = (atoi (value2) / 100.0); else bg->back.alpha = 0.5; } else if (strcmp (key, "border_color") == 0) { Background* bg = &g_array_index(backgrounds, Background, backgrounds->len-1); extract_values(value, &value1, &value2, &value3); get_color (value1, bg->border.color); if (value2) bg->border.alpha = (atoi (value2) / 100.0); else bg->border.alpha = 0.5; } /* Panel */ else if (strcmp (key, "panel_monitor") == 0) { panel_config.monitor = config_get_monitor(value); } else if (strcmp (key, "panel_size") == 0) { extract_values(value, &value1, &value2, &value3); char *b; if ((b = strchr (value1, '%'))) { b[0] = '\0'; panel_config.pourcentx = 1; } panel_config.area.width = atoi(value1); if (panel_config.area.width == 0) { // full width mode panel_config.area.width = 100; panel_config.pourcentx = 1; } if (value2) { if ((b = strchr (value2, '%'))) { b[0] = '\0'; panel_config.pourcenty = 1; } panel_config.area.height = atoi(value2); } } else if (strcmp (key, "panel_items") == 0) { new_config_file = 1; panel_items_order = strdup(value); int j; for (j=0 ; j < strlen(panel_items_order) ; j++) { if (panel_items_order[j] == 'L') launcher_enabled = 1; if (panel_items_order[j] == 'T') taskbar_enabled = 1; if (panel_items_order[j] == 'B') { #ifdef ENABLE_BATTERY battery_enabled = 1; #else fprintf(stderr, "tint2 is build without battery support\n"); #endif } if (panel_items_order[j] == 'S') { // systray disabled in snapshot mode if (snapshot_path == 0) systray_enabled = 1; } if (panel_items_order[j] == 'C') clock_enabled = 1; } } else if (strcmp (key, "panel_margin") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.marginx = atoi (value1); if (value2) panel_config.marginy = atoi (value2); } else if (strcmp (key, "panel_padding") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.area.paddingxlr = panel_config.area.paddingx = atoi (value1); if (value2) panel_config.area.paddingy = atoi (value2); if (value3) panel_config.area.paddingx = atoi (value3); } else if (strcmp (key, "panel_position") == 0) { extract_values(value, &value1, &value2, &value3); if (strcmp (value1, "top") == 0) panel_position = TOP; else { if (strcmp (value1, "bottom") == 0) panel_position = BOTTOM; else panel_position = CENTER; } if (!value2) panel_position |= CENTER; else { if (strcmp (value2, "left") == 0) panel_position |= LEFT; else { if (strcmp (value2, "right") == 0) panel_position |= RIGHT; else panel_position |= CENTER; } } if (!value3) panel_horizontal = 1; else { if (strcmp (value3, "vertical") == 0) panel_horizontal = 0; else panel_horizontal = 1; } } else if (strcmp (key, "font_shadow") == 0) panel_config.g_task.font_shadow = atoi (value); else if (strcmp (key, "panel_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.area.bg = &g_array_index(backgrounds, Background, id); } else if (strcmp (key, "wm_menu") == 0) wm_menu = atoi (value); else if (strcmp (key, "panel_dock") == 0) panel_dock = atoi (value); else if (strcmp (key, "urgent_nb_of_blink") == 0) max_tick_urgent = atoi (value); else if (strcmp (key, "panel_layer") == 0) { if (strcmp(value, "bottom") == 0) panel_layer = BOTTOM_LAYER; else if (strcmp(value, "top") == 0) panel_layer = TOP_LAYER; else panel_layer = NORMAL_LAYER; } /* Battery */ else if (strcmp (key, "battery_low_status") == 0) { #ifdef ENABLE_BATTERY battery_low_status = atoi(value); if(battery_low_status < 0 || battery_low_status > 100) battery_low_status = 0; #endif } else if (strcmp (key, "battery_low_cmd") == 0) { #ifdef ENABLE_BATTERY if (strlen(value) > 0) battery_low_cmd = strdup (value); #endif } else if (strcmp (key, "bat1_font") == 0) { #ifdef ENABLE_BATTERY bat1_font_desc = pango_font_description_from_string (value); #endif } else if (strcmp (key, "bat2_font") == 0) { #ifdef ENABLE_BATTERY bat2_font_desc = pango_font_description_from_string (value); #endif } else if (strcmp (key, "battery_font_color") == 0) { #ifdef ENABLE_BATTERY extract_values(value, &value1, &value2, &value3); get_color (value1, panel_config.battery.font.color); if (value2) panel_config.battery.font.alpha = (atoi (value2) / 100.0); else panel_config.battery.font.alpha = 0.5; #endif } else if (strcmp (key, "battery_padding") == 0) { #ifdef ENABLE_BATTERY extract_values(value, &value1, &value2, &value3); panel_config.battery.area.paddingxlr = panel_config.battery.area.paddingx = atoi (value1); if (value2) panel_config.battery.area.paddingy = atoi (value2); if (value3) panel_config.battery.area.paddingx = atoi (value3); #endif } else if (strcmp (key, "battery_background_id") == 0) { #ifdef ENABLE_BATTERY int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.battery.area.bg = &g_array_index(backgrounds, Background, id); #endif } else if (strcmp (key, "battery_hide") == 0) { #ifdef ENABLE_BATTERY percentage_hide = atoi (value); if (percentage_hide == 0) percentage_hide = 101; #endif } /* Clock */ else if (strcmp (key, "time1_format") == 0) { if (new_config_file == 0) { clock_enabled = 1; if (panel_items_order) { char* tmp = g_strconcat(panel_items_order, "C", NULL); g_free( panel_items_order ); panel_items_order = tmp; } else panel_items_order = g_strdup("C"); } if (strlen(value) > 0) { time1_format = strdup (value); clock_enabled = 1; } } else if (strcmp (key, "time2_format") == 0) { if (strlen(value) > 0) time2_format = strdup (value); } else if (strcmp (key, "time1_font") == 0) { time1_font_desc = pango_font_description_from_string (value); } else if (strcmp(key, "time1_timezone") == 0) { if (strlen(value) > 0) time1_timezone = strdup(value); } else if (strcmp(key, "time2_timezone") == 0) { if (strlen(value) > 0) time2_timezone = strdup(value); } else if (strcmp (key, "time2_font") == 0) { time2_font_desc = pango_font_description_from_string (value); } else if (strcmp (key, "clock_font_color") == 0) { extract_values(value, &value1, &value2, &value3); get_color (value1, panel_config.clock.font.color); if (value2) panel_config.clock.font.alpha = (atoi (value2) / 100.0); else panel_config.clock.font.alpha = 0.5; } else if (strcmp (key, "clock_padding") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.clock.area.paddingxlr = panel_config.clock.area.paddingx = atoi (value1); if (value2) panel_config.clock.area.paddingy = atoi (value2); if (value3) panel_config.clock.area.paddingx = atoi (value3); } else if (strcmp (key, "clock_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.clock.area.bg = &g_array_index(backgrounds, Background, id); } else if (strcmp(key, "clock_tooltip") == 0) { if (strlen(value) > 0) time_tooltip_format = strdup (value); } else if (strcmp(key, "clock_tooltip_timezone") == 0) { if (strlen(value) > 0) time_tooltip_timezone = strdup(value); } else if (strcmp(key, "clock_lclick_command") == 0) { if (strlen(value) > 0) clock_lclick_command = strdup(value); } else if (strcmp(key, "clock_rclick_command") == 0) { if (strlen(value) > 0) clock_rclick_command = strdup(value); } /* Taskbar */ else if (strcmp (key, "taskbar_mode") == 0) { if (strcmp (value, "multi_desktop") == 0) panel_mode = MULTI_DESKTOP; else panel_mode = SINGLE_DESKTOP; } else if (strcmp (key, "taskbar_padding") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.g_taskbar.area.paddingxlr = panel_config.g_taskbar.area.paddingx = atoi (value1); if (value2) panel_config.g_taskbar.area.paddingy = atoi (value2); if (value3) panel_config.g_taskbar.area.paddingx = atoi (value3); } else if (strcmp (key, "taskbar_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.g_taskbar.background[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); if (panel_config.g_taskbar.background[TASKBAR_ACTIVE] == 0) panel_config.g_taskbar.background[TASKBAR_ACTIVE] = panel_config.g_taskbar.background[TASKBAR_NORMAL]; } else if (strcmp (key, "taskbar_active_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.g_taskbar.background[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); } else if (strcmp (key, "taskbar_name") == 0) { taskbarname_enabled = atoi (value); } else if (strcmp (key, "taskbar_name_padding") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.g_taskbar.area_name.paddingxlr = panel_config.g_taskbar.area_name.paddingx = atoi (value1); } else if (strcmp (key, "taskbar_name_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.g_taskbar.background_name[TASKBAR_NORMAL] = &g_array_index(backgrounds, Background, id); if (panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] == 0) panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = panel_config.g_taskbar.background_name[TASKBAR_NORMAL]; } else if (strcmp (key, "taskbar_name_active_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.g_taskbar.background_name[TASKBAR_ACTIVE] = &g_array_index(backgrounds, Background, id); } else if (strcmp (key, "taskbar_name_font") == 0) { taskbarname_font_desc = pango_font_description_from_string (value); } else if (strcmp (key, "taskbar_name_font_color") == 0) { extract_values(value, &value1, &value2, &value3); get_color (value1, taskbarname_font.color); if (value2) taskbarname_font.alpha = (atoi (value2) / 100.0); else taskbarname_font.alpha = 0.5; } else if (strcmp (key, "taskbar_name_active_font_color") == 0) { extract_values(value, &value1, &value2, &value3); get_color (value1, taskbarname_active_font.color); if (value2) taskbarname_active_font.alpha = (atoi (value2) / 100.0); else taskbarname_active_font.alpha = 0.5; } /* Task */ else if (strcmp (key, "task_text") == 0) panel_config.g_task.text = atoi (value); else if (strcmp (key, "task_icon") == 0) panel_config.g_task.icon = atoi (value); else if (strcmp (key, "task_centered") == 0) panel_config.g_task.centered = atoi (value); else if (strcmp (key, "task_width") == 0) { // old parameter : just for backward compatibility panel_config.g_task.maximum_width = atoi (value); panel_config.g_task.maximum_height = 30; } else if (strcmp (key, "task_maximum_size") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.g_task.maximum_width = atoi (value1); panel_config.g_task.maximum_height = 30; if (value2) panel_config.g_task.maximum_height = atoi (value2); } else if (strcmp (key, "task_padding") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.g_task.area.paddingxlr = panel_config.g_task.area.paddingx = atoi (value1); if (value2) panel_config.g_task.area.paddingy = atoi (value2); if (value3) panel_config.g_task.area.paddingx = atoi (value3); } else if (strcmp (key, "task_align") == 0) { extract_values(value, &value1, &value2, &value3); printf("task_align: %s\n", value1); if (strcmp (value1, "left") == 0) panel_config.g_task.align = ALIGN_LEFT; else if (strcmp (value1, "center") == 0) panel_config.g_task.align = ALIGN_CENTER; else if (strcmp (value1, "right") == 0) panel_config.g_task.align = ALIGN_RIGHT; else fprintf(stderr, "Unknown value for task_align: %s\n", value1); } else if (strcmp (key, "task_font") == 0) { panel_config.g_task.font_desc = pango_font_description_from_string (value); } else if (g_regex_match_simple("task.*_font_color", key, 0, 0)) { gchar** split = g_regex_split_simple("_", key, 0, 0); int status = get_task_status(split[1]); g_strfreev(split); extract_values(value, &value1, &value2, &value3); float alpha = 1; if (value2) alpha = (atoi (value2) / 100.0); get_color (value1, panel_config.g_task.font[status].color); panel_config.g_task.font[status].alpha = alpha; panel_config.g_task.config_font_mask |= (1<<status); } else if (g_regex_match_simple("task.*_icon_asb", key, 0, 0)) { gchar** split = g_regex_split_simple("_", key, 0, 0); int status = get_task_status(split[1]); g_strfreev(split); extract_values(value, &value1, &value2, &value3); panel_config.g_task.alpha[status] = atoi(value1); panel_config.g_task.saturation[status] = atoi(value2); panel_config.g_task.brightness[status] = atoi(value3); panel_config.g_task.config_asb_mask |= (1<<status); } else if (g_regex_match_simple("task.*_background_id", key, 0, 0)) { gchar** split = g_regex_split_simple("_", key, 0, 0); int status = get_task_status(split[1]); g_strfreev(split); int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.g_task.background[status] = &g_array_index(backgrounds, Background, id); panel_config.g_task.config_background_mask |= (1<<status); if (status == TASK_NORMAL) panel_config.g_task.area.bg = panel_config.g_task.background[TASK_NORMAL]; } // "tooltip" is deprecated but here for backwards compatibility else if (strcmp (key, "task_tooltip") == 0 || strcmp(key, "tooltip") == 0) panel_config.g_task.tooltip_enabled = atoi(value); /* Systray */ else if (strcmp (key, "systray_padding") == 0) { if (new_config_file == 0 && systray_enabled == 0) { systray_enabled = 1; if (panel_items_order) { char* tmp = g_strconcat(panel_items_order, "S", NULL); g_free( panel_items_order ); panel_items_order = tmp; } else panel_items_order = g_strdup("S"); } extract_values(value, &value1, &value2, &value3); systray.area.paddingxlr = systray.area.paddingx = atoi (value1); if (value2) systray.area.paddingy = atoi (value2); if (value3) systray.area.paddingx = atoi (value3); } else if (strcmp (key, "systray_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; systray.area.bg = &g_array_index(backgrounds, Background, id); } else if (strcmp(key, "systray_sort") == 0) { if (strcmp(value, "descending") == 0) systray.sort = -1; else if (strcmp(value, "ascending") == 0) systray.sort = 1; else if (strcmp(value, "left2right") == 0) systray.sort = 2; else if (strcmp(value, "right2left") == 0) systray.sort = 3; } else if (strcmp(key, "systray_icon_size") == 0) { systray_max_icon_size = atoi(value); } else if (strcmp(key, "systray_icon_asb") == 0) { extract_values(value, &value1, &value2, &value3); systray.alpha = atoi(value1); systray.saturation = atoi(value2); systray.brightness = atoi(value3); } /* Launcher */ else if (strcmp (key, "launcher_padding") == 0) { extract_values(value, &value1, &value2, &value3); panel_config.launcher.area.paddingxlr = panel_config.launcher.area.paddingx = atoi (value1); if (value2) panel_config.launcher.area.paddingy = atoi (value2); if (value3) panel_config.launcher.area.paddingx = atoi (value3); } else if (strcmp (key, "launcher_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; panel_config.launcher.area.bg = &g_array_index(backgrounds, Background, id); } else if (strcmp(key, "launcher_icon_size") == 0) { launcher_max_icon_size = atoi(value); } else if (strcmp(key, "launcher_item_app") == 0) { char *app = strdup(value); panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, app); } else if (strcmp(key, "launcher_apps_dir") == 0) { GList *list = dir_scan_alpha(value, "*.desktop"); for (list = g_list_first(list); list; list = g_list_next(list)) { fprintf(stderr, "Add launcher app: %s\n", (const char *)list->data); panel_config.launcher.list_apps = g_slist_append(panel_config.launcher.list_apps, (char *)strdup((const char *)list->data)); } // Cleanup g_list_free_full(list, g_free); } else if (strcmp(key, "launcher_icon_theme") == 0) { // if XSETTINGS manager running, tint2 use it. if (!icon_theme_name) icon_theme_name = strdup(value); } else if (strcmp(key, "launcher_icon_asb") == 0) { extract_values(value, &value1, &value2, &value3); launcher_alpha = atoi(value1); launcher_saturation = atoi(value2); launcher_brightness = atoi(value3); } else if (strcmp(key, "launcher_tooltip") == 0) { launcher_tooltip_enabled = atoi(value); } /* Tooltip */ else if (strcmp (key, "tooltip_show_timeout") == 0) { int timeout_msec = 1000*atof(value); g_tooltip.show_timeout_msec = timeout_msec; } else if (strcmp (key, "tooltip_hide_timeout") == 0) { int timeout_msec = 1000*atof(value); g_tooltip.hide_timeout_msec = timeout_msec; } else if (strcmp (key, "tooltip_padding") == 0) { extract_values(value, &value1, &value2, &value3); if (value1) g_tooltip.paddingx = atoi(value1); if (value2) g_tooltip.paddingy = atoi(value2); } else if (strcmp (key, "tooltip_background_id") == 0) { int id = atoi (value); id = (id < backgrounds->len && id >= 0) ? id : 0; g_tooltip.bg = &g_array_index(backgrounds, Background, id); } else if (strcmp (key, "tooltip_font_color") == 0) { extract_values(value, &value1, &value2, &value3); get_color(value1, g_tooltip.font_color.color); if (value2) g_tooltip.font_color.alpha = (atoi (value2) / 100.0); else g_tooltip.font_color.alpha = 0.1; } else if (strcmp (key, "tooltip_font") == 0) { g_tooltip.font_desc = pango_font_description_from_string(value); } /* Mouse actions */ else if (strcmp (key, "mouse_middle") == 0) get_action (value, &mouse_middle); else if (strcmp (key, "mouse_right") == 0) get_action (value, &mouse_right); else if (strcmp (key, "mouse_scroll_up") == 0) get_action (value, &mouse_scroll_up); else if (strcmp (key, "mouse_scroll_down") == 0) get_action (value, &mouse_scroll_down); /* autohide options */ else if (strcmp(key, "autohide") == 0) panel_autohide = atoi(value); else if (strcmp(key, "autohide_show_timeout") == 0) panel_autohide_show_timeout = 1000*atof(value); else if (strcmp(key, "autohide_hide_timeout") == 0) panel_autohide_hide_timeout = 1000*atof(value); else if (strcmp(key, "strut_policy") == 0) { if (strcmp(value, "follow_size") == 0) panel_strut_policy = STRUT_FOLLOW_SIZE; else if (strcmp(value, "none") == 0) panel_strut_policy = STRUT_NONE; else panel_strut_policy = STRUT_MINIMUM; } else if (strcmp(key, "autohide_height") == 0) { panel_autohide_height = atoi(value); if (panel_autohide_height == 0) { // autohide need height > 0 panel_autohide_height = 1; } } // old config option else if (strcmp(key, "systray") == 0) { if (new_config_file == 0) { systray_enabled = atoi(value); if (systray_enabled) { if (panel_items_order) { char* tmp = g_strconcat(panel_items_order, "S", NULL); g_free( panel_items_order ); panel_items_order = tmp; } else panel_items_order = g_strdup("S"); } } } #ifdef ENABLE_BATTERY else if (strcmp(key, "battery") == 0) { if (new_config_file == 0) { battery_enabled = atoi(value); if (battery_enabled) { if (panel_items_order) { char* tmp = g_strconcat(panel_items_order, "B", NULL); g_free( panel_items_order ); panel_items_order = tmp; } else panel_items_order = g_strdup("B"); } } } #endif else fprintf(stderr, "tint2 : invalid option \"%s\",\n upgrade tint2 or correct your config file\n", key); if (value1) free (value1); if (value2) free (value2); if (value3) free (value3); }
static void gst_fameenc_class_init (GstFameEncClass * klass) { GObjectClass *gobject_class = NULL; GstElementClass *gstelement_class = NULL; fame_context_t *context; fame_list_t *walk; GList *props = NULL, *props_walk; gint current_prop = ARG_FAME_PROPS_START; gobject_class = (GObjectClass *) klass; gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_peek_parent (klass); gobject_class->set_property = gst_fameenc_set_property; gobject_class->get_property = gst_fameenc_get_property; gobject_class->finalize = gst_fameenc_finalize; fame_object_name = g_quark_from_string ("GstFameObjectName"); context = fame_open (); g_assert (context); /* first sort the list */ walk = context->type_list; while (walk) { props = g_list_insert_sorted (props, walk, (GCompareFunc) gst_fameenc_item_compare); walk = walk->next; } props_walk = props; while (props_walk) { GArray *array; const gchar *current_type; gint current_len; gint current_value; fame_object_t *current_default; gint default_index; walk = (fame_list_t *) props_walk->data; array = g_array_new (TRUE, FALSE, sizeof (GEnumValue)); current_type = walk->type; current_value = 0; current_len = strlen (walk->type); current_default = fame_get_object (context, current_type); default_index = 1; do { if (strstr (walk->type, "/")) { GEnumValue value; if (current_default == walk->item) default_index = current_value; value.value = current_value++; value.value_name = g_strdup (walk->type); value.value_nick = g_strdup (walk->item->name); g_array_append_val (array, value); } props_walk = g_list_next (props_walk); if (props_walk) walk = (fame_list_t *) props_walk->data; } while (props_walk && !strncmp (walk->type, current_type, current_len)); if (array->len > 0) { GType type; GParamSpec *pspec; type = g_enum_register_static (g_strdup_printf ("GstFameEnc_%s", current_type), (GEnumValue *) array->data); pspec = g_param_spec_enum (current_type, current_type, g_strdup_printf ("The FAME \"%s\" object", current_type), type, default_index, G_PARAM_READWRITE); g_param_spec_set_qdata (pspec, fame_object_name, (gpointer) current_type); g_object_class_install_property (G_OBJECT_CLASS (klass), current_prop++, pspec); } } g_object_class_install_property (gobject_class, ARG_BITRATE, g_param_spec_int ("bitrate", "Bitrate", "Target bitrate (0 = VBR)", 0, 5000000, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, ARG_QUALITY, g_param_spec_int ("quality", "Quality", "Percentage of quality of compression (versus size)", 0, 100, 75, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, ARG_PATTERN, g_param_spec_string ("pattern", "Pattern", "Encoding pattern of I, P, and B frames", "IPPPPPPPPPPP", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, ARG_FRAMES_PER_SEQUENCE, g_param_spec_int ("frames-per-sequence", "Frames Per Sequence", "The number of frames in one sequence", 1, G_MAXINT, 12, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, ARG_FAME_VERBOSE, g_param_spec_boolean ("fame-verbose", "Fame Verbose", "Make FAME produce verbose output", FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, ARG_BUFFER_SIZE, g_param_spec_int ("buffer-size", "Buffer Size", "Set the decoding output buffer size", 0, 1024 * 1024, FAMEENC_BUFFER_SIZE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); }
static int decode_data(double **data, const xmlChar * input, dataFormat data_format, codingTypes coding, byteOrder byte_order, int max_input_len) { GArray *data_stream, *debase64_buf, *decoded_data; char *p, *end_ptr; unsigned int i; double val; int data_count = 0; gwy_debug("start."); if (input == NULL) { g_warning("SPML: decode_data(): NULL input"); *data = NULL; return 0; } switch (coding) { case ZLIB_COMPR_BASE64: /* XXX: Is input guaranteed to be nul-terminated? */ decode_b64((const gchar*)input, &debase64_buf); if (inflate_dynamic_array(debase64_buf, &data_stream) != 0) { g_warning("Cannot inflate compressed data."); g_array_free(debase64_buf, TRUE); if (data_stream != NULL) { g_array_free(data_stream, TRUE); } *data = NULL; return 0; } g_array_free(debase64_buf, TRUE); break; case BASE64: /* XXX: Is input guaranteed to be nul-terminated? */ decode_b64((const gchar*)input, &data_stream); break; case ASCII: p = (char *)input; data_stream = g_array_new(FALSE, FALSE, sizeof(double)); while (p != NULL) { double num; if (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') { p++; continue; } num = g_ascii_strtod(p, &end_ptr); if (num == 0 && end_ptr == p) { g_warning("SPML: decode_data(): No conversion performed " "from ASCII string."); break; } g_array_append_val(data_stream, num); p = end_ptr; data_count++; } break; /*/ TODO: */ case HEX: case BINARY: g_warning("SPML: decode_data(): Data coding 'HEX' and 'BINARY' " "not supported."); break; case UNKNOWN_CODING: break; } if (coding == ASCII) { /* we have already decoded data */ if (max_input_len != -1 && data_count != max_input_len) { /* not enough input data to fill array defined by length * max_input_len */ g_warning("SPML: decode_data():\n" "Input has not the same length as declared in " "dimensions\n" "(max:%d vs read:%d). Has the channel attribute\n" "'channelReadMethodName'? The channel may be one\n" "dimensional data used for axis values but not as\n" "a source of data for Gwyddion.", max_input_len, data_count); g_array_free(data_stream, TRUE); *data = NULL; return 0; } else { *data = (double *)data_stream->data; /* we can free dynamic array, but not */ g_array_free(data_stream, FALSE); /* containing data. */ gwy_debug("Datacount: %d", data_count); return data_count; } } decoded_data = g_array_new(FALSE, FALSE, sizeof(double)); p = data_stream->data; i = 0; switch (data_format) { case FLOAT32: while (i < data_stream->len) { val = get_float32(&p, byte_order); g_array_append_val(decoded_data, val); data_count++; i += sizeof(float); } break; case FLOAT64: while (i < data_stream->len) { val = get_float64(&p, byte_order); g_array_append_val(decoded_data, val); i += sizeof(double); } break; case INT8: while (i < data_stream->len) { val = get_int8(&p); g_array_append_val(decoded_data, val); i += sizeof(gint8); } break; case INT16: while (i < data_stream->len) { val = get_int16(&p, byte_order); g_array_append_val(decoded_data, val); i += sizeof(gint16); } break; case INT32: while (i < data_stream->len) { val = get_int32(&p, byte_order); g_array_append_val(decoded_data, val); i += sizeof(gint32); } break; case UINT32: while (i < data_stream->len) { val = get_uint32(&p, byte_order); g_array_append_val(decoded_data, val); i += sizeof(guint32); } break; case UINT8: while (i < data_stream->len) { val = get_uint8(&p); g_array_append_val(decoded_data, val); i += sizeof(guint8); } break; case UINT16: while (i < data_stream->len) { val = get_uint16(&p, byte_order); g_array_append_val(decoded_data, val); i += sizeof(guint16); } break; case STRING: g_warning ("SPML: decode_data(): Data format 'String' not supported."); break; case UNKNOWN_DATAFORMAT: g_warning("SPML: decode_data(): Unknown dataformat."); break; } g_array_free(data_stream, TRUE); data_count = decoded_data->len; if (max_input_len != -1 && data_count != max_input_len) { g_warning("SPML: decode_data():\n" "Input has not the same length as declared in dimensions\n" "(max:%d vs read:%d). Has the channel attribute\n" "'channelReadMethodName'? The channel may be one\n" "dimensional data used for axis values but not as\n" "a source of data for Gwyddion.", max_input_len, data_count); g_array_free(decoded_data, TRUE); *data = NULL; return 0; } *data = (double *)decoded_data->data; g_array_free(decoded_data, FALSE); /* we can free dynamic array, but not */ /* containing data. */ gwy_debug("Datacount: %d", data_count); return data_count; }
int32_t ppb_video_capture_enumerate_devices(PP_Resource video_capture, struct PP_ArrayOutput output, struct PP_CompletionCallback callback) { int32_t retval; struct pp_video_capture_s *vc = pp_resource_acquire(video_capture, PP_RESOURCE_VIDEO_CAPTURE); if (!vc) { trace_error("%s, bad resource\n", __func__); return PP_ERROR_BADRESOURCE; } GArray *vc_devices = g_array_new(FALSE, TRUE, sizeof(PP_Resource)); struct dirent **namelist; int n = scandir("/dev/v4l/by-path", &namelist, NULL, NULL); if (n >= 0) { for (int k = 0; k < n; k ++) { if (strcmp(namelist[k]->d_name, ".") == 0) continue; if (strcmp(namelist[k]->d_name, "..") == 0) continue; char *fullpath = g_strdup_printf("/dev/v4l/by-path/%s", namelist[k]->d_name); char *shortname = NULL; if (video_device_is_usable(fullpath, &shortname)) { PP_Resource device; device = ppb_device_ref_create(vc->instance->id, ppb_var_var_from_utf8_z(shortname), ppb_var_var_from_utf8_z(fullpath), PP_DEVICETYPE_DEV_VIDEOCAPTURE); g_array_append_val(vc_devices, device); free(shortname); } g_free(fullpath); } for (int k = 0; k < n; k ++) free(namelist[k]); free(namelist); } PP_Resource *devs = output.GetDataBuffer(output.user_data, vc_devices->len, sizeof(PP_Resource)); if (!devs) { retval = PP_ERROR_FAILED; for (int k = 0; k < vc_devices->len; k ++) ppb_core_release_resource(g_array_index(vc_devices, PP_Resource, k)); goto err; } for (int k = 0; k < vc_devices->len; k ++) devs[k] = g_array_index(vc_devices, PP_Resource, k); retval = PP_OK_COMPLETIONPENDING; ppb_core_call_on_main_thread2(0, callback, PP_OK, __func__); err: pp_resource_release(video_capture); g_array_free(vc_devices, TRUE); return retval; }
/* * recurse == 1: don't expand '@(command)@' * recurse == 2: don't expand '@<java script>@' */ gchar* expand(const char* s, guint recurse) { enum exp_type etype; char* end_simple_var = "\t^°!\"§$%&/()=?'`'+~*'#-:,;@<>| \\{}[]¹²³¼½"; char* ret = NULL; char* vend = NULL; GError* err = NULL; gchar* cmd_stdout = NULL; gchar* mycmd = NULL; GString* buf = g_string_new(""); GString* js_ret = g_string_new(""); while (s && *s) { switch(*s) { case '\\': g_string_append_c(buf, *++s); s++; break; case '@': etype = get_exp_type(s); s++; switch(etype) { case EXP_SIMPLE_VAR: vend = strpbrk(s, end_simple_var); if(!vend) vend = strchr(s, '\0'); break; case EXP_BRACED_VAR: s++; vend = strchr(s, '}'); if(!vend) vend = strchr(s, '\0'); break; case EXP_EXPR: s++; vend = strstr(s, ")@"); if(!vend) vend = strchr(s, '\0'); break; case EXP_JS: s++; vend = strstr(s, ">@"); if(!vend) vend = strchr(s, '\0'); break; case EXP_ESCAPE: s++; vend = strstr(s, "]@"); if(!vend) vend = strchr(s, '\0'); break; /*@notreached@*/ case EXP_ERR: break; } assert(vend); ret = g_strndup(s, vend-s); if(etype == EXP_SIMPLE_VAR || etype == EXP_BRACED_VAR) { expand_variable(buf, ret); if(etype == EXP_SIMPLE_VAR) s = vend; else s = vend+1; } else if(recurse != 1 && etype == EXP_EXPR) { /* execute program directly */ if(ret[0] == '+') { mycmd = expand(ret+1, 1); g_spawn_command_line_sync(mycmd, &cmd_stdout, NULL, NULL, &err); g_free(mycmd); } /* execute program through shell, quote it first */ else { mycmd = expand(ret, 1); gchar *quoted = g_shell_quote(mycmd); gchar *tmp = g_strdup_printf("%s %s", uzbl.behave.shell_cmd?uzbl.behave.shell_cmd:"/bin/sh -c", quoted); g_spawn_command_line_sync(tmp, &cmd_stdout, NULL, NULL, &err); g_free(mycmd); g_free(quoted); g_free(tmp); } if (err) { g_printerr("error on running command: %s\n", err->message); g_error_free (err); } else if (*cmd_stdout) { size_t len = strlen(cmd_stdout); if(len > 0 && cmd_stdout[len-1] == '\n') cmd_stdout[--len] = '\0'; /* strip trailing newline */ g_string_append(buf, cmd_stdout); g_free(cmd_stdout); } s = vend+2; } else if(recurse != 2 && etype == EXP_JS) { /* read JS from file */ if(ret[0] == '+') { GArray *tmp = g_array_new(TRUE, FALSE, sizeof(gchar *)); mycmd = expand(ret+1, 2); g_array_append_val(tmp, mycmd); run_external_js(uzbl.gui.web_view, tmp, js_ret); g_array_free(tmp, TRUE); } /* JS from string */ else { mycmd = expand(ret, 2); eval_js(uzbl.gui.web_view, mycmd, js_ret, "(command)"); g_free(mycmd); } if(js_ret->str) { g_string_append(buf, js_ret->str); g_string_free(js_ret, TRUE); js_ret = g_string_new(""); } s = vend+2; } else if(etype == EXP_ESCAPE) { mycmd = expand(ret, 0); char *escaped = g_markup_escape_text(mycmd, strlen(mycmd)); g_string_append(buf, escaped); g_free(escaped); g_free(mycmd); s = vend+2; } g_free(ret); ret = NULL; break; default: g_string_append_c(buf, *s); s++; break; } } g_string_free(js_ret, TRUE); return g_string_free(buf, FALSE); }
/** * spapr_drc_populate_dt * * @fdt: libfdt device tree * @path: path in the DT to generate properties * @owner: parent Object/DeviceState for which to generate DRC * descriptions for * @drc_type_mask: mask of sPAPRDRConnectorType values corresponding * to the types of DRCs to generate entries for * * generate OF properties to describe DRC topology/indices to guests * * as documented in PAPR+ v2.1, 13.5.2 */ int spapr_drc_populate_dt(void *fdt, int fdt_offset, Object *owner, uint32_t drc_type_mask) { Object *root_container; ObjectProperty *prop; ObjectPropertyIterator iter; uint32_t drc_count = 0; GArray *drc_indexes, *drc_power_domains; GString *drc_names, *drc_types; int ret; /* the first entry of each properties is a 32-bit integer encoding * the number of elements in the array. we won't know this until * we complete the iteration through all the matching DRCs, but * reserve the space now and set the offsets accordingly so we * can fill them in later. */ drc_indexes = g_array_new(false, true, sizeof(uint32_t)); drc_indexes = g_array_set_size(drc_indexes, 1); drc_power_domains = g_array_new(false, true, sizeof(uint32_t)); drc_power_domains = g_array_set_size(drc_power_domains, 1); drc_names = g_string_set_size(g_string_new(NULL), sizeof(uint32_t)); drc_types = g_string_set_size(g_string_new(NULL), sizeof(uint32_t)); /* aliases for all DRConnector objects will be rooted in QOM * composition tree at DRC_CONTAINER_PATH */ root_container = container_get(object_get_root(), DRC_CONTAINER_PATH); object_property_iter_init(&iter, root_container); while ((prop = object_property_iter_next(&iter))) { Object *obj; sPAPRDRConnector *drc; sPAPRDRConnectorClass *drck; uint32_t drc_index, drc_power_domain; if (!strstart(prop->type, "link<", NULL)) { continue; } obj = object_property_get_link(root_container, prop->name, NULL); drc = SPAPR_DR_CONNECTOR(obj); drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); if (owner && (drc->owner != owner)) { continue; } if ((drc->type & drc_type_mask) == 0) { continue; } drc_count++; /* ibm,drc-indexes */ drc_index = cpu_to_be32(drck->get_index(drc)); g_array_append_val(drc_indexes, drc_index); /* ibm,drc-power-domains */ drc_power_domain = cpu_to_be32(-1); g_array_append_val(drc_power_domains, drc_power_domain); /* ibm,drc-names */ drc_names = g_string_append(drc_names, drck->get_name(drc)); drc_names = g_string_insert_len(drc_names, -1, "\0", 1); /* ibm,drc-types */ drc_types = g_string_append(drc_types, spapr_drc_get_type_str(drc->type)); drc_types = g_string_insert_len(drc_types, -1, "\0", 1); } /* now write the drc count into the space we reserved at the * beginning of the arrays previously */ *(uint32_t *)drc_indexes->data = cpu_to_be32(drc_count); *(uint32_t *)drc_power_domains->data = cpu_to_be32(drc_count); *(uint32_t *)drc_names->str = cpu_to_be32(drc_count); *(uint32_t *)drc_types->str = cpu_to_be32(drc_count); ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-indexes", drc_indexes->data, drc_indexes->len * sizeof(uint32_t)); if (ret) { error_report("Couldn't create ibm,drc-indexes property"); goto out; } ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-power-domains", drc_power_domains->data, drc_power_domains->len * sizeof(uint32_t)); if (ret) { error_report("Couldn't finalize ibm,drc-power-domains property"); goto out; } ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-names", drc_names->str, drc_names->len); if (ret) { error_report("Couldn't finalize ibm,drc-names property"); goto out; } ret = fdt_setprop(fdt, fdt_offset, "ibm,drc-types", drc_types->str, drc_types->len); if (ret) { error_report("Couldn't finalize ibm,drc-types property"); goto out; } out: g_array_free(drc_indexes, true); g_array_free(drc_power_domains, true); g_string_free(drc_names, true); g_string_free(drc_types, true); return ret; }
void load_file_position (const vfs_path_t * filename_vpath, long *line, long *column, off_t * offset, GArray ** bookmarks) { char *fn; FILE *f; char buf[MC_MAXPATHLEN + 100]; const size_t len = vfs_path_len (filename_vpath); /* defaults */ *line = 1; *column = 0; *offset = 0; /* open file with positions */ fn = mc_config_get_full_path (MC_FILEPOS_FILE); f = fopen (fn, "r"); g_free (fn); if (f == NULL) return; /* prepare array for serialized bookmarks */ if (bookmarks != NULL) *bookmarks = g_array_sized_new (FALSE, FALSE, sizeof (size_t), MAX_SAVED_BOOKMARKS); while (fgets (buf, sizeof (buf), f) != NULL) { const char *p; gchar **pos_tokens; /* check if the filename matches the beginning of string */ if (strncmp (buf, vfs_path_as_str (filename_vpath), len) != 0) continue; /* followed by single space */ if (buf[len] != ' ') continue; /* and string without spaces */ p = &buf[len + 1]; if (strchr (p, ' ') != NULL) continue; pos_tokens = g_strsplit (p, ";", 3 + MAX_SAVED_BOOKMARKS); if (pos_tokens[0] == NULL) { *line = 1; *column = 0; *offset = 0; } else { *line = strtol (pos_tokens[0], NULL, 10); if (pos_tokens[1] == NULL) { *column = 0; *offset = 0; } else { *column = strtol (pos_tokens[1], NULL, 10); if (pos_tokens[2] == NULL) *offset = 0; else if (bookmarks != NULL) { size_t i; *offset = (off_t) g_ascii_strtoll (pos_tokens[2], NULL, 10); for (i = 0; i < MAX_SAVED_BOOKMARKS && pos_tokens[3 + i] != NULL; i++) { size_t val; val = strtoul (pos_tokens[3 + i], NULL, 10); g_array_append_val (*bookmarks, val); } } } } g_strfreev (pos_tokens); } fclose (f); }
/*! \brief set_offline_mode() is called when the "Offline Mode" button is clicked in the general tab and is used to present the user with list of firmware choices to select one for loading to work in offline mode (no connection to an ECU) */ G_MODULE_EXPORT gboolean set_offline_mode(void) { GtkWidget * widget = NULL; gchar * filename = NULL; gboolean tmp = TRUE; GArray *pfuncs = NULL; PostFunction *pf = NULL; GAsyncQueue *io_repair_queue = NULL; Firmware_Details *firmware = NULL; void (*load_firmware_details)(void *,const gchar *) = NULL; ENTER(); firmware = (Firmware_Details *)DATA_GET(global_data,"firmware"); io_repair_queue = (GAsyncQueue *)DATA_GET(global_data,"io_repair_queue"); /* Cause Serial Searcher thread to abort.... */ if (io_repair_queue) g_async_queue_push(io_repair_queue,&tmp); filename = present_firmware_choices(); if (!filename) { DATA_SET(global_data,"offline",GINT_TO_POINTER(FALSE)); DATA_SET(global_data,"interrogated",GINT_TO_POINTER(FALSE)); widget = lookup_widget("interrogate_button"); if (GTK_IS_WIDGET(widget)) gtk_widget_set_sensitive(GTK_WIDGET(widget),TRUE); widget = lookup_widget("offline_button"); if (GTK_IS_WIDGET(widget)) gtk_widget_set_sensitive(GTK_WIDGET(widget),TRUE); plugins_shutdown(); /* Does this need a delay? */ personality_choice(); EXIT(); return FALSE; } DATA_SET_FULL(global_data,"last_offline_profile",g_strdup(filename),g_free); DATA_SET(global_data,"offline",GINT_TO_POINTER(TRUE)); DATA_SET(global_data,"interrogated",GINT_TO_POINTER(TRUE)); /* Disable interrogation button */ widget = lookup_widget("interrogate_button"); if (GTK_IS_WIDGET(widget)) gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE); widget = lookup_widget("netaccess_table"); if (GTK_IS_WIDGET(widget)) gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE); queue_function("kill_conn_warning"); if (!firmware) { firmware = g_new0(Firmware_Details,1); DATA_SET(global_data,"firmware",firmware); } if (get_symbol("load_firmware_details",(void **)&load_firmware_details)) { load_firmware_details(firmware,filename); } else printf("Unable to load firmware details!\n"); pfuncs = g_array_new(FALSE,TRUE,sizeof(PostFunction *)); pf = g_new0(PostFunction,1); pf->name = g_strdup("update_interrogation_gui_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("load_realtime_map_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("initialize_dashboards_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("load_status_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("load_rt_text_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("load_gui_tabs_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("start_statuscounts_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("disable_burner_buttons_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); /* BUG, causes deadlock pf = g_new0(PostFunction,1); pf->name = g_strdup("offline_ecu_restore_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); */ pf = g_new0(PostFunction,1); pf->name = g_strdup("setup_menu_handlers_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("enable_3d_buttons_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("ready_msg_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("cleanup_pf"); get_symbol(pf->name,(void **)&pf->function_w_arg); pf->w_arg = TRUE; pfuncs = g_array_append_val(pfuncs,pf); io_cmd(NULL,pfuncs); /* io_cmd(firmware->get_all_command,NULL); */ widget = lookup_widget("binary_logging_frame"); if (GTK_IS_WIDGET(widget)) gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE); widget = lookup_widget("interrogate_button"); if (GTK_IS_WIDGET(widget)) gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE); widget = lookup_widget("offline_button"); if (GTK_IS_WIDGET(widget)) gtk_widget_set_sensitive(GTK_WIDGET(widget),FALSE); g_list_foreach(get_list("get_data_buttons"),set_widget_sensitive,GINT_TO_POINTER(FALSE)); pfuncs = g_array_new(FALSE,TRUE,sizeof(PostFunction *)); pf = g_new0(PostFunction,1); pf->name = g_strdup("reset_temps_pf"); get_symbol(pf->name,(void **)&pf->function); pf->w_arg = FALSE; pfuncs = g_array_append_val(pfuncs,pf); pf = g_new0(PostFunction,1); pf->name = g_strdup("cleanup_pf"); get_symbol(pf->name,(void **)&pf->function_w_arg); pf->w_arg = TRUE; pfuncs = g_array_append_val(pfuncs,pf); io_cmd(NULL,pfuncs); EXIT(); return FALSE; }