void kmain(void) { clear_screen(); greeting(); while(1) {/* Nothing */} /* So the processor doesn't execute junk after this file */ }
//SETUP FUNCTION void setup() { //INITIALIZE SERVO OBJECTS initialize(); //GREETING AND CALIBRATION calibrate(); greeting(); }
void lcd_attach(struct device *parent, struct device *self, void *aux) { printf("\n"); /* Say hello to the world on LCD. */ greeting(); }
int main(int argc, char* argv[]) { create_symbol_table(); register_builtins(); greeting(); yyparse(); free_symbol_table(); printf("\n"); return 0; }
int smtp_client::greeting_helo(const string_ref& domain, posix_error_callback& ec) { /* returns 2xx on success */ int r = 0; if (!is_2xx(r = greeting(ec))) { return r; } return helo(domain, ec); }
int main (int argc, char **argv) { greeting(); if (argc==1 || atoi(argv[1])==0) { printf("10 factorial is %d\n", factorial(10)); } else { int num=atoi(argv[1]); printf("%d factorial is %d\n", num,factorial(num)); } }
int main(int argc, char *argv[]) { (void)argc; (void)argv; printf("\nTest-case #1: \n\t\t how binding works - la_symbind32/64() is called once\n"); printf(PROG_TAG "Attempt #1: Going to call greeting() from libfoo.so\n"); greeting(); printf(PROG_TAG "Attempt #2: Going to call greeting() from libfoo.so\n"); greeting(); printf("\nTest-case #2:\n\t\t Intercept functions from libfoo.so by Auditing library\n"); printf(PROG_TAG "Attempt #1: Going to call to_be_hooked() from libfoo.so\n"); to_be_hooked(); printf(PROG_TAG "Attempt #2: Going to call to_be_hooked() from libfoo.so\n"); to_be_hooked(); return 0; }
int main(int argc, char *argv[]) { char name[32]; if (argv[1]) strncpy(name, argv[1], sizeof(name)); else strcpy(name, "user"); greeting(name); return 0; }
int shell(FILE * f, const char * (* prompt)(void), void (* greeting)(FILE *), const struct shell_cmd * cmd_tab) { char hist_buf[SIZEOF_CMD_HISTORY + SHELL_HISTORY_MAX * SHELL_LINE_MAX]; char line[SHELL_LINE_MAX]; struct cmd_history * history; int ret = 0; DCC_LOG(LOG_TRACE, "history_init()"); history = history_init(hist_buf, sizeof(hist_buf), SHELL_LINE_MAX); if (greeting) greeting(f); do { char * stat; char * cp; fprintf(f, "%s", prompt()); if (history_readline(history, f, line, SHELL_LINE_MAX) == NULL) return -1; if ((cp = shell_stripline(line)) == NULL) continue; history_add(history, cp); cp = line; ret = 0; while ((stat = cmd_get_next(&cp)) != NULL) { struct shell_cmd * cmd; if ((cmd = cmd_lookup(cmd_tab, stat)) == NULL) { fprintf(f, "Command not found!\n"); break; } ret = cmd_exec(f, cmd, stat); if ((ret < 0) && (ret != SHELL_ABORT)) { fprintf(f, "Error: %d\n", -ret); break; } } } while (ret != SHELL_ABORT); return 0; }
static VALUE greeting_hello(VALUE self) { /* * Setup for function located in ../../static_libs/hello_user.c */ char * greeting(char *); /* * return a string VALUE from a char * that ruby can handle and assign to variables */ return rb_str_new2(greeting(RSTRING_PTR(rb_iv_get(self, "@name")))); }
int main(int argc, char *argv[]) { io s; parseenv(); parseargs(argc, argv); initconn(&s); c = &s; atexit(quit); greeting(&s); getlatest(&s); exit(EXIT_SUCCESS); }
void ip_task(void){ switch(sock_state){ case IP_STATE_NO_SOCKET: if(socket(0, Sn_MR_TCP, 5000, 0) == 0) sock_state = IP_STATE_SOCKET; break; case IP_STATE_SOCKET: switch (listen(0)){ case SOCK_OK : sock_state = IP_STATE_LISTEN; break; case SOCKERR_SOCKCLOSED : sock_state = IP_STATE_CLOSE; } break; case IP_STATE_LISTEN : switch(getSn_SR(0)){ case SOCK_LISTEN : _delay_ms(100); break; case SOCK_ESTABLISHED: sock_state = IP_STATE_ECHO; break; default: sock_state = IP_STATE_CLOSE; } break; case IP_STATE_CLOSE: disconnect(0); close(0); sock_state=IP_STATE_NO_SOCKET; break; case IP_STATE_ECHO: if (getSn_SR(0) == SOCK_ESTABLISHED) { sock_state = echo(); } else { sock_state = IP_STATE_CLOSE; } break; case IP_STATE_GREETING: if (getSn_SR(0) == SOCK_ESTABLISHED) { sock_state = greeting(); } else { sock_state = IP_STATE_CLOSE; } break; } }
/* * cpu_startup: allocate memory for variable-sized tables. */ void cpu_startup() { vaddr_t minaddr, maxaddr; char pbuf[9]; extern void greeting __P((void)); if (fputype != FPU_NONE) m68k_make_fpu_idle_frame(); /* * Initialize the kernel crash dump header. */ cpu_init_kcore_hdr(); /* * Good {morning,afternoon,evening,night}. */ printf("%s%s", copyright, version); identifycpu(); format_bytes(pbuf, sizeof(pbuf), ctob(physmem)); printf("total memory = %s\n", pbuf); minaddr = 0; /* * Allocate a submap for physio */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, false, NULL); /* * Finally, allocate mbuf cluster submap. */ mb_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, nmbclusters * mclbytes, VM_MAP_INTRSAFE, false, NULL); format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free)); printf("avail memory = %s\n", pbuf); /* * Say "Hi" to the world */ greeting(); }
int main() { greeting(); printf("Here you can see the prog that reads Evgeny Onegin from txt \nfile and sorts it\n"); FILE *input; //FILE *output; input = fopen("input", "r"); { //output = fopen("output", "w"); int f_len = filelength(fileno(input)); assert (f_len >= 0); char* buffer = (char *) calloc(f_len+1, sizeof(*buffer)); assert(buffer > 0); fread(buffer, f_len, sizeof(char), input); fclose(input); int howmuch_str = find_strnum(buffer, f_len); assert (howmuch_str >= 0); char **data = (char **) calloc(howmuch_str+1, sizeof(**data)); place_str (buffer, data, f_len); qsort (data, howmuch_str, sizeof(char*), &compareStr); for (int i = 0; i < howmuch_str; ++i) { assert (0 <= i && i < howmuch_str); puts(data[i]); } } /*else { printf("ERROR_TXT! Unable to create or open new txt file. Contact developer.\n"); return 0; }*/ return 0; }
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-// bool SOCKS5_Client::connect() { Core::Logger::logItLn("[SOCKS5 Client] Connecting..."); if( TCP_Client::connect() ) { if( !greeting() ) return false; if( auth_mod ) if( !authenticate() ) return false; /// @todo bind, udp if( cmd == SOCKS5::CMD_CONNECT ) return askConnect(); return true; } return false; }
main(int argc, char * argv[]) { //note the format for arguments //unsigned int stackaddr = get_sp(); //printf("Stack Pointer ESP value is 0x%x\n", get_sp()); greeting(argv[1], argv[2]); //call function, pass title & name printf("Bye %s %s\n", argv[1], argv[2]); //say "bye" } //exit program
int main(void) { greeting(); greeting2(); return 0; }
//!----------------------------------- int main() { greeting(); processList(); return 0; }
int main (int argc, char * argv[]) { int nbytes; // number of bytes received and sent by sendto() int toSend; //size of bytes to be sent by sendto() int sockfd; //this will be our socket char buffer[MAXMSGSIZE]; //Buffer to receive respones from server char msg[MAXMSGSIZE]; //Message or command to be sent to the server int done = 0; //bool for control looping struct sockaddr_in remote; //"Internet socket address structure" int fileError = 0; if (argc < 3) { printf("USAGE: <server_ip> <server_port>\n"); exit(1); } /****************** Here we populate a sockaddr_in struct with information regarding where we'd like to send our packet i.e the Server. ******************/ bzero(&remote,sizeof(remote)); //A brief explanation of some of the functions used in the code is provided here. However, for in depth understanding of the functions, please read the ma//zero the struct remote.sin_family = AF_INET; //address family remote.sin_port = htons(atoi(argv[2])); //sets port to network byte order remote.sin_addr.s_addr = inet_addr(argv[1]); //sets remote IP address //Causes the system to create a generic socket of type UDP (datagram) sockfd = socket(PF_INET,SOCK_DGRAM,0); if (sockfd < 0) { printf("unable to create socket"); } //Tell user possible commands greeting(); while(!done){ int BUFFERSIZE = 256; char input[BUFFERSIZE]; //buffer to standard input fgets(input, BUFFERSIZE, stdin); char command[BUFFERSIZE]; char file[BUFFERSIZE]; int n; //Parse through command n = sscanf(input, "%s %s", command, file); //Get [file_name] command if(strcmp(command, "get") == 0 && n == 2){ bzero(&msg,sizeof(msg)); strcpy(msg, input); toSend = strlen(msg); //Put [file_name] command }else if(strcmp(command, "put") == 0 && n == 2){ FILE *fp; long file_size; //open file fp=fopen(file, "rb"); if(fp == NULL){ printf("Error opening file!\n"); continue; } //obtain file size fseek(fp, 0, SEEK_END); file_size = ftell(fp); rewind(fp); bzero(&msg,sizeof(msg)); size_t result = fread(msg, 1, file_size, fp); if(result != file_size){ printf("File reading error!"); fclose(fp); continue; } toSend = result; fclose(fp); //ls command }else if(strcmp(command, "ls") == 0 && n == 1){ bzero(&msg,sizeof(msg)); strcpy(msg, "ls"); toSend = strlen(msg); }else if(strcmp(command, "exit") == 0 && n == 1){//exit command printf("Telling server to bug off! \n"); bzero(&msg,sizeof(msg)); strcpy(msg, "exit"); toSend = strlen(msg); done = 1; }else{ //non valid command printf("invalid command!(client)\n"); continue; //continue so nothing is sent to server. } /****************** sendto() sends immediately. it will report an error if the message fails to leave the computer however, with UDP, there is no error if the message is lost in the network once it leaves the computer. ******************/ nbytes = sendto(sockfd, msg, toSend, 0, (struct sockaddr *)&remote, sizeof(remote)); //printf("Client sent: %d bytes", nbytes); if(nbytes < 0){ printf("Client says: Error sending response to server\n"); } // Blocks till bytes are received struct sockaddr_in from_addr; socklen_t addr_length = sizeof from_addr; bzero(buffer, sizeof(buffer)); nbytes = recvfrom(sockfd, buffer, MAXMSGSIZE, 0, (struct sockaddr*)&from_addr, &addr_length); if(nbytes < 0){ printf("Client says: Error reading server response\n"); } printf("Server says %s\n\n", buffer); //SPECIAL CASE FOR PUT GIVE FILENAME TO SERVER ON REQUEST if(strcmp(buffer, "FilenameRequest")==0){ //send filename printf("file on client side: %s \n", file); nbytes = sendto(sockfd, file, strlen(file), 0, (struct sockaddr *)&remote, sizeof(remote)); if(nbytes < 0){ printf("Client says: Error reading server response\n"); } //Receive success/fail nbytes = recvfrom(sockfd, buffer, MAXMSGSIZE, 0, (struct sockaddr*)&from_addr, &addr_length); if(nbytes < 0){ printf("Client says: Error reading server response\n"); } printf("Server says %s\n\n", buffer); } //If server returns file error on get, dont write to file if(strcmp(buffer, "Error opening file on server!")==0){ fileError = 1; }else{ fileError = 0; } //SPECIAL CASE FOR GET FILENAME if(strcmp(command,"get")==0 && !fileError){ //write file FILE * fp; fp = fopen(file, "wb"); if(fwrite(buffer, 1, nbytes, fp) != nbytes || fp == NULL){ printf("File write failure!\n"); }else{ printf("File write success!\n"); } fclose(fp); } } close(sockfd); return 0; }
int main(void) { printf("%s\n", greeting()); return 0; }
main(int argc, char * argv[]){ greeting(argv[1], argv[2]); printf("Bye %s %s\n", argv[1], argv[2]); }
int main() { greeting(); processTask(); return 0; }
void cpu_startup() { caddr_t v; int sz, i; vsize_t size; int base, residual; vaddr_t minaddr, maxaddr, uarea_pages; /* * Initialize error message buffer (at end of core). * avail_end was pre-decremented in luna88k_bootstrap() to compensate. */ for (i = 0; i < btoc(MSGBUFSIZE); i++) pmap_kenter_pa((paddr_t)msgbufp + i * NBPG, avail_end + i * NBPG, VM_PROT_READ | VM_PROT_WRITE); pmap_update(pmap_kernel()); initmsgbuf((caddr_t)msgbufp, round_page(MSGBUFSIZE)); /* Determine the machine type from FUSE ROM data */ get_fuse_rom_data(); if (strncmp(fuse_rom_data, "MNAME=LUNA88K+", 14) == 0) { machtype = LUNA_88K2; } /* Determine the 'auto-boot' device from NVRAM data */ get_nvram_data(); get_autoboot_device(); /* * Good {morning,afternoon,evening,night}. */ printf(version); identifycpu(); printf("real mem = %d\n", ctob(physmem)); /* * Check front DIP switch setting */ printf("dipsw = 0x%x\n", dipswitch); /* Check DIP switch 1 - 1 */ if ((0x8000 & dipswitch) == 0) { boothowto |= RB_SINGLE; } /* Check DIP switch 1 - 3 */ if ((0x2000 & dipswitch) == 0) { boothowto |= RB_ASKNAME; } /* Check DIP switch 1 - 4 */ if ((0x1000 & dipswitch) == 0) { boothowto |= RB_CONFIG; } /* * Check frame buffer depth. */ switch (hwplanebits) { case 0: /* No frame buffer */ case 1: case 4: case 8: break; default: printf("unexpected frame buffer depth = %d\n", hwplanebits); hwplanebits = 0; break; } #if 0 /* just for test */ /* * Get boot arguments */ { char buf[256]; char **p = (volatile char **)0x00001120; strncpy(buf, *p, 256); if (buf[255] != '\0') buf[255] = '\0'; printf("boot arg: (0x%x) %s\n", *p, buf); } #endif /* * Find out how much space we need, allocate it, * and then give everything true virtual addresses. */ sz = (int)allocsys((caddr_t)0); if ((v = (caddr_t)uvm_km_zalloc(kernel_map, round_page(sz))) == 0) panic("startup: no room for tables"); if (allocsys(v) - v != sz) panic("startup: table size inconsistency"); /* * Grab UADDR virtual address */ uarea_pages = UADDR; uvm_map(kernel_map, (vaddr_t *)&uarea_pages, USPACE, NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0)); if (uarea_pages != UADDR) panic("uarea_pages %lx: UADDR not free", uarea_pages); /* * Grab the OBIO space that we hardwired in pmap_bootstrap */ obiova = OBIO_START; uvm_map(kernel_map, (vaddr_t *)&obiova, OBIO_SIZE, NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0)); if (obiova != OBIO_START) panic("obiova %lx: OBIO not free", obiova); /* * Now allocate buffers proper. They are different than the above * in that they usually occupy more virtual memory than physical. */ size = MAXBSIZE * nbuf; if (uvm_map(kernel_map, (vaddr_t *) &buffers, round_page(size), NULL, UVM_UNKNOWN_OFFSET, 0, UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, UVM_ADV_NORMAL, 0))) panic("cpu_startup: cannot allocate VM for buffers"); minaddr = (vaddr_t)buffers; if ((bufpages / nbuf) >= btoc(MAXBSIZE)) { /* don't want to alloc more physical mem than needed */ bufpages = btoc(MAXBSIZE) * nbuf; } base = bufpages / nbuf; residual = bufpages % nbuf; for (i = 0; i < nbuf; i++) { vsize_t curbufsize; vaddr_t curbuf; struct vm_page *pg; /* * Each buffer has MAXBSIZE bytes of VM space allocated. Of * that MAXBSIZE space, we allocate and map (base+1) pages * for the first "residual" buffers, and then we allocate * "base" pages for the rest. */ curbuf = (vaddr_t)buffers + (i * MAXBSIZE); curbufsize = PAGE_SIZE * ((i < residual) ? (base+1) : base); while (curbufsize) { pg = uvm_pagealloc(NULL, 0, NULL, 0); if (pg == NULL) panic("cpu_startup: not enough memory for " "buffer cache"); pmap_kenter_pa(curbuf, VM_PAGE_TO_PHYS(pg), VM_PROT_READ | VM_PROT_WRITE); curbuf += PAGE_SIZE; curbufsize -= PAGE_SIZE; } } pmap_update(pmap_kernel()); /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. */ exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, 16 * NCARGS, VM_MAP_PAGEABLE, FALSE, NULL); /* * Allocate map for physio. */ phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, VM_PHYS_SIZE, 0, FALSE, NULL); printf("avail mem = %ld (%d pages)\n", ptoa(uvmexp.free), uvmexp.free); printf("using %d buffers containing %d bytes of memory\n", nbuf, bufpages * PAGE_SIZE); /* * Set up buffers, so they can be used to read disk labels. */ bufinit(); /* * Initialize the autovectored interrupt list. */ isrinit(); /* * Configure the system. */ if (boothowto & RB_CONFIG) { #ifdef BOOT_CONFIG user_config(); #else printf("kernel does not support -c; continuing..\n"); #endif } /* * Say hello to the world on LCD. */ greeting(); }
int lcdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p) { int val; /* check if the device opened with write mode */ switch(cmd) { case LCDCLS: case LCDHOME: case LCDMODE: case LCDDISP: case LCDMOVE: case LCDSEEK: case LCDRESTORE: if ((flag & FWRITE) == 0) return EACCES; break; } switch(cmd) { case LCDCLS: lcdctrl(LCD_CLS); break; case LCDHOME: lcdctrl(LCD_HOME); break; case LCDMODE: val = *(int *)addr; switch (val) { case LCDMODE_C_LEFT: case LCDMODE_C_RIGHT: case LCDMODE_D_LEFT: case LCDMODE_D_RIGHT: lcdctrl(val); break; default: return EINVAL; } break; case LCDDISP: val = *(int *)addr; if ((val & 0x7) != val) return EINVAL; lcdctrl(val | 0x8); break; case LCDMOVE: val = *(int *)addr; switch (val) { case LCDMOVE_C_LEFT: case LCDMOVE_C_RIGHT: case LCDMOVE_D_LEFT: case LCDMOVE_D_RIGHT: lcdctrl(val); break; default: return EINVAL; } break; case LCDSEEK: val = *(int *)addr & 0x7f; lcdctrl(val | 0x80); break; case LCDRESTORE: greeting(); break; default: return ENOTTY; } return 0; }
/************************************************************************ * main() Initialize & start citadel ************************************************************************/ void main(int argc, char *argv[]) { int i, cfg_ctdl = FALSE; long b; char init_baud; static char prompt[92]; char *envprompt; cfg.bios = 1; cit_init_timer(); /* initialize cit_time() and cit_timer() */ cfg.attr = 7; /* logo gets white letters */ setscreen(); /* initialize screen system */ memset(&parm,0,sizeof(parm)); for (i = 1; i < argc; i++) { if (argv[i][0] == '/' || argv[i][0] == '-') { switch (tolower(argv[i][1])) { #ifndef ATARI_ST case 'd': /* DesqView/TopView */ parm.dv = 1; cPrintf("DesqView/TopView mode\n"); break; case 'b': /* baud rate (for shell) */ if (argv[i + 1]) { b = atol(argv[++i]); for (init_baud = 0; bauds[init_baud]; ++init_baud) if (bauds[init_baud] == b) { parm.baud = init_baud; cPrintf("Initial baud rate fixed at %ld\n", b); break; } } break; case 'm': parm.memcheck = !parm.memcheck; break; #endif case 'c': /* Configure system */ cfg_ctdl = TRUE; break; case 'p': /* pace output */ if (argv[i + 1]) { parm.pace = atoi(argv[++i]); cPrintf("Output pacing %d\n", parm.pace); } break; case 's': /* run in shell from another BBS (door). */ cPrintf("Shell mode\n"); parm.door = TRUE; break; /*#ifndef ATARI_ST*/ #ifndef FLOPPY case 'e': /* use EMS */ if (_OvrInitEms(0, 0, 0)) { cPrintf("EMS memory initialization failed!\n"); parm.ems = 1; } break; #endif /*#endif*/ case 'v': /* just do events */ parm.events = 1; break; /*#ifndef ATARI_ST*/ #ifndef FLOPPY case 'x': /* use exteneded memory */ if (_OvrInitExt(0, 0)) cPrintf("Extended memory initialization failed!\n"); parm.ext = 1; break; #endif /*#endif*/ case 'l': /* log in user */ if (argv[i + 1]) { parm.login = argv[++i]; cPrintf("Auto-login\n"); } break; case 'u': /* log in user */ if (argv[i + 1]) { parm.user = argv[++i]; cPrintf("Auto-login %s\n", parm.user); } break; default: cPrintf("\nUnknown commandline switch '%s'.\n", argv[i]); cPrintf("Valid DOS command line switches:\n"); cPrintf(" -b baud Starting baud rate (300-19200)\n"); cPrintf(" -c Read configuration files\n"); cPrintf(" -d DesqView/TopView\n"); #ifndef FLOPPY cPrintf(" -e Use EMS memory for overlays\n"); #endif cPrintf(" -l str Log in using initials;password in str\n"); cPrintf(" -m Memory check during idle time, start\n"); cPrintf(" -p num Set output pacing to num\n"); cPrintf(" -s Run as a shell from another BBS\n"); cPrintf(" -u 'name' Log in using specifed user name"); cPrintf(" -v Just run cron events\n"); #ifndef FLOPPY cPrintf(" -x Use extended memory for overlays (386/486 only!)\n"); #endif exit(1); } } } if (cfg_ctdl) /* force reconfigure? */ unlink("etc.tab"); logo(); /* prints out system logo */ if (cit_time() < 607415813L) { cPrintf("\n\nPlease set your time and date!\n"); exit(1); } /* set prompt for shells */ envprompt = getenv("PROMPT"); if (!envprompt) envprompt = "$p$g"; sprintf(prompt, "PROMPT=\r\nType EXIT to return to FredCit\r\n%s", envprompt); if (putenv(prompt)) { cPrintf("\n\nCan not set DOS prompt!\n"); delay (5000); } /* initialize citadel */ initCitadel(); if (parm.baud) { cfg.initbaud = parm.baud; baud(cfg.initbaud); } if (parm.door) { detectflag = 1; // carrier(); // if (haveCarrier) { // carrdetect(); // newCarrier = 1; /* make hello blurb show up */ // } } greeting(); sysReq = FALSE; if (cfg.f6pass[0]) ConLock = TRUE; if (parm.dv) { cfg.bios = 1; directvideo = 0; } if (parm.login) { normalizeString(parm.login); /* normalize string in environment */ login(parm.login,NULL); } else if (parm.user && !loggedIn) { normalizeString(parm.user); /* normalize string in environment */ if (findPerson(parm.user, &lBuf) != ERROR) login(lBuf.lbin,lBuf.lbpw); } /* read in door interface files */ if (parm.door) { readDoorFiles(0); } /* update25(); */ do_idle(0); /* install critical error handler */ harderr(cit_herror_handler); /* execute main command loop */ if (!parm.events) command_loop(); else { do_cron_loop(); } exitcitadel(); }
void startUp(int argc, const char *argv[]) { #if __BORLANDC__ >= 1106 set_new_handler(0); #endif strcpy(fullExePath, argv[0]); #ifndef WINCIT fseek(stdin, 0, SEEK_CUR); // Borland says to fseek() before setbuf() setbuf(stdin, NULL); #endif #ifndef WINCIT #ifdef MULTI if (!initTaskInfo(&ti)) #else cfg.maxrooms = 0 ; if (!initFakeTaskInfo()) #endif { printf("Could not create initial task information structure.\n"); exit(200); } #endif tzset(); critical(TRUE); #ifndef WINCIT if (checkDataVer() != NumericVer) { printf("CTDL.DAT is version %d; version %d needed.\n", checkDataVer(), NumericVer); critical(FALSE); exit(200); } if (!read_messages()) { printf("Could not read messages from CTDL.DAT\n"); critical(FALSE); exit(200); } InitializeTimer(); #else if (checkDataVer() != NumericVer) { char bbb[100]; sprintf(bbb, "CTDL.DAT is version %d; version %d needed.", checkDataVer(), NumericVer); MessageBox(NULL, bbb, NULL, MB_ICONSTOP | MB_OK); exit(200); } if (!read_messages()) { MessageBox(NULL, "Could not read messages from CTDL.DAT.", NULL, MB_ICONSTOP | MB_OK); exit(200); } WNDCLASS wndclass; // define and register the main window class wndclass.style = 0; // CS_HREDRAW | CS_VREDRAW wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, "CITADEL"); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); // define and register the logo window class wndclass.lpszMenuName = NULL; wndclass.lpfnWndProc = logoWndProc; wndclass.lpszClassName = "Citadel Logo"; if (!RegisterClass(&wndclass)) { MessageBox(NULL, "Could not register logo window", NULL, MB_ICONSTOP | MB_OK); exit(200); } #ifdef NAHERROR // define and register the error window class wndclass.style = CS_VREDRAW; wndclass.lpfnWndProc = errorWndProc; wndclass.lpszClassName = "Citadel Error"; if (!RegisterClass(&wndclass)) { MessageBox(NULL, "Could not register error window", NULL, MB_ICONSTOP | MB_OK); exit(200); } // define and register the msg window class wndclass.lpfnWndProc = msgWndProc; wndclass.lpszClassName = "Citadel Message"; if (!RegisterClass(&wndclass)) { MessageBox(NULL, "Could not register msg window", NULL, MB_ICONSTOP | MB_OK); exit(200); } #endif #endif // initialize all drivers to internal functions #ifdef WINCIT // com // initrs = (void (cdecl *)(int,int,int,int,int,int)) nullFunc; // deinitrs = nullFunc; // ringstatrs = (int (cdecl *)(void)) nullFunc; // carrstatrs = (int (cdecl *)(void)) nullFunc; // statrs = (int (cdecl *)(void)) nullFunc; // flushrs = nullFunc; // getrs = (int (cdecl *)(void)) nullFunc; // putrs = (void (cdecl *)(char)) nullFunc; // dtrrs = (void (cdecl *)(int)) nullFunc; // flushoutrs = nullFunc; #else // Start using BIOS charattr = bioschar; stringattr = biosstring; // com initrs = InitRS; deinitrs = DeInitRS; ringstatrs = RingStatRS; carrstatrs = CarrStatRS; statrs = StatRS; flushrs = FlushRS; getrs = GetRS; putrs = PutRS; dtrrs = DtrRS; flushoutrs = nullFunc; // ups initups = nullFunc; deinitups = nullFunc; statups = NULL; // kbd initkbd = nullFunc; deinitkbd = nullFunc; statcon = StatCON; getcon = GetCON; sp_press = special_pressed; // snd init_sound = (int (cdecl *)(void)) nullFunc; close_sound = (int (cdecl *)(void)) nullFunc; get_version = (int (cdecl *)(void)) nullFunc; query_drivers = (int (cdecl *)(void)) nullFunc; query_status = (int (cdecl *)(void)) nullFunc; start_snd_src = (int (cdecl *)(int, const void *)) nullFunc; play_sound = (int (cdecl *)(int)) nullFunc; stop_sound = (int (cdecl *)(int)) nullFunc; pause_sound = (int (cdecl *)(int)) nullFunc; resume_sound = (int (cdecl *)(int)) nullFunc; read_snd_stat = (int (cdecl *)(int)) nullFunc; set_midi_map = (int (cdecl *)(int)) nullFunc; get_src_vol = (int (cdecl *)(int)) nullFunc; set_src_vol = (int (cdecl *)(int, int)) nullFunc; set_fade_pan = (int (cdecl *)(void *)) nullFunc; strt_fade_pan = (int (cdecl *)(void)) nullFunc; stop_fade_pan = (int (cdecl *)(int)) nullFunc; pse_fade_pan = (int (cdecl *)(void)) nullFunc; res_fade_pan = (int (cdecl *)(void)) nullFunc; read_fade_pan = (int (cdecl *)(int)) nullFunc; get_pan_pos = (int (cdecl *)(int)) nullFunc; set_pan_pos = (int (cdecl *)(int, int)) nullFunc; say_ascii = (int (cdecl *)(const char *, int)) nullFunc; #endif parseArgs(argc, argv); #ifndef WINCIT if (!cfg.bios) { charattr = directchar; stringattr = directstring; } #endif #ifndef WINCIT if (!cmdLine[1]) { uchar *ptr = (uchar *) MK_FP(_psp, 128); if (ptr[0]) { memcpy(cmdLine, ptr + 1, max(128, ptr[0])); cmdLine[ptr[0]] = 0; } } OC.whichIO = CONSOLE; #endif if (!initCitadel()) { #ifndef WINCIT DeinitializeTimer(); #endif critical(FALSE); exit(200); } #ifndef WINCIT ScreenSaver.Update(); #endif if (BoardNameHash && hash(cfg.nodeTitle) != BoardNameHash) { crashout(getmsg(681)); } #ifndef WINCIT // Set system to a known state OC.Echo = BOTH; OC.SetOutFlag(IMPERVIOUS); modStat = FALSE; OC.whichIO = CONSOLE; OC.setio(); if (!(login_pw || login_user || (slv_door && cfg.forcelogin))) { CommPort->FlushInput(); greeting(); } Cron.ResetTimer(); if (slv_net) { doccr(); if(read_tr_messages()) { cPrintf(gettrmsg(49), slv_node); dump_tr_messages(); } if (net_callout(slv_node)) { did_net(slv_node); } ExitToMsdos = TRUE; } if (slv_door) // set according to carrier { // set baud rate even if carrier not present if (slv_baud != PS_ERROR) { CommPort->SetSpeed(slv_baud); } else { CommPort->SetSpeed(cfg.initbaud); } for (ModemSpeedE i = MS_300; i < MS_NUM; i = (ModemSpeedE) (i +1)) { if (connectbauds[i] == bauds[CommPort->GetSpeed()]) { CommPort->SetModemSpeed(i); break; } } if (CommPort->HaveConnection()) { CarrierJustFound(); OC.whichIO = MODEM; OC.setio(); } else { OC.whichIO = CONSOLE; OC.setio(); } } setdefaultTerm(TT_ANSI); StatusLine.Toggle(); // Turns it on (starts life off). ScreenSaver.SetMayTurnOn(TRUE); time(&LastActiveTime); TimeoutChecking = TRUE; if (*cmd_script) { #ifdef WINCIT runScript(cmd_script, NULL); #else runScript(cmd_script); #endif } doEvent(EVT_STARTUP); #endif }
/********************************************************************** * * Function: main() * * Description: Entry point into console version of sample * program that exercises the calibration * functions. * * Argument(s): argCount - the number of arguments provided * argValue - pointer to the list of char strings * representing the command line arguments. * * Return: void * */ int main( int argCount, char ** argValue ) { int retValue = OK ; MATRIX matrix ; POINT display ; int n ; greeting() ; /* The following call calculates the translation matrix that */ /* results when the three consecutive points in the sample */ /* set are used. Such points are assumed to be properly */ /* spaced within the screen surface. */ /* Note that we call the function twice as we would normally */ /* do within a calibration routine. The first time we call */ /* it using a perfect set of display and screen arguments. */ /* Such a call is made to obtain a calibration matrix that is */ /* just good enough to collect samples to do the real */ /* calibration. */ /* */ /* */ /* */ /* NOTE! NOTE! NOTE! */ /* */ /* setCalibrationMatrix() and getDisplayPoint() will do fine */ /* for you as they are, provided that your digitizer */ /* resolution does not exceed 10 bits (1024 values). Higher */ /* resolutions may cause the integer operations to overflow */ /* and return incorrect values. If you wish to use these */ /* functions with digitizer resolutions of 12 bits (4096 */ /* values) you will either have to a) use 64-bit signed */ /* integer variables and math, or b) judiciously modify the */ /* operations to scale results by a factor of 2 or even 4. */ /* */ setCalibrationMatrix( &perfectDisplaySample[0], &perfectScreenSample[0], &matrix ) ; /* Look at the matrix values when we use a perfect sample set. */ /* The result is a unity matrix. */ printf("\n\nLook at the unity matrix:\n\n" "matrix.An = % 8ld matrix.Bn = % 8ld matrix.Cn = % 8ld\n" "matrix.Dn = % 8ld matrix.En = % 8ld matrix.Fn = % 8ld\n" "matrix.Divider = % 8ld\n", matrix.An,matrix.Bn,matrix.Cn, matrix.Dn,matrix.En,matrix.Fn, matrix.Divider ) ; /* Now is when we need to do the work to collect a real set of */ /* calibration data. */ /* Draw three targets on your display. Drawing one at time is */ /* probably a simpler implementation. These targets should be */ /* widely separated but also avoid the areas too near the */ /* edges where digitizer output tends to become non-linear. */ /* The recommended set of points is (in display resolution */ /* percentages): */ /* */ /* ( 15, 15) */ /* ( 50, 85) */ /* ( 85, 50) */ /* */ /* Each time save the display and screen set (returned by the */ /* digitizer when the user touches each calibration target */ /* into the corresponding array). */ /* Since you normalized your calibration matrix above, you */ /* should be able to use touch screen data as it would be */ /* provided by the digitizer driver. When the matrix equals */ /* unity, getDisplayPoint() returns the same raw input data */ /* as output. */ /* Call the function once more to obtain the calibration */ /* factors you will use until you calibrate again. */ setCalibrationMatrix( &displaySample[0], &screenSample[0], &matrix ) ; /* Let's see the matrix values for no particular reason. */ printf("\n\nThis is the actual calibration matrix that we will use\n" "for all points (until we calibrate again):\n\n" "matrix.An = % 8d matrix.Bn = % 8d matrix.Cn = % 8d\n" "matrix.Dn = % 8d matrix.En = % 8d matrix.Fn = % 8d\n" "matrix.Divider = % 8d\n", matrix.An,matrix.Bn,matrix.Cn, matrix.Dn,matrix.En,matrix.Fn, matrix.Divider ) ; /* Now, lets use the complete set of screen samples to verify */ /* that the calculated calibration matrix does its job as */ /* expected. */ printf("\n\nShow the results of our work:\n\n" " Screen Sample Translated Sample Display Sample\n\n" ) ; /* In a real application, your digitizer driver interrupt */ /* would probably do the following: */ /* 1) collect raw digitizer data, */ /* 2) filter the raw data which would probably contain */ /* position jitter, */ /* 3) filter out repeated values (a touch screen */ /* controller normally continues causing interrupts */ /* and collecting data as long as the user is */ /* pressing on the screen), and */ /* 4) call the function getDisplayPoint() to obtain */ /* the display coordinates that the user meant to */ /* input as he touched the screen. */ /* */ /* This code sample, of course, only uses sample data. So we */ /* simply run through all the available sample points. */ for( n = 0 ; n < MAX_SAMPLES ; ++n ) { getDisplayPoint( &display, &screenSample[n], &matrix ) ; printf(" % 6d,%-6d % 6d,%-6d % 6d,%-6d\n", screenSample[n].x, screenSample[n].y, display.x, display.y, displaySample[n].x, displaySample[n].y ) ; } return( retValue ) ; } // end of main()
int main() { greeting(); return 0; }
char doRegular(char expand, char c) { char toReturn; int i; int done = 0; label doorinfo; toReturn = FALSE; for (i = 0; !expand && i < MAXEXTERN && extCmd[i].name[0]; ++i) { if (c == toupper(extCmd[i].name[0]) && (onConsole || !extCmd[i].local)) { done = 1; mPrintf("\b%s", extCmd[i].name); doCR(); if (changedir(cfg.aplpath) == ERROR) { mPrintf(" -- Can't find application directory.\n\n"); changedir(cfg.homepath); } /* apsystem(extCmd[i].command); */ sprintf(doorinfo, "DORINFO%d.DEF", onConsole ? 0 : userdat.apl_com); extFmtRun(extCmd[i].command, doorinfo); } } if (!done) { switch (c) { case 'S': if (gl_user.sysop && expand) { mPrintf("\b\bSysop Menu"); doCR(); doSysop(); } else { toReturn = TRUE; } break; case 'A': if (gl_user.aide) { doAide(expand, 'E'); } else { toReturn = TRUE; } break; case 'C': doChat(expand, '\0'); break; case 'D': doDownload(expand); break; case 'E': doEnter(expand, 'm'); break; case 'F': doRead(expand, 'f'); break; case 'G': doGoto(expand, FALSE); break; case 'H': doHelp(expand); break; case 'I': doIntro(); break; case 'J': mPrintf("\bJump back to "); unGotoRoom(); break; case 'K': doKnown(expand, 'r'); break; case 'L': if (!loggedIn) { doLogin(expand); } else { if (!getYesNo(confirm, 0)) break; doLogout(expand, 's'); doLogin(expand); } break; case 'N': case 'O': case 'R': doRead(expand, tolower(c)); break; case 'B': doGoto(expand, TRUE); break; case 'T': doLogout(expand, 'q'); break; case 'U': doUpload(expand); break; case 'X': if (!expand) { doEnter(expand, 'x'); } else { doXpert(); } break; case '=': case '+': doNext(); break; case '\b': mPrintf(" "); case '-': doPrevious(); break; case ']': case '>': doNextHall(); break; case '[': case '<': doPreviousHall(); break; case '~': mPrintf("\bAnsi %s\n ", gl_term.ansiOn ? gl_str.off : gl_str.on); gl_term.ansiOn = !gl_term.ansiOn; break; case '!': mPrintf("\bIBM Graphics %s\n ", gl_term.IBMOn ? gl_str.off:gl_str.on); gl_term.IBMOn = !gl_term.IBMOn; break; case '?': nextmenu("mainopt", &(cfg.cnt.mainopttut), 1); listExterns(); break; case 0: /* never gets here in shell mode... */ if (newCarrier) { greeting(); if (cfg.forcelogin) { doCR(); doCR(); i = 0; while (!loggedIn && gotCarrier()) { doLogin(2); if (++i > 3) { Initport(); toReturn = TRUE; break; } } } newCarrier = FALSE; } if (logBuf.lbflags.NODE && loggedIn) { net_slave(); haveCarrier = FALSE; modStat = FALSE; newCarrier = FALSE; justLostCarrier = FALSE; onConsole = FALSE; disabled = FALSE; callout = FALSE; delay(2000); Initport(); cfg.callno++; terminate(FALSE, FALSE); } if (justLostCarrier || ExitToMsdos) { justLostCarrier = FALSE; if (loggedIn) terminate(FALSE, FALSE); } break; /* irrelevant value */ default: toReturn = TRUE; break; } } /* if they get unverified online */ if (logBuf.VERIFIED) terminate(FALSE, FALSE); /* update25(); */ do_idle(0); return toReturn; }
int main() { greeting(std::cout); return 0; }