home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 15
/
CD_ASCQ_15_070894.iso
/
news
/
683
/
recio120
/
rbget.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-04-08
|
2KB
|
65 lines
/*****************************************************************************
MODULE: rbget.c
PURPOSE: defines rbget series of functions for recio library
COPYRIGHT: (C) 1994 William Pierpoint
COMPILER: Borland C Version 3.1
OS: MSDOS Version 6.2
VERSION: 1.20
RELEASE: April 8, 1994
*****************************************************************************/
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "_rbget.h"
/****************************************************************************/
unsigned long /* return unsigned long */
str2ul( /* convert string to unsigned long */
const char *nptr, /* pointer to string to convert */
char **endptr, /* pointer to conversion leftover string */
int base) /* base (radix) of number */
/****************************************************************************/
/* note: unlike strtoul, str2ul tests for a negative number */
{
unsigned long ul=0UL; /* result to return */
const char *np=nptr; /* pointer to string */
errno = 0;
/* skip over white space */
while (isspace(*np)) np++;
/* if first non-white space is a minus sign */
if (*np == '-') {
/* position endptr at the minus sign */
if (endptr) *endptr = (char *) np;
} else {
ul = strtoul(nptr, endptr, base);
}
return (ul);
}
/****************************************************************************/
/* rbget_fn() - define rbget functions */
/****************************************************************************/
#define uint unsigned int
#define ulong unsigned long
#ifdef __BORLANDC__
#pragma warn -ccc
#endif
rbget_fn( int, rbgeti, 0, long, strtol, INT_MIN, INT_MAX)
rbget_fn( uint, rbgetui, 0, ulong, str2ul, 0, UINT_MAX)
rbget_fn( long, rbgetl, 0L, long, strtol, LONG_MIN, LONG_MAX)
rbget_fn( ulong, rbgetul, 0L, ulong, str2ul, 0, ULONG_MAX)