dsdploginfo.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include <stdarg.h>
00007 #include <sys/types.h>
00008 #include <stdlib.h>
00009 #include <malloc.h>
00010 #include "dsdpsys.h"
00011 #include "dsdpbasictypes.h"
00012
00013 #define DSDP_NULL 0
00014 #define DSDP_MAX_PATH_LEN 200
00015
00021 typedef void* DSDPObject;
00022
00023
00024
00025 static FILE *dsdp_history=0;
00026
00027
00028
00029
00030
00031
00032
00033
00034 static int DSDPLogPrintInfo = 0;
00035 static int DSDPLogPrintInfoNull = 0;
00036 static FILE *DSDPLogInfoFile = DSDP_NULL;
00037 static int rank=0;
00038
00039 void DSDPSetRank(int rrank){
00040 rank=rrank;
00041 return;
00042 }
00043
00044 #undef __FUNCT__
00045 #define __FUNCT__ "DSDPLogInfoAllow"
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 int DSDPLogInfoAllow(int flag, char *filename)
00068 {
00069 char fname[DSDP_MAX_PATH_LEN], tname[5];
00070 int prank=0;
00071 char* ierr;
00072
00073 DSDPFunctionBegin;
00074 if (flag && filename) {
00075 sprintf(tname, ".%d", prank);
00076 ierr = strcat(fname, tname);
00077 } else if (flag) {
00078 DSDPLogInfoFile = stdout;
00079 }
00080 DSDPLogPrintInfo = flag;
00081 DSDPLogPrintInfoNull = flag;
00082 DSDPFunctionReturn(0);
00083 }
00084
00085 #undef __FUNCT__
00086 #define __FUNCT__ "DSDPLogInfo"
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 void DSDPLogFInfo(void *vobj, int outlevel, const char message[], ...)
00113 {
00114 va_list Argp;
00115 int urank;
00116 size_t len;
00117 char string[8*1024];
00118
00119 DSDPFunctionBegin;
00120 DSDPLogInfoFile = stdout;
00121 if (DSDPLogPrintInfo < outlevel) return;
00122 if ((DSDPLogPrintInfoNull < outlevel) && !vobj) return;
00123
00124 urank = 0;
00125 if (rank>0) return;
00126
00127 va_start(Argp, message);
00128 sprintf(string, "[%d][%2d] DSDP: ", rank,outlevel);
00129 len = strlen(string);
00130 #if defined(DSDP_HAVE_VPRINTF_CHAR)
00131 vsprintf(string+len, message, (char *) Argp);
00132 #else
00133 vsprintf(string+len, message, Argp);
00134 #endif
00135 fprintf(DSDPLogInfoFile, "%s", string);
00136 fflush(DSDPLogInfoFile);
00137 if (dsdp_history) {
00138 #if defined(DSDP_HAVE_VPRINTF_CHAR)
00139 vfprintf(dsdp_history, message, (char *) Argp);
00140 #else
00141 vfprintf(dsdp_history, message, Argp);
00142 #endif
00143 }
00144 va_end(Argp);
00145 return;
00146
00147 }