Reuse, not rework
Home

License Awareness



Highly Reusable Software

By activity
Professions, Sciences, Humanities, Business, ...

User Interface
Text-based, GUI, Audio, Video, Keyboards, Mouse, Images,...

Text Strings
Conversions, tests, processing, manipulation,...

Math
Integer, Floating point, Matrix, Statistics, Boolean, ...

Processing
Algorithms, Memory, Process control, Debugging, ...

Stored Data
Data storage, Integrity, Encryption, Compression, ...

Communications
Networks, protocols, Interprocess, Remote, Client Server, ...

Hard World
Timing, Calendar and Clock, Audio, Video, Printer, Controls...

File System
Management, Filtering, File & Directory access, Viewers, ...


NAME

librock_ssconsl - string scan for a long int in the specified radix (base)
librock_sscons - string scan for an int in the specified radix (base)
librock_ssdec - string scan for an int in base 10
#License - #Source code - #Example Use -

SYNOPSIS

#include <librock/parse.h>
int
librock_ssconsl(
    const char *strptr,
    int radix,
    long librock_PTR *plRet
);

int
librock_sscons(
    const char *sptr,
    int radix,
    int *piRet
);

int
librock_ssdec(
    const char *sptr,
    int *piRet
);

DESCRIPTION

Skip leading ' ' or '\t', accept an optional '-', then convert to an int or long int in the specified radix (base.)

Stores conversion result indirectly (at pRet, if not NULL), and returns the number of characters processed.

Radix can be up to 36. A-Z are taken in upper or lower case for digits after 0-9.

When radix == 0, takes prefix from the string

     prefix - radix
       0    - octal
       0x   - hex
       0b   - binary
    default - decimal

Processing stops at the first character not a valid digit
in the radix.

Returns number of characters processed or 0 if could not
process any characters. If 0 is returned, the value at *pRet
is unchanged.

Typical use is to replace atol(), to gain the additional
radix conversions or to determine that characters were
processed.

#ifdef librock_TYPICAL_USE_sscons
    const char *ptr = "07 0x08 0b1001 10 Q 11";
    while(1) {
        int val;
        int cnt = librock_sscons(ptr,0,&val);
        if (!cnt) {
            break;
        }
        printf("%d\n",val);
        ptr += cnt;
        while (*ptr == ' ') {
            ptr++;
        }
    }
#endif

USES

    // [No external calls]

LICENSE

  Copyright 1998-2002 Forrest J. Cavalier III, http://www.mibsoftware.com
  Licensed under BSD-ish license, NO WARRANTY. Copies must retain this block.
  License text in <librock/license/librock.txt> librock_LIDESC_HC=12440211096131f5976d36be0cddca4cd9152e45

Source Code

./text/convert/integer/ss.c (implementation, plus source of this manual page)

Tests and Supported Platform Types

This is a representative sample. Librock code is highly portable. For a particular platform not reported here, request paid support

librock_sscons passed tests in tss (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_sscons passed tests in tss (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_ssconsl passed tests in tss (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_ssconsl passed tests in tss (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)
librock_ssdec passed tests in tss (Unix/Linux/BSD: 2002/08/08 sys=FreeBSD using gcc)
librock_ssdec passed tests in tss (WIN32: 2002/08/08 sys=NT 4.0 using MSVC)


This software is part of Librock

Rapid reuse, without rework. Details
This page copyright (C) 2002-2003 Forrest J. Cavalier III, d-b-a Mib Software, Saylorsburg PA 18353, USA

Verbatim copying and distribution of this generated page is permitted in any medium provided that no changes are made.
(The source of this manual page may be covered by a more permissive license which allows modifications.)

Want to help? We welcome comments, patches. -- Need help? Request paid support.