DNSServiceErrorType DNSSD_API TXTRecordSetValue( TXTRecordRef *txtref, const char *key, uint8_t length, const void *value) { TXTRecordInternal *t; uint8_t *p; size_t l, n; AVAHI_WARN_LINKAGE; assert(key); assert(txtref); l = strlen(key); if (*key == 0 || strchr(key, '=') || l > 0xFF) /* Empty or invalid key */ return kDNSServiceErr_Invalid; if (!(t = INTERNAL_PTR(txtref))) return kDNSServiceErr_NoMemory; n = l + (value ? length + 1 : 0); if (n > 0xFF) return kDNSServiceErr_Invalid; if (make_sure_fits_in(t, 1 + n) < 0) return kDNSServiceErr_NoMemory; remove_key(t, key); p = t->buffer + t->size; *(p++) = (uint8_t) n; t->size ++; memcpy(p, key, l); p += l; t->size += l; if (value) { *(p++) = '='; memcpy(p, value, length); t->size += length + 1; } assert(t->size <= t->max_size); return kDNSServiceErr_NoError; }
static void editfile(char *filename){ int mode = 0; //1 edit mode printbuffer(); int location = k_strlen(file_buffer); typeOffset =(location+1)*2; updateCursor(typeOffset/2); typeTeBottom(); key next; while(1){ if(key_queue_is_empty()) continue; next = remove_key(); if(mode){ if(next.scancode==75 && location>0){ location--; typeOffset =2*getScreenPos(location); updateCursor(typeOffset/2);}//left arrow if(next.scancode==77 && location<fileBufferLength()-1){ location++; typeOffset =2*getScreenPos(location); updateCursor(typeOffset/2);}//right arrow if(next.scancode==72 && getScreenPos(location)>VGA_W){ int desired = getScreenPos(location)-VGA_W; while(getScreenPos(location)>desired) location--; typeOffset =2*getScreenPos(location); updateCursor(typeOffset/2);}//up arrow if(next.scancode==80 && getScreenPos(location)/VGA_W<getScreenPos(fileBufferLength())/VGA_W){ int desired = getScreenPos(location)+VGA_W; while(getScreenPos(location)<desired && location<fileBufferLength()-1) location++; if(getScreenPos(location)>desired) location--; typeOffset =2*getScreenPos(location); updateCursor(typeOffset/2);}//down arrow if(next.key==27) { mode =0; typeTeBottom(); continue; } if(next.key==0) continue; if(next.key!='\b') addToFileBuff(next.key, location++);//file_buffer[location++]=next.key; else removeFromFileBuff(location--);//file_buffer[--location]=0; clearScreen(); printbuffer(); typeOffset = 2*getScreenPos(location); updateCursor(typeOffset/2); } else{ if(next.key=='q') break; else if(next.key=='w') createorreplacefile(filename, file_buffer); else if(next.key=='e') { mode = 1; clearScreen(); printbuffer();} } } }
void readCommand(){ clearBuffer(); int pos = 0, line=((typeOffset/2)/VGA_W); //%VGA_H; clearLine(); updateCursor(typeOffset/2); key next; while(1){ if(key_queue_is_empty()) continue; next = remove_key(); /*printint(next.scancode); print(" "); continue;*/ if(next.scancode==75 && pos>0){pos--;} //left arrow if(next.scancode==77 && pos<bufferLength()-1){pos++;} //right arrow if(next.scancode==72) { lookupHistory(); pos=k_strlen(textBuffer); }//up arrow if(next.scancode==80) { lookdownHistory(); pos=k_strlen(textBuffer); }//down arrow if(next.key=='\n') { if(typeOffset>(VGA_H-1)*VGA_W*2) {scroll();typeOffset-=2*VGA_W;} typeOffset=(typeOffset+VGA_W*2)-(typeOffset/2)%VGA_W*2; return; }else if(next.key=='\b') {if(pos==0) continue; else charFromBuffer(pos--);} else if(next.key=='\t') { int num = splitString(textBuffer, ' '); int i; for(i =0;i<num;i++){argv[i]=stringArray[i];} char *ac = autoComp(argv[i-1]); while(*ac!=0) {charToBuffer(*ac,pos++); ac++;} }else if(next.key!=0) {if(pos>(BUFFERSIZE)/2-4) continue; else charToBuffer(next.key, pos++);} if(line==VGA_H-1 && bufferLength()>=VGA_W){scroll();line--;} typeOffset = line*VGA_W*2; typePrompt(); int save = typeOffset; print(textBuffer); clearLine(); typeOffset = save+pos*2; updateCursor(typeOffset/2); } }
static void key_removed (DBusGProxy *proxy, const char *key, CryptUIKeyset *keyset) { gchar *k = NULL; if (!keyset->priv->expand_keys) key = k = cryptui_key_get_base (key); if (g_hash_table_lookup (keyset->priv->keys, key)) { /* Remove all cached properties for this key */ g_hash_table_remove (keyset->priv->key_props, key); remove_key (key, NULL, keyset); } g_free (k); }
DNSServiceErrorType DNSSD_API TXTRecordRemoveValue(TXTRecordRef *txtref, const char *key) { TXTRecordInternal *t; int found; AVAHI_WARN_LINKAGE; assert(key); assert(txtref); if (*key == 0 || strchr(key, '=') || strlen(key) > 0xFF) /* Empty or invalid key */ return kDNSServiceErr_Invalid; if (!(t = INTERNAL_PTR(txtref))) return kDNSServiceErr_NoError; found = remove_key(t, key); return found ? kDNSServiceErr_NoError : kDNSServiceErr_NoSuchKey; }
bool AvlTree<T>::remove_key(NodePtr node) { if(!node) { return false; } if(!node->has_both_sons()) { NodePtr son; son = node->has_lson() ? node->get_lson() : node->get_rson(); if(node == m_root) { m_root = son; } node->substitute(son); rebalance(son); m_size--; } else { auto next = node->find_next(); node->set_value(next->get_value()); remove_key(next); } return true; }
int iter_delete(int target,Node *pnt){ int k; int found; if (pnt==NULL) return FALSE; else{ found=linear_search(target,pnt,&k); if (found) if (pnt->branch[k-1]){ find_successor(pnt,k); if (!(found=iter_delete(pnt->key[k],pnt->branch[k]))) printerror("Key not found."); }else remove_key(pnt,k); else found=iter_delete(target,pnt->branch[k]); if (pnt->branch[k] != NULL) if (pnt->branch[k]->count<MIN_ORDER) restore_key(pnt,k); return found; } }
/* * @return: * 1 : needed to be checked that the node @t is empty leaf or not! * 0 : all done successfully * -1: cannot find node(symbol is not in trie) */ static int remove_key(struct node *n, const u8 *p, u32 sz, void(*vfree)(void *)) { register int fi = *p >> 4; register int bi = *p & 0x0f; if (sz > 0) { /* check that there is front & back node */ if (n->n[fi] && n->n[fi]->n[bi]) { switch(remove_key(n->n[fi]->n[bi], p + 1, sz - 1, vfree)) { case 1: return remove_empty_byte_leaf(n, *p); case 0: return 0; } } /* Cannot find symbol! */ return -1; } else { /* * End of stream. * We need to check this node has valid data. * If yes, remove value! * If not, key is not valid one! */ if (n->v) { if (vfree) (*vfree)(n->v); n->v = NULL; return 1; } else return -1; } }
int main() { Chave chave, inicializadora; short rrn, pos; strcpy(inicializadora.chave, "SHE01\0"); BTPAGE page; if (btopen()) /* try to open btree.dat and get root */ printf("Arquivo aberto de índice aberto com sucesso!\n"); else root = create_tree(inicializadora); /* if btree.dat not there, create it */ strcpy(chave.chave, "BBB02\0"); chave.rrn_dados = 22; insert(root, chave); strcpy(chave.chave, "CCC02\0"); insert(root, chave); strcpy(chave.chave, "DDD02\0"); insert(root, chave); strcpy(chave.chave, "EEE02\0"); insert(root, chave); strcpy(chave.chave, "FFF02\0"); insert(root, chave); strcpy(chave.chave, "GGG02\0"); insert(root, chave); strcpy(chave.chave, "HHH02\0"); insert(root, chave); strcpy(chave.chave, "III02\0"); insert(root, chave); strcpy(chave.chave, "JJJ02\0"); insert(root, chave); strcpy(chave.chave, "KKK02\0"); insert(root, chave); strcpy(chave.chave, "LLL02\0"); insert(root, chave); strcpy(chave.chave, "MMM02\0"); insert(root, chave); strcpy(chave.chave, "NNN02\0"); insert(root, chave); strcpy(chave.chave, "OOO02\0"); insert(root, chave); strcpy(chave.chave, "PPP02\0"); insert(root, chave); strcpy(chave.chave, "QQQ02\0"); insert(root, chave); strcpy(chave.chave, "RRR02\0"); insert(root, chave); strcpy(chave.chave, "SSS02\0"); chave.rrn_dados = 45; insert(root, chave); strcpy(chave.chave, "TTT02\0"); insert(root, chave); strcpy(chave.chave, "UUU02\0"); insert(root, chave); strcpy(chave.chave, "VVV02\0"); insert(root, chave); strcpy(chave.chave, "VVX02\0"); insert(root, chave); strcpy(chave.chave, "VVW02\0"); insert(root, chave); strcpy(chave.chave, "WWW02\0"); insert(root, chave); strcpy(chave.chave, "WWY02\0"); insert(root, chave); strcpy(chave.chave, "YYY02\0"); insert(root, chave); strcpy(chave.chave, "XXX02\0"); insert(root, chave); strcpy(chave.chave, "ZZZ02\0"); insert(root, chave); printf("\n"); strcpy(chave.chave, "BBB02\0"); if (search_key_on_tree(root, chave, &rrn, &pos)) printf("RRN %d\n", rrn); else printf("Nao achouw\n"); print_btree(root); strcpy(chave.chave, "ZZZ02\0"); remove_key(root, chave); print_btree(root); strcpy(chave.chave, "YYY02\0"); remove_key(root, chave); print_btree(root); strcpy(chave.chave, "VVX02\0"); remove_key(root, chave); print_btree(root); btclose(); return 0; }
int main(int argc, char *argv[]) { int i; long type = REG_SZ; char c, path[256], key[256], *value = NULL; HKEY root = 0; int Option_Index; int list = 0, del = 0; int newkey, status; static struct option Long_Options[] = { {"registry", 1, 0, 'r'}, {"list", 0, 0, 'l'}, {"key", 1, 0, 'k'}, {"value", 1, 0, 'v'}, {"type", 1, 0, 't'}, {"del", 0, 0, 'd'}, }; while(1) { c = getopt_long(argc, argv, "r:lk:v:t:id", Long_Options, &Option_Index); if (c == EOF) break; switch(c) { case 'r': localregpathname = optarg; break; case 'l': list = 1; break; case 'k': parse_key(optarg, &root, path, key); break; case 'v': value = optarg; break; case 't': if (!strcmp(optarg, "string")) type = REG_SZ; else if (!strcmp(optarg, "dword")) type = REG_DWORD; break; case 'd': del = 1; break; } } if (localregpathname == NULL || (! list && ! root)) { printf("Must specify '-r' and either '-k' or '-l'\n"); return 1; } if (del && (list || value)) { printf("Can't specify '-d' along with '-l' or '-v'\n"); return 1; } open_registry(); insert_handle(HKEY_LOCAL_MACHINE, "HKLM"); insert_handle(HKEY_CURRENT_USER, "HKCU"); if (del) { char tmpname[256]; sprintf(tmpname, "%s\\%s", path, key); remove_key(root, tmpname); return 0; } if (list) { for (i=0; i < reg_size; i++) { if (regs[i].type == DIR) { printf("Directory: %s\n", regs[i].name); } else if (regs[i].type == REG_DWORD) { DWORD v = *(DWORD *)regs[i].value; printf("%s :: %08x type: DWORD\n", regs[i].name, v); } else if (regs[i].type == REG_SZ) { printf("%s :: '%s' len: %d type: String\n", regs[i].name, regs[i].value, regs[i].len); } else { printf("%s :: '%s' len: %d type: %08x\n", regs[i].name, regs[i].value, regs[i].len, regs[i].type); } } } if (root) { RegCreateKeyExA(root, path, 0, 0, 0, 0, 0, &newkey, &status); if (value != NULL) { int len; DWORD v; if (type == REG_DWORD) { len = sizeof(DWORD); v = strtoul(value, NULL, 0); value = (char *)&v; } else len = strlen(value)+1; printf("%08x -- %d\n", *value, len); RegSetValueExA(newkey, key, 0, type, value, len); } } return 0; }
int main (int argc, char **argv) { apr_pool_t *pool; char *to_remove = NULL; int index; int c; int action = 0; if (argc < 2) { help(); return 0; } while ((c = getopt (argc, argv, "nkxsdahvur:")) != -1) switch (c) { case 'd': action = action | PRINT; break; case 'u': action = action | PRINT_MODSEC_VARS; break; case 'x': action = action | PRINT_ONLY_EXPIRED; break; case 'k': action = action | SHRINK; break; case 's': action = action | STATUS; break; case 'n': action = action | EXTRACT; break; case 'r': to_remove = optarg; break; case 'v': verbose = 1; break; case '?': if (optopt == 'r') fprintf (stderr, "Option -%c requires an argument.\n", optopt); else if (isprint (optopt)) fprintf (stderr, "Unknown option `-%c'.\n", optopt); else fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt); return 1; case 'h': default: help(); return; } apr_initialize(); /* atexit(apr_terminate()); */ apr_pool_create(&pool, NULL); for (index = optind; index < argc; index++) { int ret = 0; char *file = argv[index]; apr_sdbm_t *db = NULL; printf ("Openning file: %s\n", file); ret = open_sdbm(pool, &db, argv[index]); if (ret < 0) { printf("Failed to open sdbm: %s\n", file); goto that_is_all_folks; } printf("Database ready to be used.\n"); if (to_remove) { printf("Removing key: %s\n", to_remove); remove_key(pool, db, to_remove); continue; } if (action == 0) { printf("Choose an option.\n"); goto that_is_all_folks; } dump_database(pool, db, action); apr_sdbm_close(db); } apr_pool_destroy(pool); that_is_all_folks: return 0; }
bool AvlTree<T>::remove_key(const T& value) { return remove_key(find_key(value)); }
/** * * 删除B树种的关键字 * * * B树的特性: * * 除根节点之外的节点必须满足: * ceil(m/2) - 1 <= n <= m-1 * n表示关键字个数 * * 对于四阶树来说,也就是关键字满足: * 1 <= n <= 3 * */ void remove_key(bnode * * root, int key) { if(root == null) { return; } bnode * node = * root; int pos = -1; bnode * theone = find(node, key, &pos); if(theone == NULL) { return; } else { //如果节点是叶节点,则直接删除元素 if(theone -> isleaf == true) { //则将此元素后面的元素向前移来删除此元素 int i = pos; while(i < theone -> keynum) { theone -> keys[i] = theone -> keys[i + 1]; i++; } //节点元素数减1 theone -> keynum --; //判断当前节点在删除关键字后还是否满足B树的节点关键字特性 merge_sibling(theone); } /** * 如果被删除的不是叶子节点,则有三种情况: * 1.左边能借 * 2.右边能借 * 3.左右都不能借 */ else { //如果节点左孩子满足富余节点的特性 if( theone -> children[pos] -> keynum > T - 1 ) { // printf("%s\n", "left"); int pos_left_max, key_left_max= -1; bnode * findnode = find_max( theone -> children[pos], &pos_left_max, &key_left_max); if(findnode != null) { remove_key(&findnode, key_left_max); } theone -> keys[pos] = key_left_max; } //如果节点右孩子满足富余节点的特性 else if(theone -> children[pos+1] -> keynum > T - 1 ) { // printf("%s\n", "right"); int pos_right_min,key_right_min= -1; bnode * findnode = find_min( theone -> children[pos+1], &pos_right_min, &key_right_min); if(findnode != null) { remove_key(&findnode, key_right_min); } theone -> keys[pos] = key_right_min; } //如果左右子节点关键字都不够用,那么需要先把左子节点,当前节点,右子节点进行合并 else if( theone -> children[pos] -> keynum == T - 1 && theone -> children[pos+1] -> keynum == T - 1) { // printf("%s\n", "mid"); //父节点下移到左子节点 theone -> children[ pos ] -> keys[ theone -> children[ pos ] -> keynum ] = theone -> keys[ pos ]; theone -> children[ pos ] -> keynum ++; //右子节点关键字并入左子节点 int i = 0; while( i < theone -> children[ pos + 1 ] -> keynum) { theone -> children[ pos ] -> keys[ theone -> children[ pos ] -> keynum + i ] = theone -> children[ pos + 1] -> keys[ i ]; theone -> children[ pos ] -> children[ theone -> children[ pos ] -> keynum + i ] = theone -> children[ pos + 1] -> children[ i ]; theone -> children[ pos ] -> children[ theone -> children[ pos ] -> keynum + i ] -> p_pos = theone -> children[ pos ] -> keynum + i; theone -> children[ pos ] -> keynum ++; i++; } //不要忘了处理最后一个孩子 theone -> children[ pos ] -> children[ theone -> children[ pos ] -> keynum + i ] = theone -> children[ pos + 1] -> children[ i ]; theone -> children[ pos ] -> children[ theone -> children[ pos ] -> keynum + i ] -> p_pos = theone -> children[ pos ] -> keynum + i; theone -> children[ pos ] -> keynum ++; //父节点全部孩子左移 int j = pos; while(j < theone -> keynum) { theone -> keys[j] = theone -> keys[j + 1]; theone -> children[j + 1] = theone -> children[j + 2]; j++; } theone -> keynum --; //不要忘记更新此节点指向的右兄弟节点(为了层级遍历) theone -> children[ pos ] -> right_sibling = theone -> children[ pos + 1 ]; //在子节点中继续删除元素 remove_key( & (theone -> children[pos]), key ); } } } }
//********************************************************************** //* The handout expected us to brute force the key. //* If not marking exactly to a mark scheme ignore this function. //* Its only called if the program is called with the -bf flag //* It tries every key against the first two characters building up a list //* of the most likely. Then uses frequency analysis to knock out unlikely keys. //* until the correct key is found uint16_t bf_key(uint8_t *inbuf, long buffsize, char bf) { struct key_l *h = NULL, *t = NULL, *iter = NULL, *tmp, *bestKey = NULL, *secondBestKey = NULL; uint16_t val, scr, cur, keycount = 0 , cutoff = 10; uint32_t key; long lim = 0; uint8_t c1 = 0, c2 = 0, pos = 2, *check = NULL; if (buffsize < 4) { printf("I need at least 4 bytes! I mean come on... Outputting garbage\n"); return 0; } if (buffsize > 40) lim = 40; else lim = buffsize; if (bf) { check = (uint8_t*)malloc(sizeof(uint8_t)*lim); if (check == NULL) printf("Warning: Check malloc failed - Best guess will be used\n"); } cur = inbuf[1] | (uint16_t)(inbuf[0]) << 8; // Round 1 - for every possible key decrypt the first two characters. // Score them based on the frequency data & keep brack of the best. for (key = 0; key < 0xFFFF; key++) { val = cur^key; c1 = val >> 8; c2 = val & 0xFF;; scr = charVal(c1) + charVal(c2) + biVal(val); if (scr > 20) { t = add_key(&h,t,key,scr); if (bestKey == NULL || scr > bestKey->score) { secondBestKey = bestKey; bestKey = t; } keycount++; } } // Subsequent rounds. While we have more than 20 keys // And have looked at less than 20 characters & haven't exhausted the buffer while (keycount > 20 && pos < 20 && pos < buffsize) { // Concatenate the two characters. cur = inbuf[pos+1] | (uint16_t)(inbuf[pos]) << 8; iter = h; // Go through all remaining keys while (iter != NULL) { // Check the score for the output characters val = cur^iter->key; c1 = val >> 8; c2 = val & 0xFF; scr = charVal(c1) + charVal(c2); if (scr > 0) { scr += biVal(val); iter->score += scr; if (scr > 20 && iter->score > cutoff) { if (iter->score > bestKey->score) { secondBestKey = bestKey; bestKey = iter; } } else { tmp = iter; iter = iter->next; if (tmp->key == bestKey->key) bestKey = getBest(bestKey->key, &secondBestKey, h); remove_key(&h, &t, tmp); keycount--; continue; } } else { tmp = iter; iter = iter->next; if (tmp->key == bestKey->key) bestKey = getBest(bestKey->key, &secondBestKey, h); remove_key(&h, &t, tmp); keycount--; continue; } iter = iter->next; } if (pos > 7 && bestKey->score > (2*secondBestKey->score)) { printf("Key took %hhu rounds. max = %lu, keycount = %hu (double second highests score)\n", pos/2, bestKey->score, keycount); pos+=20; break; } if (check != NULL) { decrypt(inbuf, check, bestKey->key, &lim); c2 = 2; for (c1 = 0; c1 < lim && c2; c1++) { if (charVal(check[c1]) < 35) c2--; } if (c1 != lim) { printf("Key failed prelim check. Abandoning 0x%X\n", bestKey->key); tmp = bestKey; bestKey = getBest(bestKey->key, &secondBestKey, h); remove_key(&h, &t, tmp); keycount--; } else { printf("Key took %hhu rounds. max = %lu, keycount = %hu (best key for round check)\n", pos/2, bestKey->score, keycount); pos+=20; break; } } cutoff*=4; pos+=2; } free(check); if (pos <=20) printf("Key took %hhu rounds. max = %lu, keycount = %hu (max blocks)\n", pos/2, bestKey->score, keycount); iter = h; key = bestKey->key; while (iter != NULL) { tmp = iter->next; free(iter); iter = tmp; } return key; }
static int set_keydefine_key(struct _select_def *conf, int key) { int oldmode; switch (key) { case KEY_TAB: ask_define(); return SHOW_DIRCHANGE; case 'a': /* add new user */ if (keymem_total < MAX_KEY_DEFINE) { int i,j; struct key_struct k; char buf[120]; clear(); move(1, 0); prints("请键入自定义键: "); do { i = igetkey(); get_key_name(i, buf); } while (!buf[0]&&i!=KEY_ESC); if (i==KEY_ESC) return SHOW_DIRCHANGE; prints("%s\n", buf); k.key = i; move(2, 0); prints("请输入替换序列(最多10个),按一次ESC结束: "); j=0; do { do { i = igetkey(); get_key_name(i, buf); } while (!buf[0]&&i!=KEY_ESC); if (i==KEY_ESC) break; prints("%s ", buf); k.mapped[j] = i; j++; if (j>=10) break; } while (1); if (j<10) k.mapped[j]=0; if (j==0) return SHOW_DIRCHANGE; k.status[0] = -1; add_key(&k); return SHOW_DIRCHANGE; } break; case 'e': set_modes(keymem[conf->pos-1].status); return SHOW_DIRCHANGE; case 's': { int i,j,x,y; struct key_struct k; char buf[120]; memmove(&k,keymem+conf->pos-1,sizeof(struct key_struct)); clear(); move(1, 0); prints("请键入自定义键: "); do { i = igetkey(); get_key_name(i, buf); } while (!buf[0]&&i!=KEY_ESC); if (i==KEY_ESC) return SHOW_DIRCHANGE; prints("%s\n", buf); k.key = i; move(2, 0); prints("请输入替换序列(最多10个),按一次ESC结束: "); j=0; do { do { i = igetkey(); get_key_name(i, buf); } while (!buf[0]&&i!=KEY_ESC); if (i==KEY_ESC) break; getyx(&y,&x); prints((x+strlen(buf)<t_columns-1)?"%s ":"\n%s ",buf); k.mapped[j] = i; j++; if (j>=10) break; } while (1); if (j<10) k.mapped[j]=0; if (j==0) return SHOW_DIRCHANGE; memcpy(keymem+conf->pos-1, &k, sizeof(struct key_struct)); return SHOW_DIRCHANGE; } break; case 'x': { struct key_struct k; int i; char buf[128]; memmove(&k,keymem+conf->pos-1,sizeof(struct key_struct)); clear(); move(1,0); prints("请键入自定义键: "); do { i=igetkey(); get_key_name(i,buf); } while (!buf[0]&&i!=KEY_ESC); if (i==KEY_ESC) return SHOW_DIRCHANGE; k.key=i; prints("%s",buf); memmove(keymem+conf->pos-1,&k,sizeof(struct key_struct)); prints("\n\n\033[1;33m%s\033[0;33m<Enter>\033[m","已更新!"); WAIT_RETURN; return SHOW_DIRCHANGE; } break; case 't': { struct key_struct k; int i,j,x,y; char buf[128]; memmove(&k,keymem+conf->pos-1,sizeof(struct key_struct)); clear(); move(1,0); prints("请输入替换序列(最多10个), 按一次ESC结束: "); for (j=0; j<10; j++) { do { i=igetkey(); get_key_name(i,buf); } while (!buf[0]&&i!=KEY_ESC); if (i==KEY_ESC) break; getyx(&y,&x); prints((x+strlen(buf)<t_columns-1)?"%s ":"\n%s ",buf); k.mapped[j]=i; } if (!j) return SHOW_DIRCHANGE; if (j<10) k.mapped[j]=0; memmove(keymem+conf->pos-1,&k,sizeof(struct key_struct)); prints("\n\n\033[1;33m%s\033[0;33m<Enter>\033[m","已更新!"); WAIT_RETURN; return SHOW_DIRCHANGE; } break; case 'd': /* delete existed user */ if (keymem_total > 0) { char ans[3]; getdata(t_lines - 1, 0, "确实要删除该定义键吗(Y/N)? [N]: ", ans, sizeof(ans), DOECHO, NULL, true); if (ans[0] == 'Y' || ans[0] == 'y') { remove_key(conf->pos-1); if (keymem_total==0) { struct key_struct key; key.key = 'A'; key.mapped[0] = 'A'; key.mapped[1] = 0; key.status[0] = 0; add_key(&key); } } return SHOW_DIRCHANGE; } break; case 'L': case 'l': oldmode = uinfo.mode; show_allmsgs(); modify_user_mode(oldmode); return SHOW_REFRESH; case 'W': case 'w': oldmode = uinfo.mode; if (!HAS_PERM(getCurrentUser(), PERM_PAGE)) break; s_msg(); modify_user_mode(oldmode); return SHOW_REFRESH; case 'u': oldmode = uinfo.mode; clear(); modify_user_mode(QUERY); t_query(NULL); modify_user_mode(oldmode); clear(); return SHOW_REFRESH; } return SHOW_CONTINUE; }
// This is called whenever the user presses Next, Back, or Finish with this step // present. Do all validation & data exchange from the dialog in this function. BOOL CCustom1Dlg::OnDismiss() { if (!UpdateData(TRUE)) return FALSE; CString sel; m_PlugTypes.GetText(m_PlugTypes.GetCurSel(), sel); // Remove the Plugin type related keys for (int i=0; i < plugin_count; i++) remove_key(plugins[i].key); remove_key(_T("FLOATING_DIALOG")); remove_key(_T("STATIC_TYPE")); remove_key(_T("TEX_TYPE")); remove_key(_T("UI_BY_MAX")); //Emptying the base class list for Class ListBox in Dlg2 ClassList.RemoveAll(); ClassList.FreeExtra(); ClassList.SetSize(0, 1); // Set plugin specific parameters for (i=0; i < plugin_count; i++) { if (_tcsicmp(sel, plugins[i].caption)!=0) continue; PlugType *plg = &plugins[i]; if (_tcsicmp(plg->sid, _T("TEXMAP_CLASS_ID"))==0) set_key(_T("TEX_TYPE"), _T("YES")); // For following plugin types the UI is automatically generated by Max if (_tcsicmp(plg->key, _T("SAMPLER_TYPE"))==0 || _tcsicmp(plg->key, _T("SHADER_TYPE"))==0 || _tcsicmp(plg->key, _T("FILTER_KERNEL_TYPE"))==0) set_key(_T("UI_BY_MAX"), _T("YES")); set_key(plg->key, _T("YES")); set_key(_T("PLUGEXT"), plg->ext); set_key(_T("SUPER_CLASS_ID"), plg->sid); // Add base class names to the base class list if (_tcsicmp(plg->bclass1, "")==0) ClassList.Add("None"); else ClassList.Add(plg->bclass1); if (_tcsicmp(plg->bclass2, "")!=0) ClassList.Add(plg->bclass2); if (!plg->rollout) set_key(_T("FLOATING_DIALOG"), _T("YES")); if (plg->staticType) set_key(_T("STATIC_TYPE"), _T("YES")); if (!plg->supported) MessageBox( _T("This plugin type is not currently supported, minimal code will be generated."), _T("Unsupported Plugin Type")); } //Deleting bitmaps return TRUE; // return FALSE if the dialog shouldn't be dismissed }