home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / nsprpub / pr / src / misc / prenv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  1.7 KB  |  56 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /*
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  * 
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  * 
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include <string.h>
  20. #include "primpl.h"
  21.  
  22. /* Lock used to lock the environment */
  23. #if defined(_PR_NO_PREEMPT)
  24. #define _PR_NEW_LOCK_ENV()
  25. #define _PR_LOCK_ENV()
  26. #define _PR_UNLOCK_ENV()
  27. #elif defined(_PR_LOCAL_THREADS_ONLY)
  28. #define _PR_NEW_LOCK_ENV()
  29. #define _PR_LOCK_ENV() { PRIntn _is; _PR_INTSOFF(_is)
  30. #define _PR_UNLOCK_ENV() _PR_INTSON(_is); }
  31. #else
  32. static PRLock *_pr_envLock;
  33. #define _PR_NEW_LOCK_ENV() {_pr_envLock = PR_NewLock();}
  34. #define _PR_LOCK_ENV() PR_Lock(_pr_envLock)
  35. #define _PR_UNLOCK_ENV() PR_Unlock(_pr_envLock)
  36. #endif
  37.  
  38. /************************************************************************/
  39.  
  40. void _PR_InitEnv()
  41. {
  42.     _PR_NEW_LOCK_ENV();
  43. }
  44.  
  45. PR_IMPLEMENT(char*) PR_GetEnv(const char *var)
  46. {
  47.     char *ev;
  48.  
  49.     if (!_pr_initialized) _PR_ImplicitInitialization();
  50.  
  51.     _PR_LOCK_ENV();
  52.     ev = _PR_MD_GET_ENV(var);
  53.     _PR_UNLOCK_ENV();
  54.     return ev;
  55. }
  56.