int8_t sd_open() { sd_close(); /* setup sd card slot */ if(!sd_raw_init()) return SD_ERROR_INIT; /* open first partition */ sd_partition = partition_open(sd_raw_read, sd_raw_read_interval, sd_raw_write, sd_raw_write_interval, 0 ); if(!sd_partition) { /* If the partition did not open, assume the storage device * is a "superfloppy", i.e. has no MBR. */ sd_partition = partition_open(sd_raw_read, sd_raw_read_interval, sd_raw_write, sd_raw_write_interval, -1 ); if(!sd_partition) return SD_ERROR_PARTITION; } /* open file system */ sd_fs = fat16_open(sd_partition); if(!sd_fs) { sd_close(); return SD_ERROR_FS; } /* open root directory */ struct fat16_dir_entry_struct directory; fat16_get_dir_entry_of_path(sd_fs, "/", &directory); sd_dd = fat16_open_dir(sd_fs, &directory); if(!sd_dd) { sd_close(); return SD_ERROR_ROOTDIR; } return SD_ERROR_NONE; }
/* * Format Diskette */ system("dosformat -fq a:"); eh_post(ERR_CONFIRM, "Format diskette"); memset(buf, 0, 2); t = sd_input(&fld2,sd_prompt(&fld2,0),&rm,buf,0); if(t == EXIT) leave(); if (t == UP_CURSOR) continue; *buf = tolower(*buf); if (*buf == 'n') leave(); if (*buf == 'y') continue; eh_post(ERR_CODE, buf); } } /* end main */ leave() { sd_close(); ss_close(); execlp("diagnostics", "diagnostics", 0); krash("leave", "diagnostics load", 1); }
close_all() { oc_close(); co_close(); ss_close(); sd_close(); }
void xml_close(int sock, xmlDocPtr doc, xmlNodePtr top) { xmlNodePtr n; #ifdef DEBUG fprintf(stderr, "Going to close something!\n"); #endif for (n = top->xmlChildrenNode; n != NULL; n = n->next) { xmlChar *p; if (xmlStrcmp(n->name, (xmlChar*)"collection") != 0) { fprintf(stderr, "Unknown node(close) name: %s\n", (char *)n->name); continue; } if ((p = xmlNodeListGetString(doc, n->xmlChildrenNode, 1)) == NULL) { fprintf(stderr, "Unable to get collection name to close.\n"); continue; } sd_close(sock, (char *)p); xmlFree(p); } }
leave() { sd_close(); ss_close(); co_close(); execlp("syscomm", "syscomm", 0); krash("leave", "syscomm load", 1); }
close_all() { ss_close(); pmfile_close(); log_close(); database_close(); sd_close(); }
close_all() { sd_close(); ss_close(); co_close(); oc_close(); od_close(); database_close(); }
/*-------------------------------------------------------------------------* * Close All Files *-------------------------------------------------------------------------*/ close_all() { co_close(); ss_close(); pmfile_close(); prodfile_close(); sd_close(); database_close(); }
/* *close all files */ close_all() { picker_close(); picker_order_close(); co_close(); ss_close(); sd_close(); database_close(); return 0; }
/** * Free resources consumed by a SERIAL_DEVICE */ void sd_destroy(SERIAL_DEVICE sd) { if (NULL != sd) { sd_close(sd); free(sd->oldtio); free(sd->tio); free(sd->last_response); free(sd); } }
int securid_verify(struct passwd *pw, char *pass, sudo_auth *auth) { struct SD_CLIENT *sd = (struct SD_CLIENT *) auth->data; int rval; rval = sd_auth(sd); sd_close(); if (rval == ACM_OK) return AUTH_SUCCESS; else return AUTH_FAILURE; }
int sd_init(void) { int err; fd = ios_open("/dev/sdio/slot0", 0); if (fd < 0) return fd; err = sd_reset_card(); if (err) { goto out; } // now in standby state err = sd_select(); if (err) goto out; // now in transfer state // Some broken cards require this: err = sd_set_blocklength(0x200); if (err) goto out; err = sd_set_bus_width(4); // XXX: Should check in SCR first. if (err) goto out; err = sd_set_clock(); // XXX: Should check. if (err) goto out; return 0; out: sd_close(); return err; }
void *StreamClient(void *pipefd) { int sockfd_connect=-1; fd_set readfds, readfds_temp; char buf[HTTP_LEN]={0}; char buf1[HTTP_LEN]={0}; char str1[PORT_LEN]={0}, str2[PORT_LEN]={0}; int length=0; int reqfd=0, resfd=0; ip_t ip_remote = ip[REMOTE][TCP]; port_t port_remote = port[REMOTE][TCP]; struct timeval timeout={10,0}, timeout_temp={0}; int ret=0; reqfd = ((int*)pipefd)[PIPE_INDEX(REQUEST,READ)]; resfd = ((int*)pipefd)[PIPE_INDEX(RESPONSE,WRITE)]; sockfd_connect = EstablishConnect(ip_remote, port_remote, SOCK_STREAM); FD_ZERO(&readfds); FD_SET_P(sockfd_connect, &readfds); FD_SET_P(reqfd, &readfds); while(1) { timeout_temp = timeout; readfds_temp = readfds; ret = select(FD_SETSIZE, &readfds_temp, NULL, NULL, NULL); handle_error_nn(ret, 1, "TRANSMIT","select() %s",strerror(errno)); if(ret == 0) { log4c_cdn(mycat, error, "TRANSMIT", "select() timeout"); exit(-1); } //monitor sockfd_connect if(FD_ISSET(sockfd_connect, &readfds_temp)) { memset(buf,0,sizeof(buf)); length = read(sockfd_connect, buf, sizeof(buf)-1); handle_error_nn(length, 0, "TRANSMIT","read() %s",strerror(errno)); log4c_cdn(mycat, info, "TRANSMIT", "receiving <== connect=%d, length=%d", sockfd_connect, length); log4c_cdn(mycat, debug, "TRANSMIT", "Packet content is\n%s",buf); if(length <= 0) { ret = sd_close(sockfd_connect); handle_error_nn(ret, 1, "TRANSMIT","close() %s",strerror(errno)); FD_CLR_P(sockfd_connect, &readfds); sockfd_connect = EstablishConnect(ip_remote, port_remote, SOCK_STREAM); FD_SET_P(sockfd_connect, &readfds); } else if(length == (sizeof(buf)-1)) { log4c_cdn(mycat, error, "socket", "http response is too large to store"); exit(-1); } else { //deal with http packet length = write(resfd, buf, strlen(buf)); handle_error_nn(length, 1, "TRANSMIT","write() %s",strerror(errno)); log4c_cdn(mycat, info, "TRANSMIT", "sending ==> resfd=%d, length=%d", resfd,length); } } //monitor request fd /*else*/ if(FD_ISSET(reqfd, &readfds_temp)) { memset(buf,0,sizeof(buf)); length = read(reqfd, buf, sizeof(buf)-1); handle_error_nn(length, 1, "TRANSMIT","read() %s",strerror(errno)); log4c_cdn(mycat, info, "TRANSMIT", "receiving <== reqfd=%d length=%d", reqfd, length); if(length == 0) { ret = sd_close(reqfd); handle_error_nn(ret, 1, "TRANSMIT","close() %s",strerror(errno)); FD_CLR_P(reqfd, &readfds); } else { strcpy(buf1, buf); strrpl(buf, buf1, "close", "keep-alive"); strcpy(buf1, buf); strrpl(buf, buf1, "Close", "keep-alive"); strcpy(buf1, buf); strrpl(buf, buf1, ip[LOCAL][TCP], server); strcpy(buf1, buf); sprintf(str1,"%hd",port[LOCAL][TCP]); sprintf(str2,"%hd",port[REMOTE][TCP]); strrpl(buf, buf1, str1, str2); length = write(sockfd_connect, buf, strlen(buf)); handle_error_nn(length, 1, "TRANSMIT","write() %s",strerror(errno)); log4c_cdn(mycat, info, "TRANSMIT", "sending ==> connect=%d, length=%d", sockfd_connect,length); log4c_cdn(mycat, debug, "TRANSMIT", "Packet content is\n%s",buf); } } } return NULL; }
close_all() { ss_close(); sd_close(); }
void sd_disable() { sd_fs_unmount(0); sd_close((struct sd_device*)dev_get_by_type(NULL, HLD_DEV_TYPE_SD)); sd_detach((struct sd_device*)dev_get_by_type(NULL, HLD_DEV_TYPE_SD)); }
int main(int argc, char **argv, char **envp) { int postsize; char *xmldata, *data; xmlDocPtr doc; xmlNodePtr cur, anode; int bbdnsock; int bbdnport; char *status = NULL; struct config_t maincfg; /* Read in config file */ maincfg = maincfgopen(); bbdnport = maincfg_get_int(&maincfg, "BLDPORT"); maincfgclose(&maincfg); key_get(systemkey); char *request_method; if (!bbdn_conect(&bbdnsock, "", bbdnport)) cgi_error(500, bstrerror()); request_method = getenv("HTTP_REQUEST_METHOD")!=NULL ? strdup(getenv("HTTP_REQUEST_METHOD")) : strdup(getenv("REQUEST_METHOD")); // We will handel the post stuf our self. Set REQUEST_METHOD to GET so cgi-util ignores it. setenv("REQUEST_METHOD", "GET", 1); if (cgi_init() != CGIERR_NONE) { cgi_error(500, "Can't init cgi-util"); } /* * Either called from command line, and then we want a file. * or a http get/put * Or we are handling a web request, and getting the data from stdin. */ if ((cgi_getentrystr("method") != NULL) && (strcmp(cgi_getentrystr("method"),"rest") == 0)) { char api[100], coll[100], url[512]; char *requrle; if (getenv("REQUEST_URI") == NULL) { cgi_error(500, "Can't read REQUEST_URI"); } requrle = strdup(getenv("REQUEST_URI")); unescape_url(requrle); sscanf(requrle,"/%[a-z]/%[a-zA-Z0-9_-]/%[^?]", api, coll, url); #ifdef DEBUG fprintf(stderr, "api: \"%s\"\n",api); fprintf(stderr, "coll: \"%s\"\n",coll); fprintf(stderr, "url: \"%s\"\n",url); fprintf(stderr, "request_method: \"%s\"\n",request_method); fprintf(stderr, "reques url \"%s\"\n",getenv("REQUEST_URI")); fprintf(stderr, "reques url unescaped \"%s\"\n",requrle); #endif free(requrle); if (strcmp(request_method,"POST") == 0 || strcmp(request_method,"ADDDELAYED") == 0 || strcmp(request_method,"PUT") == 0) { if (getenv("CONTENT_LENGTH") == NULL) { cgi_error(500, "Can't read CONTENT_LENGTH"); } // Get data length postsize = atoi(getenv("CONTENT_LENGTH")); data = malloc(postsize + 1); if (data == NULL) { cgi_error(500, "Can't allocate data."); } // Read data fread(data, 1, postsize, stdin); data[postsize] = '\0'; // add in to repo if (bbdn_docadd(bbdnsock, coll, // collection name url, // url cgi_getentrystr("documenttype"), // document type data, // data postsize, // data size 0, // lastmodified cgi_getentrystr("acl_allow")!=NULL ? cgi_getentrystr("acl_allow") : "Everyone", // acl allow cgi_getentrystr("acl_denied"), // acl denied cgi_getentrystr("title"), // title cgi_getentrystr("documentformat"), // document format cgi_getentrystr("attributes"), // attributes NULL, // image 0 // image size ) != 1) { cgi_error(500, "bbdn_docadd() failed. Can't add document."); } if (strcmp(request_method,"ADDDELAYED") != 0) { // close it sd_close(bbdnsock, coll); } asprintf(&status,"Added %s to %s\n",url,coll); } else if (strcmp(request_method,"DELETE") == 0) { if (url[0] == '\0') { if (sd_deletecollection(bbdnsock, coll) != 1) { cgi_error(500, "Can't delete collection"); } asprintf(&status,"Deleted collection %s\n",coll); } else { if (bbdn_deleteuri(bbdnsock, coll, url) != 1) { cgi_error(500, "Can't delete document"); } asprintf(&status,"Deleted url %s in %s\n",url,coll); } } else if (strcmp(request_method,"CLOSE") == 0) { sd_close(bbdnsock, coll); asprintf(&status,"Closed %s\n",coll); } else { cgi_error(500, "Unknown request method \"%s\"", request_method ); } #ifdef DEBUG // Print the envirement so we can better see what is going on. char** env; for (env = envp; *env != 0; env++) { char* thisEnv = *env; fprintf(stderr, "%s\n", thisEnv); } #endif } else if ((cgi_getentrystr("do") != NULL) && (strcmp(cgi_getentrystr("do"),"add") == 0)) { char *data; int datasize; int n; const char *url = getenv("HTTP_X_FILENAME") ? getenv("HTTP_X_FILENAME") : cgi_getentrystr("url"); const char *coll = cgi_getentrystr("collection"); if (url == NULL) { cgi_error(500, "No url specified. Either set http header HTTP_X_FILENAME or get parameter 'url'.\n"); } if (coll == NULL) { cgi_error(500, "No collection specified\n"); } char *tmpname; FILE *fh; asprintf(&tmpname,"/tmp/%s",url); fh = fopen(tmpname,"wb"); if (fh == NULL) { cgi_error(500, "Can't open file %s",tmpname); } if ((data = malloc( atoi(getenv("CONTENT_LENGTH")) )) == NULL) { cgi_error(500, "Can't malloc data"); } datasize = 0; while ((n = fread ((unsigned char *)(data + datasize),1,1024,stdin)) > 0) { datasize += n; } fwrite(data,1,datasize,fh); fclose(fh); free(tmpname); // bbdn_docadd(bbdnsock, xmldoc.collection, uri, xmldoc.documenttype, xmldoc.body, xmldoc.bodysize, // xmldoc.lastmodified, xmldoc.aclallow, xmldoc.acldeny, xmldoc.title, xmldoc.documentformat, xmldoc.attributes, image, image_size); bbdn_docadd(bbdnsock, coll, url, "", data, datasize, 0, "Everyone", "", "omp1", "", "", NULL, 0); // close it sd_close(bbdnsock, coll); } else if ((cgi_getentrystr("do") != NULL) && (strcmp(cgi_getentrystr("do"),"delete") == 0)) { const char *url = getenv("HTTP_X_FILENAME") ? getenv("HTTP_X_FILENAME") : cgi_getentrystr("url"); const char *coll = cgi_getentrystr("collection"); if (url == NULL) { cgi_error(500, "No url specified. Either set http header HTTP_X_FILENAME or get parameter 'url'.\n"); } if (coll == NULL) { cgi_error(500, "No collection specified\n"); } bbdn_deleteuri(bbdnsock, coll, url); asprintf(&status,"%s deleted.\n", url); } else if (getenv("CONTENT_LENGTH") != NULL) { // Get data length postsize = atoi(getenv("CONTENT_LENGTH")); xmldata = malloc(postsize + 1); // Read data fread(xmldata, 1, postsize, stdin); xmldata[postsize] = '\0'; //fprintf(stderr, "Received %i bytes.\n", postsize); //fprintf(stderr, "Got document:\n%s\n", xmldata); //parsing xml doc = xmlParseDoc((xmlChar*)xmldata); if (doc == NULL) cgi_error(500, "Unable to parse document"); cur = xmlDocGetRootElement(doc); if (cur == NULL) { xmlFreeDoc(doc); cgi_error(500, "empty document"); } // Some document checking if (xmlStrcmp(cur->name, (const xmlChar *)ROOT_NODE_NAME)) { xmlFreeDoc(doc); cgi_error(500, "document of the wrong type, root node != %s, but %s\n", ROOT_NODE_NAME, cur->name); } if ((anode = xml_find_child(cur, "key")) != NULL) { char *p; p = (char *)xmlNodeListGetString(doc, anode->xmlChildrenNode, 1); if (p == NULL) cgi_error(500, "No key data"); if ((systemkey[0] != '\0') && (!key_equal(systemkey, p))) { cgi_error(500, "Keys does not match: Got \"%s\" but wanted \"%s\"\n",p,systemkey); } } else { cgi_error(500, "Did not receive a key"); } if ((anode = xml_find_child(cur, "version")) != NULL) { xmlChar *p; p = xmlNodeListGetString(doc, anode->xmlChildrenNode, 1); version = atoi((char*)p); xmlFree(p); } else { cgi_error(500, "Did not receive a version number"); } for (cur = cur->xmlChildrenNode; cur != NULL; cur = cur->next) { if ((!xmlStrcmp(cur->name, (const xmlChar *) "key"))){ // Ignore } else if ((!xmlStrcmp(cur->name, (const xmlChar *) "version"))){ // Ignore } else if ((!xmlStrcmp(cur->name, (const xmlChar *) "add"))){ xml_add(bbdnsock, doc, cur); } else if ((!xmlStrcmp(cur->name, (const xmlChar *) "delete"))){ xml_delete(bbdnsock, doc, cur); } else if ((!xmlStrcmp(cur->name, (const xmlChar *) "close"))) { xml_close(bbdnsock, doc, cur); } else if ((!xmlStrcmp(cur->name, (const xmlChar *) "create"))) { xml_create(bbdnsock, doc, cur); } else if ((!xmlStrcmp(cur->name, (const xmlChar *) "users"))) { xml_users(doc, cur); } else if ((!xmlStrcmp(cur->name, (const xmlChar *) "gcwhispers"))) { xml_gcwhispers(bbdnsock, doc, cur); } else if ((!xmlStrcmp(cur->name, (const xmlChar *) "error"))) { xml_errormsg(bbdnsock, doc, cur); } else if ((!xmlStrcmp(cur->name, (xmlChar*)"text"))) { //fprintf(stderr, "Got text: %s\n", xmlNodeListGetString(doc, cur, 1)); // Ignore for now } else { warnx("Unknown xml node '%s'", cur->name); } } } else { cgi_error(500, "Didn't receive any command or data."); } if (status != NULL) { printf("Content-type: text/plain\n\n"); printf(status); } else { cgi_error(500, "Reached end of program without status."); } return 0; }
eParseResult gcode_parse_line (tLineBuffer *pLine) { int j; eParseResult result = PR_OK; for (j=0; j < pLine->len; j++) { gcode_parse_char (pLine->data [j]); } // end of line //if ((c == 10) || (c == 13)) { if ( #ifdef REQUIRE_LINENUMBER (next_target.N >= next_target.N_expected) && (next_target.seen_N == 1) #else 1 #endif ) { if ( #ifdef REQUIRE_CHECKSUM ((next_target.checksum_calculated == next_target.checksum_read) && (next_target.seen_checksum == 1)) #else ((next_target.checksum_calculated == next_target.checksum_read) || (next_target.seen_checksum == 0)) #endif ) { if (sd_writing_file) { if (next_target.seen_M && (next_target.M >= 20) && (next_target.M <= 29)) { if (next_target.seen_M && next_target.M == 29) { // M29 - stop writing sd_writing_file = false; sd_close (&file); serial_writestr("Done saving file\r\n"); } else { // else - do not write SD M-codes to file serial_writestr("ok\r\n"); } } else { // lines in files must be LF terminated for sd_read_file to work if (pLine->data [pLine->len-1] == 13) { pLine->data [pLine->len-1] = 10; } if (sd_write_to_file(pLine->data, pLine->len)) { serial_writestr("ok\r\n"); } else { serial_writestr("error writing to file\r\n"); } } } else { // process result = process_gcode_command(); // expect next line number if (next_target.seen_N == 1) { next_target.N_expected = next_target.N + 1; } } } else { serial_writestr("Expected checksum "); serwrite_uint8(next_target.checksum_calculated); serial_writestr("\r\n"); request_resend(); } } else { serial_writestr("Expected line number "); serwrite_uint32(next_target.N_expected); serial_writestr("\r\n"); request_resend(); } // reset variables next_target.seen_X = next_target.seen_Y = next_target.seen_Z = \ next_target.seen_E = next_target.seen_F = next_target.seen_S = \ next_target.seen_P = next_target.seen_N = next_target.seen_M = \ next_target.seen_checksum = next_target.seen_semi_comment = \ next_target.seen_parens_comment = next_target.checksum_read = \ next_target.checksum_calculated = 0; next_target.chpos = 0; last_field = 0; read_digit.sign = read_digit.exponent = 0; value = 0; // dont assume a G1 by default next_target.seen_G = 0; next_target.G = 0; if (next_target.option_relative) { next_target.target.x = next_target.target.y = next_target.target.z = 0.0; next_target.target.e = 0.0; } } return result; }
main() { register long k; unsigned char t, incode[2], ans[2], yn[2], again[2]; unsigned char timestr[30], datetime[15], intime[20]; long systime; long pid, status; putenv("_=transac_output"); chdir(getenv("HOME")); open_all(); fix(transac_output); sd_screen_off(); sd_clear_screen(); sd_text(transac_output); sd_screen_on(); sd_prompt(&fld[0], 0); while(1) { for (k = 15; k <= 20; k++) { sd_cursor(0, k, 1); sd_clear_line(); } while(1) { memset(incode, 0, 2); t = sd_input(&fld[0], 0, 0, incode, 0); if(t == EXIT) leave(); if(t == UP_CURSOR) continue; if (!*incode) break; *incode = tolower(*incode); if (*incode != 'c' && *incode != 'd' && *incode != 'p' && *incode != 'e') { eh_post(ERR_CODE, incode); continue; } break; } if (*incode == 'p') { if (sp->sp_to_flag != 'y' && sp->sp_to_flag != 'b') { eh_post(LOCAL_MSG, "No Transaction File Feature"); continue; } sd_wait(); if((pid = fork()) == 0) { ss_close(); execlp("transac_short_rpt", "transac_short_rpt", 0); exit(1); } else pid = wait(&status); if (pid > 0 && !status) eh_post(ERR_CONFIRM, "Short Printing"); else eh_post(CRASH_MSG, "tranac_short_rpt failed"); continue; } if (*incode == 'e') { if (sp->sp_to_flag != 'y' && sp->sp_to_flag != 'b') { eh_post(LOCAL_MSG, "No Transaction File Feature"); continue; } while(1) { memset(ans, 0, 2); /* are you sure response */ memset(yn, 0, 2); t = sd_input(&fld[5],sd_prompt(&fld[5],0), 0, yn, 0); if (t == EXIT) leave(); if (t == UP_CURSOR) break; *ans = code_to_caps(*yn); if(*ans != 'y' && *ans != 'n') { eh_post(ERR_YN,0); continue; } if(*ans == 'y') { eh_post(LOCAL_MSG, "Purging Transaction File"); database_open(); xt_open(); transaction_setkey(0); begin_work(); while (!transaction_next(&xt, LOCK)) { transaction_delete(); commit_work(); begin_work(); } commit_work(); xt_close(); database_close(); sp->sp_to_count = 0; eh_post(PURGE_TRANS, 0); } break; } /* end while(1) */ continue; } /* end if */ if (*incode == 'c' || *incode == 'd') { if (sp->sp_to_mode != 0x20 || sp->sp_oi_mode == *incode) /* F071395 */ { eh_post(LOCAL_MSG, "Device/Port In Use"); continue; } } if (*incode == 'd') { while(1) { memset(ans, 0, 2); memset(yn, 0, 2); t = sd_input(&fld[1],sd_prompt(&fld[1],0), 0, yn, 0); if (t == EXIT) leave(); if (t == UP_CURSOR) break; *ans = code_to_caps(*yn); if(*ans != 'y' && *ans != 'n') { eh_post(ERR_YN,0); continue; } break; } if (t == UP_CURSOR) continue; if (*ans == 'n') continue; /* abort diskette in */ } while(1) { memset(again, 0, 2); /* retransmit response */ memset(yn, 0, 2); t = sd_input(&fld[2],sd_prompt(&fld[2],0), 0, yn, 0); if (t == EXIT) leave(); if (t == UP_CURSOR) break; *again = code_to_caps(*yn); if (*again != 'y' && *again != 'n') { eh_post(ERR_YN, 0); continue; } break; } if (t == UP_CURSOR) continue; while(1) { memset(ans, 0, 2); /* purge response */ memset(yn, 0, 2); t = sd_input(&fld[3],sd_prompt(&fld[3],0), 0, yn, 0); if(t == EXIT) leave(); if(t == UP_CURSOR) break; *ans = code_to_caps(*yn); if(*ans != 'y' && *ans != 'n') { eh_post(ERR_YN,0); continue; } break; } if(*ans == 'y') { sd_prompt(&fld[4],0); systime = time(0) - sp->sp_purge_window; strcpy(timestr, ctime(&systime)); timestr[24] = 0; sd_cursor(0,18,25); sd_text("Default Date/Time:"); sd_cursor(0,18,54); sd_text(×tr[4]); sd_cursor(0,20,25); sd_text("Format is:"); sd_cursor(0,20,54); sd_text("mm/dd/yyyy hh:mm:ss"); while(1) { t = sd_input(&fld[4], 0, 0, intime, 0); if(t == EXIT) leave(); if(t == UP_CURSOR) break; if(*intime != 0) { if(!time_convert(intime, &systime)) { eh_post(ERR_TIME, intime); continue; } } eh_post(LOCAL_MSG, "Purging Orders"); if ((pid = fork()) == 0) { sprintf(datetime, "%d", systime); ss_close(); execlp("order_purge", "order_purge", datetime, 0); exit(1); } else pid = wait(&status); if (pid > 0 && !status) eh_post(ERR_CONFIRM, "Order purge"); else eh_post(CRASH_MSG, "order_purge failed"); break; } if (t == UP_CURSOR) continue; } if (*again == 'n') /* transmit current file */ { eh_post(LOCAL_MSG, "Extracting Transactions"); if ((pid = fork()) == 0) { ss_close(); execlp("transac_copy", "transac_copy", 0); exit(1); } else pid = wait(&status); if (pid < 0 || status) { eh_post(LOCAL_MSG, "transac_copy failed"); continue; } eh_post(ERR_CONFIRM, "Transaction File"); } /* * Start Transaction Output Operations */ if (*incode == 'c') /* comm output */ { if (sp->sp_commo_trans_out == 'n') { eh_post(LOCAL_MSG, "No Communication Feature"); continue; } eh_post(LOCAL_MSG, "Sending Transactions"); sd_close(); sp->sp_to_mode = 'c'; if (fork() == 0) { if (sp->sp_commo_trans_out == 'k') { ss_close(); execlp("com_kermit_out", "com_kermit_out", 0); } else { ss_close(); execlp("comsend", "comsend", 0); } ss_open(); sd_open(); sp->sp_to_mode = 0x20; eh_post(LOCAL_MSG, "Program Not Found"); continue; } pid = wait(&status); sp->sp_to_mode = 0x20; sd_open(); if (pid < 0 || status) { eh_post(LOCAL_MSG, "Communications Failed"); } else eh_post(ERR_CONFIRM, "Transactions Output"); continue; } if (*incode == 'd') { sd_wait(); sp->sp_to_mode = 'd'; sprintf(message, command); status = system(message); sp->sp_to_mode = 0x20; if (status) eh_post(LOCAL_MSG, "Diskette output failed"); else eh_post(ERR_CONFIRM, "Tranaction Output"); } } }