NCBI C Toolkit Cross Reference

C/connect/ncbi_priv.c


  1 /* $Id: ncbi_priv.c,v 6.14 2008/12/01 16:34:35 kazimird Exp $
  2  * ===========================================================================
  3  *
  4  *                            PUBLIC DOMAIN NOTICE
  5  *               National Center for Biotechnology Information
  6  *
  7  *  This software/database is a "United States Government Work" under the
  8  *  terms of the United States Copyright Act.  It was written as part of
  9  *  the author's official duties as a United States Government employee and
 10  *  thus cannot be copyrighted.  This software/database is freely available
 11  *  to the public for use. The National Library of Medicine and the U.S.
 12  *  Government have not placed any restriction on its use or reproduction.
 13  *
 14  *  Although all reasonable efforts have been taken to ensure the accuracy
 15  *  and reliability of the software and data, the NLM and the U.S.
 16  *  Government do not and cannot warrant the performance or results that
 17  *  may be obtained by using this software or data. The NLM and the U.S.
 18  *  Government disclaim all warranties, express or implied, including
 19  *  warranties of performance, merchantability or fitness for any particular
 20  *  purpose.
 21  *
 22  *  Please cite the author in any work or product based on this material.
 23  *
 24  * ===========================================================================
 25  *
 26  * Author:  Denis Vakatov
 27  *
 28  * File Description:
 29  *   Private aux. code for the "ncbi_*.[ch]"
 30  *
 31  */
 32 
 33 #include "ncbi_priv.h"
 34 #if defined(NCBI_OS_UNIX)
 35 #  include <unistd.h>
 36 #elif defined(NCBI_OS_MSWIN)
 37 #  include <windows.h>
 38 #else
 39 #  include <connect/ncbi_socket.h>
 40 #endif /*NCBI_OS_...*/
 41 #include <stdarg.h>
 42 #include <stdlib.h>
 43 #include <string.h>
 44 
 45 
 46 int     g_NCBI_ConnectRandomSeed = 0;
 47 
 48 MT_LOCK g_CORE_MT_Lock           = 0;
 49 LOG     g_CORE_Log               = 0;
 50 REG     g_CORE_Registry          = 0;
 51 
 52 
 53 extern int g_NCBI_ConnectSrandAddend(void)
 54 {
 55 #if   defined(NCBI_OS_UNIX)
 56     return (int) getpid(); 
 57 #elif defined(NCBI_OS_MSWIN)
 58     return (int) GetCurrentProcessId();
 59 #else
 60     return SOCK_GetLocalHostAddress(eDefault);
 61 #endif /*NCBI_OS_...*/ 
 62 }
 63 
 64 
 65 extern const char* g_CORE_Sprintf(const char* fmt, ...)
 66 {
 67     static const size_t buf_size = 4096;
 68     char*   buf;
 69     va_list args;
 70 
 71     if (!(buf = (char*) malloc(buf_size)))
 72         return 0;
 73     *buf = '\0';
 74 
 75     va_start(args, fmt);
 76 #ifdef HAVE_VSNPRINTF
 77     vsnprintf(buf, buf_size, fmt, args);
 78 #else
 79     vsprintf (buf,           fmt, args);
 80 #endif /*HAVE_VSNPRINTF*/
 81     assert(strlen(buf) < buf_size);
 82     va_end(args);
 83     return buf;
 84 }
 85 
 86 
 87 extern const char* g_CORE_RegistryGET
 88 (const char* section,
 89  const char* name,
 90  char*       value,
 91  size_t      value_size,
 92  const char* def_value)
 93 {
 94     const char* ret_value;
 95     CORE_LOCK_READ;
 96     ret_value = REG_Get(g_CORE_Registry,
 97                         section, name, value, value_size, def_value);
 98     CORE_UNLOCK;
 99     return ret_value;
100 }
101 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.