static void rduser(USER *user) { FILE *in; char *buf, *name, *qth; user->name = strdup("?_name"); user->qth = strdup("?_qth"); in = nfopeni(RtUsr, "r"); if (in) { buf = mallocw(LINE128); while(fgets(buf, LINE128, in)) { rip(buf); name = strlop(buf, ' '); if (!matchi(buf, user->call)) continue; if (!name) break; qth = strlop(name, ' '); strnew(&user->name, name); if (!qth) break; strnew(&user->qth, qth); break; } free(buf); nfclose(&in); } }
/* Read in secret password (turns off echo) */ char * readpass(char *buf, int n) { void (*old_handler)(int); /* Turn off echoing */ skey_echo(0); /* Catch SIGINT and save old signal handler */ old_handler = signal(SIGINT, trapped); if (fgets(buf, n, stdin) == NULL) buf[0] = '\0'; rip(buf); (void)putc('\n', stderr); (void)fflush(stderr); /* Restore signal handler and turn echo back on */ if (old_handler != SIG_ERR) (void)signal(SIGINT, old_handler); skey_echo(1); sevenbit(buf); return(buf); }
void TrainingSetGenerator::GenerateFromSensor(PointCloud const& input, std::vector<float> const& localRes) { Grid2Num.Resize(input.height, input.width); Pixel2Num.resize(input.height * input.width); int indexNoNan = 0; for (int y = 0; y < input.height; ++y) { for (int x = 0; x < input.width; ++x) { PointType point = input.at(x, y); int & pixelNum = Pixel2Num[y * input.width + x]; if (pointHasNan(point)) { pixelNum = -1; continue; } RangeImagePoint rip(point); for (int j = -Width_ + 1; j <= Width_; ++j) { if (TossCoin()) { // localRes is indexed by nan-removed number PointType shifted = rip.shift(Step_ * localRes.at(indexNoNan), j); int num = AddPoint(x, y, shifted, j <= 0 ? +1 : -1); if (j == 0) { pixelNum = num; } } } indexNoNan++; } } }
/* Read in an s/key OTP (does not turn off echo) */ char * readskey(char *buf, int n) { if (fgets(buf, n, stdin) == NULL) buf[0] = '\0'; rip(buf); sevenbit(buf); return(buf); }
int main() { int32 challenge=0; char chall[80]; char pass[80]; MD5_CTX md; int i; printf("Enter challenge (in hex): "); fflush(stdout); fgets(chall,sizeof(chall),stdin); rip(chall); printf("Enter password: "******"%02x",md.digest[i] & 0xff); printf("\n"); #else printf("%s\n", md5sum(challenge, pass)); /* md5sum() in files.c */ #endif return 0; }
static ri_ptr createTagCloudItem( const std::string& name, float weight, int tracks, int seconds, const std::string& source) { ri_ptr rip( new ResolvedItem ); rip->set_json_value( "name", name ); rip->set_json_value( "weight", weight ); rip->set_json_value( "count", tracks ); rip->set_json_value( "seconds", seconds ); rip->set_json_value( "source", source ); return rip; }
/* * Perform a nameserver lookup of specified type using specified * unpacker to extract data, if found. */ static int do_ns_lookup( char *name, byte dtype, unpacker_funct unpacker, void *data, sockfunct_t fn ) // S. Lawson { /* longword temp; */ int result = 0; // init to false int count, i; byte timeout[ MAX_NAMESERVERS ]; struct useek qp; /* temp buffer */ udp_Socket ds; /* temp buffer */ word oldhndlcbrk; question = &qp; dom_sock = &ds; if (!name) return( 0 ); rip( name ); if (!_domaintimeout) _domaintimeout = sock_delay << 2; timeoutwhen = set_timeout( _domaintimeout ); count = 0; memset( &timeout, 0, sizeof( timeout )); oldhndlcbrk = wathndlcbrk; wathndlcbrk = 1; /* enable special interrupt mode */ watcbroke = 0; do { if ( (loc_domain = nextdomain( def_domain, count )) == NULL ) count = -1; /* use default name */ for ( i = 0; i < _last_nameserver ; ++i ) { if (!timeout[i]) if ((result = Sdomain( name, dtype, unpacker, data, count != -1 , def_nameservers[i], &timeout[i], fn)) == 1) // S. Lawson break; /* got name, bail out of loop */ if (result==-1) break; // S. Lawson } if (count == -1) break; count++; } while (!result); watcbroke = 0; /* always clean up */ wathndlcbrk = oldhndlcbrk; if (result==-1) result=0; // S. Lawson return( result ); }
/* * resolve() * convert domain name -> address resolution. * returns 0 if name is unresolvable right now */ longword resolve_fn( char *name, sockfunct_t fn ) // S. Lawson { longword ipaddr; // S. Lawson #define DNSCACHESIZE 4 // cache up to 4 names #define DNSCACHELENGTH 32 // up to 32 characters #define DNSCACHETIMEOUT 120 // for up to 2 minutes static char DNScacheName[DNSCACHESIZE][DNSCACHELENGTH]; static longword DNScacheIP[DNSCACHESIZE]; static longword DNScacheTimeout[DNSCACHESIZE]={0,0,0,0}; static char DNScacheNext=0; int DNScacheScan; if( !name ) return 0L; rip( name ); // S. Lawson - trim for cache scan if ( isaddr( name )) return( aton( name )); // S. Lawson for (DNScacheScan=0 ; DNScacheScan<DNSCACHESIZE ; DNScacheScan++) { if (DNScacheTimeout[DNScacheScan]==0L) continue; if (chk_timeout(DNScacheTimeout[DNScacheScan])) { DNScacheTimeout[DNScacheScan]=0L; continue; } if(!strcmpi(DNScacheName[DNScacheScan],name)) return DNScacheIP[DNScacheScan]; } #ifdef NOTUSED // S. Lawson if( do_ns_lookup(name, DTYPEA, typea_unpacker, &ipaddr) ) return (intel(ipaddr)); else return (0L); #else // S. Lawson if( do_ns_lookup(name, DTYPEA, typea_unpacker, &ipaddr, fn) ) { strncpy(DNScacheName[DNScacheNext], name, DNSCACHELENGTH); DNScacheName[DNScacheNext][DNSCACHELENGTH-1]='\0'; DNScacheIP[DNScacheNext]=intel(ipaddr); DNScacheTimeout[DNScacheNext]=set_timeout(DNSCACHETIMEOUT); if (++DNScacheNext>=DNSCACHESIZE) DNScacheNext=0; return (intel(ipaddr)); } return (0L); #endif // S. Lawson }
/* Log messages of the form * Tue Jan 31 00:00:00 1987 44.64.0.7:1003 open FTP */ void trace_log(struct iface *ifp,char *fmt, ...) { va_list ap; char *cp; long t; FILE *fp; if((fp = ifp->trfp) == NULL) return; t = secclock(); cp = ctime((time_t *) &t); rip(cp); fprintf(fp,"%s - ",cp); va_start(ap,fmt); vfprintf(fp,fmt,ap); va_end(ap); fprintf(fp,"\n"); }
int main(int argc, char *argv[]) { struct mscab_decompressor *cabd; struct mscabd_cabinet *cab, *c; int err; MSPACK_SYS_SELFTEST(err); if (err) return 0; if ((cabd = mspack_create_cab_decompressor(NULL))) { for (argv++; *argv; argv++) { if ((cab = cabd->search(cabd, *argv))) { for (c = cab; c; c = c->next) rip(*argv, c->base_offset, c->length); cabd->close(cabd, cab); } } mspack_destroy_cab_decompressor(cabd); } return 0; }
/** * Main method * @param[in] argc Number of arguments * @param[in] argv Arguments vector */ int main(int argc, char* argv[]) { exePath = argv[0]; printf("Rom Signature Tool V%s by Fardjad.\n", VERSION); if (argc != 3) { printUsage(); } char* command = argv[1]; char* fileName = argv[2]; if ((stricmp(command, "rip")) == 0) { rip(fileName); } else if ((stricmp(command, "nullsign") == 0)) { nullSign(fileName); } else { printUsage(); } return SUCCESS; }
virtual bool report_results(const query_uid& qid, const std::vector< json_spirit::Object >& results) { std::vector< ri_ptr > v; BOOST_FOREACH( const json_spirit::Object & o, results ) { ri_ptr rip(new ResolvedItem( o )); // if no preference specified, set to preference of this plugin. // in some cases, plugins will know varied preferences per-result // eg: a p2p plugin would know certain peers are less reliable // but normally you just use a global value per plugin. // ie Local > LAN > some web service if( rip->preference() == -1 ) { // not set, use global pref of this plugin: rip->set_preference( preference() ); } else { // use lowest preference of reported, or our own for this plugin if( preference() < rip->preference() ) rip->set_preference( preference() ); } v.push_back( rip ); }
void instr_sti(vm_t* vm, warrior_t* warrior) { rip("tbd sti"); }
/* * Verify response to a S/Key challenge. * * Return codes: * -1: Error of some sort; database unchanged * 0: Verify successful, database updated * 1: Verify failed, database unchanged * * The database file is always closed by this call. */ int skeyverify(struct skey *mp, char *response) { char key[SKEY_BINKEY_SIZE], fkey[SKEY_BINKEY_SIZE]; char filekey[SKEY_BINKEY_SIZE], *cp, *last; size_t nread; if (response == NULL) goto verify_failure; /* * The record should already be locked but lock it again * just to be safe. We don't wait for the lock to become * available since we should already have it... */ if (flock(fileno(mp->keyfile), LOCK_EX | LOCK_NB) != 0) goto verify_failure; /* Convert response to binary */ rip(response); if (etob(key, response) != 1 && atob8(key, response) != 0) goto verify_failure; /* Neither english words nor ascii hex */ /* Compute fkey = f(key) */ (void)memcpy(fkey, key, sizeof(key)); f(fkey); /* * Reread the file record NOW in case it has been modified. * The only field we really need to worry about is mp->val. */ (void)fseek(mp->keyfile, 0L, SEEK_SET); if ((nread = fread(mp->buf, 1, sizeof(mp->buf), mp->keyfile)) == 0 || !isspace((unsigned char)mp->buf[nread - 1])) goto verify_failure; if ((mp->logname = strtok_r(mp->buf, " \t\r\n", &last)) == NULL) goto verify_failure; if ((cp = strtok_r(NULL, " \t\r\n", &last)) == NULL) goto verify_failure; if ((cp = strtok_r(NULL, " \t\r\n", &last)) == NULL) goto verify_failure; if ((mp->seed = strtok_r(NULL, " \t\r\n", &last)) == NULL) goto verify_failure; if ((mp->val = strtok_r(NULL, " \t\r\n", &last)) == NULL) goto verify_failure; /* Convert file value to hex and compare. */ atob8(filekey, mp->val); if (memcmp(filekey, fkey, SKEY_BINKEY_SIZE) != 0) goto verify_failure; /* Wrong response */ /* * Update key in database. * XXX - check return values of things that write to disk. */ btoa8(mp->val,key); mp->n--; (void)fseek(mp->keyfile, 0L, SEEK_SET); (void)fprintf(mp->keyfile, "%s\n%s\n%d\n%s\n%s\n", mp->logname, skey_get_algorithm(), mp->n, mp->seed, mp->val); (void)fflush(mp->keyfile); (void)ftruncate(fileno(mp->keyfile), ftello(mp->keyfile)); (void)fclose(mp->keyfile); mp->keyfile = NULL; return (0); verify_failure: (void)fclose(mp->keyfile); mp->keyfile = NULL; return (-1); }
static int getinp(CIRCUIT *circuit) { if (!rxlinet(circuit->buf, ln_ibuf)) return FALSE; rip(circuit->buf); return true; }
int cmdparse( struct cmds cmds[], char *line, void *p ){ struct cmds *cmdp; char *argv[NARG]; char **pargv; int argc,i; /* Remove cr/lf */ rip(line); for(argc = 0;argc < NARG;argc++) argv[argc] = NULL; for(argc = 0;argc < NARG;){ int qflag = FALSE; /* Skip leading white space */ while(isspace(*line & 0xff)) line++; if(*line == '\0') break; /* '#' is start of comment */ if(*line == '#') break; /* Check for quoted token */ if(*line == '"'){ line++; /* Suppress quote */ qflag = TRUE; } argv[argc++] = line; /* Beginning of token */ if(qflag){ /* Find terminating delimiter */ if((line = stringparse(line)) == NULL){ return -1; } } else { /* Find space or tab. If not present, * then we've already found the last * token. */ while(*line && !isspace(*line & 0xff)) line++; } if(*line) *line++ = 0; } if (argc < 1) { /* empty command line */ argc = 1; argv[0] = ""; } if (argv[0][0] == '?') return print_help(cmds); /* Look up command in table; prefix matches are OK */ for(cmdp = cmds;cmdp->name != NULL;cmdp++){ if(strncmp(argv[0],cmdp->name,strlen(argv[0])) == 0) break; } if(cmdp->name == NULL) { if(cmdp->argc_errmsg != NULL) printf("%s\n",cmdp->argc_errmsg); return -1; } argv[0] = cmdp->name; if(argc < cmdp->argcmin) { /* Insufficient arguments */ printf("Usage: %s\n",cmdp->argc_errmsg); return -1; } if(cmdp->func == NULL) return 0; if(cmdp->stksize == 0){ return (*cmdp->func)(argc,argv,p); } else { #ifndef SINGLE_THREADED /* Make private copy of argv and args, * spawn off subprocess and return. */ pargv = (char **)callocw(argc,sizeof(char *)); for(i=0;i<argc;i++) pargv[i] = strdup(argv[i]); newproc(cmdp->name,cmdp->stksize, (void (*)(int,void *,void *))cmdp->func,argc,pargv,p,1); #endif return 0; } }
int test_wz( char* file, unsigned int low, unsigned int up, unsigned char* res) { unsigned int i,k; unsigned int v; unsigned char b; printf("Recover random prepended bytes from the archive\n"); printf("====================================\n\n"); memset( stat, 0, MAX_LEVEL*4); printf("Archive: %s\n",file); nbfiles = rip( file, seeds, sizes, MAXFILES); set_data_buff( seeds ); for(i=0;i<nbfiles;i++) seeds[i]=seeds[i*10]; #if 0 printf("Seeds: "); for(i=0;i<nbfiles;i++) printf("%X ",seeds[i]); printf("\n"); printTime(); #endif init_time=0; success =0; /* DEBUG low = 0xBC25AB2E - 1000; up = 0xBC25AB2F; low = (0x589e05c7 + 0x404373ab) - 2000; up = (0x589e05c7 + 0x404373ab) ; */ printf("seed range [%x ; %x]\n",low,up); printf("seed range [%u ; %u]\n",low,up); for( seed = low ; seed < up; seed++) { initialize_P1(seed & 0x0FFFFFFF); initialize_P2(); memcpy( rand_data[0], ptr, 4*10 ); /* KEY 3 */ v=*ptr; _asm{ sar v,16h } k3 = v ^ seeds[0]; // k3 is 8-bit value recover(); } printTime(); printf("-- STATISTICS --\n"); for(i=0;i<MAX_LEVEL;i++) printf("Level %02d: %d\n",i,stat[i]); printf("Done\n"); /* return result if any */ for(k=0;k<5;k++) { for(i=0;i<10;i++) { res[k*10+i] = rand_suc[k][i]; } } return success; }
int doaxui(int argc, char *argv[],void *p) { char *cp; char name[AXBUF]; char buf[256]; int i; char tmpcall[AXALEN]; char tmpcall2[AXALEN]; struct session *sp; struct mbuf *bp; struct iface *axif,*ifc; int first = 1; int goto_restart = 0, goto_done = 0; /* Check if this comes from console */ if(Curproc->input != Command->input) return 1; /* Check to see if AXUI is already running. Only one copy at a time */ if (Axui_sock != -1) { tprintf("%s already running\n", Sestypes[AXUITNC]); return 1; } if(((axif = if_lookup(argv[1])) == NULLIF) || (axif->type != CL_AX25)) { tprintf("Iface %s not defined or not an AX25 type interface\n",argv[1]); return 1; } if (argc == 2 || setcall (tmpcall, argv[2]) == -1) memcpy (tmpcall, Ax25multi[IDCALL], AXALEN); if(argc > 3) /* digis present? */ if(connect_filt(argc,argv,tmpcall,axif) == 0) return 1; /* Now everything seems okay ! Get a session */ if((sp = newsession("axui",AXUITNC,1)) == NULLSESSION) { j2tputs(TooManySessions); return 1; } while (1) { /* restart: replace GOTO label with while loop */ tprintf("%s%s session %u UI frames %s->%s on interface %s\n", (first) ? "" : "\n", Sestypes[sp->type],sp->num, pax25(buf, axif->hwaddr), pax25(name,tmpcall), axif->name); Axui_sock = Curproc->output; first = 0; /* Process whatever's typed on the terminal */ while(recvline(Curproc->input,buf,sizeof(buf)-1) >= 0) { goto_restart = 0; /* replaces GOTO label */ goto_done = 0; /* replaces GOTO label */ if(buf[0] == '/') { rip (buf); cp = skipnonwhite(buf); /* advance to first arg */ cp = skipwhite(cp); /* process commands */ switch(tolower(buf[1])) { case 'h': case '?': j2tputs("<Cmds>: /c call; /i iface; /q (to quit); /t (toggle timestamp)\n"); goto_restart = 1; break; case 'c': if (argc > 3) { j2tputs(DigisUsed); break; } if (setcall (tmpcall2, cp) == -1) break; memcpy (tmpcall, tmpcall2, AXALEN); goto_restart = 1; break; case 'i': if (argc > 3) { j2tputs(DigisUsed); break; } if(((ifc = if_lookup(cp)) != NULLIF) && (ifc->type == CL_AX25)) { axif = ifc; goto_restart = 1; } else j2tputs ("<invalid interface>\n"); break; case 'b': case 'e': case 'q': goto_done = 1; break; case 't': ui_timestamp = !ui_timestamp; break; } if (goto_done) /* replaces GOTO 'done:' label */ break; if (goto_restart) /* replaces GOTO 'restart:' label */ break; } else { i = strlen(buf); if((bp = alloc_mbuf(i)) == NULLBUF) break; /* unwritten protocol is that AX.25 lines end in \r, not \n. * recvline will always return at least one character. If the * operater typed more than sizeof(buf) - 1 without eol, * TOUGH! - K5JB */ buf[i - 1] = '\r'; bp->cnt = i; memcpy(bp->data,buf,(size_t)i); /* send it */ (*axif->output)(axif, tmpcall, axif->hwaddr, PID_NO_L3, bp); } usflush(Curproc->output); } if (!goto_restart) /* means the recv_line while naturally exited */ break; /* this covers the goto_done cases nicely */ } /* end of GOTO while loop */ /* done: */ if (argc > 3) /* remove digi route added by connect_filt */ ax_drop(tmpcall, axif, 0); Axui_sock = -1; tprintf("\n%s session %u closed: EOF\n", Sestypes[sp->type],sp->num); keywait(NULLCHAR,1); freesession(sp); return 0; }
int hfdd_connect (char *cc) { char cbuf[20], *cptr, *ccptr, **pargv; int cnt; pargv = (char **)callocw(3,sizeof(char *)); /* just to get this working, it needs better structure */ for (ccptr = cc, cnt = 0; cnt < 3; cnt++) { cptr = cbuf; while (*ccptr && *ccptr != ' ') *cptr++ = *ccptr++; *cptr = 0; /* 20Mar2006, Maiko, Remove any EOL (end of line) chars */ if (cnt == 2) rip (cbuf); if (hfdd_debug) log (-1, "cbuf [%s]", cbuf); pargv[cnt] = j2strdup (cbuf); if (*ccptr == ' ') ccptr++; } hfdd_conn_flag = 0; /* 03Feb2005, MAKE SURE this is set !!! */ /* * 16Apr2007, Maiko (VE4KLM), Identify which device interface is, now * that I have the KAM connect working nicely, I need to add the other * devices, PTC now, the DXP will be later. */ /* 17Feb2007, Maiko, New way to conn */ if (hfdd_is_kam (pargv[1])) kam_make_call (pargv[2]); else if (hfdd_is_ptc (pargv[1])) ptc_make_call (pargv[2]); /* 23Apr2008, Maiko, Now support AEA PK232 modem */ /* 10Sep2008, Maiko, New queue system for PK232, different function */ else if (hfdd_is_pk232 (pargv[1])) pk232_connect (pargv[1], pargv[2]); else if (hfdd_is_dxp (pargv[1])) log (-1, "dxp not supported YET ..."); #ifdef WINMOR /* 07Apr2010, Maiko, Support the WINMOR Sound Card modem */ else if (hfdd_is_winmor (pargv[1])) winmor_make_call (pargv[2]); #endif /* * 16Feb2007, Maiko, Need a function to request connect from hfddsrv * used to be hfdd_console here - no more, since hfddsrv fulltime now */ if (hfdd_debug) log (-1, "trying [%s]", pargv[2]); /* 04Mar2006, Maiko, Fix up this wait for connection ... */ while (!hfdd_conn_flag) j2pause (100); if (hfdd_conn_flag == -1) { if (hfdd_debug) log (-1, "[%s] no connection", pargv[2]); return -1; } if (hfdd_debug) log (-1, "[%s] connected - assign socket pair", pargv[2]); /* use socket pair like bbs side, 08Jan2005 */ if (j2socketpair (AF_LOCAL, SOCK_STREAM, 0, fwds) == -1) { log (-1, "socketpair failed, errno %d", errno); return -1; } seteol (fwds[0], "\r"); seteol (fwds[1], "\r"); /* seteol (fwds[0], "\r\n"); seteol (fwds[1], "\r\n"); */ hfdd_fwdsock = fwds[0]; /* this is for our local access */ sockmode (fwds[1], SOCK_ASCII); return (fwds[1]); /* this one becomes m->user in forward.c */ }
void ClusterGeoIpService::threadMain() throw() { char linebuf[65536]; char buf[65536]; long n,lineptr; while (_run) { { Mutex::Lock _l(_sOutputLock); _sOutputFd = -1; _sInputFd = -1; _sPid = 0; int stdinfds[2] = { 0,0 }; // sub-process's stdin, our output int stdoutfds[2] = { 0,0 }; // sub-process's stdout, our input ::pipe(stdinfds); ::pipe(stdoutfds); long p = (long)::vfork(); if (p < 0) { Thread::sleep(500); continue; } else if (p == 0) { ::close(stdinfds[1]); ::close(stdoutfds[0]); ::dup2(stdinfds[0],STDIN_FILENO); ::dup2(stdoutfds[1],STDOUT_FILENO); ::execl(_pathToExe.c_str(),_pathToExe.c_str(),(const char *)0); ::exit(1); } else { ::close(stdinfds[0]); ::close(stdoutfds[1]); _sOutputFd = stdinfds[1]; _sInputFd = stdoutfds[0]; _sPid = p; } } lineptr = 0; while (_run) { n = ::read(_sInputFd,buf,sizeof(buf)); if (n <= 0) { if (errno == EINTR) continue; else break; } for(long i=0;i<n;++i) { if (lineptr > (long)sizeof(linebuf)) lineptr = 0; if ((buf[i] == '\n')||(buf[i] == '\r')) { linebuf[lineptr] = (char)0; if (lineptr > 0) { //fprintf(stderr,"ClusterGeoIpService: >> %s\n",linebuf); try { std::vector<std::string> result(Utils::split(linebuf,",","","")); if ((result.size() >= 7)&&(result[1] == "1")) { InetAddress rip(result[0],0); if ((rip.ss_family == AF_INET)||(rip.ss_family == AF_INET6)) { _CE ce; ce.ts = OSUtils::now(); ce.x = (int)::strtol(result[4].c_str(),(char **)0,10); ce.y = (int)::strtol(result[5].c_str(),(char **)0,10); ce.z = (int)::strtol(result[6].c_str(),(char **)0,10); //fprintf(stderr,"ClusterGeoIpService: %s is at %d,%d,%d\n",rip.toIpString().c_str(),ce.x,ce.y,ce.z); { Mutex::Lock _l2(_cache_m); _cache[rip] = ce; } } } } catch ( ... ) {} } lineptr = 0; } else linebuf[lineptr++] = buf[i]; } } ::close(_sOutputFd); ::close(_sInputFd); ::kill(_sPid,SIGTERM); Thread::sleep(250); ::kill(_sPid,SIGKILL); ::waitpid(_sPid,(int *)0,0); } }
void *pyrip_thread (void *arg) { printf ("in thread first\n"); thread_arg_s *thread_arg = (thread_arg_s *)arg; char **filenames_c = thread_arg->filenames_c; text_tag_s **text_tags = thread_arg->text_tags; rip_opts_s *rip_opts = thread_arg->rip_opts; int size = thread_arg->size; char *device = thread_arg->device; cdrom_drive *drive; int i; /* child thread*/ printf ("in thread\n"); printf ("thread_arg: %s\n", thread_arg->device); printf ("device: %s\n", device); if (strcmp (device, "auto") == 0) { drive = cdda_find_a_cdrom (0, NULL); } else { drive = cdda_identify (device, 0, NULL); } if (drive == NULL) { log_msg ("Couldn't get a CD drive", FL, FN, LN); exit (1); } cdda_open (drive); if (filenames_c == NULL) { log_msg ("Error allocating filenames_c", FL, FN, LN); } for (i = 0; i < size; i++) { print_text_tag (text_tags[i]); } rip (drive, text_tags, filenames_c); for (i = 0; i < size; i++) { //free_text_tag (text_tags[i]); printf ("freeing filename\n"); free (filenames_c[i]); } //free (text_tags); printf ("freeing filenames\n"); free (filenames_c); printf ("freeing device\n"); free (device); printf ("freeing rip opts\n"); free_rip_opts (rip_opts); printf ("freeing thread arg\n"); free (thread_arg); //Py_DECREF (tags); //cdda_close (drive); printf ("done freeing, detaching\n"); pthread_detach (pthread_self ()); printf ("done\n"); return NULL; }
int main() { FILE * fin = fopen("input.txt", "r"); FILE * fout = fopen("output.txt", "w"); tree root; tree node; tree rear, front; int n, tmp; int i; fscanf(fin, "%d", &n); root = (tree)malloc(sizeof(*root)); root->next = NULL; root->parent = NULL; root->rc = NULL; root->lc = NULL; node = root; for ( i = 0 ; i < n ; i ++ ) { fscanf(fin, "%d", &tmp); insert(&root, &node, tmp); } front = root->next; rear = root->next; while(1) { if(rear->next != NULL) { rear = rear->next; if(rear->val != 0 ) { rear->parent = front; front->lc = rear; } } if(rear->next != NULL) { rear = rear->next; if(rear->val != 0) { rear->parent = front; front->rc = rear; } } front = front->next; if(front == NULL) { break; } } inorder((root->next), fout); rip(&root); //free(root); fclose(fin); fclose(fout); return 0; }
int main () { to toma; int op; toma.saude = 100; toma.fome = 10; toma.felicidade = 50; toma.xp = 0; printf("Bem vindo ao seu Tamagotchi"); printf("\n\n"); printf("\nInforme o nome do seu Tamagotchi\n"); fgets(toma.nome,50,stdin); system("cls"); printf("seu tamagotchi esta vivo =D\n"); while (op!=6){ mostratoma(); printf("\n1 - Mostar status\n"); printf("2 - Dar comida\n"); printf("3 - Brincar\n"); printf("4 - Dar remedio\n"); printf("5 - Evoluir\n"); printf("6 - Sair\n"); scanf("%d",&op); fflush(stdin); if(toma.saude==0){ rip(); } switch (op){ case 1 : { system("cls"); printf("Status\n Nome : %s\n Saude : %d\n Fome : %d\n Felicidade : %d\n",toma.nome,toma.saude,toma.fome,toma.felicidade); break; } case 2 :{ system("cls"); printf("voce alimentou seu tamagotchi"); toma.fome+=10; if(toma.fome==50){ system("cls"); printf("CUIDADO, Seu tamagotchi esta cheio!!!\n"); printf("Ele podera ficar doente..."); } if(toma.fome==100){ printf("seu tamagotchi esta Doente!!!\n"); printf("RAPIDO de o remedio ao seu tamagotchi..."); toma.saude-=50; } if(toma.fome==110){ toma.saude-=50; } break; } case 3:{ brincar(); toma.felicidade+=10; break; } case 4:{ system("cls"); printf("Voce deu remedio ao seu tamagotchi, ele nao esta mais doente"); toma.saude+=50; toma.fome=0; break; } case 5:{ system("cls"); if(toma.xp <50){ printf("Seu tamagotchi ainda nao esta pronto para evoluir :(\n"); } break; } default:{return 0; break; } } } return 0; }