void CSerialModem::DoCommand() { cmdbuf[cmdpos] = 0; cmdpos = 0; //Reset for next command upcase(cmdbuf); LOG_MSG("Command sent to modem: ->%s<-\n", cmdbuf); /* Check for empty line, stops dialing and autoanswer */ if (!cmdbuf[0]) { reg[0]=0; // autoanswer off return; } //else { //MIXER_Enable(mhd.chan,false); // dialing = false; // SendRes(ResNOCARRIER); // goto ret_none; //} /* AT command set interpretation */ if ((cmdbuf[0] != 'A') || (cmdbuf[1] != 'T')) { SendRes(ResERROR); return; } if (strstr(cmdbuf,"NET0")) { telnetmode = false; SendRes(ResOK); return; } else if (strstr(cmdbuf,"NET1")) { telnetmode = true; SendRes(ResOK); return; } char * scanbuf = &cmdbuf[2]; while (1) { // LOG_MSG("loopstart ->%s<-",scanbuf); char chr = GetChar(scanbuf); switch (chr) { case 'D': { // Dial char * foundstr=&scanbuf[0]; if (*foundstr=='T' || *foundstr=='P') foundstr++; // Small protection against empty line and long string if ((!foundstr[0]) || (strlen(foundstr)>100)) { SendRes(ResERROR); return; } char* helper; // scan for and remove spaces; weird bug: with leading spaces in the string, // SDLNet_ResolveHost will return no error but not work anyway (win) while(foundstr[0]==' ') foundstr++; helper=foundstr; helper+=strlen(foundstr); while(helper[0]==' ') { helper[0]=0; helper--; } //Large enough scope, so the buffers are still valid when reaching Dail. char buffer[128]; char obuffer[128]; if (strlen(foundstr) >= 12) { // Check if supplied parameter only consists of digits bool isNum = true; size_t fl = strlen(foundstr); for (size_t i = 0; i < fl; i++) if (foundstr[i] < '0' || foundstr[i] > '9') isNum = false; if (isNum) { // Parameter is a number with at least 12 digits => this cannot // be a valid IP/name // Transform by adding dots size_t j = 0; size_t foundlen = strlen(foundstr); for (size_t i = 0; i < foundlen; i++) { buffer[j++] = foundstr[i]; // Add a dot after the third, sixth and ninth number if (i == 2 || i == 5 || i == 8) buffer[j++] = '.'; // If the string is longer than 12 digits, // interpret the rest as port if (i == 11 && strlen(foundstr)>12) buffer[j++] = ':'; } buffer[j] = 0; foundstr = buffer; // Remove Zeros from beginning of octets size_t k = 0; size_t foundlen2 = strlen(foundstr); for (size_t i = 0; i < foundlen2; i++) { if (i == 0 && foundstr[0] == '0') continue; if (i == 1 && foundstr[0] == '0' && foundstr[1] == '0') continue; if (foundstr[i] == '0' && foundstr[i-1] == '.') continue; if (foundstr[i] == '0' && foundstr[i-1] == '0' && foundstr[i-2] == '.') continue; obuffer[k++] = foundstr[i]; } obuffer[k] = 0; foundstr = obuffer; } } Dial(foundstr); return; } case 'I': // Some strings about firmware switch (ScanNumber(scanbuf)) { case 3: SendLine("DOSBox Emulated Modem Firmware V1.00"); break; case 4: SendLine("Modem compiled for DOSBox version " VERSION); break; } break; case 'E': // Echo on/off switch (ScanNumber(scanbuf)) { case 0: echo = false; break; case 1: echo = true; break; } break; case 'V': switch (ScanNumber(scanbuf)) { case 0: numericresponse = true; break; case 1: numericresponse = false; break; } break; case 'H': // Hang up switch (ScanNumber(scanbuf)) { case 0: if (connected) { SendRes(ResNOCARRIER); EnterIdleState(); return; } // else return ok } break; case 'O': // Return to data mode switch (ScanNumber(scanbuf)) { case 0: if (clientsocket) { commandmode = false; return; } else { SendRes(ResERROR); return; } } break; case 'T': // Tone Dial case 'P': // Pulse Dial break; case 'M': // Monitor case 'L': // Volume ScanNumber(scanbuf); break; case 'A': // Answer call if (waitingclientsocket) { AcceptIncomingCall(); } else { SendRes(ResERROR); return; } return; case 'Z': { // Reset and load profiles // scan the number away, if any ScanNumber(scanbuf); if (clientsocket) SendRes(ResNOCARRIER); Reset(); break; } case ' ': // skip space break; case 'Q': { // Response options // 0 = all on, 1 = all off, // 2 = no ring and no connect/carrier in answermode Bitu val = ScanNumber(scanbuf); if(!(val>2)) { doresponse=val; break; } else { SendRes(ResERROR); return; } } case 'S': { // Registers Bitu index=ScanNumber(scanbuf); if(index>=SREGS) { SendRes(ResERROR); return; //goto ret_none; } while(scanbuf[0]==' ') scanbuf++; // skip spaces if(scanbuf[0]=='=') { // set register scanbuf++; while(scanbuf[0]==' ') scanbuf++; // skip spaces Bitu val = ScanNumber(scanbuf); reg[index]=val; break; } else if(scanbuf[0]=='?') { // get register SendNumber(reg[index]); scanbuf++; break; } //else LOG_MSG("print reg %d with %d",index,reg[index]); } break; case '&': { // & escaped commands char cmdchar = GetChar(scanbuf); switch(cmdchar) { case 'K': { Bitu val = ScanNumber(scanbuf); if(val<5) flowcontrol=val; else { SendRes(ResERROR); return; } break; } case '\0': // end of string SendRes(ResERROR); return; default: LOG_MSG("Modem: Unhandled command: &%c%d",cmdchar,ScanNumber(scanbuf)); break; } break; } case '\\': { // \ escaped commands char cmdchar = GetChar(scanbuf); switch(cmdchar) { case 'N': // error correction stuff - not emulated if (ScanNumber(scanbuf) > 5) { SendRes(ResERROR); return; } break; case '\0': // end of string SendRes(ResERROR); return; default: LOG_MSG("Modem: Unhandled command: \\%c%d",cmdchar, ScanNumber(scanbuf)); break; } break; } case '\0': SendRes(ResOK); return; default: LOG_MSG("Modem: Unhandled command: %c%d",chr,ScanNumber(scanbuf)); break; } } }
bool DOS_OpenFile(char const * name,Bit8u flags,Bit16u * entry,bool fcb) { /* First check for devices */ if (flags>2) LOG(LOG_FILES,LOG_ERROR)("Special file open command %X file %s",flags,name); else LOG(LOG_FILES,LOG_NORMAL)("file open command %X file %s",flags,name); DOS_PSP psp(dos.psp()); Bit16u attr = 0; Bit8u devnum = DOS_FindDevice(name); bool device = (devnum != DOS_DEVICES); if(!device && DOS_GetFileAttr(name,&attr)) { //DON'T ALLOW directories to be openened.(skip test if file is device). if((attr & DOS_ATTR_DIRECTORY) || (attr & DOS_ATTR_VOLUME)){ DOS_SetError(DOSERR_ACCESS_DENIED); return false; } } char fullname[DOS_PATHLENGTH];Bit8u drive;Bit8u i; /* First check if the name is correct */ if (!DOS_MakeName(name,fullname,&drive)) return false; Bit8u handle=255; /* Check for a free file handle */ for (i=0;i<DOS_FILES;i++) { if (!Files[i]) { handle=i; break; } } if (handle==255) { DOS_SetError(DOSERR_TOO_MANY_OPEN_FILES); return false; } /* We have a position in the main table now find one in the psp table */ *entry = fcb?handle:psp.FindFreeFileEntry(); if (*entry==0xff) { DOS_SetError(DOSERR_TOO_MANY_OPEN_FILES); return false; } bool exists=false; if (device) { Files[handle]=new DOS_Device(*Devices[devnum]); } else { exists=Drives[drive]->FileOpen(&Files[handle],fullname,flags)||Drives[drive]->FileOpen(&Files[handle],upcase(fullname),flags); if (exists) Files[handle]->SetDrive(drive); } if (exists || device ) { Files[handle]->AddRef(); if (!fcb) psp.SetFileHandle(*entry,handle); return true; } else { //Test if file exists, but opened in read-write mode (and writeprotected) if(((flags&3) != OPEN_READ) && Drives[drive]->FileExists(fullname)) DOS_SetError(DOSERR_ACCESS_DENIED); else { if(!PathExists(name)) DOS_SetError(DOSERR_PATH_NOT_FOUND); else DOS_SetError(DOSERR_FILE_NOT_FOUND); } return false; } }
/** * Execute the command LISTHDR (LH) which lists header values * * @param nerr * Error Return Flag * - 0 on Success * * @date 970425: Fix bug so display fits in the window. maf * @date 970129: Print file number (jdfl). maf * @date 961212: All of the header variables are now in the default list. * Added INCLUSIVE option to show headers whether they are * defined or not. maf * @date 900507: Fixed bug with an odd number of items being listed with * the two-column output option. (VAX/VMS bug fix.) * @date 890104: Now sending output to message handling system. * @date 860930: Added a wait mechanism after each full screen. * @date 841026: Extensive modifications made to entire subroutine. * @date 820806: Changed to newest set of parsing and checking functions. * Updated line formatting using F77 character constructs. * @date 820119: Fixed bug in listing KHDR values. * @date 811029: Changed floating point output to G8.1 format. * @date 810528: Added option to list only first file in dfl. * @date 810223: Added check for null data file list. * @date 810120: Changed to output message retrieval from disk. * */ void xlh(int *nerr) { char kerase[41], kline[MCMSG+1], kresp[9], krpttx[MRPT][41], ktok[9], kwait[9]; int lwait; int j, j_, jdfl, jrpt, jrpt_, jrpttx, jrpttx_, jsprpt, junk1, junk2, junk3, nc1, nc2, nc3, nc4, nctx[MRPT], nctxm, nferr, nlscrn, nlw, nrpttx, ntused; static int iform = 1; static char kblank[41] = " "; char *cattemp; char *strtemp1, *strtemp2, *strtemp3, *strtemp4, *strtemp5; int idx, ldef ; char *tmp; int *const Nctx = &nctx[0] - 1; *nerr = 0; ldef = FALSE; for( idx = 0 ; idx < 8 ; idx++ ) ktok[idx] = ' ' ; ktok[ 8 ] = '\0' ; /* currently executing listhdr command. maf 961212 */ cmhdr.llh = TRUE ; for( idx = 0 ; idx < MCMSG ; idx++ ) kline[ idx ] = ' ' ; kline[ MCMSG ] = '\0' ; jsprpt = 0; /* - Loop on each token in command: */ while ( lcmore( nerr ) ){ /* -- "DEFAULT/PICKS/SPECIAL": change type of header report. */ if( lclist( (char*)kmlhf.krpttp,9, cmlhf.nrpttp, &cmlhf.irpttp ) ){ if( cmlhf.irpttp == 1 || cmlhf.irpttp == 4 ){ for( j = 1; j <= cmlhf.nstrpt; j++ ){ j_ = j - 1; strcpy( kmlhf.krpt[j_], kmlhf.kstrpt[j_] ); } cmlhf.nrpt = cmlhf.nstrpt; } else if( cmlhf.irpttp == 2 ){ for( j = 1; j <= cmlhf.npkrpt; j++ ){ j_ = j - 1; strcpy( kmlhf.krpt[j_], kmlhf.kpkrpt[j_] ); } cmlhf.nrpt = cmlhf.npkrpt; } else if( cmlhf.irpttp == 3 ){ for( j = 1; j <= cmlhf.nsprpt; j++ ){ j_ = j - 1; strcpy( kmlhf.krpt[j_], kmlhf.ksprpt[j_] ); } cmlhf.nrpt = cmlhf.nsprpt; } } /* -- "FILES ALL/nlist": print all headers or only a subset. */ else if( lckey( "FILES#$",8 ) ){ if( lckey( "ALL$",5 ) ){ cmlhf.lstall = TRUE; } else if( lckey( "NONE$",6 ) ){ ldef = TRUE; } else if( lcia( 1, cmdfm.ndfl, cmlhf.ilhlst, &cmlhf.nlhlst ) ){ cmlhf.lstall = FALSE; } } /* -- "INCLUSIVE": print headers even if they are undefined.*/ else if ( lklog( "INC#LUSIVE$", 12, &cmhdr.linc ) ) { /* do nothing */ } /* -- "COLUMNS n": change number of output columns. */ else if( lkirc( "COLUMNS#$",10, 1, 2, &cmlhf.nlhcol ) ) { /* do nothing */ } /* -- "FIRST": Obsolete keyword for first file only. */ else if( lckey( "FIRST#$",8 ) ){ cmlhf.lstall = FALSE; cmlhf.nlhlst = 1; Ilhlst[1] = 1; } else if( lcchar( MCPW, ktok,9, &ntused ) ){ if( jsprpt < MSPRPT ){ jsprpt = jsprpt + 1; strcpy( kmlhf.ksprpt[jsprpt - 1], ktok ); cmlhf.nrpt = jsprpt; strcpy( kmlhf.krpt[cmlhf.nrpt - 1], ktok ); } else{ *nerr = 1309; setmsg( "ERROR", *nerr ); apimsg( jsprpt ); } } else{ /* -- Bad syntax. */ cfmt( "ILLEGAL OPTION:",17 ); cresp(); } } if( *nerr != 0 ) { /* no longer executing xlh() */ cmhdr.llh = FALSE ; return; } /* - Save length of special report if needed. */ if( jsprpt > 0 ) cmlhf.nsprpt = jsprpt; if( ldef ) { /* no longer executing xlh(). */ cmhdr.llh = FALSE; return; } /* CHECKING PHASE: */ /* - Check for null data file list. */ vflist( nerr ); if( *nerr != 0 ) { /* no longer executing xlh().*/ cmhdr.llh = FALSE ; return; } /* EXECUTION PHASE: */ /* - Get screen attributes (number of lines per screen and * text to send to erase screen, if any.) */ getalphainfo( &nlscrn, kerase,41 ); if( nlscrn <= 0 ) nlscrn = 23; if( cmlhf.lstall ){ setinputmode( "ALL" ); } else{ setinputmode( "SELECT" ); selectinputfiles( cmlhf.ilhlst, cmlhf.nlhlst ); } nlw = 0; gettextwait( kwait,9 ); lwait = memcmp(kwait,"ON",2) == 0; autooutmsg( TRUE ); setmsg( "OUTPUT", 99 ); if(!use_tty()) { lwait = FALSE; } jdfl = 0; L_4000: if( nextinputfile( &jdfl ) ){ getfil( jdfl, FALSE, &junk1, &junk2, &junk3, nerr ); if( *nerr != 0 ) { autooutmsg( FALSE ); /* no longer executing xlh(). */ cmhdr.llh = FALSE ; return ; } if((tmp = string_list_get(datafiles, jdfl-1))) { aplmsg( " ",2 ); cattemp = malloc(7+strlen(tmp)+7); sprintf(cattemp, " FILE: %s - %d", tmp, jdfl); aplmsg( cattemp, strlen ( cattemp ) + 1 ); free(cattemp); memset(kline,'-',strlen(tmp)+6); kline[strlen(tmp)+6]='\n'; kline[strlen(tmp)+7]='\0'; aplmsg( kline,MCMSG+1 ); nlw = nlw + 4; } nrpttx = 0; nctxm = 0; for( jrpt = 1; jrpt <= cmlhf.nrpt; jrpt++ ){ jrpt_ = jrpt - 1; nrpttx = nrpttx + 1; formhv( (char*)kmlhf.krpt[jrpt_],9, iform, (char*)krpttx[nrpttx - 1], 41, &nferr ); if( nferr == 0 ){ Nctx[nrpttx] = indexc((char*)krpttx[nrpttx - 1], 41, '=' ); nctxm = max( nctxm, Nctx[nrpttx] ); } else if ( !cmhdr.linc ) { nrpttx = nrpttx - 1; } } if( cmlhf.nlhcol == 1 ){ for( jrpttx = 1; jrpttx <= nrpttx; jrpttx++ ){ jrpttx_ = jrpttx - 1; nc1 = 2 + nctxm - Nctx[jrpttx]; nc2 = indexb( (char*)krpttx[jrpttx_],41 ); strtemp1 = malloc(nc1+1); strtemp2 = malloc(nc2+1); strncpy(strtemp1,kblank,nc1); strncpy(strtemp2,krpttx[jrpttx_],nc2); strtemp1[nc1] = '\0'; strtemp2[nc2] = '\0'; sprintf(kline," %s %s",strtemp1,strtemp2); free(strtemp1); free(strtemp2); aplmsg( kline,MCMSG+1 ); nlw = nlw + 1; if( lwait && (nlw >= (nlscrn - 2)) ){ outmsg(); clrmsg(); setmsg( "OUTPUT", 99 ); zgpmsg( "Waiting $",10, kresp,9 ); upcase( kresp, 1, kresp,9 ); nlw = 0; if( kresp[0] == 'K' || kresp[0] == 'Q' ) { autooutmsg( FALSE ); /* no longer executing xlh(). */ cmhdr.llh = FALSE ; return ; } else if( kresp[0] == 'G' ){ if( strcmp(kerase," ") != 0 ) { fprintf(MUNOUT," %s\n",kerase); } lwait = FALSE; } else if( kresp[0] == 'N' ){ if( strcmp(kerase," ") != 0 ) { fprintf(MUNOUT," %s\n",kerase); } goto L_4000; } } } } else { strcpy( krpttx[nrpttx], " " ); for( jrpttx = 1; jrpttx <= nrpttx; jrpttx += 2 ){ jrpttx_ = jrpttx - 1; nc1 = 2 + nctxm - Nctx[jrpttx]; nc2 = indexb( (char*)krpttx[jrpttx_],41 ); nc3 = 2 + nctxm - Nctx[jrpttx + 1]; nc4 = indexb( (char*)krpttx[jrpttx_ + 1],41 ); if( nc4 > 0 ){ strtemp1 = malloc(nc1+1); strtemp2 = malloc(nc2+1); strtemp3 = malloc(nc3+1); strtemp4 = malloc(nc4+1); strncpy(strtemp1,kblank,nc1); strtemp1[nc1] = '\0'; strncpy(strtemp2,krpttx[jrpttx_],nc2); strtemp2[nc2] = '\0'; strncpy(strtemp3,kblank,nc3); strtemp3[nc3] = '\0'; strncpy(strtemp4,krpttx[jrpttx_ + 1],nc4); strtemp4[nc4] = '\0'; if ((nc1+nc2) < 40 ) { strtemp5 = malloc(40-(nc1+nc2)+1); memset(strtemp5,' ',40-(nc1+nc2)); strtemp5[40-(nc1+nc2)] = '\0'; sprintf(kline," %s%s%s%s%s", strtemp1,strtemp2,strtemp5,strtemp3,strtemp4); free(strtemp5); } else { sprintf(kline," %s%s%s%s", strtemp1,strtemp2,strtemp3,strtemp4); } free(strtemp1); free(strtemp2); free(strtemp3); free(strtemp4); } else{ strtemp1 = malloc(nc1+1); strtemp2 = malloc(nc2+1); strncpy(strtemp1,kblank,nc1); strtemp1[nc1] = '\0'; strncpy(strtemp2,krpttx[jrpttx_],nc2); strtemp2[nc2] = '\0'; sprintf(kline," %s%s",strtemp1,strtemp2); free(strtemp1); free(strtemp2); } aplmsg( kline,MCMSG+1 ); nlw = nlw + 1; if( lwait && (nlw >= (nlscrn - 1)) ){ outmsg(); clrmsg(); setmsg( "OUTPUT", 99 ); nlw = 0; zgpmsg( "Waiting $",10, kresp,9 ); upcase( kresp, 1, kresp,9 ); if( kresp[0] == 'K' || kresp[0] == 'Q' ) { autooutmsg( FALSE ); /* no longer executing xlh(). */ cmhdr.llh = FALSE ; return ; } else if( kresp[0] == 'G' ){ if( strcmp(kerase," ") != 0 ) { fprintf(MUNOUT," %s\n",kerase); } lwait = FALSE; } else if( kresp[0] == 'N' ){ if( strcmp(kerase," ") != 0 ) { fprintf(MUNOUT," %s\n",kerase); } goto L_4000; } } } } /* -- Loop on entries in input dfl. */ goto L_4000; } /* - Turn automatic output mode off before returning. */ autooutmsg( FALSE ); /* no longer executing xlh() */ cmhdr.llh = FALSE ; return; }
/* Procedure to select the matching filenames Author: J. Jansen */ int sel_image(struct dirent *name) { char *name_tmp = name->d_name; char *filename_tmp = filename_r; int numfrag = -1, ip, i = -1; #define MAX_FRAGS 64 char *frags[MAX_FRAGS]; #ifdef VMS Bool not_first_star = True; upcase( name_tmp ); /* VMS-file system is not case selective */ if ( *filename_tmp == '*' ) { not_first_star = False; filename_tmp++; } #endif if (numfrag == -1) { ++numfrag; while ((ip = index_dir(filename_tmp, (char *) "*"))) { if (numfrag >= MAX_FRAGS) { numfrag--; goto FAIL; } if ((frags[numfrag] = (char *) malloc(ip)) == NULL) { numfrag--; goto FAIL; } (void) strcpy(frags[numfrag], "\0"); (void) strncat(frags[numfrag], filename_tmp, ip - 1); ++numfrag; filename_tmp = filename_tmp + ip; } if ( strlen( filename_tmp ) != 0 ) { if (numfrag > 0 && frags[numfrag] != NULL) free(frags[numfrag]); if ((frags[numfrag] = (char *) malloc(strlen(filename_tmp) + 1)) == NULL) { numfrag--; goto FAIL; } (void) strcpy(frags[numfrag], filename_tmp); } else numfrag--; } #ifdef VMS i = 0; ip = index_dir(name_tmp, frags[i]); free(frags[i]); if ( not_first_star ) { if ( ip != 1 ) goto FAIL; } else { if ( ip == 0 ) goto FAIL; } name_tmp = name_tmp + ip; if ( numfrag > 0 ) { for (i = 1; i <= numfrag; ++i) { #else for (i = 0; i <= numfrag; ++i) { #endif ip = index_dir(name_tmp, frags[i]); free(frags[i]); if (ip == 0) { goto FAIL; } name_tmp = name_tmp + ip; } #ifdef VMS } #endif return (1); FAIL: { int j; for (j = i + 1; j <= numfrag; ++j) free(frags[j]); return (0); } } /* scandir implementiation for VMS Author: J. Jansen */ /* name changed to scan_dir to solve portablity problems */ #define _MEMBL_ 64 int scan_dir(const char *directoryname, struct dirent ***namelist, int (*specify) (struct dirent *), int (*compare) (const void *, const void *)) { DIR *dirp; struct dirent *new_entry, **namelist_tmp; int size_tmp, num_list_tmp; if (debug) (void) printf("scan_dir directoryname %s\n", directoryname); if ((dirp = opendir(directoryname)) == NULL) { if (debug) (void) printf("scan_dir can not open directoryname %s\n", directoryname); return (-1); } size_tmp = _MEMBL_; /*- * PURIFY on SunOS4 and on Solaris 2 reports a cumulative memory leak on * the next line when used with the modes/glx/text3d.cc file. It only * leaks like this for the C++ modes, and is OK in the C modes. */ if ((namelist_tmp = (struct dirent **) malloc(size_tmp * sizeof (struct dirent *))) == NULL) { if (debug) (void) printf("scan_dir no memory\n"); return (-1); } num_list_tmp = 0; while ((new_entry = readdir(dirp)) != NULL) { #ifndef VMS if (!strcmp(new_entry->d_name, ".") || !strcmp(new_entry->d_name, "..")) continue; #endif if (specify != NULL && !(*specify) (new_entry)) continue; if (++num_list_tmp >= size_tmp) { size_tmp = size_tmp + _MEMBL_; if ((namelist_tmp = (struct dirent **) realloc( (void *) namelist_tmp, size_tmp * sizeof (struct dirent *))) == NULL) { if (debug) (void) printf("scan_dir no memory\n"); return (-1); } } if ((namelist_tmp[num_list_tmp - 1] = (struct dirent *) malloc(sizeof (struct dirent) #ifdef SVR4 + strlen(new_entry->d_name) #endif )) == NULL) return (-1); (void) strcpy(namelist_tmp[num_list_tmp - 1]->d_name, new_entry->d_name); *namelist = namelist_tmp; } (void) closedir(dirp); if (num_list_tmp && compare != NULL) (void) qsort((void *) namelist_tmp, num_list_tmp, sizeof (struct dirent *), compare); if (debug) (void) printf("scan_dir number %d\n", num_list_tmp); *namelist = namelist_tmp; return (num_list_tmp); }
AUTOEXEC(Section* configuration):Module_base(configuration) { /* Register a virtual AUOEXEC.BAT file */ std::string line; Section_line * section=static_cast<Section_line *>(configuration); /* Check -securemode switch to disable mount/imgmount/boot after running autoexec.bat */ bool secure = control->cmdline->FindExist("-securemode",true); /* add stuff from the configfile unless -noautexec or -securemode is specified. */ char * extra = const_cast<char*>(section->data.c_str()); if (extra && !secure && !control->cmdline->FindExist("-noautoexec",true)) { /* detect if "echo off" is the first line */ bool echo_off = !strncasecmp(extra,"echo off",8); if (!echo_off) echo_off = !strncasecmp(extra,"@echo off",9); /* if "echo off" add it to the front of autoexec.bat */ if(echo_off) autoexec_echo.InstallBefore("@echo off"); /* Install the stuff from the configfile */ autoexec[0].Install(section->data); } /* Check to see for extra command line options to be added (before the command specified on commandline) */ /* Maximum of extra commands: 10 */ Bitu i = 1; while (control->cmdline->FindString("-c",line,true) && (i <= 11)) { #if defined (WIN32) || defined (OS2) //replace single with double quotes so that mount commands can contain spaces for(Bitu temp = 0;temp < line.size();++temp) if(line[temp] == '\'') line[temp]='\"'; #endif //Linux users can simply use \" in their shell autoexec[i++].Install(line); } /* Check for the -exit switch which causes dosbox to when the command on the commandline has finished */ bool addexit = control->cmdline->FindExist("-exit",true); /* Check for first command being a directory or file */ char buffer[CROSS_LEN]; char orig[CROSS_LEN]; char cross_filesplit[2] = {CROSS_FILESPLIT , 0}; /* Combining -securemode and no parameter leaves you with a lovely Z:\. */ if ( !control->cmdline->FindCommand(1,line) ) { if ( secure ) autoexec[12].Install("z:\\config.com -securemode"); } else { struct stat test; strcpy(buffer,line.c_str()); if (stat(buffer,&test)){ getcwd(buffer,CROSS_LEN); strcat(buffer,cross_filesplit); strcat(buffer,line.c_str()); if (stat(buffer,&test)) goto nomount; } if (test.st_mode & S_IFDIR) { autoexec[12].Install(std::string("MOUNT C \"") + buffer + "\""); autoexec[13].Install("C:"); if(secure) autoexec[14].Install("z:\\config.com -securemode"); } else { char* name = strrchr(buffer,CROSS_FILESPLIT); if (!name) { //Only a filename line = buffer; getcwd(buffer,CROSS_LEN); strcat(buffer,cross_filesplit); strcat(buffer,line.c_str()); if(stat(buffer,&test)) goto nomount; name = strrchr(buffer,CROSS_FILESPLIT); if(!name) goto nomount; } *name++ = 0; if (access(buffer,F_OK)) goto nomount; autoexec[12].Install(std::string("MOUNT C \"") + buffer + "\""); autoexec[13].Install("C:"); /* Save the non-modified filename (so boot and imgmount can use it (long filenames, case sensivitive)) */ strcpy(orig,name); upcase(name); if(strstr(name,".BAT") != 0) { if(secure) autoexec[14].Install("z:\\config.com -securemode"); /* BATch files are called else exit will not work */ autoexec[15].Install(std::string("CALL ") + name); if(addexit) autoexec[16].Install("exit"); } else if((strstr(name,".IMG") != 0) || (strstr(name,".IMA") !=0 )) { //No secure mode here as boot is destructive and enabling securemode disables boot /* Boot image files */ autoexec[15].Install(std::string("BOOT ") + orig); } else if((strstr(name,".ISO") != 0) || (strstr(name,".CUE") !=0 )) { /* imgmount CD image files */ /* securemode gets a different number from the previous branches! */ autoexec[14].Install(std::string("IMGMOUNT D \"") + orig + std::string("\" -t iso")); //autoexec[16].Install("D:"); if(secure) autoexec[15].Install("z:\\config.com -securemode"); /* Makes no sense to exit here */ } else { if(secure) autoexec[14].Install("z:\\config.com -securemode"); autoexec[15].Install(name); if(addexit) autoexec[16].Install("exit"); } } } nomount: VFILE_Register("AUTOEXEC.BAT",(Bit8u *)autoexec_data,(Bit32u)strlen(autoexec_data)); }
bool WildFileCmp(const char * file, const char * wild) { char file_name[9]; char file_ext[4]; char wild_name[9]; char wild_ext[4]; const char * find_ext; Bitu r; strcpy(wild_name, strcpy(file_name, " ")); strcpy(wild_ext, strcpy(file_ext, " ")); find_ext = strrchr(file, '.'); if (find_ext) { Bitu size = (Bitu)(find_ext-file); if (size > 8) size = 8; memcpy(file_name, file, size); find_ext++; memcpy(file_ext, find_ext, (strlen(find_ext)>3) ? 3 : strlen(find_ext)); } else memcpy(file_name, file, (strlen(file) > 8) ? 8 : strlen(file)); upcase(file_name); upcase(file_ext); find_ext = strrchr(wild, '.'); if (find_ext) { Bitu size = (Bitu)(find_ext-wild); if (size > 8) size = 8; memcpy(wild_name, wild,size); find_ext++; memcpy(wild_ext, find_ext, (strlen(find_ext)>3) ? 3 : strlen(find_ext)); } else memcpy(wild_name, wild, (strlen(wild) > 8) ? 8 : strlen(wild)); upcase(wild_name); upcase(wild_ext); // Names are right do some checking r = 0; while ( r <8) { if (wild_name[r] == '*') break; if (wild_name[r] != '?' && wild_name[r] != file_name[r]) return false; r++; } r = 0; while (r < 3) { if (wild_ext[r] == '*') return true; if (wild_ext[r] != '?' && wild_ext[r] != file_ext[r]) return false; r++; } return true; }
static void read_buffer(void) { char line[LINE_BUFFER_SIZE]; unsigned int ptr, current, *last; init_hash(); ptr = 0; while (fgetl(line, sizeof(line), fpInput)) { char LM_Buf[8]; if (LM) { if (strlen(line) > 7) { strncpy(LM_Buf, &line[7], 7); LM_Buf[7] = 0; upcase(LM_Buf); ++totLines; } else *LM_Buf = 0; line[7] = 0; upcase(line); } else if (cut_len) line[cut_len] = 0; ++totLines; last = &buffer.hash[line_hash(line)]; #if ARCH_LITTLE_ENDIAN && !ARCH_INT_GT_32 current = *last; #else current = get_int(last); #endif while (current != ENTRY_END_HASH) { if (!strcmp(line, &buffer.data[current + 4])) break; last = (unsigned int *)&buffer.data[current]; current = get_int(last); } if (current != ENTRY_END_HASH) { if (LM && *LM_Buf) goto DoExtraLM; continue; } put_int(last, ptr); put_data(ptr, ENTRY_END_HASH); ptr += 4; strcpy(&buffer.data[ptr], line); ptr += strlen(line) + 1; if (ptr > vUNIQUE_BUFFER_SIZE - sizeof(line) - 8) break; DoExtraLM:; if (LM && *LM_Buf) { last = &buffer.hash[line_hash(LM_Buf)]; #if ARCH_LITTLE_ENDIAN && !ARCH_INT_GT_32 current = *last; #else current = get_int(last); #endif while (current != ENTRY_END_HASH) { if (!strcmp(LM_Buf, &buffer.data[current + 4])) break; last = (unsigned int *)&buffer.data[current]; current = get_int(last); } if (current != ENTRY_END_HASH) continue; put_int(last, ptr); put_data(ptr, ENTRY_END_HASH); ptr += 4; strcpy(&buffer.data[ptr], LM_Buf); ptr += strlen(LM_Buf) + 1; if (ptr > vUNIQUE_BUFFER_SIZE - sizeof(line) - 8) break; } } if (ferror(fpInput)) pexit("fgets"); put_data(ptr, ENTRY_END_LIST); }
static void handle_tick(struct tm *tick_time, TimeUnits units_changed) { if (units_changed & DAY_UNIT) { char *sys_locale = setlocale(LC_ALL, "it_IT"); // APP_LOG(APP_LOG_LEVEL_DEBUG, "%s", sys_locale); static char date_day[4]; static char date_monthday[3]; static char date_month[6]; static char full_date_text[20]; /*strftime(date_day, sizeof(date_day), "%a", tick_time);*/ /*snprintf(date_day, sizeof(date_day), "%s", locale_day_name(tick_time->tm_wday, mLanguage));*/ strftime(date_day, sizeof(date_day), "%a", tick_time); strftime(date_monthday, sizeof(date_monthday), "%d", tick_time); if (date_monthday[0] == '0') { memmove(&date_monthday[0], &date_monthday[1], sizeof(date_monthday) - 1); //remove leading zero } strftime(date_month, sizeof(date_month), "%b", tick_time); char date_test[50]; strftime(date_test, sizeof(date_test), "%a %b", tick_time); // APP_LOG(APP_LOG_LEVEL_DEBUG, "%s", date_test); /*snprintf(date_month, sizeof(date_month), "%s", locale_month_name(tick_time->tm_mon, mLanguage)); //tick_time->tm_mon */ if(mConfigDateFormat==0) { snprintf(full_date_text, sizeof(full_date_text), "%s %s%s %s", upcase(date_day), date_monthday, getDaySuffix(tick_time->tm_mday), upcase(date_month)); } else { snprintf(full_date_text, sizeof(full_date_text), "%s %s %s", upcase(date_day), date_monthday, upcase(date_month)); } text_layer_set_text(mDateLayer, full_date_text); } if (units_changed & HOUR_UNIT) { static char hour_text[] = "00"; if(mConfigHourlyVibe) { //vibe! vibes_short_pulse(); } if(mConfigStyle==5) { if(tick_time->tm_hour<6 || tick_time->tm_hour>17) { //nightMode(); } } if(clock_is_24h_style()) { strftime(hour_text, sizeof(hour_text), "%H", tick_time); } else { strftime(hour_text, sizeof(hour_text), "%I", tick_time); if (hour_text[0] == '0') { layer_set_frame(mTimeLayer, GRect(-13, 0, 144, 168)); //shift time left to centralise it memmove(&hour_text[0], &hour_text[1], sizeof(hour_text) - 1); //remove leading zero } else { layer_set_frame(mTimeLayer, GRect(0, 0, 144, 168)); } } text_layer_set_text(mTimeHourLayer, hour_text); } if (units_changed & MINUTE_UNIT) { static char minute_text[] = "00"; strftime(minute_text, sizeof(minute_text), "%M", tick_time); text_layer_set_text(mTimeMinutesLayer, minute_text); if(FREQUENCY_MINUTES == mTimerMinute) { fetch_data(); mTimerMinute = 0; } else { mTimerMinute++; } } if (mConfigBlink && (units_changed & SECOND_UNIT)) { layer_set_hidden(text_layer_get_layer(mTimeSeparatorLayer), tick_time->tm_sec%2); } }
int main(int argc, char *argv[]) { cout << "Pulse of Prices Databases Ver 1.10 creator of " << __DATE__ << "\n" "Copyright (c) 1995, 1996 by Sergey Gershtein. Ural-Relcom, Ltd.\n" "---------------------------------------------------------------\n" "This program converts Oferta's Pulse database files from " "current directory\n" "into Pulse of Prices Viewer format.\n\n"; #ifndef DEBUG char *final_dir=".\\"; if (argc>1) if (argv[1][0]=='?' || argv[1][1]=='?') { cout << "Usage: " << argv[0] << " <dest_dir>\n\n" "All the Oferta *.dbf files and optionally payments.ini file\n" "must be in current directory. The resulting pulse.* files will\n" "be stored in the <dest_dir> directory.\n" "Be prepared that it may take a long time to create the bases.\n" "You can stop the program at any time by pressing Ctrl-C.\n"; return 0; } else final_dir=argv[1]; #else if (argc>1) cout << "### This version was compiled with DEBUG option set.\n" "### It does not understand your argument '"<<argv[1]<<"'\n"; #endif cout << "Opening files:\n"; // clearing all the read-only attrs and stuff _rtl_chmod(b_address,1,0); _rtl_chmod(b_offer,1,0); _rtl_chmod(b_product,1,0); _rtl_chmod(b_prodtype,1,0); // opening the bases BSS *o_address=open_dbf(b_address); cout << " " << b_address; if (!o_address) { cout << " - error opening file\n"; return 1; } else cout << endl; BSS *o_offer = open_dbf(b_offer); cout << " " << b_offer; if (!o_offer) { cout << " - error opening file\n"; return 1; } else cout << endl; BSS *o_product = open_dbf(b_product); cout << " " << b_product; if (!o_product) { cout << " - error opening file\n"; return 1; } else cout << endl; BSS *o_prodtype = open_dbf(b_prodtype); cout << " " << b_prodtype; if (!o_prodtype) { cout << " - error opening file\n"; return 1; } else cout << endl; // bases opened. Now reading... ------------------------ PPF --------------- #ifndef NOPPF { cout << "Creating pulse.ppf... "; if (!ppf.create(final_dir,(ushort)o_address->Amount)) { cout << "file creation error!\n"; return 1; } ppf.firm = new char[17]; ppf.address = new char[61]; ppf.fullname = new char[120]; for (ushort n=1; n<=o_address->Amount; n++) { // for each record if (n%10==1) { cout.width(6); cout << n << ' '; cout << "\x8\x8\x8\x8\x8\x8\x8"; } if (read_dbf(o_address,n)) { cout << "Error reading database record!\n"; return 1; } if (read_buf(o_address,ppf.firm,NULL,ppf.address,ppf.fullname, &ppf.phone[0],&ppf.phone[1],&ppf.phone[2],&ppf.phone[3],&ppf.area)) { cout << "Error parsing database record!\n"; return 1; } for (char *s=ppf.firm; (*s=upcase(*s))!=0; s++) ; // upcase firm name if (!ppf.write()) { cout << "Error writing record!\n"; return 1; } } delete[] ppf.firm; delete[] ppf.address; delete[] ppf.fullname; ppf.close(); cout << n << " records processed.\n"; } #endif // --------------------------- creating PPG file ----------------------------- #ifndef NOPPG { int n; long dsup=0, ddem=0; cout << "Reading groups information... "; for (n=0; n<o_product->Amount; n++) { nidx[n]=n+1; cout << "\x8\x8\x8\x8\x8\x8\x8"; cout.width(6); cout << (int)n << ' '; if (read_dbf(o_product,n+1)) { cout << "Error reading database record!\n"; return 1; } unsigned int recno; long last; if (read_buf(o_product,NULL,&recno,&g1[n],&last)) { cout << "Error parsing database record!\n"; return 1; } if (read_dbf(o_prodtype,recno)) { cout << "Error reading database prodtyp_.dbf!\n"; return 1; } int supply; if (read_buf(o_prodtype,NULL,NULL,NULL,&supply)) { cout << "Error parsing database prodtyp_.dbf record!\n"; return 1; } if (supply) { dsup+=last-g1[n]+1; g1[n]-=ddem; } else { // demand ddem+=last-g1[n]+1; g1[n]-=dsup; } g1[n]--; // we start from zero, not one } cout << "\nSorting groups with InsertSort... "; for (int k=(int)o_product->Amount-2; k>=0; k--) { char save=nidx[k]; // save k-th element long sav1=g1[k]; for (int j=k+1; (j<=o_product->Amount-1) && cmpgr(o_product,save,nidx[j])>0; j++) { nidx[j-1]=nidx[j]; g1[j-1]=g1[j]; } nidx[j-1] = save; g1[j-1] = sav1; if (k%7==0) { cout.width(3); cout << k << "\x8\x8\x8"; } } cout << "Done sorting. \n"; cout << "Creating pulse.ppg... "; if (!ppg.create(final_dir,(ushort)o_product->Amount)) { cout << "file creation error!\n"; return 1; } ppg.gname = new char[61]; for (n=0; n<o_product->Amount; n++) { // for each record cout << "\x8\x8\x8\x8\x8\x8\x8"; cout.width(6); cout << (int)n << ' '; if (read_dbf(o_product,nidx[n])) { cout << "Error reading database record!\n"; return 1; } unsigned int recno; if (read_buf(o_product,ppg.gname,&recno,&ppg.gfirst,&ppg.gsize)) { cout << "Error parsing database record!\n"; return 1; } ppg.gsize-=(--ppg.gfirst); // number of records, not the last record long gf=ppg.gfirst; ppg.gfirst=g1[n]; // not absolute one, but address in the index if (read_dbf(o_prodtype,recno)) { cout << "Error reading database prodtyp_.dbf!\n"; return 1; } int supply; if (read_buf(o_prodtype,NULL,NULL,NULL,&supply)) { cout << "Error parsing database prodtyp_.dbf record!\n"; return 1; } ppg.issupply = !(ppg.isdemand=(supply==0)); if (!ppg.write()) { cout << "Error writing record!\n"; return 1; } g1[n]=gf; // now g1 contains what gfirst used to be } delete[] ppg.gname; ppg.close(); cout << "records processed.\n"; } #endif // creating .ppd file (uff..) { try { ppi.paym = new Paym[30]; // let's start with 30 payment methods ulong pmno[30]; // number of times payment methods are used ppi.npaym = 0; #ifdef DEBUG cout << "## coreleft: " << coreleft() << endl; #endif ushort cblno=(ushort)((coreleft()-20000)/2048/4); VArrayL ndx(o_offer->Amount*2+2,"s_index.$$$",2048,cblno); cout << "Virtual array created: " << cblno << " 2048-element blocks allocated" " for buffer\n"; cout << "Memory should left afterwards: " << (coreleft() - ((long)cblno)*2048*4) << endl; cout << "Creating pulse.ppd... "; ppd.dupdate.Today(); ppd.dcreate = ppd.dupdate; if (!ppd.create(final_dir)) { cout << "file creation error!\n"; return 1; } for (long n=1; n<=o_offer->Amount; n++) { // for each record if (n%19==1) { cout.width(7); cout << n << ' '; cout << "\x8\x8\x8\x8\x8\x8\x8\x8"; } if (read_dbf(o_offer,n)) { cout << "Error reading database record!\n"; return 1; } double dprice; char payment[4]; char date[7]; if (read_buf(o_offer,NULL,NULL,&ppd.drec.fcode,NULL,&dprice, payment,date,ppd.drec.ad)) { cout << "Error parsing database record!\n"; return 1; } ppd.drec.price=dprice; ppd.drec.fcode--; date[2]=date[5]=0; ppd.drec.dsubmit = Date(atoi(date),atoi(date+3),ppd.dcreate.year()); for (int i=0; i<ppi.npaym; i++)// do we know this payment method? if (upcase(ppi.paym[i].abbr[0])==upcase(payment[0]) && upcase(ppi.paym[i].abbr[1])==upcase(payment[1]) && upcase(ppi.paym[i].abbr[2])==upcase(payment[2])) break; if (i>=ppi.npaym) { // new payment method ppi.npaym = i+1; pmno[i]=0; for (int j=0; j<4; j++) ppi.paym[i].abbr[j]=payment[j]; ppi.paym[i].coef=1; // roubles form by default. } ppd.drec.pcode = i; pmno[i]++; for (char *s=ppd.drec.ad; (*s=upcase(*s))!=0; s++) ; if ((ndx[n-1]=ppd.write())==0) { cout << "Error writing record!\n"; return 1; } } ppd.close(); cout << (n-1) << " records processed.\n"; cout << (int)ppi.npaym << " payment methods were encountered:\n"; for (int i=0; i<ppi.npaym; i++) { if (i>0) cout << ", "; for (int j=0; j<4; j++) cout << ppi.paym[i].abbr[j]; cout << " - "; cout.width(7); cout << pmno[i]; } cout << endl; // finding minimum course cout << "Looking for the USD course... "; if (!ppg.open(final_dir)) { cout << "Error opening pulse.ppg!\n"; return 1; } for (int i0=0; i0<ppg.Ngroups(); i0++) { if (!ppg.read()) { cout << "Error reading pulse.ppg record "<<i0<<"!\n"; return 1; } if (strstr(ppg.gname,"‚€‹ž’€") && ppg.issupply) break; } double usdk=1e+10; if(!ppd.open(final_dir)) { cout << "Error opening pulse.ppd!\n"; return 1; } if (i0>=ppg.Ngroups()) { cout << "!!!!!!!!!!!!!!!!! Not found !!!!!!!!!!!!!!!!!!!\n"; usdk=4700; // ???? } else { for (i=0;i<ppg.gsize;i++) { // looking for course if (!ppd.read(ndx[g1[i0]+i])) { cout << "Error reading pulse.ppd records!\n"; return 1; } if (strstr(ppd.drec.ad,"��Ž„€†€ USD") && ppd.drec.price<usdk) // found usdk = ppd.drec.price; } if (usdk<1e+9) cout << usdk << " roubles/$\n"; else { cout << "Records not found!\n"; usdk = 0; } } ppg.close(); // working with payments.ini file cout << "Checking "<<payments_ini<<" file... "; ifstream inif(payments_ini,ios::in); if (!inif) cout << "File not found.\n"; else { // working with the file cout << "File found\n"; while (!inif.eof()) { char pmt[4]; char line[30]; inif.read(pmt,4); // read four characters of payment type if (inif.eof()) break; inif.getline(line,29); for (i=0; i<ppi.npaym; i++) if (upcase(ppi.paym[i].abbr[0])==upcase(pmt[0]) && upcase(ppi.paym[i].abbr[1])==upcase(pmt[1]) && upcase(ppi.paym[i].abbr[2])==upcase(pmt[2])) { // found char *c; for (c=line; *c<=' '; c++); // skip leading blanks if (*c=='$') // dollar conversion coef ppi.paym[i].coef = atof(++c)*usdk; else ppi.paym[i].coef = atof(c); cout << " "; for (int j=0; j<4; j++) cout << ppi.paym[i].abbr[j]; cout << " = " << ppi.paym[i].coef << " roubles\n"; break; } // payment methods found } // while not eof inif.close(); } // .ini file found // building demand and supply lists cout << "Building demand and supply lists... "; long nsup=0, ndem=0; // number of supply and demand records if (!ppg.open(final_dir)) { cout << "Error opening pulse.ppg!\n"; return 1; } for (i=0; i<ppg.Ngroups(); i++) { if (!ppg.read()) { cout << "Error reading pulse.ppg record "<<i<<"!\n"; return 1; } if (ppg.issupply) nsup+=ppg.gsize; else if (ppg.isdemand) { ndem+=ppg.gsize; for (int j=0; j<ppg.gsize; j++) // set high bit to 1 for demand ndx[g1[i]+j]=ndx(g1[i]+j) | 0x80000000l; } cout.width(7); cout << (ndem+nsup) << "\x8\x8\x8\x8\x8\x8\x8"; } cout << "Done \n " << nsup << " supply records.\n " << ndem << " demand records.\n"; ppg.close(); // creating ppi file ------------------------------------- cout << "Creating pulse.ppi:\n "; if (!ppi.create(final_dir)) { cout << "File creation error!\n"; return 1; } if (!ppi.write()) { // writing initial payment info records cout << "Error writing payment info records!\n"; return 1; } else cout << "Payment information stored.\n"; cout << " Writing supply records list... "; if (!ppi.iselect(iSupply)) { cout << "Error storing index offset!\n"; return 1; } for (n=0; n<o_offer->Amount; n++) // for each element if ((ndx(n) & 0x80000000l)==0) // supply if (!ppi.write(ndx(n))) { cout << "Error writing index element!\n"; return 1; } else if (n%33==1) { cout.width(7); cout << n << "\x8\x8\x8\x8\x8\x8\x8"; } cout << "Done. \n"; cout << " Writing demand records list... "; if (!ppi.iselect(iDemand)) { cout << "Error storing index offset!\n"; return 1; } for (n=0; n<o_offer->Amount; n++) // for each element if ((ndx(n) & 0x80000000l)!=0) // demand if (!ppi.write(ndx(n)&0x7fffffffl)) { cout << "Error writing index element!\n"; return 1; } else if (n%33==1) { cout.width(7); cout << n << "\x8\x8\x8\x8\x8\x8\x8"; } cout << "Done. \n"; #ifndef NOASORT qsortads(ppd,ndx,0,o_offer->Amount-1); // quick sort by names cout << " Writing supply records list... "; if (!ppi.iselect(iSrtSupply)) { cout << "Error storing index offset!\n"; return 1; } for (n=0; n<o_offer->Amount; n++) // for each element if ((ndx(n) & 0x80000000l)==0) // supply if (!ppi.write(n)) { cout << "Error writing index element!\n"; return 1; } else if (n%33==1) { cout.width(7); cout << n << "\x8\x8\x8\x8\x8\x8\x8"; } cout << "Done. \n"; cout << " Writing demand records list... "; if (!ppi.iselect(iSrtDemand)) { cout << "Error storing index offset!\n"; return 1; } for (n=0; n<o_offer->Amount; n++) // for each element if ((ndx(n) & 0x80000000l)!=0) // demand if (!ppi.write(n/*ndx(n)&0x7fffffffl*/)) { cout << "Error writing index element!\n"; return 1; } else if (n%33==1) { cout.width(7); cout << n << "\x8\x8\x8\x8\x8\x8\x8"; } cout << "Done. \n"; #endif // alpha sort cout << "Building indexes for each payment type:\n"; cout << " Supply... "; ulong pmcur[30]; // index positions for each payment type pmcur[0]=0; for (n=0; n<ppi.npaym-1; n++) { pmcur[(int)n+1]=pmcur[(int)n]+pmno[(int)n]; pmno[(int)n]=pmcur[(int)n]; #ifdef DEBUG cout << "pmcur[" << n << "]=" << pmcur[n] << " "; #endif } #ifdef DEBUG cout << endl; #endif pmno[(int)n]=pmcur[(int)n]; // now pmno points to the beginnings of the lists, pmcur - to the endings // long ll=0; for (n=0; n<nsup; n++) { if (!ppd.read(ppi(n,TRUE),FALSE)) { // not reading ad string cerr << "Error reading data #1!\n"; return 1; } union { ulong l; float f; } u; u.f = ppd.drec.price; #ifdef DEBUG if (pmcur[ppd.drec.pcode]+o_offer->Amount+1>=o_offer->Amount*2+2) { cerr << "@1: pcode=" << (int)ppd.drec.pcode << ", pmcur[pcode]=" << (long)pmcur[ppd.drec.pcode] << ", Amount=" << o_offer->Amount << endl; } #endif ndx[pmcur[ppd.drec.pcode]+o_offer->Amount+1]=u.l; ndx[pmcur[ppd.drec.pcode]++]=n; if (n%13==1) { cout.width(7); cout << n << "\x8\x8\x8\x8\x8\x8\x8"; } } cout << n << " elements done.\n"; cout << " Sorting the lists:\n"; for (n=0; n<ppi.npaym; n++) { // sorting all lists if (pmno[(int)n]>=pmcur[(int)n]) continue; // no records for this payment type #ifdef HEAPSORT cout << " HeapSorting "; #else cout << " QuickSorting "; #endif for (int j=0; j<4; j++) cout << ppi.paym[(int)n].abbr[j]; cout << "... "; #ifdef HEAPSORT heapsort(ppd,ppi,ndx,pmno[(int)n],pmcur[(int)n]-1,TRUE); #else qsortprice(ppd,ppi,ndx,pmno[(int)n],pmcur[(int)n]-1, TRUE,o_offer->Amount+1); #endif #ifdef SORTCHECK cout << "DEBUG: Checking sort order..."; if (!ppd.read(ppi(ndx(pmno[(int)n]),TRUE),FALSE)) { cout << "ee!"; return -1; } for (long ll=pmno[(int)n]+1; ll<pmcur[(int)n]; ll++) { float pr=ppd.drec.price; union { ulong l; float f; } u1; u1.l=ndx(ll+o_offer->Amount+1); if (!ppd.read(ppi(ndx(ll),TRUE))) { cout << "ee!"; return -1; } if (pr>ppd.drec.price) { cout << ll << ": SORT ERROR!\n"; // return -1; } cout.width(8); cout << ll << "\x8\x8\x8\x8\x8\x8\x8\x8"; } cout << "Sort OK\n"; #endif } cout << " Storing indexes... "; for (int jj=0; jj<o_product->Amount; jj++) nidx0[nidx[jj]-1]=jj; for (int pc=0; pc<ppi.npaym; pc++) { ppi.iselect(iPaym+pc*2); for (int gr=0; gr<o_product->Amount; gr++) gfirst[gr]=glast[gr]=-1; for (long n=pmno[pc]; n<pmcur[pc]; n++) { ppi.write(ndx(n)); // finding to which group ndx(n) belongs... Binary search int left=0, right=(int)(o_product->Amount-1), mid; while (left<right) { mid=(right+left)/2; if (ndx(n)<g1[nidx0[mid]]) right=mid-1; else if (ndx(n)>=g1[nidx0[mid]] && (mid==o_product->Amount-1 || ndx(n)<g1[nidx0[mid+1]])) { // found left=mid; break; } else left=mid+1; } // group found if (gfirst[nidx0[left]]==-1) gfirst[nidx0[left]]=n-pmno[pc]; glast[nidx0[left]]=n-pmno[pc]; // information stored in the array if (n%13==1) { cout.width(7); cout << n << "\x8\x8\x8\x8\x8\x8\x8"; } } for (gr=0; gr<o_product->Amount; gr++) ppi.writeg(gr,gfirst[gr],glast[gr]); } cout << nsup << " elements done.\n"; for (n=0; n<ppi.npaym; n++) { pmno[(int)n]=pmcur[(int)n]; } // now pmno points to the beginnings of the lists, pmcur - to the endings cout << " Demand... "; for (n=0; n<ndem; n++) { if (!ppd.read(ppi(n,FALSE),FALSE)) { // demand records cerr << "Error reading data #1!\n"; return 1; } union { ulong l; float f; } u; u.f = ppd.drec.price; ndx[pmcur[ppd.drec.pcode]+o_offer->Amount+1]=u.l; ndx[pmcur[ppd.drec.pcode]++]=n; if (n%13==1) { cout.width(7); cout << n << "\x8\x8\x8\x8\x8\x8\x8"; } } cout << n << " elements done.\n"; cout << " Sorting the lists:\n"; for (n=0; n<ppi.npaym; n++) { // sorting all lists if (pmno[(int)n]>=pmcur[(int)n]) continue; // no records for this payment type #ifdef HEAPSORT cout << " HeapSorting "; #else cout << " QuickSorting "; #endif for (int j=0; j<4; j++) cout << ppi.paym[(int)n].abbr[j]; cout << "... "; #ifdef HEAPSORT heapsort(ppd,ppi,ndx,pmno[(int)n],pmcur[(int)n]-1,FALSE); #else qsortprice(ppd,ppi,ndx,pmno[(int)n],pmcur[(int)n]-1, FALSE,o_offer->Amount+1); #endif } cout << " Storing indexes... "; for (pc=0; pc<ppi.npaym; pc++) { ppi.iselect(iPaym+pc*2+1); for (long n=pmno[pc]; n<pmcur[pc]; n++) { ppi.write(ndx(n)); if (n%13==1) { cout.width(7); cout << n << "\x8\x8\x8\x8\x8\x8\x8"; } } } cout << ndem << " elements done.\n"; ppd.close(); // NOT TO FORGET ppi.close(); delete[] ppi.paym; } catch (VArrayErr err) { cout << "Virtual array exception #" << (int)err.code() << "\n"; return 1; } catch (xalloc xa) { cout << "Memory allocation failure: " << xa.requested() << "bytes.\n"; return 1; } catch (...) { cout << "Unhandled exception!\n"; return 1; } } cout << "Closing Oferta's files... "; if (close_dbf(o_address) || close_dbf(o_product) || close_dbf(o_prodtype) || close_dbf(o_offer)) { cout << "Error closing Oferta's bases!\n"; return 1; } cout << "Done.\n"; return 0; }
int main( int argc, char *argv[]) { char *fnames[32]; int nr_files = 0; FILE *obj = NULL; TEXT_RLD tr; char *objname = NULL; char *lstname = NULL; int arg; int i; STACK stack; int errcount; if (argc <= 1) { print_help(); exit(EXIT_FAILURE); } for (arg = 1; arg < argc; arg++) if (*argv[arg] == '-') { char *cp; cp = argv[arg] + 1; if (!stricmp(cp, "h")) { print_help(); } else if (!stricmp(cp, "v")) { print_version(stderr); } else if (!stricmp(cp, "e")) { /* Followed by options to enable */ /* Since /SHOW and /ENABL option names don't overlap, I consolidate. */ if(arg >= argc-1 || !isalpha((unsigned char)*argv[arg+1])) { usage("-e must be followed by an option to enable\n"); } upcase(argv[++arg]); enable_tf(argv[arg], 1); } else if (!stricmp(cp, "d")) { /* Followed by an option to disable */ if(arg >= argc-1 || !isalpha((unsigned char)*argv[arg+1])) { usage("-d must be followed by an option to disable\n"); } upcase(argv[++arg]); enable_tf(argv[arg], 0); } else if (!stricmp(cp, "m")) { /* Macro library */ /* This option gives the name of an RT-11 compatible macro library from which .MCALLed macros can be found. */ if(arg >= argc-1 || *argv[arg+1] == '-') { usage("-m must be followed by a macro library file name\n"); } arg++; int allow_olb = strcmp(argv[argc-1], "-x") == 0; mlbs[nr_mlbs] = mlb_open(argv[arg], allow_olb); if (mlbs[nr_mlbs] == NULL) { fprintf(stderr, "Unable to register macro library %s\n", argv[arg]); exit(EXIT_FAILURE); } nr_mlbs++; } else if (!stricmp(cp, "p")) { /* P for search path */ /* The -p option gives the name of a directory in which .MCALLed macros may be found. */ { if(arg >= argc-1 || *argv[arg+1] == '-') { usage("-p must be followed by a macro search directory\n"); } append_env("MCALL", argv[arg+1]); arg++; } } else if (!stricmp(cp, "I")) { /* I for include path */ /* The -I option gives the name of a directory in which .included files may be found. */ { if(arg >= argc-1 || *argv[arg+1] == '-') { usage("-I must be followed by a include file search directory\n"); } append_env("INCLUDE", argv[arg+1]); arg++; } } else if (!stricmp(cp, "o")) { /* The -o option gives the object file name (.OBJ) */ if(arg >= argc-1 || *argv[arg+1] == '-') { usage("-o must be followed by the object file name\n"); } ++arg; objname = argv[arg]; } else if (!stricmp(cp, "l")) { /* The option -l gives the listing file name (.LST) */ /* -l - enables listing to stdout. */ if(arg >= argc-1 || (argv[arg+1][0] == '-' && argv[arg+1][1] != '\0')) { usage("-l must be followed by the listing file name (- for standard output)\n"); } lstname = argv[++arg]; if (strcmp(lstname, "-") == 0) lstfile = stdout; else lstfile = fopen(lstname, "w"); } else if (!stricmp(cp, "x")) { /* The -x option invokes macro11 to expand the contents of the registered macro libraries (see -m) into individual .MAC files in the current directory. No assembly of input is done. This must be the last command line option. */ int m; if(arg != argc-1) { usage("-x must be the last option\n"); } for (m = 0; m < nr_mlbs; m++) mlb_extract(mlbs[m]); return EXIT_SUCCESS; } else if (!stricmp(cp, "ysl")) { /* set symbol_len */ if (arg >= argc-1) { usage("-s must be followed by a number\n"); } else { char *s = argv[++arg]; char *endp; int sl = strtol(s, &endp, 10); if (*endp || sl < SYMMAX_DEFAULT || sl > SYMMAX_MAX) { usage("-s must be followed by a number\n"); } symbol_len = sl; } } else if (!stricmp(cp, "yus")) { /* allow underscores */ symbol_allow_underscores = 1; } else if (!stricmp(cp, "yl1")) { /* list the first pass, in addition to the second */ list_pass_0++; } else if (!stricmp(cp, "yd")) { enabl_debug++; } else { fprintf(stderr, "Unknown option %s\n", argv[arg]); print_help(); exit(EXIT_FAILURE); } } else { fnames[nr_files++] = argv[arg]; } if (objname) { obj = fopen(objname, "wb"); if (obj == NULL) return EXIT_FAILURE; } add_symbols(&blank_section); text_init(&tr, NULL, 0); module_name = memcheck(strdup(".MAIN.")); xfer_address = new_ex_lit(1); /* The undefined transfer address */ stack_init(&stack); /* Push the files onto the input stream in reverse order */ for (i = nr_files - 1; i >= 0; --i) { STREAM *str = new_file_stream(fnames[i]); if (str == NULL) { report(NULL, "Unable to open file %s\n", fnames[i]); exit(EXIT_FAILURE); } stack_push(&stack, str); } DOT = 0; current_pc->section = &blank_section; last_dot_section = NULL; pass = 0; stmtno = 0; lsb = 0; next_lsb = 1; lsb_used = 0; last_macro_lsb = -1; last_locsym = 32767; last_cond = -1; sect_sp = -1; suppressed = 0; assemble_stack(&stack, &tr); if (list_pass_0 && lstfile) { list_symbol_table(); } #if 0 if (enabl_debug > 1) dump_all_macros(); #endif assert(stack.top == NULL); migrate_implicit(); /* Migrate the implicit globals */ write_globals(obj); /* Write the global symbol dictionary */ #if 0 sym_hist(&symbol_st, "symbol_st"); /* Draw a symbol table histogram */ #endif text_init(&tr, obj, 0); stack_init(&stack); /* Superfluous... */ /* Re-push the files onto the input stream in reverse order */ for (i = nr_files - 1; i >= 0; --i) { STREAM *str = new_file_stream(fnames[i]); if (str == NULL) { report(NULL, "Unable to open file %s\n", fnames[i]); exit(EXIT_FAILURE); } stack_push(&stack, str); } DOT = 0; current_pc->section = &blank_section; last_dot_section = NULL; pass = 1; stmtno = 0; lsb = 0; next_lsb = 1; lsb_used = 0; last_macro_lsb = -1; last_locsym = 32767; pop_cond(-1); sect_sp = -1; suppressed = 0; errcount = assemble_stack(&stack, &tr); text_flush(&tr); while (last_cond >= 0) { report(NULL, "%s:%d: Unterminated conditional\n", conds[last_cond].file, conds[last_cond].line); pop_cond(last_cond - 1); errcount++; } for (i = 0; i < nr_mlbs; i++) mlb_close(mlbs[i]); write_endmod(obj); if (obj != NULL) fclose(obj); if (errcount > 0) fprintf(stderr, "%d Errors\n", errcount); if (lstfile) { list_symbol_table(); } if (lstfile && strcmp(lstname, "-") != 0) fclose(lstfile); return errcount > 0 ? EXIT_FAILURE : EXIT_SUCCESS; }
int main(int argc, char *argv[]) { // This array of strings has all the available codes to choose from for collecting data const char* const codes[] = {"WELD","BEND","PI","BORE WALL","CAD", "COMBO BEND","EXPIPE","LE","NG","NGC","OHP","ROCKSHIELD","TOPIPE", "TRENCHBREAKER","UGUT"}; char choice[20]; // user choice for the above list of codes printf ("Choose a code from the list: \n"); int i; for (i = 0; i < 15; ++i) { printf ("%s\n",codes[i]); } printf ("--> "); fgets(choice,20,stdin); // get user choice here upcase(choice); // function to convert all characters to uppercase if(strcmp(choice, "WELD\n") == 0) { printf ("Weld!\n"); } else if(strcmp(choice, "BEND\n") == 0) { printf ("Bend!\n"); } else if(strcmp(choice, "PI\n") == 0) { printf ("PI\n"); } else if(strcmp(choice, "BORE WALL\n") == 0) { printf ("Bore Wall.\n"); } else if(strcmp(choice, "CAD\n") == 0) { printf ("cad!\n"); } else if(strcmp(choice, "COMBO BEND\n") == 0) { printf ("combo bend!\n"); } else if(strcmp(choice, "EXPIPE\n") == 0) { printf("expipe\n"); } else if(strcmp(choice, "LE\n") == 0) { printf ("Le\n"); } else if(strcmp(choice, "NG\n") == 0) { printf ("ng\n"); } else if(strcmp(choice, "NGC\n") == 0) { printf ("ngc\n"); } else if(strcmp(choice, "OHP\n") == 0) { printf ("ohp\n"); } else if(strcmp(choice, "ROCKSHIELD\n") == 0) { printf ("rockshield\n"); } else if(strcmp(choice, "TOPIPE\n") == 0) { printf ("topipe\n"); } else if(strcmp(choice, "TRENCHBREAKER\n") == 0) { printf ("trenchbreaker\n"); } else if(strcmp(choice, "UGUT\n") == 0) { printf ("ugut\n"); } else { printf ("That is not a valid selection\n"); } return 0; }
void DOS_Drive_Cache::CreateShortName(CFileInfo* curDir, CFileInfo* info) { Bits len = 0; bool createShort = false; char tmpNameBuffer[CROSS_LEN]; char* tmpName = tmpNameBuffer; // Remove Spaces strcpy(tmpName,info->orgname); upcase(tmpName); createShort = RemoveSpaces(tmpName); // Get Length of filename char* pos = strchr(tmpName,'.'); if (pos) { // ignore preceding '.' if extension is longer than "3" if (strlen(pos)>4) { while (*tmpName=='.') tmpName++; createShort = true; } pos = strchr(tmpName,'.'); if (pos) len = (Bits)(pos - tmpName); else len = (Bits)strlen(tmpName); } else { len = (Bits)strlen(tmpName); } // Should shortname version be created ? createShort = createShort || (len>8); if (!createShort) { char buffer[CROSS_LEN]; strcpy(buffer,tmpName); createShort = (GetLongName(curDir,buffer)>=0); } if (createShort) { // Create number char buffer[8]; info->shortNr = CreateShortNameID(curDir,tmpName); sprintf(buffer,"%d",info->shortNr); // Copy first letters Bits tocopy = 0; size_t buflen = strlen(buffer); if (len+buflen+1>8) tocopy = (Bits)(8 - buflen - 1); else tocopy = len; safe_strncpy(info->shortname,tmpName,tocopy+1); // Copy number strcat(info->shortname,"~"); strcat(info->shortname,buffer); // Add (and cut) Extension, if available if (pos) { // Step to last extension... pos = strrchr(tmpName, '.'); // add extension strncat(info->shortname,pos,4); info->shortname[DOS_NAMELENGTH] = 0; } // keep list sorted for CreateShortNameID to work correctly if (curDir->longNameList.size()>0) { if (!(strcmp(info->shortname,curDir->longNameList.back()->shortname)<0)) { // append at end of list curDir->longNameList.push_back(info); } else { // look for position where to insert this element bool found=false; std::vector<CFileInfo*>::iterator it; for (it=curDir->longNameList.begin(); it!=curDir->longNameList.end(); ++it) { if (strcmp(info->shortname,(*it)->shortname)<0) { found = true; break; } } // Put it in longname list... if (found) curDir->longNameList.insert(it,info); else curDir->longNameList.push_back(info); } } else { // empty file list, append curDir->longNameList.push_back(info); } } else { strcpy(info->shortname,tmpName); } RemoveTrailingDot(info->shortname); }
void Spice::readFile(string nome, Circuit& netlist, bool reading_cadence) { ifstream arq (nome.c_str()); string linha; if (!arq.is_open()) throw AstranError("Could not open Spice file: " + nome ); vector<string> palavras; string palavra; CellNetlst subcktCell,topCell; CellNetlst *currentCell=&topCell; topCell.setName(upcase(removeExt(getFileName(nome)))); string cellName; unsigned int lineNr=0; while (!arq.eof()){ lineNr++; getline(arq,linha); palavras.clear(); istrstream clin(linha.c_str()); while (clin>>palavra) palavras.push_back(upcase(palavra)); if (palavras.size() == 0 || palavras[0] == ".GLOBAL") continue; if (palavras[0] == "*INTERFACE"){ if(palavras.size() == 4 || palavras.size() == 6){ IOType type; direction orient; switch(palavras[2][palavras[2].size()-1]){ case 'N': orient=N; break; case 'S': orient=S; break; case 'E': orient=E; break; case 'W': orient=W; break; default: throw AstranError("Line" + intToStr(lineNr) + ": Interface orientation unknown."); } switch(palavras[3][0]){ case 'I': type=IOTYPE_INPUT; break; case 'O': type=IOTYPE_OUTPUT; break; default: throw AstranError("Line" + intToStr(lineNr) + ": Interface type unknown. Use INPUT or OUTPUT"); } topCell.insertInOut(palavras[1]); netlist.insertInterface(palavras[1], orient, type, 0, 0); } else throw AstranError("Line" + intToStr(lineNr) + ": Number of parameters for *interface is not correct"); continue; } if (reading_cadence && palavras[0] == "*" && palavras.size() == 5 && palavras[1] == "SUBCIRCUIT"){ currentCell->clear(); topCell.setName(palavras[4].substr(0,palavras[4].size()-1)); } if (palavras[0][0] == '*' || palavras[0][0] == 'C' || palavras[0][0] == '+' || palavras[0][0] == 'D' || (palavras[0][0]=='X' && reading_cadence)) // corrigir aqui para ler o '+' e ignorar os parâmetros desnecessários continue; if (palavras[0] == ".MODEL" || palavras[0] == ".END") break; if (palavras[0] == ".SUBCKT" && currentCell==&topCell && !reading_cadence){ // It's a new cell definition. . . subcktCell.clear(); currentCell=&subcktCell; cellName=palavras[1]; // compare if subcircuit name is the same as the top cell name if(cellName == topCell.getName()){ string topname = topCell.getName() + "-TOP"; topCell.setName(topname); } for (int p=2; p<palavras.size(); p++) currentCell->insertInOut(palavras[p]); } else if (palavras[0] == string(".INCLUDE")){ readFile(getPath(nome)+palavras[1],netlist,reading_cadence); // throw AstranError("Could not read included file in line: " + intToStr(lineNr)); } // declaring transistor in subcircuit read from Cadence else if (palavras[0][0] == 'M' && palavras.size()>=5){ // insert in and out pins if (reading_cadence){ for (int p=1; p<5; ++p){ if (!isNumber(palavras[p]) || palavras[p] == "0") currentCell->insertInOut(palavras[p]); } } // identify transistor type transType type; if(palavras[5]=="PMOS" || palavras[5]=="CMOSP" || palavras[5]=="MODP" || palavras[5]=="PMOS_VTL") type=PMOS; else if(palavras[5]=="NMOS" || palavras[5]=="CMOSN" || palavras[5]=="MODN" || palavras[5]=="NMOS_VTL") type=NMOS; else throw AstranError("Line" + intToStr(lineNr) + ": Parameter " + palavras[5] + " is incorrect. Use NMOS or PMOS"); // get parameters' values float length=0, width=0; for (int p=6; p<palavras.size(); p++){ int pos=palavras[p].find("="); string parm=palavras[p].substr(0,pos++); float tam=atof((palavras[p].substr(pos)).c_str())*getFactor(palavras[p][palavras[p].size()-1])*getFactor(palavras[p][palavras[p].size()-2]); if(parm=="L") length=tam; else if(parm=="W") width=tam; else if(parm!="AD" && parm!="PD" && parm!="AS" && parm!="PS" && parm!="NRD" && parm!="NRS" && parm!="M") throw AstranError("Line" + intToStr(lineNr) + ": Parameter " + parm + " not supported"); } // insert transistor in cell currentCell->insertTrans(palavras[0], palavras[1], palavras[2], palavras[3], type, length, width); } else if (palavras[0][0] == 'X' && !reading_cadence){ string instName=palavras[0]; vector<string> net_ids; int p; for (p=1; p<palavras.size()-1; p++) net_ids.push_back(palavras[p]); currentCell->insertInstance(instName, palavras[p], net_ids); } else if (currentCell==&subcktCell && palavras[0] == ".ENDS"){ currentCell->setName(cellName); netlist.insertCell(*currentCell); currentCell=&topCell; } else throw AstranError("Line" + intToStr(lineNr)); } if(topCell.getNets().size() != 0) netlist.insertCell(topCell); }
static void init_c(statedes *st, bindes *bd) {int i; char fn[BFLRG], upck[BFLRG], s[BFMG]; char *p, **el, **sl, **ul, **hl; const char *pck; FILE *fc, *fh, *fp; cmeta *cm; pck = st->pck; snprintf(upck, BFLRG, pck, -1); upcase(upck); /* make the C metadata from the derivedc file */ hl = NULL; el = NULL; sl = NULL; ul = NULL; fp = open_file("r", "%s.derivedc", pck); if (fp != NULL) {for (i = 0; TRUE; i++) {p = fgets(s, BFMG, fp); if (p == NULL) break; LAST_CHAR(p) = '\0'; if (blank_line(p) == TRUE) continue; else if (strncmp(p, "include = ", 10) == 0) hl = tokenize(p+10, " \t", 0); else if (strncmp(p, "enum e_", 7) == 0) el = lst_add(el, p); else if (strncmp(p, "struct s_", 9) == 0) sl = lst_add(sl, p); else if (strncmp(p, "union u_", 8) == 0) ul = lst_add(ul, p);}; el = lst_add(el, NULL); sl = lst_add(sl, NULL); ul = lst_add(ul, NULL); fclose(fp);}; cm = MAKE(cmeta); cm->hdrs = hl; cm->enums = el; cm->structs = sl; cm->unions = ul; bd->data = cm; /* open C file */ if ((st->path == NULL) || (strcmp(st->path, ".") == 0)) snprintf(fn, BFLRG, "gc-%s.c", pck); else snprintf(fn, BFLRG, "%s/gc-%s.c", st->path, pck); fc = open_file("w", fn); bd->fp[0] = fc; fprintf(fc, "/*\n"); fprintf(fc, " * GC-%s.C - support routines for %s\n", upck, upck); fprintf(fc, " * NOTE: this file was automatically generated by blang\n"); fprintf(fc, " * any manual changes will not be effective\n"); fprintf(fc, " *\n"); fprintf(fc, " */\n"); fprintf(fc, "\n"); fprintf(fc, "#include \"cpyright.h\"\n"); if (hl != NULL) {for (i = 0; hl[i] != NULL; i++) fprintf(fc, "#include \"%s\"\n", hl[i]);}; /* fprintf(fc, "#include \"%s_int.h\"\n", pck); */ fprintf(fc, "#include \"%s_gen.h\"\n", pck); fprintf(fc, "\n"); /* open header file */ if ((st->path == NULL) || (strcmp(st->path, ".") == 0)) snprintf(fn, BFLRG, "gc-%s.h", pck); else snprintf(fn, BFLRG, "%s/gc-%s.h", st->path, pck); fh = open_file("w", fn); bd->fp[1] = fh; fprintf(fh, "/*\n"); fprintf(fh, " * GC-%s.H - header containing support for %s\n", upck, upck); fprintf(fh, " * NOTE: this file was automatically generated by blang\n"); fprintf(fh, " * any manual changes will not be effective\n"); fprintf(fh, " *\n"); fprintf(fh, " */\n"); fprintf(fh, "\n"); fprintf(fh, "#include \"cpyright.h\"\n"); fprintf(fh, "\n"); fprintf(fh, "#ifndef GEN_%s_H\n", upck); fprintf(fh, "#define GEN_%s_H\n", upck); fprintf(fh, "\n"); return;}