void gen_basis() { int k, m; short blk[64]; printf("u_int dct_basis[64][64/sizeof(u_int)] = {\n"); for (k = 0; k < 64; ++k) { printf("{"); memset((char*)blk, 0, sizeof(blk)); blk[COLZAG[k]] = FIX(1); v_rdct(blk); for (m = 0; m < 64; ) { printf("%d,%d,\n", find(multab, nmul, blk[m+0]) << 24 | find(multab, nmul, blk[m+1]) << 16 | find(multab, nmul, blk[m+2]) << 8 | find(multab, nmul, blk[m+3]), find(multab, nmul, blk[m+4]) << 24 | find(multab, nmul, blk[m+5]) << 16 | find(multab, nmul, blk[m+6]) << 8 | find(multab, nmul, blk[m+7])); m += 8; } printf("},\n"); } printf("};\n\n"); }
void pkcs11_mechanism_list(FILE * outfile, const char *url, unsigned int flags, common_info_st * info) { int ret; int idx; unsigned long mechanism; const char *str; pkcs11_common(info); FIX(url, outfile, 0, info); idx = 0; do { ret = gnutls_pkcs11_token_get_mechanism(url, idx++, &mechanism); if (ret >= 0) { str = NULL; if (mechanism <= sizeof(mech_list) / sizeof(mech_list[0])) str = mech_list[mechanism]; if (str == NULL) str = "UNKNOWN"; fprintf(outfile, "[0x%.4lx] %s\n", mechanism, str); } } while (ret >= 0); return; }
// shouldn't need to check alive bit - never called for dead voices (no zombie channels possible) // FIXME: bloat int adsr(const AdsrParams* params, AdsrState* state) { int out = state->value; // TODO: use time constant to precalc coefs, skip to next if value == zing // TODO: precalculate coefficients g = 1 - exp(1/(T*fs)) // TODO: use linear ramp at attack stage? state->value = lowpass_juttu(state->currentcoef, state->nextvalue); if (++state->time >= state->nexttime) { switch (state->section) { case ADSR_ATTACK: state->currentcoef = params->decay; state->nextvalue = params->sustain; break; case ADSR_DECAY: state->currentcoef = FIX(1); state->value = params->sustain; // TODO: do i need this when it has went there already break; case ADSR_SUSTAIN: state->currentcoef = params->release; break; case ADSR_RELEASE: break; default: assert(0); // no zombie channels } state->nexttime = params->nexttime[state->section]; state->section++; } return out; }
ptr S_cputime(void) { struct timespec tp; s_gettime(time_process, &tp); return S_add(S_mul(S_integer_time_t(tp.tv_sec), FIX(1000)), Sinteger((tp.tv_nsec + 500000) / 1000000)); }
void pkcs11_get_random(FILE * outfile, const char *url, unsigned bytes, common_info_st * info) { int ret; uint8_t *output; pkcs11_common(info); FIX(url, outfile, 0, info); output = malloc(bytes); if (output == NULL) { fprintf(stderr, "Memory error\n"); exit(1); } ret = gnutls_pkcs11_token_get_random(url, output, bytes); if (ret < 0) { fprintf(stderr, "gnutls_pkcs11_token_get_random: %s\n", gnutls_strerror(ret)); exit(1); } fwrite(output, 1, bytes, outfile); return; }
static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, size_t size, struct group **res) { FILE *f; char *line = 0; size_t len = 0; char **mem = 0; size_t nmem = 0; int rv = 0; size_t i; int cs; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); f = fopen("/etc/group", "rbe"); if (!f) { rv = errno; goto done; } *res = 0; while (__getgrent_a(f, gr, &line, &len, &mem, &nmem)) { if (name && !strcmp(name, gr->gr_name) || !name && gr->gr_gid == gid) { if (size < len + (nmem+1)*sizeof(char *) + 32) { rv = ERANGE; break; } *res = gr; buf += (16-(uintptr_t)buf)%16; gr->gr_mem = (void *)buf; buf += (nmem+1)*sizeof(char *); memcpy(buf, line, len); FIX(name); FIX(passwd); for (i=0; mem[i]; i++) gr->gr_mem[i] = mem[i]-line+buf; gr->gr_mem[i] = 0; break; } } free(mem); free(line); fclose(f); done: pthread_setcancelstate(cs, 0); return rv; }
int libnet_insert_ipo(struct ipoption *opt, u_char opt_len, u_char *buf) { struct libnet_ip_hdr *ip_hdr; u_char *p; u_short s, j; u_char i; if (!buf) { return (-1); } ip_hdr = (struct libnet_ip_hdr *)(buf); s = UNFIX(ip_hdr->ip_len); if ((s + opt_len) > IP_MAXPACKET) { /* * Nope. Too big. */ #if (__DEBUG) libnet_error(LIBNET_ERR_WARNING, "insert_ipo: options list would result in too large of a packet\n"); #endif return (-1); } /* * Do we have more then just an IP header? */ if (s > LIBNET_IP_H) { /* * Move over whatever's in the way. */ memmove((u_char *)ip_hdr + LIBNET_IP_H + opt_len, (u_char *)ip_hdr + LIBNET_IP_H, opt_len); } /* * Copy over option list. We rely on the programmer having been * smart enough to allocate enough heap memory here. Uh oh. */ p = (u_char *)ip_hdr + LIBNET_IP_H; memcpy(p, opt->ipopt_list, opt_len); /* * Count up number of 32-bit words in options list, padding if * neccessary. */ for (i = 0, j = 0; i < opt_len; i++) (i % 4) ? j : j++; ip_hdr->ip_hl += j; ip_hdr->ip_len = FIX(opt_len + s); return (1); }
METHODDEF void start_pass_merged_upsample (j_decompress_ptr cinfo) { my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; INT32 i, x2; SHIFT_TEMPS /* Mark the spare buffer empty */ upsample->spare_full = FALSE; /* Initialize total-height counter for detecting bottom of image */ upsample->rows_to_go = cinfo->output_height; /* Initialize the YCC=>RGB conversion tables. * This is taken directly from jdcolor.c; see that file for more info. */ upsample->Cr_r_tab = (int *)alloc_small_wrapper((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); upsample->Cb_b_tab = (int *)alloc_small_wrapper((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(int)); upsample->Cr_g_tab = (INT32 *)alloc_small_wrapper((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); upsample->Cb_g_tab = (INT32 *)alloc_small_wrapper((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * SIZEOF(INT32)); for (i = 0; i <= MAXJSAMPLE; i++) { /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ /* The Cb or Cr value we are thinking of is x = i - MAXJSAMPLE/2 */ x2 = 2*i - MAXJSAMPLE; /* twice x */ /* Cr=>R value is nearest int to 1.40200 * x */ upsample->Cr_r_tab[i] = (int) RIGHT_SHIFT(FIX(1.40200/2) * x2 + ONE_HALF, SCALEBITS); /* Cb=>B value is nearest int to 1.77200 * x */ upsample->Cb_b_tab[i] = (int) RIGHT_SHIFT(FIX(1.77200/2) * x2 + ONE_HALF, SCALEBITS); /* Cr=>G value is scaled-up -0.71414 * x */ upsample->Cr_g_tab[i] = (- FIX(0.71414/2)) * x2; /* Cb=>G value is scaled-up -0.34414 * x */ /* We also add in ONE_HALF so that need not do it in inner loop */ upsample->Cb_g_tab[i] = (- FIX(0.34414/2)) * x2 + ONE_HALF; } }
int getrlimit(int resource, struct rlimit *rlim) { unsigned long k_rlim[2]; int ret = syscall(SYS_prlimit64, 0, resource, 0, mcfi_sandbox_mask(rlim)); if (!ret) { FIX(rlim->rlim_cur); FIX(rlim->rlim_max); } if (!ret || errno != ENOSYS) return ret; if (syscall(SYS_getrlimit, resource, mcfi_sandbox_mask(k_rlim)) < 0) return -1; rlim->rlim_cur = k_rlim[0] == -1UL ? RLIM_INFINITY : k_rlim[0]; rlim->rlim_max = k_rlim[1] == -1UL ? RLIM_INFINITY : k_rlim[1]; FIX(rlim->rlim_cur); FIX(rlim->rlim_max); return 0; }
/* * Initialize the YCbCr->RGB conversion tables. The conversion * is done according to the 6.0 spec: * * R = Y + Cr*(2 - 2*LumaRed) * B = Y + Cb*(2 - 2*LumaBlue) * G = Y * - LumaBlue*Cb*(2-2*LumaBlue)/LumaGreen * - LumaRed*Cr*(2-2*LumaRed)/LumaGreen * * To avoid floating point arithmetic the fractional constants that * come out of the equations are represented as fixed point values * in the range 0...2^16. We also eliminate multiplications by * pre-calculating possible values indexed by Cb and Cr (this code * assumes conversion is being done for 8-bit samples). */ static void TIFFYCbCrToRGBInit(TIFFYCbCrToRGB* ycbcr, TIFF* tif) { TIFFRGBValue* clamptab; float* coeffs; int i; clamptab = (TIFFRGBValue*)( (tidata_t) ycbcr+TIFFroundup(sizeof (TIFFYCbCrToRGB), sizeof (long))); _TIFFmemset(clamptab, 0, 256); /* v < 0 => 0 */ ycbcr->clamptab = (clamptab += 256); for (i = 0; i < 256; i++) clamptab[i] = i; _TIFFmemset(clamptab+256, 255, 2*256); /* v > 255 => 255 */ TIFFGetFieldDefaulted(tif, TIFFTAG_YCBCRCOEFFICIENTS, &coeffs); _TIFFmemcpy(ycbcr->coeffs, coeffs, 3*sizeof (float)); { float f1 = 2-2*LumaRed; int32 D1 = FIX(f1); float f2 = LumaRed*f1/LumaGreen; int32 D2 = -FIX(f2); float f3 = 2-2*LumaBlue; int32 D3 = FIX(f3); float f4 = LumaBlue*f3/LumaGreen; int32 D4 = -FIX(f4); int x; ycbcr->Cr_r_tab = (int*) (clamptab + 3*256); ycbcr->Cb_b_tab = ycbcr->Cr_r_tab + 256; ycbcr->Cr_g_tab = (int32*) (ycbcr->Cb_b_tab + 256); ycbcr->Cb_g_tab = ycbcr->Cr_g_tab + 256; /* * i is the actual input pixel value in the range 0..255 * Cb and Cr values are in the range -128..127 (actually * they are in a range defined by the ReferenceBlackWhite * tag) so there is some range shifting to do here when * constructing tables indexed by the raw pixel data. * * XXX handle ReferenceBlackWhite correctly to calculate * Cb/Cr values to use in constructing the tables. */ for (i = 0, x = -128; i < 256; i++, x++) { ycbcr->Cr_r_tab[i] = (int)((D1*x + ONE_HALF)>>SHIFT); ycbcr->Cb_b_tab[i] = (int)((D3*x + ONE_HALF)>>SHIFT); ycbcr->Cr_g_tab[i] = D2*x; ycbcr->Cb_g_tab[i] = D4*x + ONE_HALF; } } }
void pkcs11_generate(FILE * outfile, const char *url, gnutls_pk_algorithm_t pk, unsigned int bits, const char *label, const char *id, int detailed, unsigned int flags, common_info_st * info) { int ret; gnutls_datum_t pubkey; gnutls_datum_t cid = {NULL, 0}; unsigned char raw_id[128]; size_t raw_id_size; pkcs11_common(info); FIX(url, outfile, detailed, info); CHECK_LOGIN_FLAG(flags); if (id != NULL) { raw_id_size = sizeof(raw_id); ret = gnutls_hex2bin(id, strlen(id), raw_id, &raw_id_size); if (ret < 0) { fprintf(stderr, "Error converting hex: %s\n", gnutls_strerror(ret)); exit(1); } cid.data = raw_id; cid.size = raw_id_size; } if (outfile == stderr || outfile == stdout) { fprintf(stderr, "warning: no --outfile was specified and the generated public key will be printed on screen.\n"); } if (label == NULL && info->batch == 0) { label = read_str("warning: Label was not specified.\nLabel: "); } ret = gnutls_pkcs11_privkey_generate3(url, pk, bits, label, &cid, GNUTLS_X509_FMT_PEM, &pubkey, info->key_usage, flags); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); if (bits != 1024 && pk == GNUTLS_PK_RSA) fprintf(stderr, "note: several smart cards do not support arbitrary size keys; try --bits 1024 or 2048.\n"); exit(1); } fwrite(pubkey.data, 1, pubkey.size, outfile); gnutls_free(pubkey.data); UNFIX; return; }
void S_alloc_init() { ISPC s; IGEN g; UINT i; if (S_boot_time) { /* reset the allocation tables */ for (s = 0; s <= max_real_space; s++) { for (g = 0; g <= static_generation; g++) { S_G.base_loc[s][g] = FIX(0); S_G.first_loc[s][g] = FIX(0); S_G.next_loc[s][g] = FIX(0); S_G.bytes_left[s][g] = 0; S_G.bytes_of_space[s][g] = 0; } } /* initialize the dirty-segment lists. */ for (i = 0; i < DIRTY_SEGMENT_LISTS; i += 1) { S_G.dirty_segments[i] = NULL; } S_G.collect_trip_bytes = default_collect_trip_bytes; /* set to final value in prim.c when known */ S_protect(&S_G.nonprocedure_code); S_G.nonprocedure_code = FIX(0); S_protect(&S_G.null_vector); find_room(space_new, 0, type_typed_object, size_vector(0), S_G.null_vector); VECTTYPE(S_G.null_vector) = (0 << vector_length_offset) | type_vector; S_protect(&S_G.null_fxvector); find_room(space_new, 0, type_typed_object, size_fxvector(0), S_G.null_fxvector); FXVECTOR_TYPE(S_G.null_fxvector) = (0 << fxvector_length_offset) | type_fxvector; S_protect(&S_G.null_bytevector); find_room(space_new, 0, type_typed_object, size_bytevector(0), S_G.null_bytevector); BYTEVECTOR_TYPE(S_G.null_bytevector) = (0 << bytevector_length_offset) | type_bytevector; S_protect(&S_G.null_string); find_room(space_new, 0, type_typed_object, size_string(0), S_G.null_string); STRTYPE(S_G.null_string) = (0 << string_length_offset) | type_string; } }
QColor inline rgb_to_yuv(const QColor &original) { int r = original.red(); int g = original.green(); int b = original.blue(); int a = original.alpha(); int y = (FIX(0.299) * r + FIX(0.587) * g + FIX(0.114) * b + ONE_HALF) >> SCALEBITS; int u = ((- FIX(0.169) * r - FIX(0.331) * g + FIX(0.499) * b + ONE_HALF) >> SCALEBITS) + 128; int v = ((FIX(0.499) * r - FIX(0.418) * g - FIX(0.0813) * b + ONE_HALF) >> SCALEBITS) + 128; return QColor(y, u, v, a); }
int libnet_write_ip(int sock, u_char *buf, int len) { int c; struct sockaddr_in sin; struct libnet_ip_hdr *ip_hdr; ip_hdr = (struct libnet_ip_hdr *)buf; #if (LIBNET_BSD_BYTE_SWAP) /* * For link access, we don't need to worry about the inconsistencies of * certain BSD kernels. However, raw socket nuances abound. Certain * BSD implmentations require the ip_len and ip_off fields to be in host * byte order. It's MUCH easier to change it here than inside the bpf * writing routine. */ ip_hdr->ip_len = FIX(ip_hdr->ip_len); ip_hdr->ip_off = FIX(ip_hdr->ip_off); #endif memset(&sin, 0, sizeof(struct sockaddr_in)); sin.sin_family = AF_INET; sin.sin_addr.s_addr = ip_hdr->ip_dst.s_addr; c = sendto(sock, buf, len, 0, (struct sockaddr *)&sin, sizeof(struct sockaddr)); #if (LIBNET_BSD_BYTE_SWAP) ip_hdr->ip_len = UNFIX(ip_hdr->ip_len); ip_hdr->ip_off = UNFIX(ip_hdr->ip_off); #endif if (c != len) { #if (__DEBUG) libnet_error(LIBNET_ERR_WARNING, "write_ip: %d bytes written (%s)\n", c, strerror(errno)); #endif } return (c); }
int main(void) { int n, s, t; int i, j; scanf("%d%d", &n, &s); for (i = 1; i <= n; ++i) { for (j = 1; j < i; ++j) { printf(" "); } printf("%d", s); t = s; for (j = i; j < n; ++j) { t = FIX(t + j); printf(" %d", t); } printf("\n"); s = FIX(s + i + 1); } return 0; }
static void Yuv2Rgb( uint8_t *r, uint8_t *g, uint8_t *b, int y1, int u1, int v1 ) { /* macros used for YUV pixel conversions */ # define SCALEBITS 10 # define ONE_HALF (1 << (SCALEBITS - 1)) # define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5)) int y, cb, cr, r_add, g_add, b_add; cb = u1 - 128; cr = v1 - 128; r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF; g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + ONE_HALF; b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF; y = (y1 - 16) * FIX(255.0/219.0); *r = vlc_uint8( (y + r_add) >> SCALEBITS ); *g = vlc_uint8( (y + g_add) >> SCALEBITS ); *b = vlc_uint8( (y + b_add) >> SCALEBITS ); #undef FIX }
void InitColorDither() { int CR, CB, i; Cr_b_tab = (int *)malloc(256*sizeof(int)); Cr_g_tab = (int *)malloc(256*sizeof(int)); Cb_g_tab = (int *)malloc(256*sizeof(int)); Cb_r_tab = (int *)malloc(256*sizeof(int)); for (i=0; i<256; i++) { CB = CR = i; CB -= 128; CR -= 128; Cb_r_tab[i] = FIX(1.40200) * CB; Cr_g_tab[i] = -FIX(0.34414) * CR; Cb_g_tab[i] = -FIX(0.71414) * CB; Cr_b_tab[i] = FIX(1.77200) * CR; } }
static int getpw_r(const char *name, uid_t uid, struct passwd *pw, char *buf, size_t size, struct passwd **res) { FILE *f; char *line = 0; size_t len = 0; int rv = 0; int cs; pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); f = fopen("/etc/passwd", "rb"); if (!f) { rv = errno; goto done; } *res = 0; while (__getpwent_a(f, pw, &line, &len)) { if (name && !strcmp(name, pw->pw_name) || !name && pw->pw_uid == uid) { if (size < len) { rv = ERANGE; break; } *res = pw; memcpy(buf, line, len); FIX(name); FIX(passwd); FIX(gecos); FIX(dir); FIX(shell); break; } } free(line); fclose(f); done: pthread_setcancelstate(cs, 0); return rv; }
static inline void yuv_to_rgb( uint8_t *r, uint8_t *g, uint8_t *b, uint8_t y1, uint8_t u1, uint8_t v1 ) { /* macros used for YUV pixel conversions */ # define SCALEBITS 10 # define ONE_HALF (1 << (SCALEBITS - 1)) # define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5)) # define CLAMP( x ) (((x) > 255) ? 255 : ((x) < 0) ? 0 : (x)); int y, cb, cr, r_add, g_add, b_add; cb = u1 - 128; cr = v1 - 128; r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF; g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + ONE_HALF; b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF; y = (y1 - 16) * FIX(255.0/219.0); *r = CLAMP((y + r_add) >> SCALEBITS); *g = CLAMP((y + g_add) >> SCALEBITS); *b = CLAMP((y + b_add) >> SCALEBITS); }
inline int ternarylook_fix_direct_implications( const int parent, const int reference ) { int i, lit1, lit2, *tImp = TernaryImp[ parent ]; for( i = TernaryImpSize[ parent ]; i > 0; i-- ) { lit1 = *(tImp++); lit2 = *(tImp++); if( lit1 == reference ) { if( IS_FIXED(lit2) ) { if( FIXED_ON_COMPLEMENT(lit2) ) return UNSAT; } else{ FIX( lit2, currentTimeStamp ); *(look_fixstackp++) = lit2; } } else if( lit2 == reference ) { if( IS_FIXED(lit1) ) { if( FIXED_ON_COMPLEMENT(lit1) ) return UNSAT; } else{ FIX( lit1, currentTimeStamp ); *(look_fixstackp++) = lit1; } } } return SAT; }
void S_thread_init() { if (S_boot_time) { S_protect(&S_G.threadno); S_G.threadno = FIX(0); #ifdef PTHREADS /* this is also reset in main.c after heap restoration */ s_thread_mutex_init(&S_tc_mutex.pmutex); S_tc_mutex.owner = s_thread_self(); S_tc_mutex.count = 0; s_thread_cond_init(&S_collect_cond); S_tc_mutex_depth = 0; #endif /* PTHREADS */ } }
ptr S_realtime(void) { struct timespec tp; time_t sec; I32 nsec; s_gettime(time_monotonic, &tp); sec = tp.tv_sec - starting_mono_tp.tv_sec; nsec = tp.tv_nsec - starting_mono_tp.tv_nsec; if (nsec < 0) { sec -= 1; nsec += 1000000000; } return S_add(S_mul(S_integer_time_t(sec), FIX(1000)), Sinteger((nsec + 500000) / 1000000)); }
build_ycc_rgb_table (j_decompress_ptr cinfo) { my_upsample_ptr upsample = (my_upsample_ptr) cinfo->upsample; int i; INT32 x; SHIFT_TEMPS upsample->Cr_r_tab = (int *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * sizeof(int)); upsample->Cb_b_tab = (int *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * sizeof(int)); upsample->Cr_g_tab = (INT32 *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * sizeof(INT32)); upsample->Cb_g_tab = (INT32 *) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, (MAXJSAMPLE+1) * sizeof(INT32)); for (i = 0, x = -CENTERJSAMPLE; i <= MAXJSAMPLE; i++, x++) { /* i is the actual input pixel value, in the range 0..MAXJSAMPLE */ /* The Cb or Cr value we are thinking of is x = i - CENTERJSAMPLE */ /* Cr=>R value is nearest int to 1.40200 * x */ upsample->Cr_r_tab[i] = (int) RIGHT_SHIFT(FIX(1.40200) * x + ONE_HALF, SCALEBITS); /* Cb=>B value is nearest int to 1.77200 * x */ upsample->Cb_b_tab[i] = (int) RIGHT_SHIFT(FIX(1.77200) * x + ONE_HALF, SCALEBITS); /* Cr=>G value is scaled-up -0.71414 * x */ upsample->Cr_g_tab[i] = (- FIX(0.71414)) * x; /* Cb=>G value is scaled-up -0.34414 * x */ /* We also add in ONE_HALF so that need not do it in inner loop */ upsample->Cb_g_tab[i] = (- FIX(0.34414)) * x + ONE_HALF; } }
void aes_call_be32(AESPB * apb) { int i; short * tmp_short; long * tmp_long; static short contrl[5]; static short global[15]; static short intin[16]; static short intout[7]; static long addrin[3]; static long addrout[1]; static AESPB native_apb = { contrl, global, intin, intout, addrin, addrout }; tmp_short = (short *)ntohl((LONG)apb->contrl); FIX(native_apb.contrl, tmp_short, 5, ntohs); tmp_short = (short *)ntohl((LONG)apb->intin); FIX(native_apb.intin, tmp_short, native_apb.contrl[1], ntohs); tmp_long = (long *)ntohl((LONG)apb->addrin); FIX(native_apb.addrin, tmp_long, native_apb.contrl[2], ntohl); aes_call(&native_apb); tmp_short = (short *)ntohl((LONG)apb->contrl); FIX(tmp_short, native_apb.contrl, 5, htons); tmp_short = (short *)ntohl((LONG)apb->intout); FIX(tmp_short, native_apb.intout, 7 /* FIXME native_apb.contrl[3] */, htons); tmp_long = (long *)ntohl((LONG)apb->addrout); FIX(tmp_long, native_apb.addrout, 1 /* FIXME native_apb.contrl[4] */, htonl); if((native_apb.contrl[0] == 23) || /* evnt_mesag */ (native_apb.contrl[0] == 25)) /* evnt_multi */ { DEBUG3("Fix evnt_multi"); if(native_apb.addrin[0] != 0) { FIX((WORD *)native_apb.addrin[0], (WORD *)native_apb.addrin[0], (MSG_LENGTH / sizeof(WORD)), htons); } DEBUG3("Fix evnt_multi finished"); } }
void pkcs11_export_pubkey(FILE * outfile, const char *url, int detailed, unsigned int flags, common_info_st * info) { int ret; gnutls_datum_t pubkey; gnutls_pkcs11_privkey_t pkey; pkcs11_common(info); FIX(url, outfile, detailed, info); CHECK_LOGIN_FLAG(flags); if (outfile == stderr || outfile == stdout) { fprintf(stderr, "warning: no --outfile was specified and the public key will be printed on screen.\n"); sleep(3); } ret = gnutls_pkcs11_privkey_init(&pkey); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } ret = gnutls_pkcs11_privkey_import_url(pkey, url, 0); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } ret = gnutls_pkcs11_privkey_export_pubkey(pkey, GNUTLS_X509_FMT_PEM, &pubkey, flags); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } gnutls_pkcs11_privkey_deinit(pkey); fwrite(pubkey.data, 1, pubkey.size, outfile); gnutls_free(pubkey.data); UNFIX; return; }
void compute_multab() { int k, m; short blk[64]; for (k = 1; k < 64; ++k) { memset((char*)blk, 0, sizeof(blk)); blk[ROWZAG[k]] = FIX(1); v_rdct(blk); for (m = 0; m < 64; ++m) { if (inlist(multab, nmul, blk[m])) continue; multab[nmul++] = blk[m]; } } }
static ptr eval(ptr x) { if (Spairp(x)) { switch (Schar_value(Scar(x))) { case '+': return S_add(First(x), Second(x)); case '-': return S_sub(First(x), Second(x)); case '*': return S_mul(First(x), Second(x)); case '/': return S_div(First(x), Second(x)); case 'q': return S_trunc(First(x), Second(x)); case 'r': return S_rem(First(x), Second(x)); case 'g': return S_gcd(First(x), Second(x)); case '=': { ptr x1 = First(x), x2 = Second(x); if (Sfixnump(x1) && Sfixnump(x2)) return Sboolean(x1 == x2); else if (Sbignump(x1) && Sbignump(x2)) return Sboolean(S_big_eq(x1, x2)); else return Sfalse; } case '<': { ptr x1 = First(x), x2 = Second(x); if (Sfixnump(x1)) if (Sfixnump(x2)) return Sboolean(x1 < x2); else return Sboolean(!BIGSIGN(x2)); else if (Sfixnump(x2)) return Sboolean(BIGSIGN(x1)); else return Sboolean(S_big_lt(x1, x2)); } case 'f': return Sflonum(S_floatify(First(x))); case 'c': S_gc(get_thread_context(), UNFIX(First(x)),UNFIX(Second(x))); return Svoid; case 'd': return S_decode_float(Sflonum_value(First(x))); default: S_prin1(x); putchar('\n'); printf("unrecognized operator, returning zero\n"); return FIX(0); } } else return x; }
void pkcs11_export(FILE * outfile, const char *url, unsigned int flags, common_info_st * info) { gnutls_pkcs11_obj_t obj; gnutls_datum_t t; int ret; unsigned int obj_flags = flags; pkcs11_common(info); FIX(url, outfile, 0, info); ret = gnutls_pkcs11_obj_init(&obj); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } ret = gnutls_pkcs11_obj_import_url(obj, url, obj_flags); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } ret = gnutls_pkcs11_obj_export3(obj, info->outcert_format, &t); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } fwrite(t.data, 1, t.size, outfile); gnutls_free(t.data); if (info->outcert_format == GNUTLS_X509_FMT_PEM) fputs("\n\n", outfile); gnutls_pkcs11_obj_deinit(obj); UNFIX; return; }
static const char *fix_builtin_names(const char *name) { #define FIX(x) if (streq(name, x)) return "_" x FIX("class"); FIX("final"); FIX("private"); FIX("protected"); FIX("public"); FIX("this"); /* TODO put all reserved names here */ #undef FIX return name; }
static void pkcs11_set_val(FILE * outfile, const char *url, int detailed, unsigned int flags, common_info_st * info, gnutls_pkcs11_obj_info_t val_type, const char *val) { int ret; gnutls_pkcs11_obj_t obj; pkcs11_common(info); FIX(url, outfile, detailed, info); CHECK_LOGIN_FLAG(flags); ret = gnutls_pkcs11_obj_init(&obj); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } ret = gnutls_pkcs11_obj_import_url(obj, url, flags); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } ret = gnutls_pkcs11_obj_set_info(obj, val_type, val, strlen(val), flags); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, gnutls_strerror(ret)); exit(1); } gnutls_pkcs11_obj_deinit(obj); return; }