int main(int argc, char *argv[]) { int i,j,k; struct itimerval quantum; struct sigaction sigdat; for(i=0; i<N; i++) { t_state[i].state = FREE; } sigemptyset(&maskval); sigdat.sa_handler = clock_isr; sigemptyset(&sigdat.sa_mask); sigdat.sa_flags = SA_RESTART; if(sigaction(SIGVTALRM, &sigdat, (struct sigaction *)0) == -1) { perror("signal set error"); exit(2); } if((i = t_init(fun1, 1)) == -1) { printf("thread failed to initialize\n"); exit(7); } if((j = t_init(fun2, 2)) == -1) { printf("thread failed to initialize\n"); exit(7); } if((k = t_init(fun3, 3)) == -1) { printf("thread failed to initialize\n"); exit(7); } printf("thread IDs are %d %d %d\n", i,j,k); quantum.it_interval.tv_sec = 0; quantum.it_interval.tv_usec = 500000; quantum.it_value.tv_sec = 0; quantum.it_value.tv_usec = 500000; current = 1; if(setitimer(ITIMER_VIRTUAL, &quantum,(struct itimerval *)0) == -1) { perror("setitimer"); exit(3); } if(setcontext(&(t_state[current].run_env)) == -1) { perror("setcontext"); exit(5); } while(1); return 0; }
/* MAIN */ int main(int argc, char *argv[]) { if ( argc < 4 ) return EXIT_FAILURE; t_timemes t_run = {0}; t_init(t_run); const char *patterns_filename = argv[1], *patt_size_pch = argv[2], *filename = argv[3]; unsigned int patt_size = atoi(patt_size_pch), text_size = 0; uchar *text = NULL, *pattern = NULL; FILE * file = NULL; text_size = read_file_content<uchar>(&text, filename); if (text == NULL) return EXIT_FAILURE; pattern = (uchar*)calloc (patt_size+1, CH_SIZE); if (pattern == NULL) { free(text); report_critical_error("Error: Can't allocate memory for pattern."); } file = fopen (patterns_filename, "rb"); if (!file) { free(text); free(pattern); report_critical_error("Error: Can't open patterns file."); } while (fread (pattern, CH_SIZE, patt_size, file)==patt_size) { t_start(t_run); cf::cf1<cf::cf1_verif_lev>(pattern, patt_size, text, text_size, K_DIFF, NULL); t_stop(t_run); } approx_cf::print_result(t_get_seconds(t_run), 0, indexes.size(), text_size, patt_size, K_DIFF); indexes.clear(); free(text); free(pattern); fclose(file); return EXIT_SUCCESS; }
/* * Test for PARSER: parse "i1+i2" or "i1+i2+..." where "i-n" is an integer. */ FUNCTION main () { IMPORT TEXT vrsion[]; TEXT string[STRINGSIZ+1]; CODE parse(); struct SYNBLK sb; CODE code; COUNT dummy; /* define indexes for our list of pointers to states */ #define s0pt 0 #define s1pt 1 #define s2pt 2 #define s3pt 3 #define s4pt 4 #define EV_SUM PA_ACCEPT + 100 /* reference the action routines */ CODE doneact(), sumact(); /* define the state structures */ static struct SHFENT shift0[] = { EV_SUM, s1pt, /* to s1 on EV_SUM */ PA_NUM, s4pt, /* to s4 on a number */ PA_TABTERM}; static struct PSTATE s0 = {0, 0, NULL, NULL, shift0}; static PA_CODE red1[] = {EOS, PA_TABTERM}; /* reduce if EOS */ static struct SHFENT shift1[] = {'+', s2pt, PA_TABTERM}; static struct PSTATE s1 = {1, PA_ACCEPT, doneact, red1, shift1}; static struct SHFENT shift2[] = {PA_NUM, s3pt, PA_TABTERM}; static struct PSTATE s2 = {0, 0, NULL, NULL, shift2}; static PA_CODE red3[] = {EOS, '+', PA_TABTERM}; static struct PSTATE s3 = {3, EV_SUM, sumact, red3, NULL}; static PA_CODE red4[] = {EOS, '+', PA_TABTERM}; static struct PSTATE s4 = {1, EV_SUM, NULL, red4, NULL}; /* list of state pointers */ struct PSTATE *statelist[]= {&s0, &s1, &s2, &s3, &s4}; parser_init (statelist, sizeof(statelist)/sizeof(struct PSTATE *)); printf(" Parser test, version %s\n", vrsion); printf(" Enter a string "); t_init(&dummy, &dummy, &dummy); t_read(string, &dummy); for (; string[0]!='@';) /* exit on '@' */ { initok(&sb, string); code = parser(&sb, statelist, s0pt); /* call the parser */ printf("Parse complete. Success/fail: %d\n", code); printf(" Enter a string "); t_read(string, &dummy); } }
base::AttributeBase* buildVariable(std::string name,int size) const { // if a sizehint is given T t_init(size_rows, size_columns, typename T::value_type() ); log(Debug) << "Building variable '"<<name <<"' of type " << this->getTypeName() <<" and number of rows "<< size << " and number of columns " << size <<Logger::endl; return new Attribute<T>( name, new internal::UnboundDataSource<internal::ValueDataSource<T> >( t_init ) ); }
int main(int argc, char** argv){ t_init(&argc, &argv, NULL); t_test(_parser_basic_parse); t_test(_parse_parent_and_siblings_test); t_test(_parse_sibling_with_children_test); t_test(_parse_parent_child_nonterminal); return t_done(); }
int main(int argc, char** argv) { t_init(&argc, &argv, NULL); t_test(ebnf_start_parsing__identifier); t_test(ebnf_start_parsing__terminal); t_test(ebnf_start_parsing__concatenate); t_test(ebnf_start_parsing__separator); t_test(ebnf_start_parsing__declaration); t_test(ebnf_start_parsing__group); t_test(ebnf_start_parsing__syntax); return t_done(); }
int main(int argc, char** argv){ t_init(); t_test(ast_empty); t_test(ast_single_node); t_test(ast_nested_nodes); t_test(ast_sibling_nodes); t_test(ast_same_index_nodes); t_test(ast_next_symbol); t_test(ast_next_sibling_symbol); t_test(ast_push_pop_state); t_test(ast_cursor_get_strings); return t_done(); }
FUNCTION static VOID init_msg(void) { CODE termtype; COUNT termlines, termcols; TEXT buffer[80]; t_init(&termtype, &termlines, &termcols); s_copy(" TAE utility process MSGBLD", buffer); t_write(buffer, T_DOUBLE); /* write msg to terminal */ t_write("", T_STDCC); return; }
int main(int argc, char** argv){ t_init(); t_test(int_to_array__one_byte); t_test(int_to_array__two_bytes); t_test(int_to_array__negative); t_test(int_to_padded_array__one_byte); t_test(int_to_padded_array_le__one_byte); t_test(array_to_int__one_byte); t_test(array_to_int__two_bytes); t_test(array_to_int__negative); return t_done(); }
int main(void){ int i; t_init(); t_create(thread_function, 1, 1); for (;;) { for(i = 0; i < 10000000; i++); printf("I am main...\n"); } return 0; }
int main (int argc, char *argv[]) { GtkWidget *window; gtk_init (&argc, &argv); t_init (); window = d_init ( ); gtk_widget_show_all (window); gtk_main (); return 0; }
int main(void) { int i; t_init(); t_create(producer, 1, 1); t_create(producer, 3, 1); t_create(consumer, 2, 1); t_yield(); t_shutdown(); return 0; }
FUNCTION CODE t_pinit ( COUNT *lines, /* out: number of lines on crt */ COUNT *columns, /* out: number of columns */ CODE *type /* out: type of terminal: */ /* T_CRT */ /* T_NOTCRT */ /* T_NOTTERM */ ) { CODE retcode; processInit = TRUE; retcode = t_init (lines, columns, type); processInit = FALSE; return (retcode); }
main () /* test case */ { struct ECB ecb; COUNT lines, columns; CODE type, term, code; TEXT string[STRINGSIZ+1]; TEXT *str; t_init(&lines, &columns, &type); t_clear(); printf("lines, columns, type = %d, %d, %d\n", lines, columns, type); t_output(10, 30, "line 10, column 30"); t_write("\nnon-CRT write to next line\n", T_STDCC); t_input(20, 10, string, &term); printf("Terminator = %s\n", (term == T_CR) ? "(return)" : "(escape)"); t_highlight (string); t_output(22, 10, string); /* echo */ t_lclear (22, 15); /* clear original except 5 character */ t_write ("hit left, right, up, down, GOLD, or any key"); code = t_gettok (); if (code == T_LEFT) str = "LEFT"; else if (code == T_RIGHT) str = "RIGHT"; else if (code == T_UP) str = "UP"; else if (code == T_DOWN) str = "DOWN"; else if (code == T_GOLD) str = "GOLD"; else if (code == T_UNKNOWN) str = "UNKNOWN"; else { string[0] = code; string[1] = EOS; str = string; } t_write (str, T_STDCC); for (;;) { t_bell(); /* bell every time controlc hit */ t_write(" ", T_STDCC); /* flush */ t_attn(&ecb); while (!e_occur(&ecb)) /* loop till event */ ; } exit (); }
int main(int argc, char **argv) { t_init(); t_create(assign, 1, 1); printf("in main(): 0\n"); t_yield(); printf("in main(): 1\n"); t_yield(); printf("in main(): 2\n"); t_yield(); printf("done...\n"); return (0); }
int main(void) { int i, k = 1; t_init(); t_create(function, 1, 1); printf("This is main()...\n"); t_create(function, 2, 1); printf("This is main()...\n"); t_create(function, 3, 1); for(i = 0; i < 5000; i++) { printf("This is main(%d)...\n", i); } printf("Begin shutdown...\n"); t_shutdown(); printf("Done with shutdown...\n"); return 0; }
int main(void) { int i; t_init(); t_create(function, 1, 1); printf("This is main(1)...\n"); t_create(function, 2, 1); printf("This is main(2)...\n"); t_create(function, 3, 1); for (i = 0; i < 4; i++) { printf("This is main(3)[%d]...\n", i); t_yield(); } printf("Begin shutdown...\n"); t_shutdown(); printf("Done with shutdown...\n"); return 0; }
int test_main() { thread_t threads[NUM_THREADS]; int tid; threads_init(); for(tid = 0; tid < NUM_THREADS; ++tid) { t_init(&threads[tid], NULL, test_mutex, "tatomic-%d", tid); } for(tid = 0; tid < NUM_THREADS; ++tid) { t_join(&threads[tid]); t_destroy(&threads[tid]); } assert(atomic_read(&counter) == (NUM_THREADS * STEPS)); threads_fini(); return 0; }
void devcntrl(FILE *fp) /* interpret device control functions */ { char str[4096]; int n; sget(str, sizeof str, fp); switch (str[0]) { /* crude for now */ case 'i': /* initialize */ fileinit(); t_init(0); break; case 'T': /* device name */ sget(devname, sizeof devname, fp); break; case 't': /* trailer */ t_trailer(); break; case 'p': /* pause -- can restart */ t_reset('p'); break; case 's': /* stop */ t_reset('s'); break; case 'r': /* resolution assumed when prepared */ fscanf(fp, "%d", &res); break; case 'f': /* font used */ fscanf(fp, "%d", &n); sget(str, sizeof str, fp); loadfont(n, str); break; } while (getc(fp) != '\n') /* skip rest of input line */ ; }
FUNCTION FILE *z_init ( #ifdef LARGE_PARBLK_FIX struct LARGE_PARBLK *block, /* out: parameter block */ #else struct PARBLK *block, /* out: parameter block */ #endif FUNINT mode /* in: mode: P_ABORT or P_CONT */ ) { IMPORT FILE *stdo_file; /* pointer to stdout file */ IMPORT BOOL term_std; /* true if terminal is stdout */ IMPORT CODE applic_type; /* application type ('c') */ IMPORT TEXT pm_type[], pk_type[]; struct VARIABLE *v; CODE termtype; COUNT termlines; COUNT termcols; TEXT msgbuf[STRINGSIZ+1]; TEXT **stdr_ptr = 0; /* stdrec string vector pointer */ COUNT len; CODE code; TEXT filemode[2]; /* create or append */ FILE *stdo_ptr; t_init(&termlines, &termcols, &termtype); /* initialize terminal pkg */ #ifdef LARGE_PARBLK_FIX code = p_inim((struct PARBLK *)block, sizeof(struct LARGE_PARBLK), mode); #else code = p_inim(block, sizeof(struct PARBLK), mode); #endif /* receive parblk from TM */ if (code != SUCCESS) return (NULL); z_call ((struct PARBLK *)block); /* application init */ v = p_find ((struct PARBLK *)block, "_STDOUT"); /* get the string */ if ((*v).v_type != V_STRING) x_error ((*block).mode, pm_type, pk_type, (uintptr_t) "_STDOUT", 0, 0); else stdr_ptr = (TEXT **) (*v).v_cvp; /* get value pointer */ term_std = (s_equal(TERMINAL, stdr_ptr[0])); /* filename = terminal ? */ #ifdef VICAR_BATCH_LOG #ifdef VAX_VMS if (s_equal("SYS$OUTPUT:.;", stdr_ptr[0])) /* alternate form of terminal */ term_std = TRUE; #endif #endif s_copy("w", filemode); /* assume create */ if (!s_equal(stdr_ptr[1] , "CREATE")) s_copy("a", filemode); #ifdef UNIX s_lower(stdr_ptr[0]); /* make file name lower case */ #endif stdo_ptr = fopen(stdr_ptr[0], filemode); /* open the file */ if (stdo_ptr == NULL) { if (mode == P_ABORT) { len = s_copy("Could not open standard output file ", msgbuf); s_bcopy(stdr_ptr[0], &msgbuf[len], STRINGSIZ); t_write(msgbuf, T_STDCC); /* errmsg to terminal*/ z_exit(-1, "TAE-STDOPEN"); /* set SFI, SKEY */ } stdo_ptr = stdout; /* Allow running with no terminal! */ /* (without triggering shell-vicar) */ } else stdo_file = stdo_ptr; /* save stdout ptr globally */ applic_type = C_TYPE; /* 'c' language application */ return (stdo_ptr); }
FUNCTION main () { struct SYNBLK sb; /* syntax block */ TEXT s[STRINGSIZ+1]; /* string buffer */ TEXT verb[TOKESIZ+1];/* verb */ TEXT key[TOKESIZ+1]; /* keyword */ TEXT *value[MAXVAL]; /* value pointers */ CODE code; COUNT count; COUNT tstnum; COUNT i; CODE dum; dumrout(&code, &tstnum); /* dummy - get addrs w/ debugger */ tstnum = 0; /* TEST 1 */ printf("\n TEST 1 \n"); s_copy("menu file=alpha a", s); initok(&sb, s); tstnum++; code = getvrb(&sb, verb); printf(" code: %d, verb: %s\n", code, verb); tstnum++; code = getkey(&sb, key); printf(" code: %d, key: %s\n", code, key); tstnum++; code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); tstnum++; code = chkend(&sb); tstnum++; /* TEST 2 */ printf("\n TEST 2 \n"); s_copy("menu (A, B, CDE) file = alpha", s); initok(&sb, s); code = getvrb(&sb, verb); printf(" code: %d, verb: %s\n", code, verb); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); code = getkey(&sb, key); printf(" code: %d, key: %s\n", code, key); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); code = chkend(&sb); /* TEST 3 */ printf("\n TEST 3 \n"); s_copy("vrb ,(A,,C,) f,", s); initok(&sb, s); code = getvrb(&sb, verb); printf(" code: %d, verb: %s\n", code, verb); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); /* TEST 4 */ printf("\n TEST 4 \n"); s_copy("(\"aaa\", \"bbb\")", s); initok(&sb, s); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); /* TEST 5 */ printf("\n TEST 5 \n"); /* white space test */ s_copy("menu (A, B, CDE) file = alpha", s); initok(&sb, s); code = getvrb(&sb, verb); printf(" code: %d, verb: %s\n", code, verb); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); code = getkey(&sb, key); printf(" code: %d, key: %s\n", code, key); code = getval(&sb, value, MAXVAL, &count); printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); code = chkend(&sb); /* USER TEST */ while (FOREVER) { printf("\n Enter a string of values:\n"); t_init(&dum, &dum, &dum); t_read(s, &dum); initok(&sb, s); code = getval(&sb, value, MAXVAL, &count); while (code !=EOS && code!=S_SYNERR) { printf(" code: %d, count: %d, values: \n", code, count); for (i=0; i<count; i++) printf(" %s\n", value[i]); code = getval(&sb, value, MAXVAL, &count); } } sb.errchr = sb.curchr - 1; synerr(&sb, "Test complete"); exit(TRUE); }
/* originally from terminal.np.c */ CODE t_pinit(COUNT* lines, COUNT* columns, CODE *type) { return t_init(lines, columns, type); }
void t_page(int n) /* do whatever new page functions */ { int m, i; char buf[1024], *bp; pgnum[np++] = n; pgadr[np] = ftell(fp); if (np > npmax) npmax = np; if (output == 0) { output = in_olist(n); t_init(1); return; } /* have just printed something, and seen p<n> for next one */ putpage(); fflush(stdout); if (nowait) return; next: for (bp = buf; (*bp = readch()); ) if (*bp++ == '\n' || bp >= &buf[sizeof buf - 1]) break; *bp = 0; switch (buf[0]) { case 0: done(); break; case '\n': output = in_olist(n); t_init(1); return; case '!': callunix(&buf[1]); fputs("!\n", stderr); break; case 'e': erase = 1 - erase; break; case 'w': wflag = 1 - wflag; break; case 'a': aspect = atof(&buf[1]); break; case '-': case 'p': m = atoi(&buf[1]) + 1; if (fp == stdin) { fputs("you can't; it's not a file\n", stderr); break; } if (np - m <= 0) { fputs("too far back\n", stderr); break; } np -= m; fseek(fp, pgadr[np], 0); output = 1; t_init(1); return; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': m = atoi(&buf[0]); for (i = 0; i < npmax; i++) if (m == pgnum[i]) break; if (i >= npmax || fp == stdin) { fputs("you can't\n", stderr); break; } np = i + 1; fseek(fp, pgadr[np], 0); output = 1; t_init(1); return; case 'o': outlist(&buf[1]); output = 0; t_init(1); return; case '?': fputs("!cmd unix cmd\n", stderr); fputs("p print this page again\n", stderr); fputs("-n go back n pages\n", stderr); fputs("n print page n (previously printed)\n", stderr); fputs("o... set the -o output list to ...\n", stderr); fputs("en n=0 -> don't erase; n=1 -> erase\n", stderr); fputs("an sets aspect ratio to n\n", stderr); break; default: fputs("?\n", stderr); break; } goto next; }