cgislsetcmp() - set user-defined variable comparison function


#include "cgi.h"

int       cgislsetcmp(sl, cmp)
CGISL    *sl;

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

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.


#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: May 19 2023
Copyright © 2023 Thunderstone Software LLC. All rights reserved.