Gtk::VBox * Extension::get_info_widget(void) { Gtk::VBox * retval = Gtk::manage(new Gtk::VBox()); Gtk::Frame * info = Gtk::manage(new Gtk::Frame("General Extension Information")); retval->pack_start(*info, true, true, 5); #if WITH_GTKMM_3_0 Gtk::Grid * table = Gtk::manage(new Gtk::Grid()); #else Gtk::Table * table = Gtk::manage(new Gtk::Table()); #endif info->add(*table); int row = 0; add_val(_("Name:"), _(name), table, &row); add_val(_("ID:"), id, table, &row); add_val(_("State:"), _state == STATE_LOADED ? _("Loaded") : _state == STATE_UNLOADED ? _("Unloaded") : _("Deactivated"), table, &row); retval->show_all(); return retval; }
/* * Removes datanode slave from pgxc_ctl configuration. */ static void emptyDatanodeSlaves() { int ii; reset_var_val(VAR_datanodeSlave, "n"); reset_var(VAR_datanodeSlaveServers); reset_var(VAR_datanodeSlaveDirs); reset_var(VAR_datanodeArchLogDirs); for (ii = 0; ii < arraySizeName(VAR_datanodeSlaveServers); ii++) { add_val(find_var(VAR_datanodeSlaveServers), "none"); add_val(find_var(VAR_coordSlaveDirs), "none"); add_val(find_var(VAR_coordArchLogDirs), "none"); } }
/* * Parse line and filter only pre-defined variables. * * This blocks any unknow variables to be build within pgxc_ctl structure. */ static void parse_line_select(char *line, char *selectThis[]) { char *varname; char *val; pgxc_ctl_var *newv; int ii; line = get_word(line, &varname); if (!varname || varname[0] == '#') return; for (ii = 0; selectThis[ii]; ii++) { if (strcmp(varname, selectThis[ii]) == 0) { if (!(newv = confirm_var(varname))) return; while((line = get_word(line, &val))) { if (val) add_val(newv, val); } } } }
/* * Get all the servers --> VAR_allServers */ static void addServer(char **name) { int ii, jj; int flag; confirm_var(VAR_allServers); for (ii = 0; name[ii]; ii++) { flag = TRUE; for (jj = 0; aval(VAR_allServers)[jj]; jj++) { if (strcmp(name[ii], aval(VAR_allServers)[jj]) != 0) continue; else { flag = FALSE; break; } } if (flag) add_val(find_var(VAR_allServers), name[ii]); } }
int main(int argc, char const *argv[]) { char* read_buf = malloc(READ_BUF_LEN); hashmap_t *hm = create_hash_map(HASHMAP_SIZE); int result = scanf("%511[a-z|A-Z|']", read_buf); int *count; while (result != EOF) { if (result == 1) { to_lower_case(read_buf); count = lookup_val(read_buf, hm); if (count != NULL) { *count = *count + 1; } else { add_val(read_buf, 1, hm); } } else if (result == 0) { scanf("%511[^a-z|A-Z|']", read_buf); } result = scanf("%511[a-z|A-Z|']", read_buf); } node_t **words = to_sorted_array(hm); for (int i = 0; i < hm->size; i++) { printf("%s %d\n", words[i]->string, words[i]->count); } return 0; }
void assign_sval(char *destName, char *val) { pgxc_ctl_var *dest = find_var(destName); reset_value(dest); add_val(dest, val); }
void add_val_name(char *name, char *val) { pgxc_ctl_var *var; if (!(var = find_var(name))) return; add_val(var, name); return; }
void assign_val(char *destName, char *srcName) { pgxc_ctl_var *dest = find_var(destName); pgxc_ctl_var *src = find_var(srcName); int ii; reset_value(dest); for (ii = 0; ii < src->val_used; ii++) add_val(dest, src->val[ii]); }
/* * Remove gtm proxies. Used when a node crashes. * Because gtm_proxy is expected to be running at any target * server, we don't have gtm_proxy slaves. * We can just initialize gtm_proy using gtminit, configure and * run it. */ static void emptyGtmProxies() { int ii; reset_var_val(VAR_gtmProxy, "n"); reset_var(VAR_gtmProxyServers); reset_var(VAR_gtmProxyNames); reset_var(VAR_gtmProxyPorts); reset_var(VAR_gtmProxyDirs); reset_var_val(VAR_gtmPxyExtraConfig, "none"); reset_var(VAR_gtmPxySpecificExtraConfig); for (ii = 0; ii < arraySizeName(VAR_allServers); ii++) { add_val(find_var(VAR_gtmProxyServers), "none"); add_val(find_var(VAR_gtmProxyNames), "none"); add_val(find_var(VAR_gtmProxyPorts), "-1"); add_val(find_var(VAR_gtmProxyDirs), "none"); add_val(find_var(VAR_gtmPxyExtraConfig), "none"); } }
t_map *check_right(t_map *map) { t_map *head; int rec; head = map; rec = 0; while (head && (head->y == map->y) && (head->prev && head->prev->y == map->y)) { head = head->prev; if (head && (head->value == map->value) && !head->lock) { head = add_val(head, map->position, (head->value + map->value)); head = add_val(head, head->position, -1); rec = 1; break; } else if (head && (((head->value != map->value) && (head->value != -1)) || (head->value == map->value && head->lock))) break; } return (rec ? check_right(map) : map); }
VOID fn_ret(CONTEXT *ctxt) { trace_enter(); if (!call_stack.is_top_forgotten()) { FID fid = call_stack.top(); if (has_return[fid] == 1) { add_val(fid, ctxt, 0, 0); } } call_stack.pop(); sp_stack.pop(); trace_leave(); }
void AIFGroup::check_thresholds() { auryn_vector_float_clip( mem, e_rev ); AurynState * thr_ptr = thr->data; for ( AurynState * i = mem->data ; i != mem->data+get_rank_size() ; ++i ) { // it's important to use rank_size here otherwise there might be spikes from units that do not exist if ( *i > ( thr_rest + *thr_ptr ) ) { NeuronID unit = i-mem->data; push_spike(unit); set_val (mem, unit, e_rest); // reset set_val (thr, unit, dthr); //refractory add_val (g_adapt1, unit, dg_adapt1); } thr_ptr++; } }
VOID fn_call(CONTEXT *ctxt, FID fid) { trace_enter(); call_stack.push(fid); UINT64 sp; PIN_GetContextRegval(ctxt, REG_RSP, (UINT8*) &sp); sp_stack.push(sp); nb_call[fid]++; unsigned int param_val_size = 1 + nb_param_int[fid] + nb_param_int_stack[fid]; for (unsigned int pid = 1; pid < param_val_size; pid++) { if (!param_is_not_addr[fid][pid]) add_val(fid, ctxt, pid, sp); } trace_leave(); }
/* * Parse line and create/update a variable. */ static void parse_line(char *line) { char *varname; char *val; pgxc_ctl_var *newv; line = get_word(line, &varname); if (!varname) return; if (!(newv = confirm_var(varname))) return; reset_value(newv); while((line = get_word(line, &val))) { if (val) { add_val(newv, val); } } }
static inline void add_vals (DespeckleHistogram *hist, const guchar *src, gint width, gint bpp, gint xmin, gint ymin, gint xmax, gint ymax) { gint x; gint y; if (xmin > xmax) return; for (y = ymin; y <= ymax; y++) { for (x = xmin; x <= xmax; x++) { add_val (hist, src, width, bpp, x, y); } } }
void add_sect(sizetvec * nns, REAL X1, REAL Y1, REAL X2, REAL Y2, d_grid * grd2) { int dx, dy, i1, i2, i, kx, ky; int d; // "residual" size_t x, y; int flag; size_t NN = grd2->getCountX(); size_t MM = grd2->getCountY(); size_t x1 = grd2->get_i(X1); size_t x2 = grd2->get_i(X2); size_t y1 = grd2->get_j(Y1); size_t y2 = grd2->get_j(Y2); dy = y2 - y1; dx = x2 - x1; REAL DY = Y2-Y1; REAL DX = X2-X1; if (dx == 0 && dy == 0) { // only one point add_val(nns, x1, y1, NN, MM); return; } kx = 1; // step by OX ky = 1; // step by OY // Selection of the main direction if ( dx < 0 ) { dx = -dx; kx = -1; // Y } else { if(dx == 0) kx = 0; // X } if (dy < 0) { dy = -dy; ky = -1; } if (dx < dy) { flag = 0; d = dx; dx = dy; dy = d; } else flag = 1; i1 = dy + dy; d = i1 - dx; i2 = d - dx; x = x1; y = y1; REAL p_x, p_y; for ( i = 0; i < dx; i++ ) { grd2->getCoordNode(x,y,p_x,p_y); add_val(nns, x, y, NN, MM); if (flag) x += kx; // step by main direction else y += ky; if( d < 0 ) {// horizontal step d += i1; } else { // diagonal step int x_0; int x_1; int y_0; int y_1; if (flag) { x_0 = x-kx; x_1 = x; y_0 = y; y_1 = y+ky; } else { y_0 = y-ky; y_1 = y; x_0 = x; x_1 = x+kx; } REAL X_0 = grd2->getCoordNodeX(x_0); REAL X_1 = grd2->getCoordNodeX(x_1); REAL Y_0 = grd2->getCoordNodeY(y_0); REAL Y_1 = grd2->getCoordNodeY(y_1); if (flag) { if (fabs( DY*(X_0-X1) + DX*(Y1-Y_1) ) - fabs( DY*(X_1-X1) + DX*(Y1-Y_0)) < 0) { x -= kx; y += ky; grd2->getCoordNode(x,y,p_x,p_y); add_val(nns, x, y, NN, MM); x += kx; } else { grd2->getCoordNode(x,y,p_x,p_y); add_val(nns, x, y, NN, MM); y += ky; } } else { if (fabs( DX*(Y_0-Y1) + DY*(X1-X_1) ) - fabs( DX*(Y_1-Y1) + DY*(X1-X_0)) < 0) { y -= ky; x += kx; grd2->getCoordNode(x,y,p_x,p_y); add_val(nns, x, y, NN, MM); y += ky; } else { grd2->getCoordNode(x,y,p_x,p_y); add_val(nns, x, y, NN, MM); x += kx; } } d += i2; } } add_val(nns, x2, y2, NN, MM); // last point };
void reset_var_val(char *name, char *val) { reset_var(name); add_val(find_var(name), val); }
/* * Add gtm proxy: to be used after all the configuration is done. * * This function only maintains internal configuration, updte configuration file, * and make backup if configured. You should run init and start it separately. */ int add_gtmProxy(char *name, char *host, int port, char *dir) { char port_s[MAXTOKEN+1]; char date[MAXTOKEN+1]; FILE *f; char **nodelist = NULL; int rc; if (is_none(host)) { elog(ERROR, "ERROR: Cannot add gtm proxy with the name \"none\".\n"); return 1; } if (is_none(dir)) { elog(ERROR, "ERROR: Cannot add gtm proxy with the directory \"none\".\n"); return 1; } if (checkSpecificResourceConflict(name, host, port, dir, TRUE)) { elog(ERROR, "ERROR: New specified name:%s, host:%s, port:%d and dir:\"%s\" conflicts with existing node.\n", name, host, port, dir); return 1; } if (!isVarYes(VAR_gtmProxy)) { assign_sval(VAR_gtmProxy, Strdup("y")); reset_var(VAR_gtmProxyNames); } add_val(find_var(VAR_gtmProxyNames), Strdup(name)); add_val(find_var(VAR_gtmProxyServers), Strdup(host)); snprintf(port_s, MAXTOKEN, "%d", port); add_val(find_var(VAR_gtmProxyPorts), Strdup(port_s)); add_val(find_var(VAR_gtmProxyDirs), Strdup(dir)); add_val(find_var(VAR_gtmPxySpecificExtraConfig), Strdup("none")); makeServerList(); if ((f = fopen(pgxc_ctl_config_path, "a")) == NULL) { /* Should it be panic? */ elog(ERROR, "ERROR: cannot open configuration file \"%s\", %s\n", pgxc_ctl_config_path, strerror(errno)); return 1; } fprintf(f, "#===================================================\n" "# pgxc configuration file updated due to GTM proxy (%s) addition\n" "# %s\n", name, timeStampString(date, MAXTOKEN+1)); fprintSval(f, VAR_gtmProxy); fprintAval(f, VAR_gtmProxyNames); fprintAval(f, VAR_gtmProxyServers); fprintAval(f, VAR_gtmProxyPorts); fprintAval(f, VAR_gtmProxyDirs); fprintAval(f, VAR_gtmPxySpecificExtraConfig); fprintf(f, "%s", "#----End of reconfiguration -------------------------\n"); fclose(f); AddMember(nodelist, name); init_gtm_proxy(nodelist); rc = start_gtm_proxy(nodelist); CleanArray(nodelist); return rc; }
static void despeckle_median (guchar *src, guchar *dst, gint width, gint height, gint bpp, gint radius, gboolean preview) { guint progress; guint max_progress; gint x, y; gint input_radius = radius; gint pos; gint ymin; gint ymax; gint xmin; gint xmax; memset (&histogram, 0, sizeof(histogram)); progress = 0; max_progress = width * height; if (! preview) gimp_progress_init(_("Despeckle")); for (y = 0; y < height; y++) { x = 0; ymin = MAX (0, y - radius); ymax = MIN (height - 1, y + radius); xmin = MAX (0, x - radius); xmax = MIN (width - 1, x + radius); hist0 = 0; histrest = 0; hist255 = 0; histogram_clean (&histogram); histogram.xmin = xmin; histogram.ymin = ymin; histogram.xmax = xmax; histogram.ymax = ymax; add_vals (&histogram, src, width, bpp, histogram.xmin, histogram.ymin, histogram.xmax, histogram.ymax); for (x = 0; x < width; x++) { const guchar *pixel; ymin = MAX (0, y - radius); /* update ymin, ymax when radius changed (FILTER_ADAPTIVE) */ ymax = MIN (height - 1, y + radius); xmin = MAX (0, x - radius); xmax = MIN (width - 1, x + radius); update_histogram (&histogram, src, width, bpp, xmin, ymin, xmax, ymax); pos = (x + (y * width)) * bpp; pixel = histogram_get_median (&histogram, src + pos); if (filter_type & FILTER_RECURSIVE) { del_val (&histogram, src, width, bpp, x, y); pixel_copy (src + pos, pixel, bpp); add_val (&histogram, src, width, bpp, x, y); } pixel_copy (dst + pos, pixel, bpp); /* * Check the histogram and adjust the diameter accordingly... */ if (filter_type & FILTER_ADAPTIVE) { if (hist0 >= radius || hist255 >= radius) { if (radius < input_radius) radius++; } else if (radius > 1) { radius--; } } } progress += width; if (! preview && y % 32 == 0) gimp_progress_update ((gdouble) progress / (gdouble) max_progress); } if (! preview) gimp_progress_update (1.0); }