Re: XForms: Example of fl_set_input_filter

Steve Lamont (
Tue, 24 Jun 97 06:28:38 PDT

To subscribers of the xforms list from (Steve Lamont) :

> Can someone show me an example of the use to the function:
> fl_set_input_filter

Sure. Here's a bit of code that filters an input field for a "legal"
file name.

First, this is where we create the form and establish the filter:

FD_rename_object *rename_object = create_form_rename_object();

fl_set_input_filter( rename_object->object_name,
name_filter );


fl_show_form( rename_object->rename_object,
"Rename Object..." );


and this is the filter itself:

static int name_filter( FL_OBJECT *obj,
const char *old, const char *cur,
int c )


int valid;

switch ( c ) {

case '\t': /* Characters we definitely don't want */
case ' ': /* since they create "troublesome" file names */
case '/': /* which have to be quoted and will cause */
case '`': /* trouble for unsophisticated lusers */
case '\'':
case '"':
case '[':
case ']':
case '*':
case '~':
case '&':
case '^':
case ';':
case '<':
case '>':
case '?':
case '|': {

valid = FL_INVALID;

default: { /* Could be valid, if printable */

if ( isprint( c ) )
valid = FL_VALID;
valid = FL_INVALID;



return valid;


This probably also could have been done with a regular expression
that would look like


The purpose of the filter is to make sure the luser doesn't enter a
file name that will cause trouble if they have to type it from the
shell. For instance


is legal but


is not since it contains a character with special meaning to the

> Thank you.

De nada.


To unsubscribe, send the message "unsubscribe" to or see
Xforms Home Page:
List Archive: