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,len;
00116 char string[8*1024];
00117
00118 DSDPFunctionBegin;
00119 DSDPLogInfoFile = stdout;
00120 if (DSDPLogPrintInfo < outlevel) return;
00121 if ((DSDPLogPrintInfoNull < outlevel) && !vobj) return;
00122
00123 urank = 0;
00124 if (rank>0) return;
00125
00126 va_start(Argp, message);
00127 sprintf(string, "[%d][%2d] DSDP: ", rank,outlevel);
00128 len = strlen(string);
00129 #if defined(DSDP_HAVE_VPRINTF_CHAR)
00130 vsprintf(string+len, message, (char *) Argp);
00131 #else
00132 vsprintf(string+len, message, Argp);
00133 #endif
00134 fprintf(DSDPLogInfoFile, "%s", string);
00135 fflush(DSDPLogInfoFile);
00136 if (dsdp_history) {
00137 #if defined(DSDP_HAVE_VPRINTF_CHAR)
00138 vfprintf(dsdp_history, message, (char *) Argp);
00139 #else
00140 vfprintf(dsdp_history, message, Argp);
00141 #endif
00142 }
00143 va_end(Argp);
00144 return;
00145
00146 }