1 /*
2  * $LynxId: HTForms.h,v 1.34 2018/05/04 22:50:54 tom Exp $
3  */
4 #ifndef HTFORMS_H
5 #define HTFORMS_H
6 
7 #ifndef LYSTRUCTS_H
8 #include <LYStructs.h>
9 #endif /* LYSTRUCTS_H */
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 /* change_form_link() calls change_form_link_ex() with all its args and FALSE
15  * as last arg
16  */ extern int change_form_link(int cur,
17 				DocInfo *newdoc,
18 				BOOLEAN *refresh_screen,
19 				int use_last_tfpos,
20 				int immediate_submit);
21 
22     extern int change_form_link_ex(int cur,
23 				   DocInfo *newdoc,
24 				   BOOLEAN *refresh_screen,
25 				   int use_last_tfpos,
26 				   int immediate_submit,
27 				   int draw_only);
28 
29 /* InputFieldData is used to pass the info between HTML.c and Gridtext.c in
30  * HText_beginInput()
31  */
32     typedef struct _InputFieldData {
33 	const char *accept;
34 	const char *align;
35 	int checked;
36 	const char *iclass;
37 	int disabled;
38 	int readonly;
39 	const char *error;
40 	const char *height;
41 	const char *id;
42 	const char *lang;
43 	const char *max;
44 	const char *maxlength;
45 	const char *md;
46 	const char *min;
47 	const char *name;
48 	int size;
49 	const char *src;
50 	const char *type;
51 	char *value;
52 	const char *width;
53 	int name_cs;		/* charset handle for name */
54 	int value_cs;		/* charset handle for value */
55 	const char *accept_cs;
56     } InputFieldData;
57 
58 /* The OptionType structure is for a linked list of option entries
59  */
60     typedef struct _OptionType {
61 	char *name;		/* the name of the entry */
62 	char *cp_submit_value;	/* the value to submit   */
63 	int value_cs;		/* charset value is in   */
64 	struct _OptionType *next;	/* the next entry        */
65     } OptionType;
66 
67 /*
68  * The FormInfo structure is used to contain the form field data within each
69  * anchor.  A pointer to this structure is in the TextAnchor struct.
70  */
71     typedef struct _FormInfo {
72 	char *name;		/* the name of the link */
73 	int number;		/* which form is the link within */
74 	int type;		/* string, int, etc. */
75 	char *value;		/* user entered string data */
76 	char *orig_value;	/* the original value */
77 	int size;		/* width on the screen */
78 	unsigned maxlength;	/* max width of data */
79 	int group;		/* a group associated with the link
80 				 *  this is used for select's
81 				 */
82 	int num_value;		/* value of the numerical fields */
83 	int hrange;		/* high numerical range */
84 	int lrange;		/* low numerical range */
85 	OptionType *select_list;	/* array of option choices */
86 	char *submit_action;	/* form's action */
87 	int submit_method;	/* form's method */
88 	char *submit_enctype;	/* form's entype */
89 	char *submit_title;	/* form's title */
90 	BOOL no_cache;		/* Always resubmit? */
91 	char *cp_submit_value;	/* option value to submit */
92 	char *orig_submit_value;	/* original submit value */
93 	int size_l;		/* The length of the option list */
94 	int disabled;		/* If YES, can't change values */
95 	int readonly;		/* If YES, can't change values */
96 	int name_cs;
97 	int value_cs;
98 	char *accept_cs;
99     } FormInfo;
100 
101 #define FormIsReadonly(form) ((form) && ((form)->disabled || (form)->readonly))
102 
103 /*
104  * As structure for info associated with a form.  There is some redundancy
105  * here, this shouldn't waste too much memory since the total number of forms
106  * (as opposed to form fields) per doc is expected to be rather small.  More
107  * things which are per form rather than per field could be moved here.  - kw
108  */
109     typedef struct _PerFormInfo {
110 	int number;		/* form number, see GridText.c */
111 	int disabled;		/* If YES, can't change values */
112 	FormInfo data;
113 	struct _PerFormInfo *next;	/* pointer to next form in doc */
114 	int nfields;		/* number of fields */
115 	FormInfo *first_field;
116 	FormInfo *last_field;	/* pointer to last field in form */
117 	char *accept_cs;
118 	char *thisacceptcs;	/* used during submit */
119     } PerFormInfo;
120 
121 #define HYPERTEXT_ANCHOR 1
122 #define INPUT_ANCHOR     2	/* forms mode input fields */
123 #define INTERNAL_LINK_ANCHOR 5	/* 1+4, can be used as bitflag... - kw */
124 
125     typedef enum {
126 	F_UNKNOWN = 0,
127 	F_TEXT_TYPE,
128 	F_PASSWORD_TYPE,
129 	F_CHECKBOX_TYPE,
130 	F_RADIO_TYPE,
131 	F_SUBMIT_TYPE,
132 	F_RESET_TYPE,
133 	F_OPTION_LIST_TYPE,
134 	F_HIDDEN_TYPE,
135 	F_TEXTAREA_TYPE,
136 	F_RANGE_TYPE,
137 	F_FILE_TYPE,
138 	F_TEXT_SUBMIT_TYPE,
139 	F_IMAGE_SUBMIT_TYPE,
140 	F_KEYGEN_TYPE,
141 	F_BUTTON_TYPE
142     } FieldTypes;
143 
144 #define F_SUBMITLIKE(type) ((type) == F_SUBMIT_TYPE || \
145 			    (type) == F_IMAGE_SUBMIT_TYPE || \
146 			    (type) == F_TEXT_SUBMIT_TYPE)
147 
148 #define F_TEXTLIKE(type) ((type) == F_TEXT_TYPE || \
149 			  (type) == F_TEXT_SUBMIT_TYPE || \
150 			  (type) == F_PASSWORD_TYPE || \
151 			  (type) == F_FILE_TYPE || \
152 			  (type) == F_TEXTAREA_TYPE)
153 
154 #define WWW_FORM_LINK_TYPE  1
155 #define WWW_LINK_TYPE   2
156 #define WWW_INTERN_LINK_TYPE   6	/* can be used as a bitflag... - kw */
157 #define LINK_LINE_FOUND	8	/* used in follow_link_number, others - kw */
158 #define LINK_DO_ARROWUP	16	/* returned by HTGetLinkOrFieldStart - kw */
159 
160 /* #define different lynx modes */
161 #define NORMAL_LYNX_MODE 1
162 #define FORMS_LYNX_MODE  2
163 
164 #define FIRST_ORDER  1
165 #define MIDDLE_ORDER 2
166 #define LAST_ORDER   3
167 
168 /* in LYForms.c */
169     extern void show_formlink_statusline(const FormInfo * form,
170 					 int for_what);
171 #ifdef __cplusplus
172 }
173 #endif
174 #endif				/* HTFORMS_H */
175