/* * save_bindings: This writes all the key bindings for ircII to the given * FILE pointer suitable for being /LOADed again in the future. */ void save_bindings (FILE *fp, int do_all) { int meta, j; int charsize = charset_size(); char meta_str[10]; *meta_str = 0; for (meta = 0; meta <= MAX_META; meta++) { if (meta != 0) sprintf(meta_str, "META%d-", meta); for (j = 0; j < charsize; j++) { if (keys[meta] && KEY(meta, j) && KEY(meta, j)->changed) { if (KEY(meta, j)->key_index < 0) fprintf(fp, "BIND %s%s META%d\n", meta_str, display_key(j), -(KEY(meta, j)->key_index)); else fprintf(fp, "BIND %s%s %s %s\n", meta_str, display_key(j), key_names[KEY(meta, j)->key_index].name, SAFE(KEY(meta, j)->stuff)); } } } }
/* * show_binding: Given an unsigned character 'X' in the meta map 'Y', this * function will display to the screen the status of that bindings in a * human-readable way. */ static void show_binding (int meta, uc c) { char meta_str[8]; *meta_str = 0; if (meta < 1 || meta > MAX_META) meta = 0; else sprintf(meta_str, "META%d-", meta); if (keys[meta] && KEY(meta, c)) { #ifdef GUI if(meta == MAX_META && c < MAX_MOUSE) say("%s is bound to %s %s", mouse_actions[c], key_names[(*keys[meta])[c]->key_index].name, SAFE(KEY(meta, c)->stuff)); else if (KEY(meta, c)->key_index < 0) #else if (KEY(meta, c)->key_index < 0) #endif say("%s%s is bound to META%d_CHARACTER", meta_str, display_key(c), -(KEY(meta, c)->key_index)); else say("%s%s is bound to %s %s", meta_str, display_key(c), key_names[KEY(meta, c)->key_index].name, SAFE(KEY(meta, c)->stuff)); } else say("%s%s is bound to NOTHING", meta_str, display_key(c)); }
char *convert_to_keystr(char *key) { int ret, loc; static char keyloc[80]; ret = lookup_function(key, &loc); *keyloc = 0; if (ret == 1) { char meta_str[8]; int i, j; int charsize = charset_size(); *meta_str = 0; for (i = 0; i <= MAX_META; i++) { if (!keys[i]) continue; for (j = 0; j < charsize; j++) if (KEY(i, j) && KEY(i, j)->key_index == loc) { if (i > 0) sprintf(meta_str, "META%d-", i); sprintf(keyloc, "%s%s", meta_str, display_key(j)); return keyloc; } } } return keyloc; }
int expose_hook(t_env *env) { if (env->image == NULL) create_image(env); ft_draw_image(env); mlx_put_image_to_window(env->mlx, env->win ,env->image, 0, 0); if (env->ui == 1) { display_key(env); ft_display_variable(env); } mlx_do_sync(env->mlx); ft_clean(env); return (0); }
int display_info(datum key, datum val) { char *ptr; int i = 0; dav_lock_discovery_fixed ld; uuid_t locktoken; time_t expires; if (val.dsize == 0) return(0); ptr = val.dptr; while(i < val.dsize) { switch (*(ptr + i++)) { case DAV_LOCK_DIRECT: { char *owner; char *auth_user; /* Create and fill a lock_discovery structure */ memcpy(&ld, ptr + i, sizeof(ld)); i += sizeof(ld); memcpy(&locktoken, ptr + i, sizeof(locktoken)); i += sizeof(locktoken); owner = ptr + i; i += strlen(owner) + 1; auth_user = ptr + i; i += strlen(auth_user) + 1; printf(" -- ["); display_key(key); printf("]: direct lock [%s,%s]", ld.scope == DAV_LOCKSCOPE_EXCLUSIVE ? "exclusive" : "shared", ld.type == DAV_LOCKTYPE_WRITE ? "write" : "unknown"); if(ld.depth == DAV_INFINITY) printf(" depth infinite\n"); else printf(" depth %i\n", ld.depth); if (ld.timeout == 0) { printf(" Timeout : infinite\n"); } else { char *foo; foo = ctime(&ld.timeout); foo[strlen(foo)-1] = 0; printf(" Timeout : [%s] (in %li seconds)\n", foo, ld.timeout - time(NULL)); } printf(" Token : [%s]\n" " Owner : \"%s\"\n" " Auth_User: \"%s\"\n", show_uuid(&locktoken), owner[0] == 10 ? "" : owner, auth_user); break; } case DAV_LOCK_INDIRECT: { datum keyref = { 0 }; /* Fill a dav_datum with this info, recurse to fill * information from that entry in the database */ memcpy(&locktoken, ptr + i, sizeof(uuid_t)); i += sizeof(uuid_t); memcpy(&expires, ptr + i, sizeof(time_t)); i += sizeof(time_t); memcpy(&keyref.dsize, ptr + i, sizeof(int)); i += sizeof(int); keyref.dptr = ptr + i; i += keyref.dsize; printf(" -- ["); display_key(key); printf("]: indirect lock by ["); display_key(keyref); printf("]\n"); if (expires == 0) { printf(" Timeout : infinite\n"); } else { char *foo; foo = ctime(&expires); foo[strlen(foo)-1] = 0; printf(" Timeout : [%s] (in %li seconds)\n", foo, expires - time(NULL)); } printf(" Token : [%s]\n", show_uuid(&locktoken)); break; } default: printf("### Invalid token\n"); return -1; } } return 0; }
/* * This program is used to generate and display WAN boot encryption and * hash keys. The paths to the keystores are predetermined. That is, the * master keystore (used to store a master HMAC SHA1 key) will always * reside in the default location, MASTER_KEY_FILE. The client keystores * will always reside in default locations that are computed using their * network number and cid values. * * Note: * The master keystore can store client keys too. This program * cannot be used to insert client keys into the master keystore. * However, it must not corrupt any client keystore inserted into * the file by other means (keymgmt). * * We do not do any file locking scheme. This means that if two * keygen commands are run concurrently, results can be disastrous. * * Returns: * KEYGEN_SUCCESS or KEYGEN_ERROR. */ int main(int argc, char **argv) { char filename[PATH_MAX]; char *filenamep; int c; boolean_t is_client = B_FALSE; boolean_t is_master = B_FALSE; boolean_t display = B_FALSE; char *net = NULL; char *cid = NULL; wbku_key_attr_t ka; wbku_retcode_t ret; /* * Do the necessary magic for localization support. */ (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); /* * Initialize program name for use by wbku_printerr(). */ wbku_errinit(argv[0]); /* * At the very least, we'll need one arg. */ if (argc < 2) { usage(argv[0]); return (KEYGEN_ERROR); } /* * Parse the options. */ ka.ka_type = WBKU_KEY_UNKNOWN; while ((c = getopt(argc, argv, "dcmo:")) != EOF) { switch (c) { case 'd': /* * Display a key. */ display = B_TRUE; break; case 'o': /* * Suboptions. */ if (process_option(optarg, &net, &cid, &ka) != 0) { usage(argv[0]); return (KEYGEN_ERROR); } break; case 'c': is_client = B_TRUE; break; case 'm': is_master = B_TRUE; break; default: usage(argv[0]); return (KEYGEN_ERROR); } } /* * Must be operating on a master or client key and if * it's a client key, then type must have been given. */ if ((is_client == is_master) || (is_client && ka.ka_type == WBKU_KEY_UNKNOWN)) { usage(argv[0]); return (KEYGEN_ERROR); } /* * If operating on the master key, then it is an HMAC SHA1 * key. Build the correct 'ka'. If we're working on a client * key, the 'ka' was already built as part of option parsing. */ if (is_master) { ret = wbku_str_to_keyattr(WBKU_KW_HMAC_SHA1, &ka, WBKU_HASH_KEY); if (ret != WBKU_SUCCESS) { wbku_printerr("Internal error\n"); return (KEYGEN_ERROR); } filenamep = MASTER_KEY_FILE; } else { /* * Build the path to the client keystore. */ if (create_client_filename(filename, sizeof (filename), net, cid, !display) != KEYGEN_SUCCESS) { return (KEYGEN_ERROR); } filenamep = filename; } /* * If display chosen, go do it. */ if (display) { return (display_key(filenamep, &ka, is_master)); } /* * Can't generate RSA key here. */ if (ka.ka_type == WBKU_KEY_RSA) { wbku_printerr("keygen cannot create RSA key\n"); return (KEYGEN_ERROR); } /* * If generating a master key, go do it. */ if (is_master) { return (master_gen_key(&ka)); } /* * Must be generating a client key, go do it. */ if (net == NULL) { net = default_net; } if (cid == NULL) { cid = default_cid; } if (client_gen_key(filename, &ka, net, cid) != KEYGEN_SUCCESS) { return (KEYGEN_ERROR); } return (KEYGEN_SUCCESS); }