| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

conv_str_bool

#include "sflconv.h"
int
conv_str_bool (
    const char *string)

Synopsis

Converts a string to a Bool. Accepts T/Y/1 as TRUE, F/N/0 as FALSE, ignoring case. Looks only at the first letter of the string. Returns 1 for TRUE, 0 for FALSE, -1 if the string was not valid.

Source Code - (sflcvsb.c)

{
    char
        ch;

    ch = tolower (string [0]);
    conv_reason = 0;                    /*  No conversion errors so far      */
    if (ch == 'y' || ch == 't' || ch == '1')
        return (1);
    else
    if (ch == 'n' || ch == 'f' || ch == '0')
        return (0);
    else
      {
        conv_reason = CONV_ERR_NOT_BOOLEAN;
        return (-1);
      }
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation