/*P2(PGM ASCII format), P3(is_ppm ASCII format), P5 (PGM Binary format), P6 (is_ppm Binary format), P7 (pgm Binary format)*/ float* loadimage(char* file_name, int &h, int &w,int *is_ppm) { FILE * file_in; char line[LEN_MAX]; int i; float imax; float *image=NULL; if(is_ppm!=NULL) *is_ppm=QX_DEF_IS_PGM; //file_in=fopen(file_name,"rb"); fopen_s(&file_in,file_name,"rb"); if(!file_in) { printf("Please check input file_name: %s\n",file_name); exit(0); } if(fgetc(file_in)=='P') //fscanf(file_in,"%d\n",&i); fscanf_s(file_in,"%d\n",&i); else { printf("Bad header in ppm file.\n"); exit(1); } while(fgets(line,LEN_MAX,file_in)!=NULL) { if(line[0]=='#') continue; else { //sscanf(line, "%d %d\n", &w, &h); sscanf_s(line, "%d %d\n", &w, &h); break; } } //fscanf(file_in, "%f\n", &imax); fscanf_s(file_in,"%f\n",&imax); switch (i) { case 7: if(is_ppm!=NULL) *is_ppm=QX_DEF_IS_PGM; image=get_binary(file_in,h,w,1); break; case 8: if(is_ppm!=NULL) *is_ppm=QX_DEF_IS_PPM; image=get_binary(file_in,h,w,3); break; default: break; } fclose(file_in); return image; }
static int cmp_exact(char *source, int index) { SHA512_CTX ctx; uint64_t *b,*c,crypt_out[8]; int i; SHA512_Init(&ctx); SHA512_Update(&ctx, gkey[index].v, gkey[index].length); SHA512_Final((unsigned char *)(crypt_out), &ctx); b = (uint64_t *)get_binary(source); c = (uint64_t *)crypt_out; for (i = 0; i < 8; i++) { uint64_t t = SWAP64(c[i])-H[i]; c[i] = SWAP64(t); } for (i = 0; i < FULL_BINARY_SIZE / 8; i++) { //examin 512bits if (b[i] != c[i]) return 0; } return 1; }
int main() { long d; printf("Enter a number: "); scanf("%ld", &d); printf("You said %ld!\n", d); char binary[32]; get_binary(d, binary); printf("That means %32s in binary!\n", binary); short s = (short) d; printf("If you turn it into a short, it becomes %d\n", s); get_binary(s, binary); printf("That means %32s in binary!\n", binary); return 0; }
void send_text (int line_number, char text[]) { int i,j=0,decimal_value,k; char ch,ascii[8]; int cursor_line1[8]={1,0,0,0,0,0,0,0};//0x80h to move cursor to start of first line int cursor_line2[8]={1,1,0,0,0,0,0,0};//0xc0h to move cursor to start of second line if (line_number==1) send_command(&cursor_line1); else send_command(&cursor_line2); for (i=0;i<20;i++) { ch=text[i]; decimal_value=ch; //printf ("\n%c %d ",ch,decimal_value); //print character and decimal value if ((decimal_value==0)|(decimal_value==9)|(decimal_value==255)|(decimal_value==10)) decimal_value=32; get_binary(decimal_value); /*for (j=0;j<8;j++) { printf("%d",bin_array[j]); //print binary value of character to be displayed } printf ("\n");*/ send_data(&bin_array); } }
static int cmp_exact(char *source, int index) { void *binary = get_binary(source); if(cur_salt->version == 0) return !memcmp(binary, crypt_out[index], 20); else return !memcmp(binary, crypt_out[index], BINARY_SIZE); }
static char *pid2appid(pid_t pid, char *buf, size_t size) { char binary[PATH_MAX]; char path[PATH_MAX], *dir, *p, *base; unsigned int len; if (!pid || !get_binary(pid, binary, sizeof(binary))) return NULL; strncpy(path, binary, sizeof(path) - 1); path[sizeof(path) - 1] = '\0'; /* fetch basename */ if ((p = strrchr(path, '/')) == NULL || p == path) { strncpy(buf, binary, size - 1); buf[size - 1] = '\0'; return buf; } base = p-- + 1; /* fetch ../bin/<basename> */ if ((p = strprev(p, '/', path)) == NULL || p == path) goto return_base; if (strncmp(p + 1, "bin/", 4) != 0) goto return_base; else p--; /* fetch dir name above bin */ if ((dir = strprev(p, '/', path)) == NULL || dir == path) goto return_base; len = (size_t)(p - dir); /* fetch 'apps' dir */ p = dir - 1; if ((p = strprev(p, '/', path)) == NULL) goto return_base; if (strncmp(p + 1, "apps/", 5) != 0) goto return_base; if (len + 1 <= size) { strncpy(buf, dir + 1, len); buf[len] = '\0'; return buf; } return_base: strncpy(buf, base, size - 1); buf[size - 1] = '\0'; return buf; }
static int cmp_exact(char *source, int index) { int i; void *bin = get_binary(source); for (i = 0; i < 8; i++) if (host_crack[index].hash[i] != ((uint64_t *) bin)[i]) return 0; return 1; }
int main(int argc, const char *argv[]) { if(argc!=2) { printf("input error,please intput an number"); } get_binary(atoi(argv[1])); return 0; }
static int cmp_exact(char *source, int index) { int i; uint64_t *bin; bin = (uint64_t *) get_binary(source); for (i=1; i < 8; i++) if (((uint64_t *) bin)[i] != crypt_key[i][index]) return 0; return 1; }
void single_star::star_transformation_story(stellar_type new_type) { char info_line[MAX_STORY_LINE_LENGTH]; stellar_type old_type = get_element_type(); real time = get_current_time(); sprintf(info_line, "%s_to_%s_at_time = %6.2f", type_string(old_type), type_string(new_type), time); add_story_line(get_node()->get_log_story(), info_line); // cerr output for debugging! cerr << endl << get_node()->format_label() << " " << info_line << " Myr (old mass = " << get_total_mass() << ")" << endl; if(is_binary_component()) { #if 0 // This should be fixed some time SPZ:26/02/03 if(get_binary()->obtain_binary_type() == Merged) { cerr << "binary is merged." << endl; } else if(get_binary()->obtain_binary_type() == Disrupted) { cerr << "binary is disrupted, other component: " << endl << type_string(get_companion()->get_element_type()) << endl; } else { cerr << "binary companion: " << type_string(get_companion()->get_element_type()) << endl; } #endif cerr << "binary companion: " << type_string(get_companion()->get_element_type()) << endl; cerr << "parent: " << get_node()->get_parent()->format_label() << endl; } }
ofint32 OFVALUE::operator ==(const OFVALUE &rhs) { if (type != rhs.type) return 1; ofuint32 j; switch (type) { case typeInteger: return value.valint == rhs.value.valint; case typeBoolean: return value.valbool == rhs.value.valbool; case typeString: return (OFOS::stricmp(get_string(), rhs.get_string())==0); case typeFloat: return value.valdbl == rhs.value.valdbl; case typeOFDateTime: return value.valdate == rhs.value.valdate; case typeIdentity: return get_OFIDENTITY() == rhs.get_OFIDENTITY(); case typeBinary: if (get_binarylength() != rhs.get_binarylength()) return 0; return (memcmp(get_binary(), rhs.get_binary(), get_binarylength()) == 0); case typeListInteger: case typeListBoolean: case typeListString: case typeListFloat: case typeListOFDateTime: case typeListIdentity: case typeListBinary: if (LISTSIZE(value) != LISTSIZE(rhs.value)) return 0; for (j=1; j <= LISTSIZE(value); j++) { OFVALUE lhs_elem = listRetrieve (j); OFVALUE rhs_elem = listRetrieve (j); if ( !(lhs_elem == rhs_elem)) return 0; } } return 1; }
static int cmp_exact(char *source, int index) { unsigned int *bin, i ; bin = (unsigned int*)get_binary(source) ; i = 4 * index + 1 ; if (bin[1] != dcc2_hash_host[i++]) return 0 ; if (bin[2] != dcc2_hash_host[i++]) return 0 ; if (bin[3] != dcc2_hash_host[i]) return 0 ; return 1 ; }
//Stellar wind routine borrowed from class helium_star void hyper_giant::stellar_wind(const real dt) { if (relative_mass<cnsts.parameters(massive_star_mass_limit)) return; real wind_mass = wind_constant * dt; if (wind_mass>=envelope_mass) { wind_mass = envelope_mass; radius = core_radius; } if (is_binary_component()) get_binary()->adjust_binary_after_wind_loss(this, wind_mass, dt); else reduce_donor_mass(wind_mass); return; }
static int cmp_exact(char *source, int count){ unsigned int *t = (unsigned int *) get_binary(source); if (!have_full_hashes){ clEnqueueReadBuffer(queue[ocl_gpu_id], buffer_out, CL_TRUE, sizeof(cl_uint) * (max_keys_per_crypt), sizeof(cl_uint) * 3 * max_keys_per_crypt, res_hashes, 0, NULL, NULL); have_full_hashes = 1; } if (t[1]!=res_hashes[count]) return 0; if (t[2]!=res_hashes[1*max_keys_per_crypt+count]) return 0; if (t[3]!=res_hashes[2*max_keys_per_crypt+count]) return 0; return 1; }
void star_cluster::stellar_wind(const real dt) { if (!get_use_hdyn()) cerr << " No stellar dynamical information present in star_cluster" << endl; real wind_mass = mass_loss_by_evolution(dt); // PRC(wind_mass); if (wind_mass >= envelope_mass) wind_mass = envelope_mass; if (is_binary_component()) get_binary()->adjust_binary_after_wind_loss(this, wind_mass, dt); else reduce_mass(wind_mass); return; }
static int cmp_exact(char *source, int index) { return !memcmp(output[index], get_binary(source), BINARY_SIZE); }
static int cmp_exact(char *source, int index) { void *binary = get_binary(source); return !memcmp(binary, crypt_out[index], BINARY_SIZE_SMALLER); }
static int cmp_exact(char *source, int index) { void *bin = get_binary(source); return !memcmp(bin, crypt_out[index], 20); }
static int cmp_exact(char *source, int index) { void *b = get_binary(source); return !memcmp(b, crypt_key[index], sizeof(crypt_key[index])); }
static GstFlowReturn gst_tta_dec_chain (GstPad * pad, GstBuffer * in) { GstTtaDec *ttadec; GstBuffer *outbuf, *buf = GST_BUFFER (in); guchar *data, *p; decoder *dec; unsigned long outsize; unsigned long size; guint32 frame_samples; long res; long *prev; ttadec = GST_TTA_DEC (GST_OBJECT_PARENT (pad)); data = GST_BUFFER_DATA (buf); size = GST_BUFFER_SIZE (buf); ttadec->tta_buf.bit_count = 0; ttadec->tta_buf.bit_cache = 0; ttadec->tta_buf.bitpos = ttadec->tta_buf.buffer_end; ttadec->tta_buf.offset = 0; decoder_init (ttadec->tta, ttadec->channels, ttadec->bytes); if (GST_BUFFER_DURATION_IS_VALID (buf)) { frame_samples = ceil ((gdouble) (GST_BUFFER_DURATION (buf) * ttadec->samplerate) / (gdouble) GST_SECOND); } else { frame_samples = ttadec->samplerate * FRAME_TIME; } outsize = ttadec->channels * frame_samples * ttadec->bytes; dec = ttadec->tta; p = ttadec->decdata; prev = ttadec->cache; for (res = 0; p < ttadec->decdata + frame_samples * ttadec->channels * ttadec->bytes;) { unsigned long unary, binary, depth, k; long value, temp_value; fltst *fst = &dec->fst; adapt *rice = &dec->rice; long *last = &dec->last; // decode Rice unsigned get_unary (&ttadec->tta_buf, data, size, &unary); switch (unary) { case 0: depth = 0; k = rice->k0; break; default: depth = 1; k = rice->k1; unary--; } if (k) { get_binary (&ttadec->tta_buf, data, size, &binary, k); value = (unary << k) + binary; } else value = unary; switch (depth) { case 1: rice->sum1 += value - (rice->sum1 >> 4); if (rice->k1 > 0 && rice->sum1 < shift_16[rice->k1]) rice->k1--; else if (rice->sum1 > shift_16[rice->k1 + 1]) rice->k1++; value += bit_shift[rice->k0]; default: rice->sum0 += value - (rice->sum0 >> 4); if (rice->k0 > 0 && rice->sum0 < shift_16[rice->k0]) rice->k0--; else if (rice->sum0 > shift_16[rice->k0 + 1]) rice->k0++; } /* this only uses a temporary variable to silence a gcc warning */ temp_value = DEC (value); value = temp_value; // decompress stage 1: adaptive hybrid filter hybrid_filter (fst, &value); // decompress stage 2: fixed order 1 prediction switch (ttadec->bytes) { case 1: value += PREDICTOR1 (*last, 4); break; // bps 8 case 2: value += PREDICTOR1 (*last, 5); break; // bps 16 case 3: value += PREDICTOR1 (*last, 5); break; // bps 24 case 4: value += *last; break; // bps 32 } *last = value; if (dec < ttadec->tta + ttadec->channels - 1) { *prev++ = value; dec++; } else { *prev = value; if (ttadec->channels > 1) { long *r = prev - 1; for (*prev += *r / 2; r >= ttadec->cache; r--) *r = *(r + 1) - *r; for (r = ttadec->cache; r < prev; r++) WRITE_BUFFER (r, ttadec->bytes, p); } WRITE_BUFFER (prev, ttadec->bytes, p); prev = ttadec->cache; res++; dec = ttadec->tta; } } outbuf = gst_buffer_new_and_alloc (outsize); memcpy (GST_BUFFER_DATA (outbuf), ttadec->decdata, outsize); GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf); GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf); gst_buffer_set_caps (outbuf, GST_PAD_CAPS (ttadec->srcpad)); return gst_pad_push (ttadec->srcpad, outbuf); }
int main(int argc, char **argv) { int opt; static const struct option long_options[] = { { "help", no_argument, 0, CHAR_MAX + 1 }, { "version", no_argument, 0, 'v' }, { NULL, 0, 0, 0 } }; program_name = argv[0]; while ((opt = getopt_long(argc, argv, "v", long_options, NULL)) != EOF) { switch (opt) { case 'v': printf("GNU pfbtops (groff) version %s\n", Version_string); exit(0); break; case CHAR_MAX + 1: /* --help */ usage(stdout); exit(0); break; case '?': usage(stderr); exit(1); break; } } if (argc - optind > 1) { usage(stderr); exit(1); } if (argc > optind && !freopen(argv[optind], "r", stdin)) { perror(argv[optind]); exit(1); } SET_BINARY(fileno(stdin)); for (;;) { int type, c, i; long n; c = getchar(); if (c != 0x80) error("first byte of packet not 0x80"); type = getchar(); if (type == 3) break; if (type != 1 && type != 2) error("bad packet type"); n = 0; for (i = 0; i < 4; i++) { c = getchar(); if (c == EOF) error("end of file in packet header"); n |= (long)c << (i << 3); } if (n < 0) error("negative packet length"); if (type == 1) get_text(n); else get_binary(n); } exit(0); }
static int cmp_exact(char *source, int index) { return DES_bs_cmp_one(get_binary(source), 64, index); }
std::vector<value> parse(Range &r, parse_flag_t flags, unsigned n = ~0) { std::vector<value> ret; for(; n != 0; --n) { type_t const t = get_type(r); switch(t) { case SMALL_INTEGER_EXT: ret.push_back(value(t, get_small_integer(r))); break; case INTEGER_EXT: ret.push_back(value(t, get_integer(r))); break; case FLOAT_EXT: ret.push_back(value(t, get_float(r))); break; case ATOM_EXT: ret.push_back(value(t, get_atom(r))); break; case SMALL_TUPLE_EXT: { if(flags & parse_complex) { // TODO } byte_t const size = get_small_tuple_size(r); ret.push_back(value(t, parse(r, flags, size))); } break; case LARGE_TUPLE_EXT: { if(flags & parse_complex) { // TODO } boost::uint32_t const size = get_large_tuple_size(r); ret.push_back(value(t, parse(r, flags, size))); } break; case NIL_EXT: ret.push_back(value()); break; case STRING_EXT: ret.push_back(value(t, get_string(r))); break; case LIST_EXT: { // TODO handle Tail! boost::uint32_t const size = get_list_size(r); /* not optimal: collecting into a vector and then constructing a list from that */ std::vector<value> tmp = parse(r, flags, size); ret.push_back(value(t, std::list<value>(tmp.begin(), tmp.end()))); } break; case BINARY_EXT: ret.push_back(value(t, get_binary(r))); break; #ifndef LIBBERT_NO_EXTENSION case X_NEW_FLOAT_EXT: ret.push_back(value(FLOAT_EXT, x_get_new_float(r))); break; #endif default: throw bert_exception("unknown type"); }; } return ret; }
/** * fm_app_chooser_dlg_dup_selected_app * @dlg: a widget * @set_default: location to get value that was used for fm_app_chooser_dlg_new() * * Retrieves a currently selected application from @dlg. * * Before 1.0.0 this call had name fm_app_chooser_dlg_get_selected_app. * * Returns: (transfer full): selected application. * * Since: 0.1.0 */ GAppInfo* fm_app_chooser_dlg_dup_selected_app(GtkDialog* dlg, gboolean* set_default) { GAppInfo* app = NULL; AppChooserData* data = (AppChooserData*)g_object_get_qdata(G_OBJECT(dlg), fm_qdata_id); switch( gtk_notebook_get_current_page(data->notebook) ) { case 0: /* all applications */ app = fm_app_menu_view_dup_selected_app(data->apps_view); break; case 1: /* custom cmd line */ { const char* cmdline = gtk_entry_get_text(data->cmdline); const char* app_name = gtk_entry_get_text(data->app_name); if(cmdline && cmdline[0]) { char* _cmdline = NULL; gboolean arg_found = FALSE; char* bin1 = get_binary(cmdline, &arg_found); g_debug("bin1 = %s", bin1); /* see if command line contains %f, %F, %u, or %U. */ if(!arg_found) /* append %f if no %f, %F, %u, or %U was found. */ cmdline = _cmdline = g_strconcat(cmdline, " %f", NULL); /* FIXME: is there any better way to do this? */ /* We need to ensure that no duplicated items are added */ if(data->mime_type) { MenuCache* menu_cache; /* see if the command is already in the list of known apps for this mime-type */ GList* apps = g_app_info_get_all_for_type(fm_mime_type_get_type(data->mime_type)); GList* l; for(l=apps;l;l=l->next) { GAppInfo* app2 = G_APP_INFO(l->data); const char* cmd = g_app_info_get_commandline(app2); char* bin2 = get_binary(cmd, NULL); if(g_strcmp0(bin1, bin2) == 0) { app = G_APP_INFO(g_object_ref(app2)); g_debug("found in app list"); g_free(bin2); break; } g_free(bin2); } g_list_foreach(apps, (GFunc)g_object_unref, NULL); g_list_free(apps); if(app) goto _out; /* see if this command can be found in menu cache */ menu_cache = menu_cache_lookup("applications.menu"); if(menu_cache) { #if MENU_CACHE_CHECK_VERSION(0, 4, 0) MenuCacheDir *root_dir = menu_cache_dup_root_dir(menu_cache); if(root_dir) #else if(menu_cache_get_root_dir(menu_cache)) #endif { GSList* all_apps = menu_cache_list_all_apps(menu_cache); GSList* l; for(l=all_apps;l;l=l->next) { MenuCacheApp* ma = MENU_CACHE_APP(l->data); const char *exec = menu_cache_app_get_exec(ma); char* bin2; if (exec == NULL) { g_warning("application %s has no Exec statement", menu_cache_item_get_id(MENU_CACHE_ITEM(ma))); continue; } bin2 = get_binary(exec, NULL); if(g_strcmp0(bin1, bin2) == 0) { app = G_APP_INFO(g_desktop_app_info_new(menu_cache_item_get_id(MENU_CACHE_ITEM(ma)))); g_debug("found in menu cache"); menu_cache_item_unref(MENU_CACHE_ITEM(ma)); g_free(bin2); break; } menu_cache_item_unref(MENU_CACHE_ITEM(ma)); g_free(bin2); } g_slist_free(all_apps); #if MENU_CACHE_CHECK_VERSION(0, 4, 0) menu_cache_item_unref(MENU_CACHE_ITEM(root_dir)); #endif } menu_cache_unref(menu_cache); } if(app) goto _out; } /* FIXME: g_app_info_create_from_commandline force the use of %f or %u, so this is not we need */ app = app_info_create_from_commandline(cmdline, app_name ? app_name : "", bin1, data->mime_type ? fm_mime_type_get_type(data->mime_type) : NULL, gtk_toggle_button_get_active(data->use_terminal), data->keep_open && gtk_toggle_button_get_active(data->keep_open)); _out: g_free(bin1); g_free(_cmdline); } } break; } if(set_default) *set_default = gtk_toggle_button_get_active(data->set_default); return app; }