/** * 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 }
/** * Create an absolute or full path name for the specified relative path name. * * @param lpsAbsPath * Pointer to a buffer to be filled with the absolute path. * @param lpsRelPath * Pointer to a null-terminated string containing the relative path. * @param nMaxLen * Maximum length of the absolute path name buffer * (<code>lpsAbsPath</code>). * @return <code>lpsAbsPath</code> if successful, <code>NULL</code> in case of * errors. */ char* dlp_fullpath(char* lpsAbsPath, const char* lpsRelPath, INT32 nMaxLen) { char lpsCwd [L_PATH+1]; /* Saved current working directory */ char lpsDir [L_PATH+1]; /* Directory part of lpsRelPath */ char lpsFile[L_PATH+1]; /* Filename part of lpsRelPath */ struct stat filestat; /* File status struct */ if (!lpsAbsPath || nMaxLen<=0) return NULL; /* No buffer, no service! */ *lpsAbsPath='\0'; /* Initialize result to empty string */ dlp_splitpath(lpsRelPath,lpsDir,lpsFile); /* Split relative path */ if (!dlp_strlen(lpsDir)) dlp_strcpy(lpsDir,"."); /* No directory -> use current one */ if(getcwd(lpsCwd,L_PATH)==NULL) return NULL; /* Save current working directory */ if (dlp_chdir(lpsDir,FALSE)!=0) { dlp_chdir(lpsCwd,FALSE); return NULL; } /* Change to relative directory ... */ if(getcwd(lpsDir,L_PATH)==NULL) return NULL; /* ... and determine its full path */ dlp_chdir(lpsCwd,FALSE); /* Change back to saved working dir. */ if (nMaxLen<(INT32)(dlp_strlen(lpsDir)+dlp_strlen(lpsFile)+2)) return NULL; /* Check return buffer size */ sprintf(lpsAbsPath,"%s%c%s",lpsDir,C_DIR,lpsFile); /* Create absolute path */ #ifdef _WINDOWS /* -- WINDOZE --> */ dlp_strreplace(lpsAbsPath,"\\","/"); /* Replace backslashes by slashes */ /* dlp_strlwr(lpsAbsPath); */ /* Convert to lower case */ #endif /* <-- */ if (stat(lpsAbsPath,&filestat)!=0) return NULL; /* Check file status (must exist) */ return lpsAbsPath; /* Return pointer to buffer */ }
/** * Prints the content of one record formatted as columns. If printing requires * more than <a href="dlp_base.html#cfn_dlp_maxprintcols">dlp_maxprintcols</a> * characters the listing will be continued on the next line(s).</p> * * @param _this * Pointer to data instance * @param nRec * Index of record to print * @param nIcFirst * Index of first component to print * @param nComps * Number of components to print * @param nIndent * Indentation (spaces) at beginning of lines (<b>Note</b>: the first * line will <em>not</em> be indented!) * @return The number of lines printed */ INT16 CGEN_PUBLIC CData_PrintRec ( CData* _this, INT32 nRec, INT32 nIcFirst, INT32 nComps, INT16 nIndent ) { INT16 nLines = 1; INT16 nCol = nIndent; INT32 nXC = 0; INT32 nC = 0; INT16 i = 0; INT16 I = 0; char sBuf[L_SSTR+1]; nXC = CData_GetNComps(_this); if (nIcFirst<0 || nIcFirst>=nXC) return 1; /* NOTE: This is still one line! */ if (nIcFirst+nComps>nXC) nComps=nXC-nIcFirst; if (nRec>=CData_GetNRecs(_this)) return 0; for (nC=nIcFirst,nCol=nIndent; nC<nIcFirst+nComps; nC++) { if (nRec<0) { /* Heading */ I=dlp_printlen(CData_GetCompType(_this,nC)); strcpy(sBuf," "); for (i=I-(INT16)dlp_strlen(CData_GetCname(_this,nC))-1; i>0; i--) strcat(sBuf," "); if(CData_CompIsMarked(_this,nC)) sBuf[dlp_strlen(sBuf)-2]='*'; strcat(sBuf,CData_GetCname(_this,nC)); nCol+=dlp_printlen(CData_GetCompType(_this,nC)); /* Count standard width (!) */ printf(sBuf); } else { /* Print values */ dlp_sprintx(sBuf,(char*)CData_XAddr(_this,nRec,nC),CData_GetCompType(_this,nC),_this->m_bExact); nCol+=dlp_printlen(CData_GetCompType(_this,nC)); /* Count standard width (!) */ dlp_strconvert(SC_PRC_ESCAPE,sBuf,sBuf); dlp_strreplace(sBuf,"\n","\\n"); dlp_strreplace(sBuf,"\r","\\r"); dlp_strreplace(sBuf,"\t","\\t"); printf(sBuf); } if ((nC<nIcFirst+nComps-1) && (nCol+dlp_printlen(CData_GetCompType(_this,nC+1))>dlp_maxprintcols()) ) { /* Line break */ strcpy(sBuf,"\n"); for (i=nIndent-(nIndent>7?7:0); i>0;i--) strcat(sBuf," "); printf(sBuf); if (nIndent>7) printf("%5ld ",(long)(nC+1)); nCol=nIndent; nLines++; } } return nLines; }