void draw_output (char *strOutputName, char *strInputName) { OUTPUT_DESC *output; char strFileName[256]; FILE *pFile = NULL; int class_cnae; output = get_output_by_name (strOutputName); sprintf (strFileName, "%s%d.cnae", (g_nDataBaseId == CNAE_TABLE_ID)? CNAE_TABLE_PATH: OBJETOS_SOCIAIS_PATH, g_nDocNumber); if ((pFile = fopen (strFileName, "r")) != NULL) { fscanf (pFile, "%d", &class_cnae); printf ("class_cnae = %d\n", class_cnae); fclose (pFile); } else { printf ("Could not read file %s\n", strFileName); return; } set_neurons (output->neuron_layer->neuron_vector, 0, output->wh * output->ww, class_cnae); update_output_image (output); glutSetWindow(output->win); glutPostWindowRedisplay (output->win); }
/* * Moves the given container to the closest output in the given direction if * such an output exists. * */ static void move_to_output_directed(Con *con, direction_t direction) { Con *old_ws = con_get_workspace(con); Con *current_output_con = con_get_output(con); Output *current_output = get_output_by_name(current_output_con->name); Output *output = get_output_next(direction, current_output, CLOSEST_OUTPUT); if (!output) { DLOG("No output in this direction found. Not moving.\n"); return; } Con *ws = NULL; GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child)); if (!ws) { DLOG("No workspace on output in this direction found. Not moving.\n"); return; } attach_to_workspace(con, ws, direction); /* fix the focus stack */ con_focus(con); /* force re-painting the indicators */ FREE(con->deco_render_params); tree_flatten(croot); ipc_send_workspace_event("focus", ws, old_ws); }
void draw_output (char *strOutputName, char *strInputName) { OUTPUT_DESC *output; output = get_output_by_name (strOutputName); set_neurons (output->neuron_layer->neuron_vector, 0, output->wh * output->ww, g_nPersonUniqueID - 1); update_output_image (output); glutSetWindow(output->win); glutPostWindowRedisplay (output->win); }
void draw_output(char *output_name, char *input_name) { OUTPUT_DESC *output; if ((g_label >= 0) && (g_label <= 9)) { output = get_output_by_name(output_name); set_neurons(output->neuron_layer->neuron_vector, 0, output->ww * output->wh, 0); // user_set_neurons(output->neuron_layer->neuron_vector, output, g_label, NUM_COLORS - 1); fill_in_all_neurons_output_with_label(output->neuron_layer->neuron_vector, output, g_label); update_output_image(output); glutSetWindow(output->win); glutPostWindowRedisplay(output->win); } }
/* * We hit the end of a map (rect or a new output) * */ static int outputs_end_map_cb(void *params_) { struct outputs_json_params *params = (struct outputs_json_params *)params_; if (params->in_rect) { params->in_rect = false; /* Ignore the end of a rect */ return 1; } /* See if we actually handle that output */ if (config.num_outputs > 0) { bool handle_output = false; for (int c = 0; c < config.num_outputs; c++) { if (strcasecmp(params->outputs_walk->name, config.outputs[c]) == 0 || (strcasecmp(config.outputs[c], "primary") == 0 && params->outputs_walk->primary)) { handle_output = true; break; } } if (!handle_output) { DLOG("Ignoring output \"%s\", not configured to handle it.\n", params->outputs_walk->name); clear_output(params->outputs_walk); FREE(params->outputs_walk); FREE(params->cur_key); return 1; } } i3_output *target = get_output_by_name(params->outputs_walk->name); if (target == NULL) { SLIST_INSERT_HEAD(outputs, params->outputs_walk, slist); } else { target->active = params->outputs_walk->active; target->primary = params->outputs_walk->primary; target->ws = params->outputs_walk->ws; target->rect = params->outputs_walk->rect; clear_output(params->outputs_walk); FREE(params->outputs_walk); } return 1; }
void input_filters_and_outputs_update(void) { conditional_filter_update(get_filter_by_name((char*)"in_saccade_translated_filter")); if(get_output_by_name((char*)"in_saccade_current_filtered_out")) output_update(get_output_by_name((char*)"in_saccade_current_filtered_out")); conditional_filter_update(get_filter_by_name((char*)"in_saccade_translated_scaled_filter")); if(get_output_by_name((char*)"in_saccade_translated_scaled_out")) output_update(get_output_by_name((char*)"in_saccade_translated_scaled_out")); conditional_filter_update(get_filter_by_name((char*)"in_saccade_translated_scaled_gaussian_filter")); if(get_output_by_name((char*)"in_saccade_translated_scaled_gaussian_out")) output_update(get_output_by_name((char*)"in_saccade_translated_scaled_gaussian_out")); conditional_filter_update(get_filter_by_name((char*)"in_saccade_trained_log_polar_filter")); if(get_output_by_name((char*)"in_saccade_trained_log_polar_out")) output_update(get_output_by_name((char*)"in_saccade_trained_log_polar_out")); }
void draw_output(char *output_name, char *input_name) { OUTPUT_DESC *output; output = get_output_by_name(output_name); if (strcmp(output_name, "character_label_out") == 0) { if ((g_label >= 0) && (g_label <= 9)) { set_neurons(output->neuron_layer->neuron_vector, 0, output->ww * output->wh, 0); // user_set_neurons(output->neuron_layer->neuron_vector, output, g_label, NUM_COLORS - 1); fill_in_all_neurons_output_with_label(output->neuron_layer->neuron_vector, output, g_label); update_output_image(output); #ifndef NO_INTERFACE glutSetWindow(output->win); glutPostWindowRedisplay(output->win); #endif } } }
static int outputs_integer_cb(void *params_, long long val) { #else static int outputs_integer_cb(void *params_, long val) { #endif struct outputs_json_params *params = (struct outputs_json_params*) params_; if (!strcmp(params->cur_key, "current_workspace")) { params->outputs_walk->ws = (int) val; FREE(params->cur_key); return 1; } if (!strcmp(params->cur_key, "x")) { params->outputs_walk->rect.x = (int) val; FREE(params->cur_key); return 1; } if (!strcmp(params->cur_key, "y")) { params->outputs_walk->rect.y = (int) val; FREE(params->cur_key); return 1; } if (!strcmp(params->cur_key, "width")) { params->outputs_walk->rect.w = (int) val; FREE(params->cur_key); return 1; } if (!strcmp(params->cur_key, "height")) { params->outputs_walk->rect.h = (int) val; FREE(params->cur_key); return 1; } return 0; } /* * Parse a string (name) * */ #if YAJL_MAJOR >= 2 static int outputs_string_cb(void *params_, const unsigned char *val, size_t len) { #else static int outputs_string_cb(void *params_, const unsigned char *val, unsigned int len) { #endif struct outputs_json_params *params = (struct outputs_json_params*) params_; if (!strcmp(params->cur_key, "current_workspace")) { char *copy = smalloc(sizeof(const unsigned char) * (len + 1)); strncpy(copy, (const char*) val, len); copy[len] = '\0'; char *end; errno = 0; long parsed_num = strtol(copy, &end, 10); if (errno == 0 && (end && *end == '\0')) params->outputs_walk->ws = parsed_num; free(copy); FREE(params->cur_key); return 1; } if (strcmp(params->cur_key, "name")) { return 0; } char *name = smalloc(sizeof(const unsigned char) * (len + 1)); strncpy(name, (const char*) val, len); name[len] = '\0'; params->outputs_walk->name = name; FREE(params->cur_key); return 1; } /* * We hit the start of a json-map (rect or a new output) * */ static int outputs_start_map_cb(void *params_) { struct outputs_json_params *params = (struct outputs_json_params*) params_; i3_output *new_output = NULL; if (params->cur_key == NULL) { new_output = smalloc(sizeof(i3_output)); new_output->name = NULL; new_output->ws = 0, memset(&new_output->rect, 0, sizeof(rect)); new_output->bar = XCB_NONE; new_output->workspaces = smalloc(sizeof(struct ws_head)); TAILQ_INIT(new_output->workspaces); new_output->trayclients = smalloc(sizeof(struct tc_head)); TAILQ_INIT(new_output->trayclients); params->outputs_walk = new_output; return 1; } if (!strcmp(params->cur_key, "rect")) { params->in_rect = true; } return 1; } /* * We hit the end of a map (rect or a new output) * */ static int outputs_end_map_cb(void *params_) { struct outputs_json_params *params = (struct outputs_json_params*) params_; if (params->in_rect) { params->in_rect = false; /* Ignore the end of a rect */ return 1; } /* See if we actually handle that output */ if (config.num_outputs > 0) { bool handle_output = false; for (int c = 0; c < config.num_outputs; c++) { if (strcasecmp(params->outputs_walk->name, config.outputs[c]) != 0) continue; handle_output = true; break; } if (!handle_output) { DLOG("Ignoring output \"%s\", not configured to handle it.\n", params->outputs_walk->name); FREE(params->outputs_walk->name); FREE(params->outputs_walk->workspaces); FREE(params->outputs_walk->trayclients); FREE(params->outputs_walk); FREE(params->cur_key); return 1; } } i3_output *target = get_output_by_name(params->outputs_walk->name); if (target == NULL) { SLIST_INSERT_HEAD(outputs, params->outputs_walk, slist); } else { target->active = params->outputs_walk->active; target->primary = params->outputs_walk->primary; target->ws = params->outputs_walk->ws; target->rect = params->outputs_walk->rect; } return 1; } /* * Parse a key. * * Essentially we just save it in the parsing-state * */ #if YAJL_MAJOR >= 2 static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, size_t keyLen) { #else static int outputs_map_key_cb(void *params_, const unsigned char *keyVal, unsigned keyLen) { #endif struct outputs_json_params *params = (struct outputs_json_params*) params_; FREE(params->cur_key); params->cur_key = smalloc(sizeof(unsigned char) * (keyLen + 1)); strncpy(params->cur_key, (const char*) keyVal, keyLen); params->cur_key[keyLen] = '\0'; return 1; } /* A datastructure to pass all these callbacks to yajl */ yajl_callbacks outputs_callbacks = { &outputs_null_cb, &outputs_boolean_cb, &outputs_integer_cb, NULL, NULL, &outputs_string_cb, &outputs_start_map_cb, &outputs_map_key_cb, &outputs_end_map_cb, NULL, NULL }; /* * Initiate the output-list * */ void init_outputs(void) { outputs = smalloc(sizeof(struct outputs_head)); SLIST_INIT(outputs); } /* * Start parsing the received json-string * */ void parse_outputs_json(char *json) { struct outputs_json_params params; params.outputs_walk = NULL; params.cur_key = NULL; params.json = json; params.in_rect = false; yajl_handle handle; yajl_status state; #if YAJL_MAJOR < 2 yajl_parser_config parse_conf = { 0, 0 }; handle = yajl_alloc(&outputs_callbacks, &parse_conf, NULL, (void*) ¶ms); #else handle = yajl_alloc(&outputs_callbacks, NULL, (void*) ¶ms); #endif state = yajl_parse(handle, (const unsigned char*) json, strlen(json)); /* FIXME: Propper errorhandling for JSON-parsing */ switch (state) { case yajl_status_ok: break; case yajl_status_client_canceled: #if YAJL_MAJOR < 2 case yajl_status_insufficient_data: #endif case yajl_status_error: ELOG("Could not parse outputs-reply!\n"); exit(EXIT_FAILURE); break; } yajl_free(handle); } /* * Returns the output with the given name * */ i3_output *get_output_by_name(char *name) { i3_output *walk; if (name == NULL) { return NULL; } SLIST_FOREACH(walk, outputs, slist) { if (!strcmp(walk->name, name)) { break; } } return walk; }