Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

Forms


Files

file  forms.c
 Forms interface.

file  forms.h
 Form interface.


Data Structures

struct  Form
 Structure describing a single form. More...

struct  FormField
 Structure describing a single form field. More...


Defines

#define FRM_ERROR   "frm_error"
 The field name that holds form error messages.


Enumerations

enum  FieldType { FT_NONE, FT_TEXT, FT_PWD, FT_FILENAME }
 Form Field type. More...

enum  FieldRelevance { FR_OPTIONAL, FR_REQUIRED }
 Field Relevance. More...


Functions

FormFieldfld_add (FormField *fld, char *nm)
 Add a new field with the given name.

int fld_count (FormField *fld)
 Get the number of form fields.

FormFieldfld_free (FormField *fld)
 Free the specified field and return NULL.

FormFieldfld_get (FormField *fld, int i)
 Get the 'i'th field in the list rooted at 'fld'.

char * fld_get_help (FormField *fld)
 Retrieve the help text for the subject field.

FormFieldfld_get_last (FormField *fld)
 Find the last field in the list rooted at 'fld'.

char * fld_get_name (FormField *fld)
 Get the name of the specified field.

FieldRelevance fld_get_relevance (FormField *fld)
 Get the relevance of this field.

char * fld_get_tip (FormField *fld)
 Get the tip text for the specified field.

FieldType fld_get_type (FormField *fld)
 Get the field type.

char * fld_get_value (FormField *fld)
 Get the value text from the field.

char * fld_get_value_by_name (FormField *fld, char *nm)
 Search the field list rooted at 'fld', and return the value of the field with the name 'nm'.

FormFieldfld_new (char *nm)
 Allocate a new field named 'nm'.

FormFieldfld_next (FormField *fld)
 Return the next field in the list after 'fld'.

void fld_set_help (FormField *fld, char *hlp)
 Set the help text for the field.

FormFieldfld_set_name (FormField *fld, char *nm)
 Set the name of the field.

void fld_set_relevance (FormField *fld, FieldRelevance r)
 Set the relevance of the field.

void fld_set_tip (FormField *fld, char *txt)
 Set the tip text for the field.

void fld_set_type (FormField *fld, FieldType typ)
 Set the type of the field.

void fld_set_value (FormField *fld, char *val)
 Set the value of the field.

char * fld_set_value_by_name (FormField *fld, char *nm, char *val)
 Search the field list rooted at 'fld', and set the value of the field(s) with the name 'nm' to 'val'.

ABuffrm_check_fields (Form *frm)
 Creates a pane from a form.

void frm_clear_fields (Form *frm)
 Clears the values of all fields, but doesn't free them.

Formfrm_free (Form *f)
 Free the specified form.

FormFieldfrm_add_field (Form *frm, char *nm, char *val)
 Add a new field to the form.

FormFieldfrm_get_field (Form *frm, int n)
 Get the 'n'th field from the form.

FieldType frm_get_field_type (Form *frm, int n)
 Get the type of the 'n'th field from the form.

int frm_get_field_count (Form *frm)
 Get the number of fields in the form.

char * frm_get_field_name (Form *frm, int i)
 Get the name of the 'i'th field on the form.

char * frm_get_title (Form *frm)
 Get the form title.

char * frm_get_value (Form *frm, int i)
 Get the value of the 'i'th field on the form.

char * frm_get_value_by_name (Form *frm, char *nm)
 Get the value of the form field with the name 'nm'.

FormFieldfrm_last_field (Form *frm)
 Get the last field on the form.

int frm_match (Form *frm1, Form *frm2)
 Compare two forms to see if they are identical.

Formfrm_new (Form *frm)
 Allocate a new form.

int frm_save_file (Form *frm, char *fn)
 Save the Form to a file.

void frm_set_field_type (Form *frm, int id, int typ)
 Set the type of the 'i'th field on the form.

Formfrm_set_title (Form *f, char *ttl)
 Set the title of the form.

void frm_set_value_by_name (Form *frm, char *nm, char *val)
 Set the value of the form field(s) named 'nm'.


Enumeration Type Documentation

enum FieldRelevance
 

Field Relevance.

Marks the field as optional or compulsory.

Enumeration values:
FR_OPTIONAL 
  • Field is optional (default)
FR_REQUIRED 
  • Field must be completed

Definition at line 40 of file forms.h.

Referenced by fld_get_relevance(), fld_set_relevance(), and frm_check_fields().

enum FieldType
 

Form Field type.

Enumeration values:
FT_NONE 
  • Invalid field type
FT_TEXT 
  • Field is a normal text field (default)
FT_PWD 
  • Field is a password field

Typed characters should be hidden in the user interface.

FT_FILENAME 
  • Field is for a filename

Definition at line 32 of file forms.h.

Referenced by fld_get_type(), fld_set_type(), and frm_get_field_type().


Function Documentation

FormField* fld_add FormField   fld,
char *    nm
 

Add a new field with the given name.

Parameters:
fld  If NULL, allocates a new field and returns it as the list.
nm  The name for the field.
Returns:
A pointer to the list. If 'fld' was NULL, the return value will be the newly allocated Field. If 'fld' was NOT NULL, the return value will be 'fld'.

Definition at line 63 of file forms.c.

References fld_new(), and FormField::next.

Referenced by frm_add_field().

int fld_count FormField   fld
 

Get the number of form fields.

Parameters:
fld  The start of the list.
Returns:
The field count.

Definition at line 86 of file forms.c.

References FormField::next.

Referenced by frm_get_field_count().

FormField* fld_free FormField   fld
 

Free the specified field and return NULL.

Parameters:
fld  The base of the list.
Returns:
Always returns NULL. This is so you can do "fields = fld_free(fields);" to NULL the pointer.

Definition at line 101 of file forms.c.

References fld_set_name(), fld_set_value(), and FormField::next.

Referenced by frm_clear(), and frm_free().

FormField* fld_get FormField   fld,
int    i
 

Get the 'i'th field in the list rooted at 'fld'.

Parameters:
fld  The start field.
i  The index of the field to find.
Returns:
A pointer to the selected field.

Definition at line 118 of file forms.c.

References FormField::next.

Referenced by frm_get_field().

char* fld_get_help FormField   fld
 

Retrieve the help text for the subject field.

Parameters:
fld  The field.
Returns:
The help string, or NULL if none specified.

Definition at line 133 of file forms.c.

References FormField::help.

Referenced by frm_print(), and frm_save_file().

char* fld_get_name FormField   fld
 

Get the name of the specified field.

Parameters:
fld 
Returns:
The name pointer. Dont free this pointer.

Definition at line 178 of file forms.c.

References FormField::name.

Referenced by frm_check_fields(), frm_copy(), frm_get_field_name(), frm_print(), and frm_save_file().

FieldRelevance fld_get_relevance FormField   fld
 

Get the relevance of this field.

Parameters:
fld  The field.
Returns:
The relevance option.

Definition at line 143 of file forms.c.

References FieldRelevance, FR_OPTIONAL, and FormField::rel.

Referenced by frm_check_fields().

char* fld_get_tip FormField   fld
 

Get the tip text for the specified field.

Parameters:
fld  The field.
Returns:
The text string, or NULL if none specified.

Definition at line 153 of file forms.c.

References FormField::tip.

Referenced by frm_print(), and frm_save_file().

FieldType fld_get_type FormField   fld
 

Get the field type.

Parameters:
fld  The field.
Returns:
The field type.
See also:
FieldType , FT_NONE , FT_TEXT , FT_PWD , FT_FILENAME

Definition at line 168 of file forms.c.

References FieldType, FT_NONE, and FormField::type.

Referenced by frm_get_field_type().

char* fld_get_value FormField   fld
 

Get the value text from the field.

Parameters:
fld  The base of the field list.
Returns:
The field value string.

Definition at line 188 of file forms.c.

References FormField::value.

Referenced by frm_check_fields(), frm_get_value(), frm_print(), and frm_save_file().

void fld_set_help FormField   fld,
char *    hlp
 

Set the help text for the field.

Parameters:
fld  The field to set the help on.
hlp  The help text.

Definition at line 242 of file forms.c.

References FormField::help.

Referenced by frm_define_field().

void fld_set_relevance FormField   fld,
FieldRelevance    r
 

Set the relevance of the field.

Parameters:
fld  The field to set the help on.
r  The relevance to set.

Definition at line 256 of file forms.c.

References FieldRelevance, and FormField::rel.

Referenced by register_XPath().

void fld_set_tip FormField   fld,
char *    txt
 

Set the tip text for the field.

Parameters:
fld  The field to set the help on.
txt  The tooltip text.

Definition at line 266 of file forms.c.

References FormField::tip.

Referenced by frm_define_field(), register_PostgreSQL(), and register_XPath().

void fld_set_type FormField   fld,
FieldType    typ
 

Set the type of the field.

Parameters:
fld  The field to modify.
m typ The new type.

Definition at line 232 of file forms.c.

References FieldType, and FormField::type.

Referenced by frm_set_field_type(), register_PostgreSQL(), and register_XPath().

void fld_set_value FormField   fld,
char *    val
 

Set the value of the field.

Parameters:
fld  The field to set.
val  The new value (may be NULL).

Definition at line 298 of file forms.c.

References FormField::value.

Referenced by fld_free(), fld_set_value_by_name(), frm_add_field(), and frm_clear_fields().

FormField* frm_add_field Form   frm,
char *    nm,
char *    val
 

Add a new field to the form.

Returns a pointer to the added field.

Definition at line 325 of file forms.c.

References Form::fld, fld_add(), fld_set_value(), and frm_last_field().

Referenced by frm_copy(), frm_define_field(), register_PostgreSQL(), and register_XPath().

ABuf* frm_check_fields Form   frm
 

Creates a pane from a form.

Parameters:
frm  The form data to use.
Returns:
A Buf containing an error message, or NULL if no error. If a Buf is returned, the caller should free it after use.

Definition at line 386 of file forms.c.

References buf_str_shrinkbyone(), buf_strcat(), FieldRelevance, fld_get_name(), fld_get_relevance(), fld_get_value(), FR_REQUIRED, frm_get_field(), and frm_get_field_count().

Referenced by db_connect_dialog_reconnect().

void frm_clear_fields Form   frm
 

Clears the values of all fields, but doesn't free them.

Parameters:
frm  The form to operate on.

Definition at line 430 of file forms.c.

References Form::fld, fld_set_value(), and FormField::next.

Referenced by pg_DBurl_to_form(), and xp_DBurl_to_form().

char* frm_get_value Form   frm,
int    i
 

Get the value of the 'i'th field on the form.

Parameters:
frm  The form to query.
i  The zero-based index.
Returns:
The value, or NULL.

Definition at line 517 of file forms.c.

References Form::fld, fld_get_value(), and frm_get_field().

Referenced by frm_match().

int frm_match Form   frm1,
Form   frm2
 

Compare two forms to see if they are identical.

Parameters:
frm1  The first form
frm2  The second form.
Returns:
Zero for a non-match, non-zero for a match.

Definition at line 596 of file forms.c.

References frm_get_field_count(), frm_get_field_name(), frm_get_value(), and frm_get_value_by_name().

int frm_save_file Form   frm,
char *    fn
 

Save the Form to a file.

Parameters:
frm  The form to save.
fn  The filename to save the file to.
Returns:
An integer error code. -1 = error opening file. 0 = success.

Definition at line 653 of file forms.c.

References _a_buf::b_dat, buf_free(), buf_new(), buf_strcat(), buf_strcpy(), Form::fld, fld_get_help(), fld_get_name(), fld_get_tip(), fld_get_value(), fld_next(), FRM_ERROR, frm_get_title(), and frm_set_value_by_name().


Generated on Sun May 9 19:19:27 2004 for GtkSQL by doxygen1.2.18