Changeset 533 for trunk/client/src/debug.c
- Timestamp:
- Jan 26, 2011, 3:31:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/src/debug.c
r508 r533 32 32 33 33 int debuglevel = 9; // we set it to 9, so we get all messages 34 char logfile[_MAX_PATH +1] = {0};35 char debugfile[_MAX_PATH +1] = {0};34 char logfile[_MAX_PATH +1]; 35 char debugfile[_MAX_PATH +1]; 36 36 char logfilename[] = "log.ndpsmb"; 37 BOOL do_logging = FALSE; 38 BOOL firstLogLine = TRUE; 37 BOOL do_logging; 38 BOOL firstLogLine; 39 HMTX logMutex; 40 char nameMutex[] = "\\SEM32\\NDPSMB"; 39 41 40 42 int debuglvl(int level) … … 48 50 } 49 51 52 void debugInit() 53 { 54 *logfile = '\0'; 55 *debugfile = '\0'; 56 do_logging = FALSE; 57 firstLogLine = TRUE; 58 logMutex = NULLHANDLE; 59 struct stat filestat; 60 APIRET rc = NO_ERROR; 61 62 // create the debugfile name 63 strncat(debugfile, getenv("ETC"), 2); 64 strncat(debugfile, "\\", sizeof(debugfile) - strlen(debugfile) -1); 65 strncat(debugfile, "ndpsmb.dbg", sizeof(debugfile) - strlen(debugfile) -1); 66 67 // is the file around? if not we have no debug 68 if (stat(debugfile, &filestat) !=0) 69 return; 70 71 //create the logfile variable 72 char *env = getenv("LOGFILES"); 73 if (env != NULL) 74 { 75 strncat(logfile, env, sizeof(logfile) -1); 76 strncat(logfile, "\\", sizeof(logfile) - strlen(logfile) -1); 77 strncat(logfile, logfilename, sizeof(logfile) - strlen(logfile) -1); 78 } 79 else 80 { 81 strncat(logfile, logfilename, sizeof(logfile) -1); 82 } 83 // set the samba logging stuff 84 do_logging = TRUE; 85 86 // now we create a sem, so that logging from different threads works 87 rc = DosCreateMutexSem(nameMutex, &logMutex, 0, FALSE); 88 if (rc == ERROR_DUPLICATE_NAME) 89 { 90 rc = DosOpenMutexSem(nameMutex, &logMutex); 91 } 92 93 return; 94 } 95 96 void debugDelete() 97 { 98 DosCloseMutexSem(logMutex); 99 return; 100 } 101 50 102 void debuglocal(int level, const char * fmt, ...) 51 103 { 52 104 FILE *f=NULL; 53 struct stat filestat;54 105 55 // do we have to log at all (not needed atm)56 /* if (!debuglvl(level))106 // do we have to log at all 107 if (!do_logging) 57 108 { 58 109 return; 59 } */110 } 60 111 61 // if the file ndpsmb.dbg is around we write a logfile62 if ( !debugfile[0])112 // if the sem is created we request it 113 if (logMutex) 63 114 { 64 strncpy(debugfile, getenv("ETC"), 2); 65 strncat(debugfile, "\\", sizeof(debugfile) - strlen(debugfile) -1); 66 strncat(debugfile, "ndpsmb.dbg", sizeof(debugfile) - strlen(debugfile) -1); 67 } /* endif */ 68 69 if (stat(debugfile, &filestat) !=0) 70 return; 71 72 //we create the logfile variable only once 73 if (!logfile[0]) 74 { 75 char *env = getenv("LOGFILES"); 76 if (env != NULL) 77 { 78 strncpy(logfile, env, sizeof(logfile) -1); 79 strncat(logfile, "\\", sizeof(logfile) - strlen(logfile) -1); 80 strncat(logfile, logfilename, sizeof(logfile) - strlen(logfile) -1); 81 } 82 else 83 { 84 strncpy(logfile, logfilename, sizeof(logfile) -1); 85 } 86 // set the samba logging stuff 87 do_logging = TRUE; 88 } /* endif */ 115 DosRequestMutexSem(logMutex, (ULONG) SEM_INDEFINITE_WAIT); 116 } 89 117 90 118 do … … 121 149 if (logfile) 122 150 { 123 fclose(f); 151 // fflush(f); 152 fclose(f); 124 153 } 125 154 } 126 155 while (0); 156 157 // if the sem is created we release it 158 if (logMutex) 159 { 160 DosReleaseMutexSem(logMutex); 161 } 162 163 return; 127 164 }
Note:
See TracChangeset
for help on using the changeset viewer.