int mb_cu_init(char *addr, unsigned int port, unsigned int local_port) { printf("\n\n" "= = = = = = = = = = = = = = = = = = =\n" "\n" "module\t:%s\n" "version\t:%s\n" "date\t:"__DATE__" "__TIME__"\n" "\n" "= = = = = = = = = = = = = = = = = = =\n" "\n\n" , MB_NAME , MB_VERSION); g_mb_req_list = list_new(); //printf("init g_mb_req_list:%p\n", g_mb_req_list); g_seq = seq_new(); g_mb_hdl = mb_hdl_new(addr , port , g_seq , g_mb_req_list); if(g_mb_hdl == NULL) { printf("mb cu init error!\n"); return -1; } else { printf("mb cu init success!\n"); } return 0; }
create_monster() { if (IS_CLONE) { set_name("bert"); set_living_name("bert"); default_config_npc(100); config_default_trade(); set_money_give_reduce( ({ 0, 2, 3, 3 }) ); seq_new("foo"); seq_addfirst("foo", ({ "@@do_give" }) );
static int64_t * seq_create (seqhash_t *s, const char *name) { int rc; int64_t *v; if (zhash_lookup (s->vhash, name)) { errno = EEXIST; return (NULL); } v = seq_new (); rc = zhash_insert (s->vhash, xstrdup (name), v); assert (rc >= 0); zhash_freefn (s->vhash, name, free); return (v); }
void run_scan( int argc, char *argv[] ) { /* Martin A. Hansen, September 2008 */ /* For each file in argv scan the file for */ /* bipartite motifs and output the motifs */ /* and their count. */ char *file = NULL; int i = 0; seq_entry *entry = NULL; uint *count_array = NULL; // size_t new_nmemb = 0; count_array = count_array_new( COUNT_ARRAY_NMEMB ); entry = seq_new( MAX_SEQ_NAME, MAX_SEQ ); for ( i = 1; i < argc; i++ ) { file = argv[ i ]; fprintf( stderr, "Scanning file: %s\n", file ); scan_file( file, entry, count_array ); fprintf( stderr, "done.\n" ); } // fprintf( stderr, "Printing motifs: ... " ); // count_array_print( count_array, COUNT_ARRAY_NMEMB, CUTOFF ); // fprintf( stderr, "done.\n" ); file = argv[ 1 ]; fprintf( stderr, "Rescanning file: %s\n", file ); rescan_file( file, entry, count_array, CUTOFF ); fprintf( stderr, "done.\n" ); seq_destroy( entry ); mem_free( &count_array ); }
int main(int argc, char **argv) { Seq *seq; char *seq_str; gzFile f; if(argc != 2) { fprintf(stderr, "usage: %s <nuc_str>\n", argv[0]); exit(2); } seq = seq_new(); seq_read_str(seq, argv[1]); fprintf(stderr, "seq->len=%ld\n", seq->len); seq_str = seq_get_seqstr(seq); fprintf(stderr, "%s\n", seq_str); my_free(seq_str); fprintf(stderr, "reading from fasta\n"); f = gzopen("test.fa.gz", "wb"); seq_write_fasta_record(seq, f); gzclose(f); fprintf(stderr, "writing to fasta\n"); f = gzopen("test.fa.gz", "rb"); seq_read_fasta_record(seq, f); gzclose(f); fprintf(stderr, "seq->len=%ld\n", seq->len); seq_str = seq_get_seqstr(seq); fprintf(stderr, "%s\n", seq_str); my_free(seq_str); seq_free(seq); return 0; }
create_monster() { /* We ignore the master object */ if (!IS_CLONE) return; set_name("ugluk"); set_race_name("troll"); set_adj("nasty"); set_long("It is a very ugly and nasty lookin' troll.\n"); /* Average stat: 5 */ default_config_npc(5); /* But we want it to have more hitpoints */ set_base_stat(SS_CON, 20); set_hp(1000); seq_new("do_things"); seq_addfirst("do_things",({"@@arm_me","say Ok, come on you bastards!"}));
int main(int argc, char **argv) { char **fasta_files; int seed_len, i, n_fasta_files; ChrTable *chr_tab; SeedTable *seed_tab; Seq *seq; gzFile gzf, out_gzf; char *out_filename; if(argc < 4) { fprintf(stderr, "usage: %s <seed_len> <chromInfo.txt> " "<output_seed_index.gz> [chr1.fa.gz [chr2.fa.gz [...]]]\n", argv[0]); exit(2); } seed_len = util_parse_long(argv[1]); fasta_files = &argv[4]; n_fasta_files = argc - 4; out_filename = argv[3]; /* read chromosomes and make table containing offsets for both * forward and reverse strands (so we can represent genomic * coordinates with a single long integer). */ chr_tab = chr_table_read(argv[2]); fprintf(stderr, "there are %d chromosomes, total length: %u\n", chr_tab->n_chr, chr_tab->total_chr_len); /* create a table to hold seed matches */ fprintf(stderr, "initializing seed table\n"); seed_tab = seed_table_new(seed_len); /* open an output file to write seed table to */ if(util_file_exists(out_filename)) { my_err("output file %s already exists\n", out_filename); exit(2); } out_gzf = util_must_gzopen(out_filename, "wb"); /* * first pass: count number of matches to each seed */ seq = seq_new(); for(i = 0; i < n_fasta_files; i++) { fprintf(stderr, "reading sequence from file %s\n", fasta_files[i]); gzf = util_must_gzopen(fasta_files[i], "rb"); while(seq_read_fasta_record(seq, gzf)) { fprintf(stderr, "%s %ld\n", seq->name, seq->len); fprintf(stderr, "counting seed matches\n"); count_matches(chr_tab, seed_tab, seq); } gzclose(gzf); } /* * second pass: store location of each match */ for(i = 0; i < n_fasta_files; i++) { fprintf(stderr, "reading sequence from file %s\n", fasta_files[i]); gzf = util_must_gzopen(fasta_files[i], "rb"); while(seq_read_fasta_record(seq, gzf)) { fprintf(stderr, "%s %ld\n", seq->name, seq->len); fprintf(stderr, "recording seed match positions\n"); add_matches(chr_tab, seed_tab, seq); } gzclose(gzf); } seq_free(seq); /* write table to file in binary format */ fprintf(stderr, "writing seed table to file %s\n", out_filename); seed_table_write(seed_tab, out_gzf); gzclose(out_gzf); chr_table_free(chr_tab); seed_table_free(seed_tab); return 0; }