static void emit_numeric_character (struct type *type, unsigned long value, struct obstack *output) { gdb_byte *buffer; buffer = alloca (TYPE_LENGTH (type)); pack_long (buffer, type, value); obstack_grow (output, buffer, TYPE_LENGTH (type)); }
void pack_table(mnbytestream_t *bs, mnhash_t *v) { struct { mnbytestream_t *bs; } params; off_t seod0, seod1; union { uint32_t *i; char *c; } u; params.bs = bs; seod0 = SEOD(bs); pack_long(bs, 0); // placeholder seod1 = SEOD(bs); (void)hash_traverse(v, (hash_traverser_t)pack_table_cb, ¶ms); u.c = SDATA(bs, seod0); *u.i = htobe32((uint32_t)SEOD(bs) - seod1); }
/* * decimal */ static void enc_decimal(amqp_value_t *v, mnbytestream_t *bs) { pack_octet(bs, v->value.dc.places); pack_long(bs, v->value.dc.value); }
/* * uint32 */ static void enc_uint32(amqp_value_t *v, mnbytestream_t *bs) { pack_long(bs, v->value.u32); }
void pack_array(mnbytestream_t *bs, mnarray_t *v) { pack_long(bs, (uint32_t)v->elnum); array_traverse(v, (array_traverser_t)pack_array_cb, bs); }
void c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter) { enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type)); struct obstack wchar_buf, output; struct cleanup *cleanups; const char *encoding; gdb_byte *buf; struct wchar_iterator *iter; int need_escape = 0; classify_type (type, get_type_arch (type), &encoding); buf = alloca (TYPE_LENGTH (type)); pack_long (buf, type, c); iter = make_wchar_iterator (buf, TYPE_LENGTH (type), encoding, TYPE_LENGTH (type)); cleanups = make_cleanup_wchar_iterator (iter); /* This holds the printable form of the wchar_t data. */ obstack_init (&wchar_buf); make_cleanup_obstack_free (&wchar_buf); while (1) { int num_chars; gdb_wchar_t *chars; const gdb_byte *buf; size_t buflen; int print_escape = 1; enum wchar_iterate_result result; num_chars = wchar_iterate (iter, &result, &chars, &buf, &buflen); if (num_chars < 0) break; if (num_chars > 0) { /* If all characters are printable, print them. Otherwise, we're going to have to print an escape sequence. We check all characters because we want to print the target bytes in the escape sequence, and we don't know character boundaries there. */ int i; print_escape = 0; for (i = 0; i < num_chars; ++i) if (!wchar_printable (chars[i])) { print_escape = 1; break; } if (!print_escape) { for (i = 0; i < num_chars; ++i) print_wchar (chars[i], buf, buflen, TYPE_LENGTH (type), byte_order, &wchar_buf, quoter, &need_escape); } } /* This handles the NUM_CHARS == 0 case as well. */ if (print_escape) print_wchar (gdb_WEOF, buf, buflen, TYPE_LENGTH (type), byte_order, &wchar_buf, quoter, &need_escape); } /* The output in the host encoding. */ obstack_init (&output); make_cleanup_obstack_free (&output); convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (), obstack_base (&wchar_buf), obstack_object_size (&wchar_buf), 1, &output, translit_char); obstack_1grow (&output, '\0'); fputs_filtered (obstack_base (&output), stream); do_cleanups (cleanups); }
afs_int32 uss_kauth_SetFields(char *username, char *expirestring, char *reuse, char *failures, char *lockout) { #ifdef USS_KAUTH_DB static char rn[] = "uss_kauth_SetFields"; #endif afs_int32 code; char misc_auth_bytes[4]; int i; afs_int32 flags = 0; Date expiration = 0; afs_int32 lifetime = 0; afs_int32 maxAssociates = -1; afs_int32 was_spare = 0; char instance = '\0'; int pwexpiry; int nfailures, locktime, hrs, mins; if (strlen(username) > uss_UserLen) { fprintf(stderr, "%s: * User field in add cmd too long (max is %d chars; truncated value is '%s')\n", uss_whoami, uss_UserLen, uss_User); return (-1); } strcpy(uss_User, username); code = uss_kauth_CheckUserName(); if (code) return (code); /* no point in doing this any sooner than necessary */ for (i = 0; i < 4; misc_auth_bytes[i++] = 0); pwexpiry = atoi(expirestring); if (pwexpiry < 0 || pwexpiry > 254) { fprintf(stderr, "Password lifetime range must be [0..254] days.\n"); fprintf(stderr, "Zero represents an unlimited lifetime.\n"); fprintf(stderr, "Continuing with default lifetime == 0 for user %s.\n", username); pwexpiry = 0; } misc_auth_bytes[0] = pwexpiry + 1; if (!strcmp(reuse, "noreuse")) { misc_auth_bytes[1] = KA_NOREUSEPW; } else { misc_auth_bytes[1] = KA_REUSEPW; if (strcmp(reuse, "reuse")) fprintf(stderr, "must specify \"reuse\" or \"noreuse\": \"reuse\" assumed\n"); } nfailures = atoi(failures); if (nfailures < 0 || nfailures > 254) { fprintf(stderr, "Failure limit must be in [0..254].\n"); fprintf(stderr, "Zero represents unlimited login attempts.\n"); fprintf(stderr, "Continuing with limit == 254 for user %s.\n", username); misc_auth_bytes[2] = 255; } else misc_auth_bytes[2] = nfailures + 1; hrs = 0; if (strchr(lockout, ':')) sscanf(lockout, "%d:%d", &hrs, &mins); else sscanf(lockout, "%d", &mins); locktime = hrs*60 + mins; if (hrs < 0 || hrs > 36 || mins < 0) { fprintf(stderr,"Lockout times must be either minutes or hh:mm.\n"); fprintf(stderr,"Lockout times must be less than 36 hours.\n"); return KABADCMD; } else if (locktime > 36*60) { fprintf(stderr, "Lockout times must be either minutes or hh:mm.\n"); fprintf(stderr, "Lockout times must be less than 36 hours.\n"); fprintf(stderr, "Continuing with lock time == forever for user %s.\n", username); misc_auth_bytes[3] = 1; } else { locktime = (locktime * 60 + 511) >> 9; /* ceil(l*60/512) */ misc_auth_bytes[3] = locktime + 1; } if (uss_SkipKaserver) { if (uss_verbose) printf("[Skipping Kaserver as requested]\n"); return 0; } /* * Make sure the module has been initialized before we start trying * to talk to AuthServers. */ if (!initDone) { code = InitThisModule(); if (code) exit(code); } if (!uss_DryRun) { if (uss_verbose) fprintf(stderr, "Setting options for '%s' in database.\n", username); was_spare = pack_long(misc_auth_bytes); if (was_spare || flags || expiration || lifetime || (maxAssociates >= 0)) { if (!expiration) expiration = uss_Expires; code = ubik_KAM_SetFields(uconn_kauthP, 0, username, &instance, flags, expiration, lifetime, maxAssociates, was_spare, /* spare */ 0); } else fprintf(stderr, "Must specify one of the optional parameters. Continuing...\n"); if (code) { afs_com_err(uss_whoami, code, "calling KAM_SetFields for %s", username); return (code); } } /*Not a dry run */ else fprintf(stderr, "\t[Dry run - user '%s' NOT changed.]\n", username); return (0); } /*uss_kauth_SetFields */