static void register_map(void) { if (im_map) return; im_map = key_alloc(); key_add(im_map, "Keystroke", &keystroke); key_add(im_map, "Mouse-event", &mouse_event); key_add(im_map, "Mode:set-mode", &set_mode); key_add(im_map, "Mode:set-numeric", &set_numeric); key_add(im_map, "Mode:set-extra", &set_extra); key_add_range(im_map, "Request:Notify:", "Request:Notify;", &request_notify); }
TEST(cps_api_key_cache,test_setup) { srand(time(NULL)); size_t _k_data[5]; memset(_k_data,0,sizeof(_k_data)); key_add(_k_data,0,10); }
static void render_format_register_map(void) { rf_map = key_alloc(); key_add(rf_map, "render-line", &render_line); key_add(rf_map, "render-line-prev", &render_line_prev); key_add(rf_map, "Close", &format_close); key_add(rf_map, "Clone", &format_clone); key_add(rf_map, "Move-EOL", &format_move_line); key_add(rf_map, "Move-Char", &format_move_horiz); key_add(rf_map, "Move-Word", &format_move_horiz); key_add(rf_map, "Move-WORD", &format_move_horiz); }
void rijn_encrypt(rijn_keysched_t *sched, unsigned char *out, const unsigned char *in) { rijn_size_t blockrows = sched->rijn_param.rijn_blockrows; int round, nrounds = sched->rijn_nrounds; rijn_block_t *out_block = (rijn_block_t *) out; rijn_block_t *in_block = (rijn_block_t *) in; key_add(out_block, in_block, &sched->rijn_roundkey[0], blockrows); for (round = 1; round < nrounds; round++) { substitute(out_block, s_box, blockrows); shift_column(out_block, blockrows); mix_row(out_block, blockrows); key_add(out_block, out_block, &sched->rijn_roundkey[round], blockrows); } substitute(out_block, s_box, blockrows); shift_column(out_block, blockrows); key_add(out_block, out_block, &sched->rijn_roundkey[round], blockrows); }
void rijn_decrypt(rijn_keysched_t *sched, unsigned char *out, const unsigned char *in) { rijn_size_t blockrows = sched->rijn_param.rijn_blockrows; int round, nrounds = sched->rijn_nrounds; rijn_block_t *out_block = (rijn_block_t *) out; rijn_block_t *in_block = (rijn_block_t *) in; key_add(out_block, in_block, &sched->rijn_roundkey[nrounds], blockrows); substitute(out_block, s_box_inverse, blockrows); shift_column_inverse(out_block, blockrows); for (round = nrounds - 1; round > 0; round--) { key_add(out_block, out_block, &sched->rijn_roundkey[round], blockrows); mix_row_inverse(out_block, blockrows); substitute(out_block, s_box_inverse, blockrows); shift_column_inverse(out_block, blockrows); } assert (round == 0); key_add(out_block, out_block, &sched->rijn_roundkey[round], blockrows); }
void key_add(size_t *_k_data, size_t pos, size_t mx) { if (pos >= 5) return; for (int a = 0, _a = 10; a < _a ; ++a ) { _k_data[pos] = a; key_add(_k_data,pos+1,mx); if ((pos+1) == 4) { cps_api_key_t *key = (cps_api_key_t*)calloc(1,sizeof(cps_api_key_t)); cps_api_key_init(key,(cps_api_qualifier_t)(_k_data[0]+1),_k_data[1]+1,_k_data[2]+1,2,_k_data[3],_k_data[4]); char b1[100]; printf("Adding for test.. %s\n",cps_api_key_print(key,b1,sizeof(b1))); lst.push_back(key); } } }
static int getallgroups (void) { DIR *dir; struct dirent *dp; char *gr; if (!(dir = opendir("."))) { LOG("getallgroups:opendir(%s):%m", snroot); return -1; } for (nr_keys = 0; (dp = readdir(dir)); nr_keys++) if (is_valid_group(gr = dp->d_name)) if (-1 == key_add(&gr, strlen(gr))) fail(2, "No memory"); closedir(dir); return 0; }
static Handle alloc_new_handle(H_Type type, const PIVFS& vfs, const VfsPath& pathname, uintptr_t key, size_t flags, va_list* init_args) { HDATA* hd = (HDATA*)pool_alloc(&hpool, 0); if(!hd) WARN_RETURN(ERR::NO_MEM); new(&hd->pathname) VfsPath; ssize_t idx = h_idx_from_data(hd); RETURN_STATUS_IF_ERR(idx); // (don't want to do this before the add-reference exit, // so as not to waste tags for often allocated handles.) const Tag tag = gen_tag(); Handle h = handle(idx, tag); // can't fail. hd->h = h; hd->key = key; hd->type = type; hd->refs = 1; if(!(flags & RES_NO_CACHE)) hd->keep_open = 1; if(flags & RES_DISALLOW_RELOAD) hd->disallow_reload = 1; hd->unique = (flags & RES_UNIQUE) != 0; hd->pathname = pathname; if(key && !hd->unique) key_add(key, h); Status err = call_init_and_reload(h, type, hd, vfs, pathname, init_args); if(err < 0) goto fail; return h; fail: // reload failed; free the handle hd->keep_open = 0; // disallow caching (since contents are invalid) (void)h_free(h, type); // (h_free already does WARN_IF_ERR) // note: since some uses will always fail (e.g. loading sounds if // g_Quickstart), do not complain here. return (Handle)err; }
char* setparsed(char *c, char **v) { char type[2], *argv[2]; unsigned int i; if(!v[0] || !v[1]) return "Nothing to parse."; if(isalpha(c[0])) { argv[0] = v[1]; argv[1] = NULL; return var_set(v[0], argv); } else if(c[0] != '<') return "Invalid first char."; if(strstr(v[0], "Button")) return button_add(v[0], v[1]); memset(&type, '-', sizeof(type)); for(i = 0; v[i] && i < LEN(type); i++) type[i] = (c[i + 2] == '\'' ? 'c' : (isdigit(c[i + 2]) ? 'i' : (c[i + 2] == '<' ? 'm' : (isalpha(c[i + 2]) ? 'n' : '-')))); for(i = 0; i < LEN(argv); i++) argv[i] = v[i + 2]; return key_add(v[0], v[1], &argv, &type); }
IC void key_mad(CKey &res, const CKey &k0, const CKey& k1, float v) { CKey k ; key_scale(k,k1,v); key_add(res,k,k0); }
static int curses_init(const struct sessmgr_sw *sm) { extern int Numrows, Numcols; if (!isatty(0)) return 0; if (initted) { #ifdef RAW_SESSMGR set_curterm(my_term); #endif refresh(); /* bring curses back to life */ } else { initscr(); /* be nice to trap errors... */ #ifdef COLOR_SUPPORT /* * I assume the curses manpage tells the truth when it claims that * colors are initialized to RGB defaults. If not, I may need to set * up the colors in question... */ if (has_colors() && start_color() != ERR && COLORS >= 8) { color_pair_map = mallocw(COLOR_PAIRS * sizeof *color_pair_map); memset(color_pair_map, -1, COLOR_PAIRS * sizeof *color_pair_map); map_colors(COLOR_BLACK, COLOR_WHITE); /* default color pair */ if(!MainColors) MainColors = LIGHTGRAY+(BLACK<<4); /* not high-intensity */ } else MainColors = 0; /* no colors available */ #endif my_term = cur_term; noecho(); nonl(); raw(); keys = key_init(); key_add(key_down, DNARROW); key_add(key_f1, -3); key_add(key_f2, -4); key_add(key_f3, -5); key_add(key_f4, -6); key_add(key_f5, -7); key_add(key_f6, -8); key_add(key_f7, -9); key_add(key_f8, -10); key_add(key_f9, -11); #ifdef M_UNIX /* SCO botches it, as per usual */ key_add(key_f0, -2); #else key_add(key_f10, -2); #endif key_add(key_left, LTARROW); key_add(key_right, RTARROW); key_add(key_up, UPARROW); key_add("\177", '\b'); /* so DEL behaves as BS */ initted = 1; } Suspense = 0; Numrows = LINES; Numcols = COLS; return 1; }