INT16 CGEN_PROTECTED CCgen::OnFile() { char lpFile[L_INPUTLINE]; GetNextDefToken(lpFile); dlp_strconvert(SC_UNESCAPE,lpFile,lpFile); dlp_strtrimleft(lpFile); dlp_strtrimright(lpFile); if (m_bMainProject) ERRORRET(ERR_INVALKEY,"FILE:","MAIN:",0,NOT_EXEC); if (m_nAncestor) return O_K; INT16 nFType = 0; if (!dlp_strlen(lpFile)) ERRORRET(ERR_EXPECTAFTER,"file name","FILE:",0,NOT_EXEC); if (m_files.FindItem(lpFile)) ERRORRET(ERR_DDEF_LIST,"FILE",lpFile,0,NOT_EXEC); char *ext = &lpFile[strlen(lpFile)-1]; while (*ext != '.' && ext != lpFile) ext--; if (dlp_strncmp(ext,".cpp",L_NAMES) ==0) nFType = FT_CPP; if (dlp_strncmp(ext,".c" ,L_NAMES) ==0) nFType = FT_C; if (dlp_strncmp(ext,".h" ,L_NAMES) ==0) nFType = FT_H; if (!nFType) ERRORRET(ERR_FILETYPE,ext,NULL,0,NOT_EXEC); SCGFile* nf = m_files.AddItem(lpFile); if (!nf) return NOT_EXEC; nf->nFType = nFType; return O_K; }
/** * dlp_sprintx w/o space padding. */ INT32 __sprintx(char* sBuf, const void* nData, INT16 nType, BOOL bExact) { dlp_sprintx(sBuf,(char*)nData,nType,bExact); dlp_strconvert(SC_PRC_ESCAPE,sBuf,sBuf); dlp_strreplace(sBuf,"\n","\\n"); dlp_strreplace(sBuf,"\r","\\r"); dlp_strreplace(sBuf,"\t","\\t"); dlp_strtrimleft(dlp_strtrimright(sBuf)); return strlen(sBuf); }
/* * Manual page at process.def */ INT16 CGEN_PUBLIC CProcess::Status() { CData* d; char s[L_INPUTLINE]; INT32 i; printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); // Protocol printf("\n Status of instance"); // Protocol printf("\n process %s",BASEINST(_this)->m_lpInstanceName); // Protocol printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); // Protocol printf("\n State : 0x%04X",m_nState); // Protocol if (m_nState!=0) // In any but the maiden state { // >> BOOL b = 0; // Comma flag printf(" ("); // Protocol if (m_nState&PRC_DATASENT ) { if(b) printf(", "); printf("data sent" ); b=1; }//... if (m_nState&PRC_RUNNING ) { if(b) printf(", "); printf("running" ); b=1; }//... if (m_nState&PRC_COMPLETE ) { if(b) printf(", "); printf("complete" ); b=1; }//... if (m_nState&PRC_KILLED ) { if(b) printf(", "); printf("killed" ); b=1; }//... if (m_nState&PRC_DATARECEIVED) { if(b) printf(", "); printf("data received"); b=1; }//... printf(")"); // Protocol } // << printf("\n Return value: %ld",(long)m_nRetVal ); // Protocol if (dlp_strlen(m_psTmpFile)) printf("\n Temp. files : %s*",m_psTmpFile); // Protocol dlp_strcpy(s,m_psCmdLine); dlp_strreplace(s,m_psTmpFile,"<tmpfile>"); // Abbreviate command line if (dlp_strlen(m_psCmdLine)) printf("\n Command line: %s" ,s); // Protocol // Show transferred data // ------------------------------------ if (m_iDto) // Have data transfer object { // >> printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); // Protocol printf("\n Transferred data"); // Protocol d = (CData*)CDlpObject_FindInstanceWord(m_iDto,PRC_S_IDSIGN,NULL); // Get signature table printf("\n - function : %s",(char*)CData_XAddr(d,0,0)); // Protocol (job function name) for (i=1; i<CData_GetNRecs(d); i++) // Loop over function arguemnts printf("\n %13s %s",i==1?"- arguments :":"",(char*)CData_XAddr(d,i,0)); // Protocol (job function arg.) d = (CData*)CDlpObject_FindInstanceWord(m_iDto,PRC_S_IDGLOB,NULL); // Get list of global instances if (d) // Have one for (i=0; i<CData_GetNRecs(d); i++) // Loop over entries printf("\n %13s %-8s %s",i==0?"- globals :":"", // Protocol (global instance) (char*)CData_XAddr(d,i,0),(char*)CData_XAddr(d,i,1)); // | printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); // Protocol printf("\n Transferred program"); // Protocol for (i=0; dlp_strlen(__sSlaveScript[i]); i++) // Loop over slave script lines { // >> dlp_strcpy(s,__sSlaveScript[i]); // Get a line if (strstr(s,"##"))*(strstr(s,"##"))='\0'; // Truncate at comment printf("\n (%02ld) %s",i,dlp_strtrimright(s)); // Protocol (script line) } // << } // << printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); printf("\n"); // Protocol return O_K; // All done }
INT32 CDlpFile_Getlen(CDlpFile* _this) { FILE* f = NULL; INT32 nCtr = 0; char lpsBuffer[L_INPUTLINE] = ""; if (!dlp_strlen(_this->m_lpsFlist)) { IERROR(_this,FIL_NEEDFL,0,0,0); return 0; } f = fopen(_this->m_lpsFlist,"r"); if (!f) { IERROR(_this,ERR_FILEOPEN,_this->m_lpsFlist,"reading",0); return 0; } while (fgets(lpsBuffer,L_INPUTLINE,f)) if(dlp_strlen(dlp_strtrimleft(dlp_strtrimright(lpsBuffer)))) nCtr++; fclose(f); return nCtr; return 0; }
/** * Prints one block of the instance in vector mode (standard). */ INT32 CGEN_PRIVATE CData_PrintVectors_Block ( CData* _this, /* Pointer to data instance */ INT32 nBlock /* Block index (<0: ignore blocks) */ ) /* Returns number of lines printed */ { INT32 i = 0; /* Universal loop counter */ INT32 nR = 0; /* Current record */ INT32 nR_ = 0; /* First record to be printed */ INT32 nR0 = 0; /* First record of current page */ INT32 nSR = 0; /* Number of records of currenr page */ INT32 nXR = 0; /* Last record to print plus one */ INT32 nC = 0; /* Current component */ INT32 nXC = 0; /* Number of components */ INT32 nWI = 0; /* Component index column width */ INT32 nW0 = 0; /* Head column width */ INT32 nW = 0; /* Column width */ INT32 nP = 0; /* Current page */ INT32 nPps = 0; /* Pages per screen */ INT32 nL = 0; /* Line counter */ BOOL bPur = FALSE; /* Print physical record unit flag */ BOOL bPuc = FALSE; /* Print physical component unit flg.*/ FLOAT64 nBuf = 0.; /* Double buffer */ char sBuf[L_SSTR+1]; /* String buffer */ /* Validate */ /* --------------------------------- */ if (nBlock>=CData_GetNBlocks(_this)) return 0; /* Requested block does not exist */ /* Initialize */ /* --------------------------------- */ nR_ = nBlock>=0 ? CData_GetNRecsPerBlock(_this)*nBlock : 0; /* Get first record to print */ nXR = nBlock>=0 ? nR_+CData_GetNRecsPerBlock(_this) : CData_GetNRecs(_this); /* Get number of records */ nXC = CData_GetNComps(_this); /* Get number of components */ bPur = _this->m_lpTable->m_fsr!=1. && _this->m_lpTable->m_fsr!=0.; /* Displaying physical record units? */ bPuc = _this->m_nCinc!=1. && _this->m_nCinc!=0.; /* Displaying physical comp. units? */ nPps = dlp_maxprintlines()/(nXC+4); /* Compute no. of pages per sceeen */ /* Print vectors */ /* --------------------------------- */ if (nBlock>=0) /* Printing blockwise? */ { /* >> */ printf("\n Block %ld (offset %ld)",(long)nBlock,(long)nR_); /* Show current block index */ dlp_inc_printlines(1); nL++; /* Adjust number of printed lines */ } /* << */ for (nR0=nR_; nR0<nXR; ) /* Loop over records */ { /* >> */ CData_PrintVectors_GetColWidth(_this,nR0,0,&nWI,&nW0,&nW); /* Comp. head and data col. widths */ nSR = (dlp_maxprintcols()-nWI-nW0-4)/(nW+1); /* Number of columns to print */ if (nR0+nSR>nXR) nSR = nXR-nR0; /* No more than there are records! */ /* Print record header */ /* - - - - - - - - - - - - - - - - */ if (bPur) /* Display physical record units? */ { /* >> */ printf("\n %s ->",__pad(strcpy(sBuf,_this->m_lpRunit),nW0+nWI,'r')); /* Print name of physical unit */ for (nR=nR0; nR<nR0+nSR; nR++) /* Loop over remaining records */ { /* >> */ nBuf = _this->m_lpTable->m_ofs + (nR-nR_)*_this->m_lpTable->m_fsr; /* Compute abscissa value */ __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact); /* Print to a string */ printf("%s ",__pad(sBuf,nW,'r')); /* Format and print to screen */ } /* << */ dlp_inc_printlines(1); nL++; /* Adjust number of printed lines*/ } /* << */ sBuf[0]='\0'; /* Clear string buffer */ if (bPuc) sprintf(sBuf,"%s| ",_this->m_lpCunit); /* Print phys. comp. unit name... */ printf("\n %s",__pad(sBuf,nW0+nWI+3,'r')); /* ... or empty string */ for (nR=nR0; nR<nR0+nSR; nR++) /* Loop over remaining records */ { /* >> */ i=nR-nR_; __sprintx(sBuf,&i,T_INT,_this->m_bExact); /* Print record index to a str. */ printf("%s%c",__pad(sBuf,nW,'r'),CData_RecIsMarked(_this,nR)?'*':' '); /* Format and print to screen */ } /* << */ sBuf[0]='\0'; /* Clear string buffer */ if (bPuc) sprintf(sBuf,"%c ",bPuc?'v':' '); /* Print down arrow ... */ printf("\n %s",__pad(sBuf,nW0+nWI+3,'r')); /* ... or empty string */ sBuf[0]='\0'; for (i=0; i<nW; i++) sBuf[i]='.'; sBuf[i]='\0'; /* Make horizonal delimiter */ for (nR=nR0; nR<nR0+nSR; nR++) printf("%s ",sBuf); /* Print one per vector */ dlp_inc_printlines(2); nL+=2; /* Adjust number of printed lines */ /* Print data */ /* - - - - - - - - - - - - - - - - */ for (nC=0; nC<nXC; ) /* Loop over components */ { /* >> */ __sprintx(sBuf,&nC,T_INT,_this->m_bExact); /* Print comp. index to a string */ printf("\n%c%s ", /* Format and print to screen */ CData_CompIsMarked(_this,nC)?'*':' ',__pad(sBuf,nWI,'r')); /* | (incl. "*" for "marked") */ if (bPuc && dlp_is_numeric_type_code(CData_GetCompType(_this,nC))) /* Display ordinate value? */ { /* >> */ nBuf = _this->m_nCofs + nC*_this->m_nCinc; /* Compute it */ __sprintx(sBuf,&nBuf,T_DOUBLE,_this->m_bExact); /* Print it to a string */ } /* << */ else strcpy(sBuf,CData_GetCname(_this,nC)); /* else display component name */ printf("%s: ",__pad(dlp_strtrimleft(dlp_strtrimright(sBuf)),nW0,'r')); /* Format and print to screen */ for (nR=nR0; nR<nR0+nSR; nR++) /* Loop over remaining records */ { /* >> */ __sprintx(sBuf,CData_XAddr(_this,nR,nC), /* Print cell value to a str. */ CData_GetCompType(_this,nC),_this->m_bExact); /* | */ if (dlp_is_symbolic_type_code(CData_GetCompType(_this,nC))) /* Is string value */ if ((INT32)dlp_strlen(sBuf)>nW) /* Will not fit in column */ dlp_strabbrv(sBuf,sBuf,nW); /* Abbreviate it */ if (dlp_is_numeric_type_code(CData_GetCompType(_this,nC))) /* Is numeric value */ if (_this->m_bNz && CMPLX_EQUAL(CData_Cfetch(_this,nR,nC),CMPLX(0.))) dlp_strcpy(sBuf,"-"); printf("%s%c",__pad(sBuf,nW,'r'), /* Format and print to screen */ CData_CellIsMarked(_this,nR*CData_GetNComps(_this)+nC)?'*':' '); /* | (incl. "*" for "marked") */ } /* << */ dlp_inc_printlines(1); nL++; /* Adjust number of printed lines*/ /* Break component listing */ /* - - - - - - - - - - - - - - - */ if (nPps==0) /* Not all comps. fit on screen */ { /* >> */ sprintf(sBuf,"component (0..%ld), cancel -3",(long)nXC-1); /* Make user hint */ if ((nC=dlp_printstop_nix(nC,sBuf,NULL))==-1) break; /* Break listing */ if (nC< -2 ) return -1; /* Cancelled by user */ if (nC>=nXC) break; /* No more components -> break */ } /* << */ else nC++; /* No breaking -> count comps. */ } /* << */ nR0+=nSR; /* First record on next page */ nP++; /* Count pages */ if (nR0<nXR) /* There are more records */ { /* >> */ printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); /* Print a separator */ dlp_inc_printlines(1); nL++; /* Adjust number of printed lines*/ } /* << */ /* Break record listing */ /* - - - - - - - - - - - - - - - - */ if (((nPps>0 && nP>=nPps) || nPps==0) && nR0<nXR) /* Complicated break condition :) */ { /* >> */ dlp_inc_printlines(dlp_maxprintlines()); /* Do stop right here */ sprintf(sBuf,"record (%ld..%ld)%s",(long)nR_,(long)nXR-1, /* Make user hint */ nBlock>=0?", cancel -3":""); /* | */ if ((nR0=dlp_printstop_nix(--nR0,sBuf,NULL))==-1) break; /* Break listing */ if (nR0< -2 ) return -1; /* Cancelled by user */ if (nR0< nR_) nR0=nR_; /* No previous blocks, please! */ if (nR0>=nXR) break; /* No more records -> break */ nP=0; /* Reset page counter */ } /* << */ } /* << */ return nL; /* Return number of printed lines */ }