diff options
author | Aaron M. Ucko <ucko@debian.org> | 2005-03-23 21:07:58 +0000 |
---|---|---|
committer | Aaron M. Ucko <ucko@debian.org> | 2005-03-23 21:07:58 +0000 |
commit | 992f39042271801456458b4d5103f9b440ba2a04 (patch) | |
tree | a2fc36299881d556d0e8ecf2c51c61645f0810c3 /corelib | |
parent | fad8f0472dfd8f5cf5b1c0d5bc4d79b83cef69d8 (diff) |
Load ncbi (6.1.20021119) into ncbi-tools6/branches/upstream/current.
Diffstat (limited to 'corelib')
-rw-r--r-- | corelib/ncbiargs.c | 6 | ||||
-rw-r--r-- | corelib/ncbienv.c | 7 | ||||
-rw-r--r-- | corelib/ncbierr.c | 11 | ||||
-rw-r--r-- | corelib/ncbifile.c | 48 | ||||
-rw-r--r-- | corelib/ncbilcl.lnx | 40 | ||||
-rw-r--r-- | corelib/ncbimem.c | 14 | ||||
-rw-r--r-- | corelib/ncbimisc.c | 9 | ||||
-rw-r--r-- | corelib/ncbisgml.c | 9 |
8 files changed, 120 insertions, 24 deletions
diff --git a/corelib/ncbiargs.c b/corelib/ncbiargs.c index 01ab1c8a..d71e4f59 100644 --- a/corelib/ncbiargs.c +++ b/corelib/ncbiargs.c @@ -35,6 +35,9 @@ * Modifications: * -------------------------------------------------------------------------- * $Log: ncbiargs.c,v $ +* Revision 6.7 2002/11/06 21:22:32 ucko +* Accept "--help" as a synonym for the less intuitive "-" +* * Revision 6.6 2001/07/03 20:03:11 juran * Don't corruptly parse argv in Mac OS. * @@ -165,7 +168,8 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname, return TRUE; } - if (xx_argc == 1 || *(xx_argv[1]+1) == '\0') + if (xx_argc == 1 || *(xx_argv[1]+1) == '\0' + || !strcmp(xx_argv[1], "--help")) { printf("\n%s arguments:\n\n", progname); curarg = ap; diff --git a/corelib/ncbienv.c b/corelib/ncbienv.c index 4f646909..5181337a 100644 --- a/corelib/ncbienv.c +++ b/corelib/ncbienv.c @@ -29,7 +29,7 @@ * * Version Creation Date: 7/7/91 * -* $Revision: 6.26 $ +* $Revision: 6.27 $ * * File Description: * portable environment functions, companions for ncbimain.c @@ -37,6 +37,9 @@ * Modifications: * -------------------------------------------------------------------------- * $Log: ncbienv.c,v $ +* Revision 6.27 2002/10/03 16:22:03 kans +* changed fgets to Nlm_FileGets +* * Revision 6.26 2002/03/28 13:29:08 kans * checks for OS_UNIX_DARWIN (EN) * @@ -1036,7 +1039,7 @@ static Nlm_Boolean Nlm_ReadConfigFile(FILE* fp) eip = NULL; lastEip = NULL; comment = NULL; - while (fgets (str, sizeof (str), fp)) { + while (Nlm_FileGets (str, sizeof (str), fp)) { ch = *str; if (ch != '\n' && ch != '\r') { if (ch == ';') { /* comment */ diff --git a/corelib/ncbierr.c b/corelib/ncbierr.c index a66b2844..d698e441 100644 --- a/corelib/ncbierr.c +++ b/corelib/ncbierr.c @@ -23,9 +23,9 @@ * * =========================================================================== * -* $Id: ncbierr.c,v 6.19 2002/08/13 20:44:19 lavr Exp $ +* $Id: ncbierr.c,v 6.20 2002/10/03 16:22:03 kans Exp $ * -* $Revision: 6.19 $ +* $Revision: 6.20 $ * * Authors: Schuler, Sirotkin (UserErr stuff) * @@ -71,6 +71,9 @@ * 03-06-95 Schuler Fixed problem with ErrMsgRoot_fopen * * $Log: ncbierr.c,v $ +* Revision 6.20 2002/10/03 16:22:03 kans +* changed fgets to Nlm_FileGets +* * Revision 6.19 2002/08/13 20:44:19 lavr * Force logging to stderr/stdout if DEBUG_PRINTOUT env.var. is set as follows: * STDOUT (case-insensitively) - log to stdout; anything else - log to stderr. @@ -1005,7 +1008,7 @@ static int ErrMsgRoot_Read (ErrMsgRoot *idx) int any_comt; /* ----- Look for MODULE line ----- */ - while (fgets(line,sizeof line,fd)) + while (Nlm_FileGets(line,sizeof line,fd)) { linenum++; if ( strchr("#\r\n", line[0]) ) @@ -1032,7 +1035,7 @@ static int ErrMsgRoot_Read (ErrMsgRoot *idx) lev1 = lev2 = NULL; tmpofs = ftell(fd); - while (fgets(line,sizeof line,fd)) + while (Nlm_FileGets(line,sizeof line,fd)) { linenum++; diff --git a/corelib/ncbifile.c b/corelib/ncbifile.c index 975a5671..7a371a67 100644 --- a/corelib/ncbifile.c +++ b/corelib/ncbifile.c @@ -29,7 +29,7 @@ * * Version Creation Date: 3/4/91 * -* $Revision: 6.25 $ +* $Revision: 6.28 $ * * File Description: * portable file routines @@ -43,6 +43,15 @@ * 11-27-94 Ostell moved includes to ncbiwin.h to avoid conflict MSC * * $Log: ncbifile.c,v $ +* Revision 6.28 2002/11/06 21:23:04 ucko +* Don't assume MIPS is IRIX; allow Linux too. +* +* Revision 6.27 2002/10/03 17:22:29 kans +* for OS_MAC or OS_UNIX_DARWIN, Nlm_FileGets does fgetc loop, stopping at the first \n or \r character, and leaving a \n as the last character before the null byte +* +* Revision 6.26 2002/10/02 14:34:17 kans +* Nlm_GetOSType and Nlm_FileCreate have ifdef OS_MAC, not WIN_MAC +* * Revision 6.25 2002/06/13 16:14:07 kans * fix includes for OS_UNIX_DARWIN with WIN_MAC (EN) * @@ -183,7 +192,7 @@ Removed disabled CD routines. #define DEFAULT_RAW_CDROM "/dev/rsr0" #endif -#ifdef PROC_MIPS +#if defined(PROC_MIPS) && !defined(OS_UNIX_LINUX) #define DEFAULT_CDROM "/dev/scsi/sc0d4l0" #endif @@ -722,9 +731,36 @@ NLM_EXTERN int LIBCALL Nlm_FilePuts (const char *ptr, FILE *fp) *****************************************************************************/ NLM_EXTERN char * LIBCALL Nlm_FileGets (Nlm_CharPtr ptr, size_t size, FILE *fp) { - if ((ptr == NULL) || (size <= 0) || (fp == NULL)) +#if defined(OS_MAC) || defined (OS_UNIX_DARWIN) + int ch; + int count; + Nlm_CharPtr tmp; +#endif + + if ((ptr == NULL) || (size < 1) || (fp == NULL)) return NULL; +#if defined(OS_MAC) || defined (OS_UNIX_DARWIN) + ch = fgetc (fp); + count = 0; + tmp = ptr; + while (ch != EOF && ch != '\0' && ch != '\n' && ch != '\r' && count < size - 1) { + *tmp = ch; + tmp++; + count++; + ch = fgetc (fp); + } + if (ch == '\n' || ch == '\r') { + *tmp = '\n'; + tmp++; + count++; + } + *tmp = '\0'; + if (count < 1) + return NULL; + return ptr; +#else return fgets(ptr,size,fp); +#endif } @@ -939,7 +975,7 @@ NLM_EXTERN Nlm_Boolean LIBCALL Nlm_FileRename (Nlm_CharPtr oldFileName, Nlm_Char * FileCreate() * *****************************************************************************/ -#ifdef WIN_MAC +#ifdef OS_MAC static OSType Nlm_GetOSType (Nlm_CharPtr str, OSType dfault) { @@ -956,7 +992,7 @@ static OSType Nlm_GetOSType (Nlm_CharPtr str, OSType dfault) NLM_EXTERN void LIBCALL Nlm_FileCreate (Nlm_CharPtr fileName, Nlm_CharPtr type, Nlm_CharPtr creator) { -#ifdef WIN_MAC +#ifdef OS_MAC Nlm_Int2 fError; Nlm_Char temp [256]; OSType fType; @@ -968,7 +1004,7 @@ NLM_EXTERN void LIBCALL Nlm_FileCreate (Nlm_CharPtr fileName, Nlm_CharPtr type, if (fileName != NULL && fileName [0] != '\0') { -#ifdef WIN_MAC +#ifdef OS_MAC // note: the following assumes either full pathname or that the current // directory is the proper location to find/create the file diff --git a/corelib/ncbilcl.lnx b/corelib/ncbilcl.lnx index af65e198..e0cd2a52 100644 --- a/corelib/ncbilcl.lnx +++ b/corelib/ncbilcl.lnx @@ -29,7 +29,7 @@ * * Version Creation Date: 8/1/94 * -* $Revision: 6.6 $ +* $Revision: 6.7 $ * * File Description: * system dependent header @@ -38,6 +38,10 @@ * Modifications: * -------------------------------------------------------------------------- * $Log: ncbilcl.lnx,v $ +* Revision 6.7 2002/11/06 21:23:47 ucko +* Handle non-i386 platforms. +* Enable large file support here, to ensure consistency. +* * Revision 6.6 2002/07/11 22:13:06 vakatov * #define MMAP_AVAIL * @@ -71,7 +75,31 @@ #define COMP_SYSV #define OS_UNIX #define OS_UNIX_LINUX +#if defined(__alpha__) || #cpu(alpha) || #machine(alpha) +#define PROC_ALPHA +#elif defined(__arm__) || #cpu(arm) || #machine(arm) +#define PROC_ARM /* ? (only occurrence) */ +#elif defined(__hppa__) || #cpu(hppa) || #machine(hppa) +#define PROC_HPPA +#elif defined(__i386__) || #cpu(i386) || #machine(i386) #define PROC_I80X86 +#elif defined(__ia64__) || #cpu(ia64) || #machine(ia64) +#define PROC_IA64 /* ? */ +#elif defined(m68k) || defined(mc68000) || #cpu(m68k) || #machine(m68k) +#define PROC_MC680X0 +#elif defined(__mips__) || defined(_mips) || #cpu(mips) || #machine(mips) +#define PROC_MIPS +#elif defined(__powerpc__) || defined(__PPC__) || #cpu(powerpc) || #machine(powerpc) +#define PROC_PPC +#elif defined(__s390__) || #cpu(s390) || #machine(s390) +#define PROC_S390 /* ? */ +#elif defined(__sh__) || #cpu(sh) || #machine(sh) +#define PROC_SH /* ? */ +#elif defined(__sparc__) || #cpu(sparc) || #cpu(sparc64) || #machine(sparc) || #machine(sparc64) +#define PROC_SPARC +#else +#warning Unknown processor type. Please define something appropriate. +#endif #define WIN_DUMB /*----------------------------------------------------------------------*/ @@ -86,6 +114,11 @@ #define _POSIX_C_SOURCE 199309L #define _XOPEN_SOURCE 500 +/* Only effective on glibc 2.1 and newer. */ +#define _LARGEFILE_SOURCE 1 +#define _LARGEFILE64_SOURCE 1 +#define _FILE_OFFSET_BITS 64 /* Should be safe, I think... */ + #ifndef _REENTRANT #define _REENTRANT #endif @@ -148,7 +181,12 @@ #define KBYTE (1024) #define MBYTE (1048576) +#include <endian.h> +#if __BYTE_ORDER == __LITTLE_ENDIAN #define IS_LITTLE_ENDIAN +#else +#define IS_BIG_ENDIAN +#endif #define TEMPNAM_AVAIL #define HAVE_MADVISE diff --git a/corelib/ncbimem.c b/corelib/ncbimem.c index fb4af3f1..af2dec13 100644 --- a/corelib/ncbimem.c +++ b/corelib/ncbimem.c @@ -29,7 +29,7 @@ * * Version Creation Date: 6/4/91 * -* $Revision: 6.22 $ +* $Revision: 6.24 $ * * File Description: * portable memory handlers for Mac, PC, Unix @@ -37,6 +37,12 @@ * Modifications: * -------------------------------------------------------------------------- * $Log: ncbimem.c,v $ +* Revision 6.24 2002/11/06 21:24:35 ucko +* Make sure MADV_NORMAL is actually defined before trying to use madvise. +* +* Revision 6.23 2002/10/28 20:19:56 kans +* removed C++ style comment +* * Revision 6.22 2002/07/11 22:14:31 vakatov * [LINUX, MMAP_AVAIL] #define __USE_BSD to get MADV_*** constants * @@ -922,7 +928,7 @@ NLM_EXTERN void Nlm_MemMapFini(Nlm_MemMapPtr mem_mapp) NLM_EXTERN Nlm_Boolean Nlm_MemMapAdvise(void* addr, size_t len, EMemMapAdvise advise) { -#if defined(HAVE_MADVISE) +#if defined(HAVE_MADVISE) && defined(MADV_NORMAL) int adv; if (!addr || !len) { return FALSE; @@ -939,7 +945,7 @@ NLM_EXTERN Nlm_Boolean Nlm_MemMapAdvise(void* addr, size_t len, EMemMapAdvise ad default: adv = MADV_NORMAL; } - // Conversion type of "addr" to char* -- Sun Solaris fix + /* Conversion type of "addr" to char* -- Sun Solaris fix */ return madvise((char*)addr, len, adv) == 0; #else return TRUE; @@ -949,7 +955,7 @@ NLM_EXTERN Nlm_Boolean Nlm_MemMapAdvise(void* addr, size_t len, EMemMapAdvise ad NLM_EXTERN Nlm_Boolean Nlm_MemMapAdvisePtr(Nlm_MemMapPtr ptr, EMemMapAdvise advise) { -#if defined(HAVE_MADVISE) +#if defined(HAVE_MADVISE) && defined(MADV_NORMAL) return ptr ? Nlm_MemMapAdvise(ptr->mmp_begin, ptr->file_size, advise) : FALSE; #else return TRUE; diff --git a/corelib/ncbimisc.c b/corelib/ncbimisc.c index 56e8f06c..2ff56458 100644 --- a/corelib/ncbimisc.c +++ b/corelib/ncbimisc.c @@ -29,7 +29,7 @@ * * Version Creation Date: 10/23/91 * -* $Revision: 6.22 $ +* $Revision: 6.23 $ * * File Description: * miscellaneous functions @@ -43,6 +43,9 @@ * 02-16-94 Epstein Retired Gestalt functions and definitions * * $Log: ncbimisc.c,v $ +* Revision 6.23 2002/11/06 21:25:10 ucko +* Don't assume MIPS is IRIX, or HPPA is HP/UX; allow Linux too, for both. +* * Revision 6.22 2002/06/13 16:14:07 kans * fix includes for OS_UNIX_DARWIN with WIN_MAC (EN) * @@ -1692,11 +1695,11 @@ NLM_EXTERN const Nlm_Char* Nlm_PlatformName(void) return "Cray"; # elif defined(PROC_CONVEX) return "Convex"; -# elif defined(PROC_HPPA) +# elif defined(PROC_HPPA) && !defined(OS_UNIX_LINUX) return "HPUX"; # elif defined(OS_UNIX_NEXT) return "NEXT"; -# elif defined(PROC_MIPS) +# elif defined(PROC_MIPS) && !defined(OS_UNIX_LINUX) return "SGI_MIPS"; # elif defined(OS_UNIX_ULTRIX) return "ULTRIX"; diff --git a/corelib/ncbisgml.c b/corelib/ncbisgml.c index df47c50f..e9d8dce5 100644 --- a/corelib/ncbisgml.c +++ b/corelib/ncbisgml.c @@ -29,7 +29,7 @@ * * Version Creation Date: 10/23/91 * -* $Revision: 6.1 $ +* $Revision: 6.2 $ * * File Description: * miscellaneous functions @@ -43,6 +43,9 @@ * * * $Log: ncbisgml.c,v $ +* Revision 6.2 2002/10/03 16:22:04 kans +* changed fgets to Nlm_FileGets +* * Revision 6.1 1997/10/29 02:44:35 vakatov * Type castings to pass through the C++ compiler * @@ -103,7 +106,7 @@ NLM_EXTERN int LIBCALL Nlm_SgmlLoadTable (void) if ((fp = FileOpen(buf,"r")) ==NULL) return FALSE; - if (!fgets(buf,sizeof buf,fp)) + if (!Nlm_FileGets(buf,sizeof buf,fp)) { ErrPostEx(SEV_WARNING,E_SGML,1,"Error reading file [sgmlbb.ent]"); return FALSE; @@ -113,7 +116,7 @@ NLM_EXTERN int LIBCALL Nlm_SgmlLoadTable (void) sgml_ascii = (char**) MemNew(x * sizeof(char*)); for (i = 0; i < x; i++) { - if ((p1 = fgets(buf,sizeof buf,fp)) == NULL) break; + if ((p1 = Nlm_FileGets(buf,sizeof buf,fp)) == NULL) break; while ((*p1 < ' ') && (*p1 != '\0')) p1++; /* skip any leading junk */ if (*p1 == '\0') break; if ( (p2 = strchr(p1,'\t')) == NULL ) break; |