internals.h revision 1.11 1 /* $NetBSD: internals.h,v 1.11 2016/03/09 19:47:13 christos Exp $ */
2
3 /*-
4 * Copyright (c) 1998-1999 Brett Lymn
5 * (blymn (at) baea.com.au, brett_lymn (at) yahoo.com.au)
6 * All rights reserved.
7 *
8 * This code has been donated to The NetBSD Foundation by the Author.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 *
30 */
31
32 #include <stdio.h>
33 #include "form.h"
34
35 #ifndef FORMI_INTERNALS_H
36 #define FORMI_INTERNALS_H 1
37
38 /* direction definitions for _formi_pos_new_field */
39 #define _FORMI_BACKWARD 1
40 #define _FORMI_FORWARD 2
41
42 /* define the default options for a form... */
43 #define DEFAULT_FORM_OPTS (O_VISIBLE | O_ACTIVE | O_PUBLIC | O_EDIT | \
44 O_WRAP | O_BLANK | O_AUTOSKIP | O_NULLOK | \
45 O_PASSOK | O_STATIC)
46
47 /* definitions of the flags for the FIELDTYPE structure */
48 #define _TYPE_NO_FLAGS 0
49 #define _TYPE_HAS_ARGS 0x01
50 #define _TYPE_IS_LINKED 0x02
51 #define _TYPE_IS_BUILTIN 0x04
52 #define _TYPE_HAS_CHOICE 0x08
53
54 typedef struct formi_type_link_struct formi_type_link;
55
56 struct formi_type_link_struct
57 {
58 FIELDTYPE *next;
59 FIELDTYPE *prev;
60 };
61
62
63 struct _formi_page_struct
64 {
65 int in_use;
66 int first;
67 int last;
68 int top_left;
69 int bottom_right;
70 };
71
72 struct _formi_tab_stops
73 {
74 struct _formi_tab_stops *fwd;
75 struct _formi_tab_stops *back;
76 unsigned char in_use;
77 unsigned pos;
78 unsigned size;
79 };
80
81 typedef struct _formi_tab_stops _formi_tab_t;
82
83 /* lines structure for the field - keeps start and ends and length of the
84 * lines in a field.
85 */
86 struct _formi_field_lines
87 {
88 _FORMI_FIELD_LINES *prev;
89 _FORMI_FIELD_LINES *next;
90 unsigned allocated;
91 unsigned length;
92 unsigned expanded;
93 char *string;
94 unsigned char hard_ret; /* line contains hard return */
95 _formi_tab_t *tabs;
96 };
97
98
99 /* function prototypes */
100 unsigned
101 _formi_skip_blanks(char *string, unsigned int start);
102 int
103 _formi_add_char(FIELD *cur, unsigned pos, char c);
104 void
105 _formi_calculate_tabs(_FORMI_FIELD_LINES *row);
106 int
107 _formi_draw_page(FORM *form);
108 int
109 _formi_find_pages(FORM *form);
110 int
111 _formi_field_choice(FORM *form, int c);
112 void
113 _formi_init_field_xpos(FIELD *field);
114 int
115 _formi_manipulate_field(FORM *form, int c);
116 int
117 _formi_pos_first_field(FORM *form);
118 int
119 _formi_pos_new_field(FORM *form, unsigned direction, unsigned use_sorted);
120 void
121 _formi_redraw_field(FORM *form, int field);
122 void
123 _formi_sort_fields(FORM *form);
124 void
125 _formi_stitch_fields(FORM *form);
126 int
127 _formi_tab_expanded_length(char *str, unsigned int start, unsigned int end);
128 int
129 _formi_update_field(FORM *form, int old_field);
130 int
131 _formi_validate_char(FIELD *field, char c);
132 int
133 _formi_validate_field(FORM *form);
134 int
135 _formi_wrap_field(FIELD *field, _FORMI_FIELD_LINES *pos);
136 int
137 _formi_sync_buffer(FIELD *field);
138
139 #ifdef DEBUG
140 void _formi_dbg_printf(const char *, ...) __printflike(1, 2);
141 #else
142 #define _formi_dbg_printf(a,...)
143 #endif /* DEBUG */
144
145 #endif
146