summaryrefslogtreecommitdiff
path: root/corelib
diff options
context:
space:
mode:
authorAaron M. Ucko <ucko@debian.org>2007-09-05 15:33:43 +0000
committerAaron M. Ucko <ucko@debian.org>2007-09-05 15:33:43 +0000
commit7647e504b18f91edcedba85e7a6ef772b2a0f48b (patch)
tree6152f91efe8f30174ce9d51525a458b85335f12b /corelib
parentb0629a94e882461a9d6cab18807c5f96501cf38f (diff)
[svn-upgrade] Integrating new upstream version, ncbi-tools6 (6.1.20070822)
Diffstat (limited to 'corelib')
-rw-r--r--corelib/drwnmfls.c2
-rw-r--r--corelib/ncbiargs.c114
-rw-r--r--corelib/ncbienv.c91
-rw-r--r--corelib/ncbierr.c9
-rw-r--r--corelib/ncbifile.c88
-rw-r--r--corelib/ncbifile.h19
-rw-r--r--corelib/ncbilcl.dwn12
-rw-r--r--corelib/ncbimisc.c45
-rw-r--r--corelib/ncbimisc.h48
-rw-r--r--corelib/ncbimsg.c22
-rw-r--r--corelib/ncbistr.c29
-rw-r--r--corelib/ncbistr.h9
-rw-r--r--corelib/ncbitime.c21
-rw-r--r--corelib/ncbiwin.h12
-rw-r--r--corelib/ncbiwww.h11
-rw-r--r--corelib/tsprintf.c34
16 files changed, 442 insertions, 124 deletions
diff --git a/corelib/drwnmfls.c b/corelib/drwnmfls.c
index fb69b829..144d7692 100644
--- a/corelib/drwnmfls.c
+++ b/corelib/drwnmfls.c
@@ -7,4 +7,4 @@
#endif
#if defined(OS_MAC) || defined(OS_UNIX_DARWIN_OLD)
# include "MoreFilesX.c"
-#endif \ No newline at end of file
+#endif
diff --git a/corelib/ncbiargs.c b/corelib/ncbiargs.c
index 68217b3f..ea2f24d2 100644
--- a/corelib/ncbiargs.c
+++ b/corelib/ncbiargs.c
@@ -35,6 +35,12 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbiargs.c,v $
+* Revision 6.10 2006/10/19 14:57:03 lavr
+* Fix repetitive arg error message to show no argument value since it's empty
+*
+* Revision 6.9 2006/10/18 19:15:43 lavr
+* Allow repetitive (boolean) flags to increment arg's intvalue [spec.cased]
+*
* Revision 6.8 2004/04/01 13:43:06 lavr
* Spell "occurred", "occurrence", and "occurring"
*
@@ -125,10 +131,10 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname,
Nlm_FreeArgs(i, ap);
return FALSE;
}
- curarg->intvalue = 0;
+ curarg->intvalue = 0;
curarg->floatvalue = 0.0;
- curarg->strvalue = NULL;
- if (curarg->defaultvalue != NULL)
+ curarg->strvalue = NULL;
+ if (curarg->defaultvalue)
{
resolved[i] = TRUE;
switch (curarg->type)
@@ -139,24 +145,18 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname,
else
curarg->intvalue = 0;
break;
- case ARG_INT: {
- long val;
- sscanf(curarg->defaultvalue, "%ld", &val);
- curarg->intvalue = val;
+ case ARG_INT:
+ curarg->intvalue = atol(curarg->defaultvalue);
break;
- }
- case ARG_FLOAT: {
- double val;
- sscanf(curarg->defaultvalue, "%lf", &val);
- curarg->floatvalue = val;
+ case ARG_FLOAT:
+ curarg->floatvalue = atof(curarg->defaultvalue);
break;
- }
case ARG_STRING:
case ARG_FILE_IN:
case ARG_FILE_OUT:
case ARG_DATA_IN:
case ARG_DATA_OUT:
- curarg->strvalue = StringSave (curarg->defaultvalue);
+ curarg->strvalue = StringSave(curarg->defaultvalue);
break;
}
}
@@ -184,17 +184,21 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname,
if (curarg->optional)
printf(" Optional");
printf("\n");
- if (curarg->defaultvalue != NULL)
+ if (curarg->defaultvalue)
printf(" default = %s\n", curarg->defaultvalue);
- if ((curarg->from != NULL) || (curarg->to != NULL))
+ if (curarg->from || curarg->to)
{
- if ((curarg->type == ARG_DATA_IN) ||
- (curarg->type == ARG_DATA_OUT))
+ if (curarg->type == ARG_DATA_IN ||
+ curarg->type == ARG_DATA_OUT)
printf(" Data Type = %s\n", curarg->from);
- else
- printf(" range from %s to %s\n",
- (curarg->from ? curarg->from: "<NULL>"),
- (curarg->to ? curarg->to : "<NULL>"));
+ else if (curarg->type == ARG_BOOLEAN ||
+ curarg->type == ARG_INT ||
+ curarg->type == ARG_FLOAT)
+ {
+ printf(" range from %s to %s\n",
+ (curarg->from ? curarg->from: "?"),
+ (curarg->to ? curarg->to : "?"));
+ }
}
}
@@ -260,7 +264,7 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname,
if (!ok && curarg->type != ARG_BOOLEAN)
{
ErrPostEx(SEV_ERROR, 0, 0,
- "No argument given for %s", curarg->prompt);
+ "No argument value given for %s", curarg->prompt);
Nlm_MemFree( resolved );
Nlm_FreeArgs(numargs, ap);
return FALSE;
@@ -276,15 +280,38 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname,
else if (TO_UPPER(*arg) == 'F')
curarg->intvalue = 0;
else if (*arg == '\0')
- curarg->intvalue = 1;
- else {
- ErrPostEx(SEV_ERROR, 0, 0,
- "%s [%s] must be one of {'T', 't', 'F', 'f'} or omitted",
- curarg->prompt, arg);
- Nlm_MemFree( resolved );
- Nlm_FreeArgs(numargs, ap);
- return FALSE;
- }
+ {
+ long idef, ifrom, ito;
+ if (curarg->from && curarg->to &&
+ sscanf(curarg->defaultvalue, "%ld", &idef) > 0 &&
+ sscanf(curarg->from, "%ld", &ifrom) > 0 &&
+ sscanf(curarg->to, "%ld", &ito) > 0 &&
+ idef == 0 && ifrom == 0 && ito > 1)
+ {
+ if (curarg->intvalue >= ito)
+ {
+ ErrPostEx(SEV_ERROR, 0, 0,
+ "%s allowed no more than %s times",
+ curarg->prompt, curarg->to);
+ Nlm_MemFree( resolved );
+ Nlm_FreeArgs(numargs, ap);
+ return FALSE;
+ }
+ else
+ curarg->intvalue++;
+ }
+ else
+ curarg->intvalue = 1;
+ }
+ else
+ {
+ ErrPostEx(SEV_ERROR, 0, 0,
+ "%s [%s] must be one of {'T', 't', 'F', 'f'}"
+ " or omitted", curarg->prompt, arg);
+ Nlm_MemFree( resolved );
+ Nlm_FreeArgs(numargs, ap);
+ return FALSE;
+ }
break;
case ARG_INT: {
@@ -293,21 +320,14 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname,
if (sscanf(arg, "%ld", &val) <= 0)
range = FALSE;
curarg->intvalue = val;
- if (range && curarg->from)
+ if (range && curarg->from && curarg->intvalue < atol(curarg->from))
{
- long ifrom;
- sscanf(curarg->from, "%ld", &ifrom);
- if (curarg->intvalue < ifrom)
range = FALSE;
}
- if (range && curarg->to)
+ if (range && curarg->to && curarg->intvalue > atol(curarg->to))
{
- long ito;
- sscanf(curarg->to, "%ld", &ito);
- if (curarg->intvalue > ito)
range = FALSE;
}
-
if ( !range )
{
ErrPostEx(SEV_ERROR, 0, 0,
@@ -328,18 +348,12 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname,
if (sscanf(arg, "%lf", &val) <= 0)
range = FALSE;
curarg->floatvalue = val;
- if (range && curarg->from)
+ if (range && curarg->from && curarg->floatvalue < atof(curarg->from))
{
- double ffrom;
- sscanf(curarg->from, "%lf", &ffrom);
- if (curarg->floatvalue < ffrom)
range = FALSE;
}
- if (range && curarg->to)
+ if (range && curarg->to && curarg->floatvalue > atof(curarg->to))
{
- double fto;
- sscanf(curarg->to, "%lf", &fto);
- if (curarg->floatvalue > fto)
range = FALSE;
}
if ( !range )
@@ -363,7 +377,7 @@ NLM_EXTERN Nlm_Boolean Nlm_GetArgs(const char* progname,
case ARG_DATA_OUT:
if ( curarg->strvalue )
MemFree(curarg->strvalue);
- curarg->strvalue = StringSave (arg);
+ curarg->strvalue = StringSave(arg);
break;
} /*** end switch ****/
}
diff --git a/corelib/ncbienv.c b/corelib/ncbienv.c
index 9529e122..1ae09269 100644
--- a/corelib/ncbienv.c
+++ b/corelib/ncbienv.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 7/7/91
*
-* $Revision: 6.43 $
+* $Revision: 6.46 $
*
* File Description:
* portable environment functions, companions for ncbimain.c
@@ -37,6 +37,15 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbienv.c,v $
+* Revision 6.46 2007/05/04 13:43:59 kans
+* GetOpSysString now checks for Windows VISTA
+*
+* Revision 6.45 2007/04/06 21:47:56 kans
+* Nlm_GetOpSysString checks gestaltSystemVersion and returns actual Mac OS X version
+*
+* Revision 6.44 2007/04/03 00:39:41 kans
+* GetOpSysString does run-time check for Rosetta
+*
* Revision 6.43 2005/12/02 13:40:00 rsmith
* In ProgramPath on Mac use case-insensitive compare to check the file extension.
*
@@ -2396,9 +2405,22 @@ NLM_EXTERN Nlm_Boolean Nlm_FreeArgs(Nlm_Int2 numargs, Nlm_ArgPtr ap)
return TRUE;
}
+#ifdef OS_UNIX_DARWIN
+#include <sys/sysctl.h>
+#endif
+
NLM_EXTERN Nlm_CharPtr Nlm_GetOpSysString (void)
{
+#ifdef OS_UNIX_DARWIN
+#ifdef PROC_PPC
+ Nlm_Boolean isRosetta = FALSE;
+ size_t len;
+ int mib [2];
+ Nlm_Char model [32];
+#endif
+ long sysVer;
+#endif
Nlm_CharPtr str = "unknown";
#if defined(OS_MAC) && !defined(OS_UNIX_DARWIN)
@@ -2422,10 +2444,71 @@ NLM_EXTERN Nlm_CharPtr Nlm_GetOpSysString (void)
#ifdef OS_UNIX_DARWIN
#ifdef PROC_PPC
- str = "MAC PPC on OS X";
+ mib [0] = CTL_HW;
+ mib [1] = HW_MODEL;
+ len = sizeof (model);
+ if (sysctl (mib, 2, &model, &len, NULL, 0) == 0) {
+ isRosetta = (Nlm_Boolean) (len == 9 && strcmp (model, "PowerMac") == 0);
+ }
+ if (isRosetta) {
+ str = "MAC Rosetta on OS X";
+ if ( Gestalt (gestaltSystemVersion, &sysVer) == noErr) {
+ if (sysVer >= 4192) {
+ str = "MAC Rosetta on OS 10.6";
+ } else if (sysVer >= 4176) {
+ str = "MAC Rosetta on OS 10.5";
+ } else if (sysVer >= 4160) {
+ str = "MAC Rosetta on OS 10.4";
+ } else if (sysVer >= 4144) {
+ str = "MAC Rosetta on OS 10.3";
+ } else if (sysVer >= 4128) {
+ str = "MAC Rosetta on OS 10.2";
+ } else if (sysVer >= 4112) {
+ str = "MAC Rosetta on OS 10.1";
+ } else {
+ str = "MAC Rosetta on OS X";
+ }
+ }
+ } else {
+ str = "MAC PPC on OS X";
+ if ( Gestalt (gestaltSystemVersion, &sysVer) == noErr) {
+ if (sysVer >= 4192) {
+ str = "MAC PPC on OS 10.6";
+ } else if (sysVer >= 4176) {
+ str = "MAC PPC on OS 10.5";
+ } else if (sysVer >= 4160) {
+ str = "MAC PPC on OS 10.4";
+ } else if (sysVer >= 4144) {
+ str = "MAC PPC on OS 10.3";
+ } else if (sysVer >= 4128) {
+ str = "MAC PPC on OS 10.2";
+ } else if (sysVer >= 4112) {
+ str = "MAC PPC on OS 10.1";
+ } else {
+ str = "MAC PPC on OS X";
+ }
+ }
+ }
#else
#ifdef PROC_I80X86
str = "MAC 386 on OS X";
+ if ( Gestalt (gestaltSystemVersion, &sysVer) == noErr) {
+ if (sysVer >= 4192) {
+ str = "MAC 386 on OS 10.6";
+ } else if (sysVer >= 4176) {
+ str = "MAC 386 on OS 10.5";
+ } else if (sysVer >= 4160) {
+ str = "MAC 386 on OS 10.4";
+ } else if (sysVer >= 4144) {
+ str = "MAC 386 on OS 10.3";
+ } else if (sysVer >= 4128) {
+ str = "MAC 386 on OS 10.2";
+ } else if (sysVer >= 4112) {
+ str = "MAC 386 on OS 10.1";
+ } else {
+ str = "MAC 386 on OS X";
+ }
+ }
#else
str = "MAC UNIX on OS X";
#endif
@@ -2461,7 +2544,9 @@ NLM_EXTERN Nlm_CharPtr Nlm_GetOpSysString (void)
version = GetVersion ();
lowbyte = (version & 0x0000FF);
if ((version & 0x80000000) == 0) {
- if (lowbyte == 5) {
+ if (lowbyte == 6) {
+ str = "MS WINDOWS VISTA";
+ } else if (lowbyte == 5) {
str = "MS WINDOWS 2000/XP";
} else if (lowbyte == 4) {
str = "MS WINDOWS NT 4.0";
diff --git a/corelib/ncbierr.c b/corelib/ncbierr.c
index d6c29bba..302b56b4 100644
--- a/corelib/ncbierr.c
+++ b/corelib/ncbierr.c
@@ -23,9 +23,9 @@
*
* ===========================================================================
*
-* $Id: ncbierr.c,v 6.23 2006/07/13 17:10:35 bollin Exp $
+* $Id: ncbierr.c,v 6.24 2006/11/09 17:46:58 kans Exp $
*
-* $Revision: 6.23 $
+* $Revision: 6.24 $
*
* Authors: Schuler, Sirotkin (UserErr stuff)
*
@@ -71,6 +71,9 @@
* 03-06-95 Schuler Fixed problem with ErrMsgRoot_fopen
*
* $Log: ncbierr.c,v $
+* Revision 6.24 2006/11/09 17:46:58 kans
+* added cast to quiet CodeWarrior complaint
+*
* Revision 6.23 2006/07/13 17:10:35 bollin
* use Uint4 instead of Uint2 for itemID values
*
@@ -536,7 +539,7 @@ NLM_EXTERN int LIBCALL Nlm_ErrPostStr (ErrSev sev, int lev1, int lev2, const cha
}
if ( s_HookOnly ) {
- die_if_necessary(severity, info);
+ die_if_necessary((ErrSev)severity, info);
ErrClear();
return ANS_NONE;
}
diff --git a/corelib/ncbifile.c b/corelib/ncbifile.c
index d24a77a3..54d8c15f 100644
--- a/corelib/ncbifile.c
+++ b/corelib/ncbifile.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/4/91
*
-* $Revision: 6.39 $
+* $Revision: 6.40 $
*
* File Description:
* portable file routines
@@ -43,6 +43,9 @@
* 11-27-94 Ostell moved includes to ncbiwin.h to avoid conflict MSC
*
* $Log: ncbifile.c,v $
+* Revision 6.40 2007/08/16 17:09:22 kans
+* moved DirExplore from sqnutils
+*
* Revision 6.39 2006/07/13 17:10:36 bollin
* use Uint4 instead of Uint2 for itemID values
*
@@ -1271,6 +1274,89 @@ NLM_EXTERN ValNodePtr LIBCALL Nlm_DirCatalog (Nlm_CharPtr pathname)
/*****************************************************************************
*
+* general file recursion functio
+*
+*****************************************************************************/
+
+NLM_EXTERN Nlm_Int4 Nlm_DirExplore (
+ Nlm_CharPtr directory,
+ Nlm_CharPtr filter,
+ Nlm_CharPtr suffix,
+ Nlm_Boolean recurse,
+ Nlm_DirExpProc proc,
+ Nlm_VoidPtr userdata
+)
+
+{
+ Nlm_Int4 count = 0;
+ Nlm_Char file [FILENAME_MAX], path [PATH_MAX];
+ Nlm_CharPtr ptr, str;
+ ValNodePtr head, vnp;
+
+ if (proc == NULL) return 0;
+ if (Nlm_StringHasNoText (directory) || Nlm_StringHasNoText (suffix)) return 0;
+
+ /* get list of all files in source directory */
+
+ head = Nlm_DirCatalog (directory);
+
+ for (vnp = head; vnp != NULL; vnp = vnp->next) {
+ if (vnp->choice == 0) {
+ str = (Nlm_CharPtr) vnp->data.ptrvalue;
+ if (! Nlm_StringHasNoText (str)) {
+
+ /* check filename for indicated suffix */
+
+ ptr = Nlm_StringStr (str, suffix);
+ if (ptr != NULL) {
+
+ /* make sure detected suffix is really at end of filename */
+
+ if (Nlm_StringCmp (ptr, suffix) == 0) {
+ *ptr = '\0';
+ } else {
+ ptr = NULL;
+ }
+ }
+
+ if (Nlm_StringHasNoText (suffix) || ptr != NULL) {
+
+ Nlm_StringNCpy_0 (path, directory, sizeof (path));
+ sprintf (file, "%s%s", str, suffix);
+ Nlm_FileBuildPath (path, NULL, file);
+
+ /* check full path/file name for desired filter */
+
+ if (Nlm_StringHasNoText (filter) || Nlm_StringStr (path, filter) != NULL) {
+
+ /* process file that satisfies optional filter and suffix constraints */
+
+ proc (path, userdata);
+ count++;
+ }
+ }
+ }
+ } else if (vnp->choice == 1 && recurse) {
+
+ /* recurse into subdirectory */
+
+ Nlm_StringNCpy_0 (path, directory, sizeof (path));
+ str = (Nlm_CharPtr) vnp->data.ptrvalue;
+ Nlm_FileBuildPath (path, str, NULL);
+
+ count += Nlm_DirExplore (path, filter, suffix, recurse, proc, userdata);
+ }
+ }
+
+ /* clean up file list */
+
+ ValNodeFreeData (head);
+
+ return count;
+}
+
+/*****************************************************************************
+*
* TmpNam()
*
*****************************************************************************/
diff --git a/corelib/ncbifile.h b/corelib/ncbifile.h
index 853e3e64..a6f440ec 100644
--- a/corelib/ncbifile.h
+++ b/corelib/ncbifile.h
@@ -32,7 +32,7 @@
*
* Version Creation Date: 1/1/91
*
-* $Revision: 6.6 $
+* $Revision: 6.7 $
*
* File Description:
* prototypes for portable file routines
@@ -40,6 +40,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbifile.h,v $
+* Revision 6.7 2007/08/16 17:09:22 kans
+* moved DirExplore from sqnutils
+*
* Revision 6.6 2004/05/07 15:57:14 kans
* added FileCache functions for buffered read, graceful handing of Unix, Mac, and DOS line endings
*
@@ -118,7 +121,18 @@ NLM_EXTERN void Nlm_FileCacheSeek (Nlm_FileCache PNTR fcp, Nlm_Int4 pos);
NLM_EXTERN Nlm_Int4 Nlm_FileCacheTell (Nlm_FileCache PNTR fcp);
NLM_EXTERN Nlm_Boolean Nlm_FileCacheFree (Nlm_FileCache PNTR fcp, Nlm_Boolean restoreFilePos);
+/* general file recursion function - directory must not be empty, proc callback function must not be NULL */
+
+typedef void (*Nlm_DirExpProc) (Nlm_CharPtr filename, Nlm_VoidPtr userdata);
+NLM_EXTERN Nlm_Int4 Nlm_DirExplore (
+ Nlm_CharPtr directory,
+ Nlm_CharPtr filter,
+ Nlm_CharPtr suffix,
+ Nlm_Boolean recurse,
+ Nlm_DirExpProc proc,
+ Nlm_VoidPtr userdata
+);
#define FileOpen Nlm_FileOpen
#define FileClose Nlm_FileClose
@@ -149,6 +163,9 @@ NLM_EXTERN Nlm_Boolean Nlm_FileCacheFree (Nlm_FileCache PNTR fcp, Nlm_Boolean re
#define FileCacheTell Nlm_FileCacheTell
#define FileCacheFree Nlm_FileCacheFree
+#define DirExpProc Nlm_DirExpProc
+#define DirExplore Nlm_DirExplore
+
#define EjectCd(sVolume, deviceName, rawDeviceName, mountPoint, mountCmd) FALSE
#define MountCd(sVolume, deviceName, mountPoint, mountCmd) FALSE
diff --git a/corelib/ncbilcl.dwn b/corelib/ncbilcl.dwn
index cf0bfadd..b8f0aa0b 100644
--- a/corelib/ncbilcl.dwn
+++ b/corelib/ncbilcl.dwn
@@ -29,7 +29,7 @@
*
* Version Creation Date: 8/1/94
*
-* $Revision: 6.7 $
+* $Revision: 6.9 $
*
* File Description:
* system dependent header
@@ -41,6 +41,12 @@
* ------- ---------- ---------------------------------------------------
*
* $Log: ncbilcl.dwn,v $
+* Revision 6.9 2007/04/06 21:10:32 kans
+* also check for 64-bit processor conditional symbols
+*
+* Revision 6.8 2007/04/02 16:06:12 kans
+* use __ppc__ and __i386__ to set proper PROC_ platform flags
+*
* Revision 6.7 2005/11/16 16:22:32 kans
* support for PowerPC and Intel chips in PROC_ and _ENDIAN flags
*
@@ -87,10 +93,10 @@
#define OS_UNIX_DARWIN
/* Mac may be PowerPC or Intel chip */
-#ifdef PER_ARCH_CFLAGS_ppc
+#if defined(__ppc__) || defined(__ppc64__)
#define PROC_PPC
#endif
-#ifdef PER_ARCH_CFLAGS_i386
+#if defined(__i386__) || defined(__x86_64__)
#define PROC_I80X86
#define PROC_I80_386
#endif
diff --git a/corelib/ncbimisc.c b/corelib/ncbimisc.c
index 96e2ab64..88fc7a93 100644
--- a/corelib/ncbimisc.c
+++ b/corelib/ncbimisc.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 10/23/91
*
-* $Revision: 6.30 $
+* $Revision: 6.32 $
*
* File Description:
* miscellaneous functions
@@ -43,6 +43,12 @@
* 02-16-94 Epstein Retired Gestalt functions and definitions
*
* $Log: ncbimisc.c,v $
+* Revision 6.32 2006/11/09 17:47:16 kans
+* added ValNodeMergeStrs
+*
+* Revision 6.31 2006/10/17 14:16:48 lavr
+* ValNodeCopyStr() to take "const char*"
+*
* Revision 6.30 2005/11/16 16:36:11 kans
* support for PowerPC and Intel chips for Macintosh
*
@@ -619,7 +625,7 @@ NLM_EXTERN ValNodePtr LIBCALL ValNodeAddStr (ValNodePtr PNTR head, Nlm_Int2 choi
* if str == NULL, does not add a ValNode
*
*****************************************************************************/
-NLM_EXTERN ValNodePtr LIBCALL ValNodeCopyStr (ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_CharPtr str)
+NLM_EXTERN ValNodePtr LIBCALL ValNodeCopyStr (ValNodePtr PNTR head, Nlm_Int2 choice, const char* str)
{
ValNodePtr newnode;
@@ -934,6 +940,41 @@ NLM_EXTERN ValNodePtr LIBCALL ValNodeSort (ValNodePtr list, int (LIBCALLBACK *co
/*****************************************************************************
*
+* ValNodeMergeStrs(list)
+* Merges chain of val node strings into a single character array
+*
+*****************************************************************************/
+NLM_EXTERN Nlm_CharPtr LIBCALL ValNodeMergeStrs (ValNodePtr list)
+
+{
+ size_t len;
+ Nlm_CharPtr ptr;
+ Nlm_CharPtr str;
+ Nlm_CharPtr tmp;
+ ValNodePtr vnp;
+
+
+ if (list == NULL) return NULL;
+
+ for (vnp = list, len = 0; vnp != NULL; vnp = vnp->next) {
+ str = (Nlm_CharPtr) vnp->data.ptrvalue;
+ len += Nlm_StringLen (str);
+ }
+ if (len == 0) return NULL;
+
+ ptr = Nlm_MemNew (sizeof (Nlm_Char) * (len + 2));
+ if (ptr == NULL) return NULL;
+
+ for (vnp = list, tmp = ptr; vnp != NULL; vnp = vnp->next) {
+ str = (Nlm_CharPtr) vnp->data.ptrvalue;
+ tmp = Nlm_StringMove (tmp, str);
+ }
+
+ return ptr;
+}
+
+/*****************************************************************************
+*
* Start Of Node List Functions
*
*****************************************************************************/
diff --git a/corelib/ncbimisc.h b/corelib/ncbimisc.h
index 97db6edb..8a4ae690 100644
--- a/corelib/ncbimisc.h
+++ b/corelib/ncbimisc.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 10/23/91
*
-* $Revision: 6.14 $
+* $Revision: 6.16 $
*
* File Description:
* prototypes of miscellaneous functions
@@ -43,6 +43,12 @@
* 06-15-93 Schuler Added macros for Gestalt functins.
*
* $Log: ncbimisc.h,v $
+* Revision 6.16 2006/11/09 17:47:16 kans
+* added ValNodeMergeStrs
+*
+* Revision 6.15 2006/10/17 14:16:48 lavr
+* ValNodeCopyStr() to take "const char*"
+*
* Revision 6.14 2002/12/17 16:45:09 kans
* CtoPstr and PtoCstr if OS_MAC or OS_UNIX_DARWIN
*
@@ -269,25 +275,29 @@ typedef struct valnode {
* Copied from SortValNode in jzcoll, renamed, for more general access
* Makes array from ValNode list, calls HeapSort, reconnects ValNode list
*
+* ValNodeMergeStrs(list)
+* Merges chain of val node strings into a single character array
+*
*****************************************************************************/
-NLM_EXTERN ValNodePtr LIBCALL ValNodeNew PROTO((ValNodePtr vnp));
-NLM_EXTERN Nlm_Int4 LIBCALL ValNodeLen PROTO((ValNodePtr vnp));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeAdd PROTO((ValNodePtr PNTR head));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeLink PROTO((ValNodePtr PNTR head, ValNodePtr newnode));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeAddStr PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_CharPtr str));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeCopyStr PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_CharPtr str));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeAddInt PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_Int4 value));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeAddBigInt (ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_Int8 value);
-NLM_EXTERN ValNodePtr LIBCALL ValNodeAddBoolean PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_Boolean value));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeAddFloat PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_FloatHi value));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeAddPointer PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_VoidPtr value));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeAddFunction PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_FnPtr value));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeFree PROTO((ValNodePtr vnp));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeFreeData PROTO((ValNodePtr vnp));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeExtract PROTO((ValNodePtr PNTR headptr, Nlm_Int2 choice));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeExtractList PROTO((ValNodePtr PNTR headptr, Nlm_Int2 choice));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeFindNext PROTO((ValNodePtr head, ValNodePtr curr, Nlm_Int2 choice));
-NLM_EXTERN ValNodePtr LIBCALL ValNodeSort PROTO((ValNodePtr list, int (LIBCALLBACK *compar) (VoidPtr, VoidPtr)));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeNew PROTO((ValNodePtr vnp));
+NLM_EXTERN Nlm_Int4 LIBCALL ValNodeLen PROTO((ValNodePtr vnp));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeAdd PROTO((ValNodePtr PNTR head));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeLink PROTO((ValNodePtr PNTR head, ValNodePtr newnode));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeAddStr PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_CharPtr str));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeCopyStr PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, const char* str));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeAddInt PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_Int4 value));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeAddBigInt (ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_Int8 value);
+NLM_EXTERN ValNodePtr LIBCALL ValNodeAddBoolean PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_Boolean value));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeAddFloat PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_FloatHi value));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeAddPointer PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_VoidPtr value));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeAddFunction PROTO((ValNodePtr PNTR head, Nlm_Int2 choice, Nlm_FnPtr value));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeFree PROTO((ValNodePtr vnp));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeFreeData PROTO((ValNodePtr vnp));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeExtract PROTO((ValNodePtr PNTR headptr, Nlm_Int2 choice));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeExtractList PROTO((ValNodePtr PNTR headptr, Nlm_Int2 choice));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeFindNext PROTO((ValNodePtr head, ValNodePtr curr, Nlm_Int2 choice));
+NLM_EXTERN ValNodePtr LIBCALL ValNodeSort PROTO((ValNodePtr list, int (LIBCALLBACK *compar) (VoidPtr, VoidPtr)));
+NLM_EXTERN Nlm_CharPtr LIBCALL ValNodeMergeStrs PROTO((ValNodePtr list));
/*** old prototypes ******
NLM_EXTERN ValNodePtr LIBCALL ValNodeLink PROTO((ValNodePtr vnp, ValNodePtr newnode));
diff --git a/corelib/ncbimsg.c b/corelib/ncbimsg.c
index d18ce7ee..a3a5ab47 100644
--- a/corelib/ncbimsg.c
+++ b/corelib/ncbimsg.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 2/13/91
*
-* $Revision: 6.10 $
+* $Revision: 6.12 $
*
* File Description:
* user alert and error messages
@@ -54,6 +54,12 @@
* input will be read properly.
*
* $Log: ncbimsg.c,v $
+* Revision 6.12 2006/12/07 14:13:56 lavr
+* #include <stdio.h> just in case for *_FILENO macros
+*
+* Revision 6.11 2006/12/07 14:13:02 lavr
+* Add checks for whether the message device is a terminal (UNIX)
+*
* Revision 6.10 2002/06/17 15:07:01 ivanov
* Added fix for BeOS platform in GetOneChar
*
@@ -151,6 +157,10 @@ static char *_filename = __FILE__;
#include "corepriv.h"
#include <tsprintf.h>
+#if defined(OS_UNIX)
+# include <stdio.h>
+# include <unistd.h>
+#endif
#ifdef __cplusplus
extern "C" {
@@ -407,7 +417,10 @@ MsgAnswer PASCAL _DefMessageHook (MsgKey key, ErrSev sev,
fprintf(stderr,"[%s] %s\n",
caption ? caption : "NULL_Caption",
message ? message : "NULL_Message");
-
+
+#if defined(OS_UNIX)
+ if (isatty(STDIN_FILENO))
+#endif
if (key>KEY_NONE && key<KEY_other)
{
int ch;
@@ -558,7 +571,10 @@ void LIBCALLBACK _DefBeepHook (void)
#endif
#elif defined(OS_UNIX) || defined(OS_VMS)
- putc(7, stderr);
+# if defined(OS_UNIX)
+ if (isatty(STDERR_FILENO))
+# endif
+ putc(7, stderr);
#endif
}
diff --git a/corelib/ncbistr.c b/corelib/ncbistr.c
index 247d575a..cc6f6ebf 100644
--- a/corelib/ncbistr.c
+++ b/corelib/ncbistr.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 3/4/91
*
-* $Revision: 6.14 $
+* $Revision: 6.16 $
*
* File Description:
* portable string routines
@@ -37,6 +37,12 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbistr.c,v $
+* Revision 6.16 2006/10/17 02:02:31 lavr
+* Fix a typo
+*
+* Revision 6.15 2006/10/16 21:06:27 lavr
+* String{HasNo|DoesHave}Text() to accept const pointer
+*
* Revision 6.14 2006/09/12 16:22:55 ludwigf
* CHANGED: Internal logic on LabelCopy() to no longer touch memory outside
* the buffer it is given to operate on.
@@ -505,29 +511,20 @@ NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_StrMove (char FAR *to, const char FAR *from)
return to;
}
-NLM_EXTERN Nlm_Boolean LIBCALL Nlm_StringHasNoText (Nlm_CharPtr str)
-
+NLM_EXTERN Nlm_Boolean LIBCALL Nlm_StringHasNoText (const char FAR *str)
{
- Nlm_Uchar ch; /* to use 8bit characters in multibyte languages */
-
- if (str != NULL) {
- ch = *str;
- while (ch != '\0') {
- if (ch > ' ') {
+ if (str) {
+ while (*str) {
+ if ((unsigned char)(*str++) > ' ')
return FALSE;
- }
- str++;
- ch = *str;
}
}
return TRUE;
}
-NLM_EXTERN Nlm_Boolean LIBCALL Nlm_StringDoesHaveText (Nlm_CharPtr str)
-
+NLM_EXTERN Nlm_Boolean LIBCALL Nlm_StringDoesHaveText (const char FAR *str)
{
- if (Nlm_StringHasNoText (str)) return FALSE;
- return TRUE;
+ return ! Nlm_StringHasNoText (str);
}
NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_TrimSpacesAroundString (Nlm_CharPtr str)
diff --git a/corelib/ncbistr.h b/corelib/ncbistr.h
index 481addbc..de276cf8 100644
--- a/corelib/ncbistr.h
+++ b/corelib/ncbistr.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/91
*
-* $Revision: 6.8 $
+* $Revision: 6.9 $
*
* File Description:
* prototypes for portable string routines
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbistr.h,v $
+* Revision 6.9 2006/10/16 21:06:27 lavr
+* String{HasNo|DoesHave}Text() to accept const pointer
+*
* Revision 6.8 2003/09/15 16:21:32 kans
* moved StringDoesHaveText from sqnutils3.c
*
@@ -174,8 +177,8 @@ NLM_EXTERN Nlm_Int2 LIBCALL Nlm_MeshStringICmp PROTO((const char FAR *str1, cons
NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_StringSearch PROTO((const char FAR *str, const char FAR *sub));
NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_StringISearch PROTO((const char FAR *str, const char FAR *sub));
-NLM_EXTERN Nlm_Boolean LIBCALL Nlm_StringHasNoText PROTO((Nlm_CharPtr str));
-NLM_EXTERN Nlm_Boolean LIBCALL Nlm_StringDoesHaveText PROTO((Nlm_CharPtr str));
+NLM_EXTERN Nlm_Boolean LIBCALL Nlm_StringHasNoText PROTO((const char FAR *str));
+NLM_EXTERN Nlm_Boolean LIBCALL Nlm_StringDoesHaveText PROTO((const char FAR *str));
NLM_EXTERN Nlm_CharPtr LIBCALL Nlm_TrimSpacesAroundString PROTO((Nlm_CharPtr str));
/* Printing 8-byte integer into platform-independent array of 8 bytes
diff --git a/corelib/ncbitime.c b/corelib/ncbitime.c
index 32260c14..9c6ac630 100644
--- a/corelib/ncbitime.c
+++ b/corelib/ncbitime.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/90
*
-* $Revision: 6.2 $
+* $Revision: 6.3 $
*
* File Description:
* misc portable routines for
@@ -38,6 +38,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbitime.c,v $
+* Revision 6.3 2006/10/19 16:58:26 lavr
+* Cache clock rate instead of requesting it each time on OS_UNIX
+*
* Revision 6.2 2001/01/19 20:26:12 kans
* support for OS_UNIX_DARWIN (contributed by William Van Etten)
*
@@ -189,6 +192,7 @@ struct _StopWatch {
#elif defined(OS_UNIX)
clock_t start;
clock_t stop;
+ clock_t rate;
#else
int dummy;
#endif
@@ -198,7 +202,12 @@ typedef struct _StopWatch Nlm_StopWatch;
NLM_EXTERN Nlm_StopWatchPtr Nlm_StopWatchNew(void)
{
#if defined(WIN32) || defined(OS_UNIX)
- return (Nlm_StopWatchPtr) Nlm_MemNew(sizeof(Nlm_StopWatch));
+ Nlm_StopWatchPtr pSW = (Nlm_StopWatchPtr)Nlm_MemNew(sizeof(Nlm_StopWatch));
+# if defined(OS_UNIX)
+ if (pSW != NULL)
+ pSW->rate = sysconf(_SC_CLK_TCK);
+# endif
+ return pSW;
#else
ErrPostEx(SEV_WARNING, 0, 0,
"StopWatch is not implemented for this platform");
@@ -274,7 +283,7 @@ NLM_EXTERN Nlm_FloatHi Nlm_GetElapsedTime(Nlm_StopWatchPtr pSW)
return res = (Nlm_FloatHi)ft.dwHighDateTime/5000000L*0x80000000L +
(Nlm_FloatHi)ft.dwLowDateTime/10000000L;
#elif defined(OS_UNIX)
- res = ((Nlm_FloatHi)pSW->stop - pSW->start) / sysconf(_SC_CLK_TCK);
+ res = ((Nlm_FloatHi)pSW->stop - pSW->start) / pSW->rate;
#else
ErrPostEx(SEV_WARNING, 0, 0,
"StopWatch is not implemented for this platform");
@@ -292,6 +301,7 @@ struct _CPUTime {
FILETIME usrtime;
#elif defined(OS_UNIX)
struct tms times;
+ clock_t rate;
#else
int dummy;
#endif
@@ -315,6 +325,7 @@ NLM_EXTERN Nlm_CPUTimePtr Nlm_CPUTimeMeasure(void)
);
#elif defined(OS_UNIX)
times(&pTime->times);
+ pTime->rate = sysconf(_SC_CLK_TCK);
#else
ErrPostEx(SEV_WARNING, 0, 0,
"CPU time measuring is not implemented for this platform");
@@ -345,7 +356,7 @@ NLM_EXTERN Nlm_FloatHi Nlm_CPUTimeGetSys(Nlm_CPUTimePtr pTime)
return (Nlm_FloatHi)pTime->systime.dwHighDateTime * 0x80000000L/5000000L
+ (Nlm_FloatHi)pTime->systime.dwLowDateTime / 10000000L;
#elif defined(OS_UNIX)
- return (Nlm_FloatHi)pTime->times.tms_stime / sysconf(_SC_CLK_TCK);
+ return (Nlm_FloatHi)pTime->times.tms_stime / pTime->rate;
#else
ErrPostEx(SEV_WARNING, 0, 0,
"CPU time measuring is not implemented for this platform");
@@ -359,7 +370,7 @@ NLM_EXTERN Nlm_FloatHi Nlm_CPUTimeGetUser(Nlm_CPUTimePtr pTime)
return (Nlm_FloatHi)pTime->usrtime.dwHighDateTime * 0x80000000L/5000000L
+ (Nlm_FloatHi)pTime->usrtime.dwLowDateTime / 10000000L;
#elif defined(OS_UNIX)
- return (Nlm_FloatHi)pTime->times.tms_utime / sysconf(_SC_CLK_TCK);
+ return (Nlm_FloatHi)pTime->times.tms_utime / pTime->rate;
#else
ErrPostEx(SEV_WARNING, 0, 0,
"CPU time measuring is not implemented for this platform");
diff --git a/corelib/ncbiwin.h b/corelib/ncbiwin.h
index ded5abbf..81eb9e70 100644
--- a/corelib/ncbiwin.h
+++ b/corelib/ncbiwin.h
@@ -29,7 +29,7 @@
*
* Version Creation Date: 1/1/91
*
-* $Revision: 6.11 $
+* $Revision: 6.12 $
*
* File Description:
* underlying window toolbox import
@@ -37,6 +37,9 @@
* Modifications:
* --------------------------------------------------------------------------
* $Log: ncbiwin.h,v $
+* Revision 6.12 2006/11/24 20:05:36 kans
+* include Carbon/Carbon.h if not MWERKS - attempting to simplify Xcode search paths
+*
* Revision 6.11 2006/09/14 19:51:37 ivanov
* Added defines for missed *LongPtr on MSVC6
*
@@ -132,6 +135,10 @@
#undef FloatHiPtr
#ifdef WIN_MAC
+#ifndef __MWERKS__
+#include <Carbon/Carbon.h>
+#endif
+#ifdef __MWERKS__
#include <Controls.h>
#if UNIVERSAL_INTERFACES_VERSION > 0x0320
#include <ControlDefinitions.h> /* pjc added 11/20/99 */
@@ -161,14 +168,17 @@
#include <Sound.h>
#include <Folders.h>
#endif
+#endif
/* used in ncbifile.c *****/
#ifdef OS_MAC
+#ifdef __MWERKS__
#include <Errors.h>
#include <Gestalt.h>
#include <MacMemory.h>
#include <Processes.h>
#endif
+#endif
#ifdef OS_UNIX_SUN
#include <sys/file.h>
diff --git a/corelib/ncbiwww.h b/corelib/ncbiwww.h
index cd074056..89ab01b4 100644
--- a/corelib/ncbiwww.h
+++ b/corelib/ncbiwww.h
@@ -1,4 +1,4 @@
-/* $Id: ncbiwww.h,v 6.7 2002/02/07 14:48:22 ivanov Exp $
+/* $Id: ncbiwww.h,v 6.8 2007/06/20 22:05:40 vakatov Exp $
* ===========================================================================
*
* PUBLIC DOMAIN NOTICE
@@ -29,7 +29,7 @@
*
* Version Creation Date: 11/03/1996
*
-* $Revision: 6.7 $
+* $Revision: 6.8 $
*
* File Description:
* This file contains main definitions to read and process HTTP
@@ -37,6 +37,11 @@
* Currently it works for all ncbi supported platforms.
*
* $Log: ncbiwww.h,v $
+* Revision 6.8 2007/06/20 22:05:40 vakatov
+* MAX_WWW_ENTRIES -- increased from 4096 to 32768.
+* It is just a quick-fix to let this code live a little longer, requested
+* by Karl and Vasuki.
+*
* Revision 6.7 2002/02/07 14:48:22 ivanov
* Added WWWGetEntriesEx(), WWWGetEntriesFormDataEx(), WWWReadFileInMemoryEx(),
* WWWGetValueSizeByIndex() -- support binary files in the multipart form-data.
@@ -113,7 +118,7 @@
/* DEFINES */
/****************************************************************************/
-#define MAX_WWW_ENTRIES 4096 /* maximum number of html tags in input */
+#define MAX_WWW_ENTRIES 32768 /* maximum number of html tags in input */
#define WWW_MAX_NAME_LEN 512 /* Limit for Name in HTML tag */
#define MISC_BROWSER 0 /* Any Browser Netscape Ver. 1 included */
diff --git a/corelib/tsprintf.c b/corelib/tsprintf.c
index 43dfaedc..35f92d13 100644
--- a/corelib/tsprintf.c
+++ b/corelib/tsprintf.c
@@ -29,7 +29,7 @@
*
* Version Creation Date: 07/10/96
*
-* $Revision: 6.10 $
+* $Revision: 6.12 $
*
* File Description:
* Memory- and MT-safe "sprintf()"
@@ -38,6 +38,12 @@
* --------------------------------------------------------------------------
*
* $Log: tsprintf.c,v $
+* Revision 6.12 2007/08/02 17:59:11 kans
+* do_div needed to take Int8 n argument
+*
+* Revision 6.11 2007/08/02 16:14:31 ucko
+* Support "ll"-prefixed arguments (assumed to be [U]Int8).
+*
* Revision 6.10 2003/12/12 23:28:25 dondosha
* Correction for Opteron, at suggestion from Nicolas Joly
*
@@ -144,7 +150,7 @@ static int skip_atoi(const char **s)
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
-static int do_div(long *n, int base)
+static int do_div(Nlm_Int8 *n, int base)
{
int res = ((unsigned long) *n) % (unsigned) base;
*n = ((unsigned long) *n) / (unsigned) base;
@@ -194,7 +200,8 @@ static int fp_count(double fp, char type, int size, int precision, int flags)
}
-static int number_count(long num, int base, int size, int precision, int type)
+static int number_count(Nlm_Int8 num, int base, int size, int precision,
+ int type)
{
int counter = 0;
int i = 0;
@@ -266,13 +273,13 @@ static size_t vsprintf_count_args(const Char PNTR fmt, va_list args,
size_t counter = 0;
const Char PNTR start_fmt = fmt;
- unsigned long num;
+ Nlm_Uint8 num;
int base;
int flags; /* flags to number() */
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
- int qualifier; /* 'h', 'l', or 'L' for integer fields */
+ int qualifier; /* 'h', 'l', 'L', or 'q' ("ll") for integer fields */
*cut_fmt = 0;
@@ -333,6 +340,10 @@ static size_t vsprintf_count_args(const Char PNTR fmt, va_list args,
if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
qualifier = *fmt;
++fmt;
+ if (qualifier == 'l' && *fmt == 'l') {
+ qualifier = 'q';
+ ++fmt;
+ }
}
/* default base */
@@ -386,6 +397,9 @@ static size_t vsprintf_count_args(const Char PNTR fmt, va_list args,
if (qualifier == 'l') {
long * ip = va_arg(args, long *);
*ip = (long)counter;
+ } else if (qualifier == 'q') {
+ Nlm_Uint8 * ip = va_arg(args, Nlm_Uint8 *);
+ *ip = (Nlm_Uint8)counter;
} else {
int * ip = va_arg(args, int *);
*ip = (int)counter;
@@ -430,13 +444,13 @@ static size_t vsprintf_count_args(const Char PNTR fmt, va_list args,
}
if (qualifier == 'l')
- num = va_arg(args, unsigned long);
- else if (qualifier == 'h')
if (flags & SIGNED)
- num = va_arg(args, int); /* sic! -- not a "short"! */
+ num = va_arg(args, long);
else
- num = va_arg(args, unsigned int);
- else if (flags & SIGNED)
+ num = va_arg(args, unsigned long);
+ else if (qualifier == 'q')
+ num = va_arg(args, Nlm_Uint8);
+ else if (flags & SIGNED) /* plain or 'h' -- short promotes to int */
num = va_arg(args, int);
else
num = va_arg(args, unsigned int);