const char* name_t::map_string(const char* str) { if (!str || !*str) return map_string(empty_string_s, empty_hash_s); // Once fnv1a is in master we can make the hash faster // with a call to the sentinel variant. std::size_t hash(detail::name_hash(str, std::strlen(str))); return map_string(str, hash); }
int get_input(double *val) { BOOLEAN inbounds = TRUE; char input_str[MAX_FIELD] = ""; int return_val; mouse_stat mouse_tel; // mouse telemetry record bell(); set_keyboard_color(BLACK, GREEN); input_monitor(); // loop until they hit ESC or they type in a decent value do { return_val = map_string( 66, 18, WHITE, BLUE, BLACK, LIGHTGRAY, MAX_FIELD, &mouse_tel, input_str, 0 ); // THF patch if (sscanf(input_str, "%lf", val) == 0) { err_message("Incorrect input. Please try again."); inbounds = FALSE; } else { if(*val < 100000.0 && *val > -10000.0) { inbounds = TRUE; } else { inbounds = FALSE; err_message("Input out of bounds."); } } } while((return_val != EscKey) && (inbounds == FALSE)); set_keyboard_color(BLACK, LIGHTGRAY); clear_monitor(); return return_val; }
List_ * get_path(Env * xs) { String_ * path_str = search(xs, string("PATH")); if (path_str) { return map_string(augment_path, tokenize(path_str, string(":"))); } else { return nil(); } }
static PyObject * Map_str(Map * self) { char mapstr[100]; map_string(self->map, mapstr); char str[200]; sprintf(str, "Map: %s", mapstr); return PyUnicode_FromString(str); }
static int send_key_request (int sock, char * phrase, unsigned char * addr, int * nbits) { /* compute the destination address from the phrase */ unsigned char destination [ADDRESS_SIZE]; char * mapped; int mlen = map_string (phrase, &mapped); sha512_bytes (mapped, mlen, (char *) destination, 1); free (mapped); random_bytes ((char *) addr, ADDRESS_SIZE); *nbits = 8; int dsize = 1; /* nbits_fingerprint with no key */ int psize = -1; struct allnet_header * hp = create_packet (dsize, ALLNET_TYPE_KEY_REQ, 10, ALLNET_SIGTYPE_NONE, addr, *nbits, destination, *nbits, NULL, NULL, &psize); if (hp == NULL) { printf ("send_key_request: unable to create packet of size %d/%d\n", dsize, psize); return 0; } int hsize = ALLNET_SIZE(hp->transport); if (psize != hsize + dsize) { printf ("send_key_request error: psize %d != %d = %d + %d\n", psize, hsize + dsize, hsize, dsize); return 0; } char * packet = (char *) hp; struct allnet_key_request * kp = (struct allnet_key_request *) (packet + hsize); kp->nbits_fingerprint = 0; #ifdef DEBUG_PRINT printf ("sending %d-byte key request\n", psize); #endif /* DEBUG_PRINT */ if (! send_pipe_message_free (sock, packet, psize, ALLNET_PRIORITY_LOCAL)) { printf ("unable to send key request message\n"); return 0; } return 1; }
int ft_prop(struct ft_cxt *cxt, const char *name, const void *data, unsigned int sz) { int off, len; off = map_string(cxt, name); if (off == NO_STRING) return -1; len = 12 + _ALIGN(sz, 4); if (!ft_make_space(cxt, &cxt->p, FT_STRUCT, len)) return -1; ft_put_word(cxt, OF_DT_PROP); ft_put_word(cxt, sz); ft_put_word(cxt, off); ft_put_bin(cxt, data, sz); return 0; }