cgislsetcmp() - set user-defined variable comparison function

SYNOPSIS

#include "cgi.h"

int       cgislsetcmp(sl, cmp)
CGISL    *sl;
CGISLCMP *cmp;

typedef int (CGISLCMP)(/* CONST char *a, CONST char *b */);


DESCRIPTION
The cgislsetcmp() function sets the comparison function used when looking up variable names in the given CGISL object. The cmp parameter points to a function with the same behavior as strcmp() - compare two strings, returning 0 if equal, < 0 if the first is "smaller", or > 0 if the first is "larger". By default the comparison function for CGISL lists is strcmp() - i.e. identical (case-sensitive) compares.

The cgislsetcmp() function returns 1 on success, 0 on error.


EXAMPLE

#include "cgi.h"

CGISL  *sl;

...

{
  char    **vals;

  cgisladdvar(sl, "Test", "test value");
  cgislsetcmp(sl, strcasecmp);     /* use case-insensitive compares */
  if ((vals = getcgisl(sl, "TEST")) != CHARPPN) {
    printf("The value of TEST is: %s\n", *vals);
  }
}


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.