int setRin_withchecks(FTYPE *rin) { FTYPE Rhor,rminus; Rhor=rhor_calc(0); *rin=setRin(setihor()); // (*rin) = 0.98 * Rhor; trifprintf("R0=%21.15g Rhor=%21.15g Rin=%21.15g Rout=%21.15g ihor=%d\n",R0,Rhor,(*rin),Rout,setihor()); if((*rin)<R0){ dualfprintf(fail_file,"Wrong Rin calculation\n"); myexit(34968346); } if((*rin)<0.0){ dualfprintf(fail_file,"Very Poor Rin<0 calculation\n"); myexit(34968347); } rminus=rhor_calc(1); if((*rin)<rminus){ dualfprintf(fail_file,"Rin<r_- : Poor Rin calculation\n"); myexit(34968348); } if((*rin)>Rhor){ dualfprintf(fail_file,"Rin>r_+ : Poor Rin calculation\n"); myexit(34968349); } return(0); }
void dispinit(void) { /* calculate the maximum displayed reference lines */ lastdispline = FLDLINE - 2; mdisprefs = lastdispline - REFLINE + 1; if (mdisprefs <= 0) { (void) printw("cscope: window must be at least %d lines high", FIELDS + 6); myexit(1); } if (COLS < MINCOLS) { (void) printw("cscope: window must be at least %d columns wide", MINCOLS); myexit(1); } if (!mouse) { if (returnrequired == NO && mdisprefs > 9) { mdisprefs = 9; /* single digit selection number */ } /* calculate the maximum selection number width */ (void) sprintf(newpat, "%d", mdisprefs); selectlen = strlen(newpat); } /* allocate the displayed line array */ displine = (int *)mymalloc(mdisprefs * sizeof (int)); }
// convert primitive velocity to coordinate 4-velocity int pr2ucon(int whichvel, FTYPE *pr, struct of_geom *geom, FTYPE*ucon) { if(whichvel==VEL4){ // here pr has true 4-velocities, as supplied by init.c if (ucon_calc_4vel(pr, geom, ucon) >= 1) { dualfprintf(fail_file, "pr2ucon(ucon_calc): space-like error\n"); return(1); } } else if(whichvel==VEL3){ // supplied vel's are 3-vels if (ucon_calc_3vel(pr, geom, ucon) >= 1) { dualfprintf(fail_file, "pr2ucon(ucon_calc): space-like error\n"); return(1); } } else if(whichvel==VELREL4){ // supplied vel's are relative 4-vels if (ucon_calc_rel4vel(pr, geom, ucon) >= 1) { dualfprintf(fail_file, "pr2ucon(ucon_calc): space-like error\n"); return(1); } } else{ dualfprintf(fail_file,"No such whichvel=%d\n",whichvel); myexit(1); } return(0); }
int Buddies::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: countOnlineUsers(); break; case 1: setUserStatus(); break; case 2: loginUser(); break; case 3: loginCurrentStatus(); break; case 4: validateUser(); break; case 5: stopifNotConnected(); break; case 6: myexit(); break; case 7: focusTabEdit(); break; case 8: structUser(); break; case 9: startChat(); break; case 10: helpAbout(); break; case 11: getSysInfo(); break; case 12: onlineNotify(); break; case 13: WriteOnWall(); break; case 14: Information(); break; case 15: dbstatus(); break; case 16: openNotes(); break; case 17: setIcon((*reinterpret_cast< int(*)>(_a[1]))); break; case 18: iconActivated((*reinterpret_cast< QSystemTrayIcon::ActivationReason(*)>(_a[1]))); break; case 19: messageClicked(); break; case 20: showMessage(); break; } _id -= 21; } return _id; }
int main(int argc, char const *argv[]) { char input[15][30]; int argnum, i; pid_list.head=NULL; pid_list.tail=NULL; enqueue(getppid(),"NEW SHELL",&pid_list); signal(SIGCHLD,childdead); signal(SIGTSTP,susp); signal(SIGQUIT,cont); setpriority(PRIO_PROCESS,0,-20); ver(); while (run){ printf("=>"); for (argnum=0; (scanf("%s",&input[argnum]))==1;argnum++) if (getchar()=='\n') break; if (strcmp(input[0],"ver")==0 && argnum==0) ver(); else if (strcmp(input[0],"help")==0 && argnum==0) help(); else if (strcmp(input[0],"help")==0 && argnum==1) helpcmd(input[argnum]); else if (strcmp(input[0],"ps")==0 && argnum==0) ps(); else if (strcmp(input[0],"kill")==0 && argnum==1) mykill(atoi(input[1])); else if (strcmp(input[0],"exec")==0 && argnum!=0) for (i=1; i<=argnum; i++) exec(input[i]); else if (strcmp(input[0],"exit")==0 && argnum==0) myexit(); else printf("Nosuch command. Check help for help.\n"); } }
main() { char name[64]; int cmd; int pid; while(1){ pid = getpid(); printf("==============================================\n"); printf("Das ist prozess %d im Umode segment=%x\n", pid, getcs()); show_menu(); printf("Command ? "); gets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : getpid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : mywait(); break; case 6 : myexit(); break; case 7 : ufork(); break; case 8 : myexec("/bin/u1"); break; case 9 : sin(); break; case 10: sout(); break; default: invalid(name); break; } } }
void parainitchecks(void) { int dimen; DIMENLOOP(dimen){ if(PARAGENDQALLOWEXTREMUM && WENOINTERPTYPE(lim[dimen])){ // if PARAMODWENO==1 implied, but if 0 allow since doesn't matter if doing weno with PARAGENDQALLOWEXTREMUM==1 // then ok } else if(PARAMODWENO==1 && PARAGENDQALLOWEXTREMUM==0 && WENOINTERPTYPE(lim[dimen])){ dualfprintf(fail_file,"WARNING: PARAGENDQALLOWEXTREMUM==0 for hybrid method, will be less accurate for turbulent regions\n"); } else if(PARAGENDQALLOWEXTREMUM==1 && lim[dimen]==PARA){ dualfprintf(fail_file,"ERROR: PARAGENDQALLOWEXTREMUM==1 but not WENO-based limiter -- will be less stable in stiff regions (e.g. near horizon). Use PARALINE instead.\n"); myexit(34643463); } if(lim[dimen]==PARAFLAT){ dualfprintf(fail_file,"WARNING: PARAFLAT inefficient compared to PARALINE, suggested to use PARALINE instead\n"); } } }
main() { redrawscreen(); /* Define the windows */ playgame(); /* Play the game */ myexit(); /* Clean up after ourselves */ }
// reset repeatedfun to zero for all tables associated with both same isextratype and whichd // use of repeated function depends upon same whichd and isextratype static void reset_repeatedfun(int isextratype, int whichd, int numcols, int firsteos, int *repeatedfun) { int coli; if(isextratype){ // note that one has no access to extra degen table if(whichd==UTOTDIFF) for(coli=0;coli<numcols;coli++) repeatedfun[firsteos+coli]=0; else{ dualfprintf(fail_file,"No such whichd=%d for isextratype=%d\n",whichd,isextratype); myexit(346262121); } } else{ int numcolslocal,firsteoslocal; int subtype; for(subtype=0;subtype<NUMTABLESUBTYPES;subtype++){ if(whichd==whichdintablesubtype[subtype]){ // then this subtype should be reset numcolslocal = numcolintablesubtype[subtype]; // ok use of numcolintablesubtype firsteoslocal=firsteosintablesubtype[subtype]; for(coli=0;coli<numcolslocal;coli++) repeatedfun[firsteoslocal+coli]=0; } } } }
gamekeys() { char *charptr; /* Set up a pointer to the variable we want to change (either for * box or for ball */ if (ballorbox) charptr=&boxoffset; else charptr=&balloffset; switch( toupper(getk()) ) { /* Use OZ to get the key */ case K_DOWN: down(charptr); break; case K_UP: up(charptr); break; case K_RIGHT: right(charptr); break; case K_LEFT: left(charptr); break; case K_SWITCH: ballorbox^=1; /* Toggle ball/box */ break; case K_EXIT: myexit(); case K_CLEAR: setuplevel(); } }
s32 convert_bin_to_iso(FILE *bin_file, char *output_dir, char *iso_file_name, u32 sector_count) { FILE *iso_file; u8 sector_buffer[2352]; u32 i; chdir(output_dir); iso_file = fopen(iso_file_name, "wb"); if (iso_file == NULL) { printf("failed to open: %s\n", iso_file_name); myexit(1); } printf("writing iso %s, %x sectors\n", iso_file_name, sector_count); for(i = 0; i < sector_count; i++) { printf("\b\b\b%3i", i*100 / sector_count); fflush(stdout); fread(sector_buffer, 2352, 1, bin_file); fwrite(sector_buffer + 16, 2048, 1, iso_file); } printf("\b\b\b100\n"); fclose(iso_file); chdir(".."); return 0; }
/* * fork a child for PCP */ pid_t pcp_fork_a_child(int unix_fd, int inet_fd, char *pcp_conf_file) { pid_t pid; pid = fork(); if (pid == 0) { close(pipe_fds[0]); close(pipe_fds[1]); myargv = save_ps_display_args(myargc, myargv); /* call PCP child main */ POOL_SETMASK(&UnBlockSig); reload_config_request = 0; pcp_do_child(unix_fd, inet_fd, pcp_conf_file); } else if (pid == -1) { pool_error("fork() failed. reason: %s", strerror(errno)); myexit(1); } return pid; }
main() { char name[64]; int cmd; /* resetVideo();*/ while(1){ pid = get_pid(); printf("==============================================\n"); printf("I am task %d in Umode at segment=%x\n", pid, getcs()); show_menu(); printf("Command ? "); mgets(name); if (name[0]==0) continue; cmd = find_cmd(name); switch(cmd){ case 0 : get_pid(); break; case 1 : ps(); break; case 2 : chname(); break; case 3 : kmode(); break; case 4 : kswitch(); break; case 5 : mywait(); break; case 6 : myexit(); break; case 7 : ufork(); break; case 8 : myexec("/u2"); break; case 9 : sin(); break; case 10 : sout(); break; default: invalid(name); break; } } }
void compute_monotonicity_line_valueonly( int recontype, int whichreduce, int preforder, int pl, int bs, int ps, int pe, int be, int *minorder, int *maxorder, int *shift, FTYPE *shockindicator, FTYPE (*df)[NBIGM], FTYPE (*monoindicator)[NBIGM], FTYPE *yin, FTYPE (*yout)[NBIGM], FTYPE (*youtpolycoef)[NBIGM] ) { int i; #if( DOMONOINTERP == JMONOINTERP ) #elif( DOMONOINTERP == SMONOINTERP ) #include "interpline.smono.h" #elif( DOMONOINTERP == NOMONOINTERP ) #else #error Unknown monointerp type #endif #if( DOMONOINTERP == JMONOINTERP ) dualfprintf(fail_file,"JMONO not setup for split indicator and value\n"); myexit(1756583); #elif( DOMONOINTERP == SMONOINTERP ) compute_smonotonicity_line_split(0,1, recontype, whichreduce, preforder, pl, bs, ps, pe, be, minorder, maxorder, shift, shockindicator, df, monoindicator, yin, yout, youtpolycoef ); #elif( DOMONOINTERP == NOMONOINTERP ) // nothing to do #else #error Unknown monointerp type #endif }
int main(int argc, char * argv[]) { ALLEGRO_CONFIG *config; ALLEGRO_EVENT event; unsigned buffer_count; unsigned samples; const char *s; initialize(); if (argc < 2) { log_printf("This example needs to be run from the command line.\nUsage: %s {audio_files}\n", argv[0]); goto done; } buffer_count = 0; samples = 0; config = al_load_config_file("ex_stream_seek.cfg"); if (config) { if ((s = al_get_config_value(config, "", "buffer_count"))) { buffer_count = atoi(s); } if ((s = al_get_config_value(config, "", "samples"))) { samples = atoi(s); } al_destroy_config(config); } if (buffer_count == 0) { buffer_count = 4; } if (samples == 0) { samples = 1024; } stream_filename = argv[1]; music_stream = al_load_audio_stream(stream_filename, buffer_count, samples); if (!music_stream) { abort_example("Stream error!\n"); } loop_start = 0.0; loop_end = al_get_audio_stream_length_secs(music_stream); al_set_audio_stream_loop_secs(music_stream, loop_start, loop_end); al_set_audio_stream_playmode(music_stream, ALLEGRO_PLAYMODE_LOOP); al_attach_audio_stream_to_mixer(music_stream, al_get_default_mixer()); al_start_timer(timer); while (!exiting) { al_wait_for_event(queue, &event); event_handler(&event); } done: myexit(); al_destroy_display(display); close_log(true); return 0; }
int main(int argc, char * argv[]) { ALLEGRO_CONFIG *config; ALLEGRO_EVENT event; unsigned buffer_count; unsigned samples; const char *s; if (argc < 2) { printf("Usage: ex_stream_seek <filename>\n"); return -1; } if (!initialize()) return 1; buffer_count = 0; samples = 0; config = al_load_config_file("ex_stream_seek.cfg"); if (config) { if ((s = al_get_config_value(config, "", "buffer_count"))) { buffer_count = atoi(s); } if ((s = al_get_config_value(config, "", "samples"))) { samples = atoi(s); } al_destroy_config(config); } if (buffer_count == 0) { buffer_count = 4; } if (samples == 0) { samples = 1024; } stream_filename = argv[1]; music_stream = al_load_audio_stream(stream_filename, buffer_count, samples); if (!music_stream) { printf("Stream error!\n"); return 1; } loop_start = 0.0; loop_end = al_get_audio_stream_length_secs(music_stream); al_set_audio_stream_loop_secs(music_stream, loop_start, loop_end); al_set_audio_stream_playmode(music_stream, ALLEGRO_PLAYMODE_LOOP); al_attach_audio_stream_to_mixer(music_stream, al_get_default_mixer()); al_start_timer(timer); while (!exiting) { al_wait_for_event(queue, &event); event_handler(&event); } myexit(); return 0; }
void fatalerror( const char *format, ...) { va_list ap; va_start( ap, format); vfprintf( stderr, format, ap); va_end( ap); myexit(1); }
int test(int n) { if ( n > 0 ) { myexit(); printf("exit no return \n"); /* 程序不可能到达这里 */ } else { return 0; } }
void cannotwrite(char *file) { char msg[MSGLEN + 1]; (void) sprintf(msg, "Removed file %s because write failed", file); myperror(msg); /* display the reason */ (void) unlink(file); myexit(1); /* calls exit(2), which closes files */ }
static RETSIGTYPE exit_handler(int sig) { int i; POOL_SETMASK(&AuthBlockSig); /* * this could happen in a child process if a signal has been sent * before resetting signal handler */ if (getpid() != mypid) { pool_debug("exit_handler: I am not parent"); POOL_SETMASK(&UnBlockSig); pool_shmem_exit(0); exit(0); } if (sig == SIGTERM) pool_log("received smart shutdown request"); else if (sig == SIGINT) pool_log("received fast shutdown request"); else if (sig == SIGQUIT) pool_log("received immediate shutdown request"); else { pool_error("exit_handler: unknown signal received %d", sig); POOL_SETMASK(&UnBlockSig); return; } exiting = 1; for (i = 0; i < pool_config->num_init_children; i++) { pid_t pid = pids[i].pid; if (pid) { kill(pid, sig); } } kill(pcp_pid, sig); POOL_SETMASK(&UnBlockSig); while (wait(NULL) > 0) ; if (errno != ECHILD) pool_error("wait() failed. reason:%s", strerror(errno)); pids = NULL; myexit(0); }
int main() { atexit(furong);//登记,不是现在调用而是程序结束时调用 atexit(fengjie);//登记,不是现在调用而是程序结束时调用 printf("登记完毕\n"); sleep(5); printf("ready to terminate\n"); myexit("call myexit", 0); printf("you cannot see me.\n"); return 0; }
void check(char *pat, char *dir, char del) { char *RAW[MAXSIZE]; int Z = 0, i; Z = stok(pat, del, RAW); for (i = 0; i < Z; i++) { if (slen(RAW[i]) > (MAXPATH - 2)) { printf("%sПолучен путь (%d) длина которого больше разрешенной%s\n", clBoldRed, i + 1, clNormal); myexit(); } if (( (RAW[i][0]) != '~') && ( (RAW[i][0]) != '/')) { printf("%sПолучен путь (%d) который не является частью фс unix%s\n", clBoldRed, i+1,clNormal); myexit(); } } suntok(pat, del, RAW, Z); }
void save_block(long filesize, char *base, char *ext) { char name[FILENAME_MAX+1]; char buffer[LINEMAX+1]; FILE *fp; strcpy(name,base); suffix_change(name,ext); if ( (fp=fopen(name,"wb"))==NULL) { snprintf(buffer,sizeof(buffer),"Can't open output file %s\n",name); myexit(buffer,1); } if (fwrite(memory,1,filesize,fp) != filesize ) { snprintf(buffer,sizeof(buffer),"Can't write to output file %s\n",name); myexit(buffer,1); } fclose(fp); }
/* * create UNIX domain socket */ static int create_unix_domain_socket(struct sockaddr_un un_addr_tmp) { struct sockaddr_un addr; int fd; int status; int len; fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1) { pool_error("Failed to create UNIX domain socket. reason: %s", strerror(errno)); myexit(1); } memset((char *) &addr, 0, sizeof(addr)); ((struct sockaddr *)&addr)->sa_family = AF_UNIX; snprintf(addr.sun_path, sizeof(addr.sun_path), un_addr_tmp.sun_path); len = sizeof(struct sockaddr_un); if (myexists(addr.sun_path)) { myunlink(addr.sun_path); } status = bind(fd, (struct sockaddr *)&addr, len); if (status == -1) { pool_error("bind(%s) failed. reason: %s", addr.sun_path, strerror(errno)); myexit(1); } if (chmod(un_addr_tmp.sun_path, 0777) == -1) { pool_error("chmod() failed. reason: %s", strerror(errno)); myexit(1); } status = listen(fd, PGPOOLMAXLITSENQUEUELENGTH); if (status < 0) { pool_error("listen() failed. reason: %s", strerror(errno)); myexit(1); } return fd; }
int hasch_seq(char *seq, int **hs, int **lu,int ktup,char *alp) { static int a[10]; int i,j,l,limit,code,flag; char residue; int alp_lu[10000]; int alp_size; alp_size=alp[0]; alp++; for ( i=0; i< alp_size; i++) { alp_lu[(int)alp[i]]=i; } l=strlen (seq); limit = (int) pow((double)(alp_size+1),(double)ktup); hs[0]=(int*)vcalloc ( l+1,sizeof (int)); lu[0]=(int*)vcalloc ( limit+1, sizeof(int)); if ( l==0)myexit(EXIT_FAILURE); for (i=1;i<=ktup;i++) a[i] = (int) pow((double)(alp_size+1),(double)(i-1)); for(i=1;i<=(l-ktup+1);++i) { code=0; flag=FALSE; for(j=1;j<=ktup;++j) { if (is_gap(seq[i+j-2])){flag=TRUE;break;} else residue=alp_lu[(int)seq[i+j-2]]; code+=residue*a[j]; } if ( flag)continue; ++code; if (lu[0][code])hs[0][i]=lu[0][code]; lu[0][code]=i; } return 0; }
void request_content(int sock, int (*sendproc)(int,char*,unsigned char*,int), char *dest, unsigned char *out, int len, float wait) { unsigned char buf[64*1024]; int len2 = sendproc(sock, dest, out, len), rc; if (len2 < 0) { perror("sendto"); myexit(1); } rc = block_on_read(sock, wait); if (rc == 1) { len2 = recv(sock, buf, sizeof(buf), 0); if (len2 > 0) { write(1, buf, len2); myexit(0); } } }
void printFile(const char file[]) { int Mc = 512; std::ifstream fIn; fIn.open(file); // open a file if (!fIn.good()) myexit(1); // Not found char buf[Mc]; while (!fIn.eof() && buf[0]!='-') { fIn.getline(buf,Mc); printf("%s", buf); printf(" \n"); } fIn.close(); }
Dtable concatenate(const Dtable& T1, const Dtable& T2) { if (T1.size()!=T2.size()) { printf("Error in concatenation : different sizes \n"); myexit(1); } Dtable T3 = T1; for (int i=0; i<T1.size(); i++) { for (int j=0; j<T2[i].size(); j++) { T3[i].push_back(T2[i][j]); } } return T3; }
fec_encode_manager_t::fec_encode_manager_t() { //int timer_fd; if ((timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK)) < 0) { mylog(log_fatal,"timer_fd create error"); myexit(1); } timer_fd64=fd_manager.create(timer_fd); reset_fec_parameter(g_fec_data_num,g_fec_redundant_num,g_fec_mtu,g_fec_queue_len,g_fec_timeout,g_fec_mode); }
void compute_monotonicity_line_indicatoronly( int recontype, int whichreduce, int preforder, int pl, int bs, int ps, int pe, int be, int *minorder, int *maxorder, int *shift, FTYPE *shockindicator, FTYPE (*df)[NBIGM], FTYPE (*monoindicator)[NBIGM], FTYPE *yin, FTYPE (*yout)[NBIGM], FTYPE (*youtpolycoef)[NBIGM] ) { int i; #if( DOMONOINTERP == JMONOINTERP ) #elif( DOMONOINTERP == SMONOINTERP ) #include "interpline.smono.h" #elif( DOMONOINTERP == NOMONOINTERP ) #else #error Unknown monointerp type #endif ///////////////// // // initialize monoindicator so can assume 0 if not using mono rather than leaving as "nan" and having to check if 0 or not // ///////////////// for(i=-NBIGBND;i<NBIG+NBIGBND;i++){ monoindicator[MONOINDTYPE][i]=0; monoindicator[MONOLEFTSET][i]=0; // or center monoindicator[MONORIGHTSET][i]=0; } #if( DOMONOINTERP == JMONOINTERP ) dualfprintf(fail_file,"JMONO not setup for split indicator and value\n"); myexit(1756582); #elif( DOMONOINTERP == SMONOINTERP ) compute_smonotonicity_line_split(1,0, recontype, whichreduce, preforder, pl, bs, ps, pe, be, minorder, maxorder, shift, shockindicator, df, monoindicator, yin, yout, youtpolycoef ); #elif( DOMONOINTERP == NOMONOINTERP ) // no monointerp used; so set the monotonicity indicators to zero // do nothing since already set to 0 #else #error Unknown monointerp type #endif }