home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 11.ddi / OWLSRC.PAK / OWLDIAG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  1.6 KB  |  59 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows - (C) Copyright 1991, 1993 by Borland International
  3. //   source\owl\owldiag.cpp
  4. //   Implementation of OWL diagnostics
  5. //----------------------------------------------------------------------------
  6. #include <owl\owlpch.h>
  7. #include <owl\point.h>
  8. #include <string.h>
  9. #include <stdlib.h>
  10.  
  11. static const char Section[] = "Diagnostics";
  12. static int InitialCheck = 0;
  13. static int DiagsAreEnabled = 0;
  14.  
  15. //
  16. // Retrieve a diag's enabled flag from a private .ini file. Master enable
  17. // switch overrides. .ini file is searched for along cwd, windowsdir, 
  18. // windowsystemdir, path, mapped network dirs.
  19. //
  20. uint8 _OWLFUNC
  21. GetDiagEnabled(char* file, char* name, uint8 e)
  22. {
  23.   char buf[32];
  24.  
  25.   OFSTRUCT ofs;
  26.   ofs.cBytes = sizeof ofs;
  27.   OpenFile(file, &ofs, OF_EXIST);
  28.   
  29.   if (!InitialCheck) {
  30.     InitialCheck = 1;
  31.     GetPrivateProfileString(Section, "Enabled", "0", buf, sizeof(buf), ofs.szPathName);
  32.     DiagsAreEnabled = atoi(buf);
  33.   }
  34.   if (!DiagsAreEnabled)
  35.     return 0;
  36.   
  37.   GetPrivateProfileString(Section, name, "", buf, sizeof(buf), ofs.szPathName);
  38.   char *pe = strtok(buf, " ");
  39.   return pe ? uint8(atoi(pe)) : e;
  40. }
  41.  
  42. //
  43. // Retrieve a diag's level setting from a private .ini file.
  44. //
  45. uint8 _OWLFUNC
  46. GetDiagLevel(char* file, char* name, uint8 l)
  47. {
  48.   char buf[32];
  49.  
  50.   OFSTRUCT ofs;
  51.   ofs.cBytes = sizeof ofs;
  52.   OpenFile(file, &ofs, OF_EXIST);
  53.  
  54.   GetPrivateProfileString(Section, name, "", buf, sizeof(buf), ofs.szPathName);
  55.   strtok(buf, " ");
  56.   char *pl = strtok(0, " ");
  57.   return pl ? uint8(atoi(pl)) : l;
  58. }
  59.