static void delivery_filename_open(struct deliver *deliver) { struct stat sb; time_t now; size_t len; int fd; FILE *fp; char *ln; char *msg; int n; #define error(m) { msg = m; goto err; } #define error2(m) { msg = m; goto err2; } setproctitle("file delivery"); fd = open(deliver->to, O_CREAT | O_APPEND | O_WRONLY, 0600); if (fd < 0) error("open"); if (fstat(fd, &sb) < 0) error("fstat"); if (S_ISREG(sb.st_mode) && flock(fd, LOCK_EX) < 0) error("flock"); fp = fdopen(fd, "a"); if (fp == NULL) error("fdopen"); time(&now); fprintf(fp, "From %s@%s %s", SMTPD_USER, env->sc_hostname, ctime(&now)); while ((ln = fgetln(stdin, &len)) != NULL) { if (ln[len - 1] == '\n') len--; if (len >= 5 && memcmp(ln, "From ", 5) == 0) putc('>', fp); fprintf(fp, "%.*s\n", (int)len, ln); if (ferror(fp)) break; } if (ferror(stdin)) error2("read error"); putc('\n', fp); if (fflush(fp) == EOF || ferror(fp)) error2("write error"); if (fsync(fd) == -1) { if (errno != EINVAL) error2("fsync"); } if (fclose(fp) == EOF) error2("fclose"); _exit(0); err2: n = errno; ftruncate(fd, sb.st_size); errno = n; err: perror(msg); _exit(1); }
bool abstract_interpreter_method_info::verify() { if (_map_oop->verify_oop()) ; else { error1("bad oop in abstract_interpreter_method_info 0x%x", this); return false; } if ( codes == (unsigned char*)map()->codes()->bytes() && length_codes == map()->codes()->length() && literals == map()->literals()->objs() && length_literals == map()->literals()->length() ) ; else { error1("inconsistency in abstract_interpreter_method_info 0x%x", this); return false; } if (!literals_object->is_objVector()) { error2("literals_object 0x%x in " "abstract_interpreter_method_info 0x%x not objVector", literals_object, this); return false; } if (!codes_object->is_byteVector()) { error2("codes_object 0x%x in " "abstract_interpreter_method_info 0x%x not byteVector", codes_object, this); return false; } return true; }
int open_archive(char *name, int mode) { unsigned short magic = 0; int fd; if (mode == CREATE) { if ((fd = creat(name, 0666)) < 0) error2(TRUE, "cannot creat %s\n", name); magic = MAGIC_NUMBER; wr_int2(fd, magic); return fd; } if ((fd = open(name, mode)) < 0) { if (mode == APPEND) { close(open_archive(name, CREATE)); if (!nocr_fl) error3(FALSE, "%s: creating %s\n", progname, name); return open_archive(name, APPEND); } error2(TRUE, "cannot open %s\n", name); } lseek(fd, 0L, 0); magic = rd_unsigned2(fd); if (magic != AALMAG && magic != ARMAG) error2(TRUE, "%s is not in ar format\n", name); return fd; }
void main (int argc, char*argv[]) { int lline=32000, i,j, ch, jeffnode, inode; char line[32000], mcmcf[96]="o.multidivtime"; FILE *fmcmc; double t; puts("Usage:\n\tTreeTimeJeff <MultidivtimeOutputFile>\n"); if(argc>1) strcpy(mcmcf, argv[1]); fmcmc=gfopen(mcmcf, "r"); /* Read root node number */ for( ; ; ) { if(fgets(line, lline, fmcmc) == NULL) error2("EOF mcmc file"); if(strstr(line, "Root node number of master tree is")==NULL) continue; sscanf(line+35, "%d", &j); com.ns=j/2+1; break; } printf("Tree has %d taxa.\n\n", com.ns); /* read tree. JeffNode read into [].branch */ for(; ; ) { ch=fgetc(fmcmc); if(ch==EOF) error2("EOF treefile"); if(ch=='(') { ungetc(ch,fmcmc); break; } } ReadTreeN(fmcmc, &i, &j, 2, 0); OutTreeN(F0,1,0); FPN(F0); FPN(F0); /* read posterior time estimates */ for(i=0; i<tree.nnode; i++) nodes[i].age=0; for( ; ; ) { if(fgets(line, lline, fmcmc) == NULL) error2("EOF mcmc file"); if(strstr(line, "Actual time node")==NULL) continue; sscanf(line+17, "%d =%lf", &jeffnode, &t); if(jeffnode<com.ns) { if(t>0) nodes[inode].age=t; } else { inode=tree.nnode-1+com.ns-jeffnode; printf("JeffNode %3d ZihengNode %3d time %9.6f\n", jeffnode,inode+1,t); nodes[inode].age=t; if(inode==com.ns) break; if(jeffnode-nodes[inode].branch != 0) printf(" node number error. "); } } for(i=0; i<tree.nnode; i++) if(i!=tree.root) nodes[i].branch=nodes[nodes[i].father].age-nodes[i].age; FPN(F0); OutTreeN(F0,1,1); FPN(F0); fclose(fmcmc); exit(0); }
static void _error(struct request *r, char *msg) { char buf[MSG_SIZE]; if (r) { error(log_strcpy3(buf, sizeof buf, r->verb,r->algorithm,msg)); if (r->digest) error2("digest", r->digest); } else error2("sha", msg); }
void TreeDistanceDistribution (FILE* fout) { /* This calculates figure 3.7 of Yang (2006). This reads the file of all trees (such as 7s.all.trees), and calculates the distribution of partition distance in all pairwise comparisons. */ int i,j,ntree, k,*nib, nsame, IBsame[NS], lpart=0; char treef[64]="5s.all.trees", *partition; FILE *ftree; double mPD[NS], PD1[NS]; /* distribution of partition distances */ puts("Tree file name?"); scanf ("%s", treef); ftree=gfopen (treef,"r"); fscanf (ftree, "%d%d", &com.ns, &ntree); printf("%2d sequences %2d trees.\n", com.ns, ntree); i=(com.ns*2-1)*sizeof(struct TREEN); if((nodes=(struct TREEN*)malloc(i))==NULL) error2("oom"); lpart = (com.ns-1)*com.ns*sizeof(char); i = ntree*lpart; printf("\n%d bytes of space requested.\n", i); partition = (char*)malloc(i); nib = (int*)malloc(ntree*sizeof(int)); if (partition==NULL || nib==NULL) error2("out of memory"); puts("\ntree #: mean prop of tree pairs with 0 1 2 ... shared bipartitions\n"); fputs("\ntree #: prop of tree pairs with 0 1 2 ... shared bipartitions\n",fout); for (i=0; i<ntree; i++) { ReadTreeN (ftree, &j, &k, 0, 1); nib[i]=tree.nbranch-com.ns; Tree2Partition(partition+i*lpart); } for(k=0; k<com.ns-3; k++) mPD[k]=0; for (i=0; i<ntree; i++,FPN(fout)) { for(k=0; k<com.ns-3; k++) PD1[k]=0; for (j=0; j<ntree; j++) { if(j==i) continue; nsame=NSameBranch(partition+i*lpart,partition+j*lpart, nib[i],nib[j],IBsame); PD1[nsame] ++; } for(k=0; k<com.ns-3; k++) PD1[k] /= (ntree-1.); for(k=0; k<com.ns-3; k++) mPD[k] = (mPD[k]*i+PD1[k])/(i+1.); printf("%8d (%5.1f%%):", i+1,(i+1.)/ntree*100); for(k=0; k<com.ns-3; k++) printf(" %7.4f", mPD[k]); fprintf(fout, "%8d:", i+1); for(k=0; k<com.ns-3; k++) fprintf(fout, " %7.4f", PD1[k]); printf("%s", (com.ns<8||(i+1)%100==0 ? "\n" : "\r")); } free(partition); free(nodes); free(nib); fclose(ftree); exit(0); }
inline void subMonomial::start(int newstart) { #ifdef CAREFUL if(newstart<=0) { error1(newstart); } else if (newstart + _length - 1 > _mono.numberOfFactors()) { error2(newstart); } else #endif { if(newstart>_start) { int diff = newstart - _start; if(diff==0) { /* do nothing */ } else if(diff==1) { ++start_iterator; } else { if(diff<0) errorh(__LINE__); for(int jjjj=1;jjjj<=diff;++jjjj,++start_iterator) {}; #if 0 ncgbadvance(start_iterator,diff); // just diff, not diff-1 #endif } _start = newstart; } else { _start = newstart; start_iterator = _mono.begin(); for(int jjjj=2;jjjj<=newstart;++jjjj,++start_iterator) {}; #if 0 ncgbadvance(start_iterator,newstart-1); #endif } } };
int NeighborNNI (int i_tree) { /* get the i_tree'th neighboring tree of tree by the nearest neighbor interchange (NNI), each tree has 2*(# internal branches) neighbors. works with rooted and unrooted binary trees. Gives the ip_th neighbor for interior branch ib. Involved branches are a..b, a..c, b..d, with a..b to be the internal branch. swap c with d, with d to be the ip_th son of b */ int i, a,b,c,d, ib=i_tree/2, ip=i_tree%2; if (tree.nbranch!=com.ns*2-2-(nodes[tree.root].nson==3)) error2 ("err NeighborNNI: multificating tree."); /* locate a,b,c,d */ for (i=0,a=0; i<tree.nbranch; i++) if (tree.branches[i][1]>=com.ns && a++==ib) break; ib=i; a=tree.branches[ib][0]; b=tree.branches[ib][1]; c=nodes[a].sons[0]; if(c==b) c=nodes[a].sons[1]; d=nodes[b].sons[ip]; /* swap nodes c and d */ tree.branches[nodes[c].ibranch][1]=d; tree.branches[nodes[d].ibranch][1]=c; BranchToNode (); return (0); }
int open_stream(mpg123_handle *fr, const char *bs_filenam, int fd) { int filept_opened = 1; int filept; /* descriptor of opened file/stream */ clear_icy(&fr->icy); /* can be done inside frame_clear ...? */ if(!bs_filenam) /* no file to open, got a descriptor (stdin) */ { filept = fd; filept_opened = 0; /* and don't try to close it... */ } #ifndef O_BINARY #define O_BINARY (0) #endif else if((filept = compat_open(bs_filenam, O_RDONLY|O_BINARY)) < 0) /* a plain old file to open... */ { if(NOQUIET) error2("Cannot open file %s: %s", bs_filenam, strerror(errno)); fr->err = MPG123_BAD_FILE; return MPG123_ERR; /* error... */ } /* now we have something behind filept and can init the reader */ fr->rdat.filelen = -1; fr->rdat.filept = filept; fr->rdat.flags = 0; if(filept_opened) fr->rdat.flags |= READER_FD_OPENED; return open_finish(fr); }
/* Open a module, including directory search. */ mpg123_module_t* open_module(const char* type, const char* name) { mpg123_module_t *module = NULL; char *workdir = NULL; char *moddir = NULL; workdir = get_the_cwd(); moddir = get_module_dir(); if(workdir == NULL || moddir == NULL) { error("Failure getting workdir or moddir! (Perhaps set MPG123_MODDIR?)"); if(workdir == NULL) fprintf(stderr, "Hint: I need to know the current working directory to be able to come back after hunting modules. I will not leave because I do not know where I am.\n"); if(workdir != NULL) free(workdir); if(moddir != NULL) free(moddir); return NULL; } if(chdir(moddir) == 0) module = open_module_here(type, name); else error2("Failed to enter module directory %s: %s", moddir, strerror(errno)); chdir(workdir); free(moddir); free(workdir); return module; }
void tst_qdeclarativeerror::copy() { QDeclarativeError error; error.setUrl(QUrl("http://www.qt-project.org/main.qml")); error.setDescription("An Error"); error.setLine(92); error.setColumn(13); QDeclarativeError error2(error); QDeclarativeError error3; error3 = error; error.setUrl(QUrl("http://www.qt-project.org/main.qml")); error.setDescription("Another Error"); error.setLine(2); error.setColumn(33); QCOMPARE(error.url(), QUrl("http://www.qt-project.org/main.qml")); QCOMPARE(error.description(), QString("Another Error")); QCOMPARE(error.line(), 2); QCOMPARE(error.column(), 33); QCOMPARE(error2.url(), QUrl("http://www.qt-project.org/main.qml")); QCOMPARE(error2.description(), QString("An Error")); QCOMPARE(error2.line(), 92); QCOMPARE(error2.column(), 13); QCOMPARE(error3.url(), QUrl("http://www.qt-project.org/main.qml")); QCOMPARE(error3.description(), QString("An Error")); QCOMPARE(error3.line(), 92); QCOMPARE(error3.column(), 13); }
int cmd_exec(struct command_t* command){ if(error1(command)) return -1; if(error2(command)) return -2; if(error3(command)) return -3; if(error4(command)) return -4; if(error5(command)) return -5; if(isNum(command->token[0])){ command->arg1 = atoi(command->token[0]); strcpy(command->operation, command->token[1]); command->arg2 = atoi(command->token[2]); } else{ strcpy(command->operation, command->token[0]); command->arg1 = atoi(command->token[1]); } DoOperation(command); return 0; }
bool check_saved_byte_map_base() { if (Byte_Map_Base() != (char*)saved_globals[ByteMapBaseReg - G0]) { error2("rSet: saved_globals for ByteMapBaseReg corrupted (%#lx vs. %#lx)", saved_globals[ByteMapBaseReg - G0], Byte_Map_Base()); return false; } return true; }
bool codeTable::verify() { bool flag = true; for (nmln* p = buckets; p < &buckets[tableSize]; ++p) { flag = flag && p->verify_list_integrity(); for (nmln* q = p->next; q != p; q = q->next) { codeTableEntry *e= entryForLink(q); nmethod* nm= e->nm; if (!nmethod::isNMethod(nm)) { error2("bad nmethod 0x%lx in bucket 0x%lx", nm, p); flag = false; } if (bucketFor(e->key.hash()) != p) { error2("code table entry 0x%lx not in bucket 0x%lx", e, p); flag = false; } } } return flag; }
ModelTracker::Scalar ModelTracker::calcReprojectionError(const ModelTracker::ImgPoint imagePoints[],const ModelTracker::Transform& transform) const { Scalar error2(0); for(unsigned int mpi=0;mpi<numModelPoints;++mpi) { /* Project the transformed model point: */ ImgPoint ip=project(transform.transform(modelPoints[mpi])); error2+=Geometry::sqrDist(ip,imagePoints[mpi]); } return error2; }
int lookup(char *key) { int i; for (i = MAXTAB-1; i >= 0 ; i--) { if (!strcmp(key,keytab[i])) { d("lookup ",symtab[i],key); return i; } } error2("INTERNAL SYMTAB LOOKUP ERROR, can't find ", key); return -1; }
int CountLHsTree (void) { /* This counts the number of labeled histories for a given rooted tree. */ int i,k, nLH, nLR[NS-1][2], change, *sons, j; double y=0; for(i=com.ns; i<tree.nnode; i++) if(nodes[i].nson!=2) error2("this works for rooted trees only"); for(i=com.ns; i<tree.nnode; i++) nLR[i-com.ns][0] = nLR[i-com.ns][1] = -1; for(k=0; k<com.ns; k++) { for(i=tree.nnode-1,change=0; i>=com.ns; i--) { sons = nodes[i].sons; for(j=0; j<2; j++) { if(nLR[i-com.ns][j] != -1) continue; if(sons[j] < com.ns) { nLR[i-com.ns][j] = 0; change = 1; } else if(nLR[sons[j]-com.ns][0] != -1 && nLR[sons[j]-com.ns][1] != -1) { nLR[i-com.ns][j] = nLR[sons[j]-com.ns][0] + nLR[sons[j]-com.ns][1] + 1; change = 1; } } } if(!change) break; } for(i=0,nLH=1; i<tree.nnode-com.ns; i++) { /* printf("\nnode %2d (%2d %2d): %2d %2d ", i+com.ns, nodes[i+com.ns].sons[0], nodes[i+com.ns].sons[1], nLR[i][0], nLR[i][1]); */ if(nLR[i][0]==-1 || nLR[i][1]==-1) error2("nLR = -1"); if(nLR[i][0] && nLR[i][1]) { nLH *= (int)Binomial((double)(nLR[i][0]+nLR[i][1]), min2(nLR[i][0], nLR[i][1]), &y); if(y) error2("y!=0 not considered"); } } return(nLH); }
bool NCodeBase::verify2(const char* name) { bool r = true; if ((int32)this & (oopSize - 1)) { error2("alignment error in %s at %#lx", name, this); r = false; } if (instsLen() > 256 * K) { error3("instr length of %s at %#lx seems too big (%ld)", name, this, instsLen()); r = false; } return r; }
void enter(char *key, char *val) { int i; d("enter ",val, key); for (i = 0; i < MAXTAB; i++) { if (keytab[i][0] == '\0') { strcpy(keytab[i],key); strcpy(symtab[i],val); return; } } error2("INTERNAL SYMTAB ENTER ERROR, can't enter ", val); return; }
static int open_track_fd (void) { /* Let reader handle invalid filept */ if(mpg123_open_fd(mh, filept) != MPG123_OK) { error2("Cannot open fd %i: %s", filept, mpg123_strerror(mh)); return 0; } debug("Track successfully opened."); fresh = TRUE; return 1; /*1 for success, 0 for failure */ }
void BB::verify() { fint count = 0; for (Node* n = first; n != last->next(); n = n->next()) { count++; n->verify(); if (n->bb() != this) error2("BB %#lx: Node %#lx doesn't point back to me", this, n); // endsBB() is true if the block isn't memoized. But when a block // is memoized after the basic block structure was created, the // assertion will complain because the BB structure is never updated // (as a matter of principle). // if (n == last && !n->endsBB() && // !(n->next() && n->next()->isMergeNode() && // ((MergeNode*)(n->next()))->didStartBB)) { // error2("BB %#lx: last Node %#lx isn't endsBB()", this, n); // fatal("compiler error"); // so it bombs when hit // } if (n->endsBB() && n != last) error2("BB %#lx: Node %#lx ends BB but isn't last node", this, n); } if (count != nnodes) error1("incorrect nnodes in BB %#lx", this); }
static int init_tinyalsa(out123_handle* ao) { if (ao==NULL) return -1; /* Set callbacks */ ao->open = open_tinyalsa; ao->flush = flush_tinyalsa; ao->write = write_tinyalsa; ao->get_formats = get_formats_tinyalsa; ao->close = close_tinyalsa; ao->deinit = deinit_tinyalsa; /* Allocate memory for data structure */ ao->userptr = malloc( sizeof( mpg123_tinyalsa_t ) ); if(ao->userptr==NULL) { if(!AOQUIET) error("failed to malloc memory for 'mpg123_tinyalsa_t'"); return -1; } memset( ao->userptr, 0, sizeof(mpg123_tinyalsa_t) ); /* Set card and device */ mpg123_tinyalsa_t* ta = (mpg123_tinyalsa_t*)ao->userptr; ta->card = 0; ta->device = 0; if (ao->device) { char *ptr = ao->device; ta->card = (unsigned int)strtol(ptr, &ptr, 10); if (strlen(ptr) > 0) { ta->device = (unsigned int)strtol(++ptr, &ptr, 10); } } /* Get card/device parameters */ ta->params = pcm_params_get(ta->card, ta->device, PCM_OUT); if (ta->params == NULL) { if(!AOQUIET) error2( "(params) Unable to open card %u PCM device %u.\n" , ta->card, ta->device ); return -1; } /* Success */ return 0; }
static int win32_net_open_connection(mpg123_string *host, mpg123_string *port) { struct addrinfo hints; struct addrinfo *addr, *addrlist; SOCKET addrcount; ws.local_socket = SOCKET_ERROR; if(param.verbose>1) fprintf(stderr, "Note: Attempting new-style connection to %s\n", host->p); memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; /* We accept both IPv4 and IPv6 ... and perhaps IPv8;-) */ hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; debug2("Atempt resolve/connect to %s:%s", host->p, port->p); msgme(addrcount = getaddrinfo(host->p, port->p, &hints, &addrlist)); if(addrcount == INVALID_SOCKET) { error3("Resolving %s:%s: %s", host->p, port->p, gai_strerror(addrcount)); return -1; } addr = addrlist; while(addr != NULL) { ws.local_socket = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); if (ws.local_socket == INVALID_SOCKET) { msgme1; } else { if(win32_net_timeout_connect(ws.local_socket, addr->ai_addr, addr->ai_addrlen) == 0) break; debug("win32_net_timeout_connect error, closing socket"); win32_net_close(ws.local_socket); ws.local_socket=SOCKET_ERROR; } addr=addr->ai_next; } if(ws.local_socket == SOCKET_ERROR) {error2("Cannot resolve/connect to %s:%s!", host->p, port->p);} else { ws.inited = 2; } freeaddrinfo(addrlist); return 1; }
static int cli_option_set(cli_option* o, const char* arg) { char* endptr; switch(o->type) { case CLI_FLAG: *(int*)o->dataptr = o->flag_value; return 0; case CLI_COUNTER: *(int*)o->dataptr += o->flag_value; return 0; case CLI_INTEGER: *(int*)o->dataptr = strtol(arg, &endptr, 10); if(*endptr) { error2("Invalid integer: ", arg); return -1; } return 1; case CLI_UINTEGER: *(unsigned*)o->dataptr = strtoul(arg, &endptr, 10); if(*endptr) { error2("Invalid unsigned integer: ", arg); return -1; } return 1; case CLI_STRINGLIST: *(cli_stringlist**)o->dataptr = stringlist_append(*(cli_stringlist**)o->dataptr, arg, o); return 1; case CLI_FUNCTION: ((cli_function*)o->dataptr)(arg, o); return 1; default: *(const char**)o->dataptr = arg; return 1; } }
/** Wait for start block token */ uint8_t sdWaitStartBlock(void) { uint8_t r; uint32_t t0 = 0; while ((r = spiRec()) == 0XFF) { t0++; _delay_us(2); if ((t0/1000) > SD_READ_TIMEOUT) { error1(SD_CARD_ERROR_READ_TIMEOUT); return 0; } } if (r == DATA_START_BLOCK) return 1; error2(SD_CARD_ERROR_READ, r); return 0; }
void writeToUserDir(Seqbyte fln,Seqbyte s) { FILE *stream;int ln,rs,spr; if (strlen(userDir) == 0) UM_ERROR("No user directory available"); // if (safeMode) UM_ERROR("File access is prohibited in safeMode"); ln = s ->data->length; if (ln > maxTempFileSize) UM_ERROR("Exceeded maxTempfileSize limit"); Seqbyte_copyto_filenameBuf(fln); spr = strspn(filenameBuf,"abcdefghijklmnopqrstuvwxyz0123456789_/."); if (spr<strlen(filenameBuf)) UM_ERROR("Illegal filename"); if (!strncmp(filenameBuf,"/",1)) error2("Illegal filename:",filenameBuf); if (strstr(filenameBuf,"..")) error2("Illegal filename",filenameBuf); if (strstr(filenameBuf,"//")) error2("Illegal filename",filenameBuf); strcpy(filenameBuf,userDir); ln = strlen(filenameBuf); Seqbyte_copyto(filenameBuf+ln,filenameBuf_length-ln,fln); if( (stream = fopen(filenameBuf, "wb" )) == NULL ) error2("Unable to write user file:",filenameBuf); { ln = s ->data->length; rs = fwrite(Arraybyte_contents(s->data),sizeof(char),ln,stream); fclose( stream ); } }
int main(void) { int n=400, noisy=0, i,j; int nr=10, ir, TimeSquare=10, algorithm; /* TimeSquare should be larger for large t */ double t=5, *Q, *pi, *space, s; char timestr[96], *AlgStr[2]={"repeated squaring", "eigensolution"}; if((Q=(double*)malloc(n*n*5*sizeof(double))) ==NULL) error2("oom"); pi=Q+n*n; space=pi+n; for(algorithm=0; algorithm<2; algorithm++) { starttime(); SetSeed(1234567); for (i=0; i<n; i++) pi[i]=rndu(); s=sum(pi,n); for (i=0; i<n; i++) pi[i]/=s; for(ir=0; ir<nr; ir++) { printf("Replicate %d/%d ", ir+1,nr); for (i=0; i<n; i++) for (j=0,Q[i*n+i]=0; j<i; j++) Q[i*n+j]=Q[j*n+i] = square(rndu()); for (i=0; i<n; i++) for (j=0; j<n; j++) Q[i*n+j] *= pi[j]; for(i=0,s=0; i<n; i++) { /* rescaling Q so that average rate is 1 */ Q[i*n+i]=0; Q[i*n+i]=-sum(Q+i*n, n); s-=pi[i]*Q[i*n+i]; } if(noisy) { matout(stdout, pi, 1, n); matout(stdout, Q, n, n); } if(algorithm==0) matexp(Q, 1, n, TimeSquare, space); else PMatQRev(Q, pi, 1, n, space); printf("%s, time: %s\n", AlgStr[algorithm], printtime(timestr)); if(noisy) matout(stdout, Q, n, n); } } return (0); }
int between_f_and_x (void) { /* this helps with the exponential transform for frequency parameters */ int i,n,fromf=0; double x[100]; for(;;) { printf("\ndirection (0:x=>f; 1:f=>x; -1:end) & #classes? "); scanf("%d",&fromf); if(fromf==-1) return(0); scanf("%d", &n); if(n>100) error2("too many classes"); printf("input the first %d values for %s? ",n-1,(fromf?"f":"x")); FOR(i,n-1) scanf("%lf",&x[i]); x[n-1]=(fromf?1-sum(x,n-1):0); f_and_x(x, x, n, fromf, 1); matout(F0,x,1,n); } }
/* This routine runs along the task list and executes any job that wants * to be run. */ static inline void check_runs(struct tm *now) { centry task; int pid; char *av[5]; char s[26]; char *q; if (tasklist == NULL) return; for (task = tasklist; task != NULL; task = task->next) { if (bit_test(task->minutes, now->tm_min) && bit_test(task->hours, now->tm_hour) && bit_test(task->months, now->tm_mon+1) && bit_test(task->dom, now->tm_mday) && bit_test(task->dow, now->tm_wday)) { asctime_r(now, s); q = strchr(s, '\n'); if (q != NULL) *q = '\0'; log3(s, " Running: ", task->prog); av[0] = "cron-parent"; /* Build the cron-parent's argv structure */ av[1] = task->prog; av[2] = itoa(task->user); av[3] = task->username; av[4] = NULL; pid = vfork(); if (pid == 0) { /* Child */ /* This job is ready to run. Exec the special cron parent * process which actually runs the job. */ //execve("/bin/cron", av, task->environ); /*Tony*/ execve("/usr/sbin/crond", av, task->environ); error("Unable to exec task: cron-parent"); _exit(0); } if (pid < 0) error2("Unable to exec task: ", task->prog); } } }
int make_conv16to8_table(mpg123_handle *fr) { int i; int mode = fr->af.encoding; /* * ????: 8.0 is right but on SB cards '2.0' is a better value ??? */ const double mul = 8.0; if(!fr->conv16to8_buf){ fr->conv16to8_buf = (unsigned char *) malloc(8192); if(!fr->conv16to8_buf) { fr->err = MPG123_ERR_16TO8TABLE; if(NOQUIET) error("Can't allocate 16 to 8 converter table!"); return -1; } fr->conv16to8 = fr->conv16to8_buf + 4096; } if(fr->af.encoding == MPG123_ENC_ULAW_8){ double m=127.0 / log(256.0); int c1; for(i=-4096;i<4096;i++) { /* dunno whether this is a valid transformation rule ?!?!? */ if(i < 0) c1 = 127 - (int) (log( 1.0 - 255.0 * (double) i*mul / 32768.0 ) * m); else c1 = 255 - (int) (log( 1.0 + 255.0 * (double) i*mul / 32768.0 ) * m); if((c1 < 0 || c1 > 255) && NOQUIET) error2("Converror %d %d",i,c1); if(c1 == 0) c1 = 2; fr->conv16to8[i] = (unsigned char) c1; } } else if(mode == MPG123_ENC_SIGNED_8) { for(i=-4096;i<4096;i++) { fr->conv16to8[i] = i>>5; } } else if(mode == MPG123_ENC_UNSIGNED_8) {