home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / owlsrc.pak / OWLDIAG.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  1.6 KB  |  60 lines

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