-
Notifications
You must be signed in to change notification settings - Fork 0
/
kitsed.c
executable file
·269 lines (217 loc) · 6.67 KB
/
kitsed.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#include <stdio.h>
#include <stdlib.h>
#include ints
#include string
#include ctype
#include smgdef
#include smg$routines
#include rms
#include starlet
#include "extools.h"
#include "screen.h"
#include "filebrowse.h"
#include "warns.h"
#include "swfile.h"
#include "colours.h"
void strupr (char *);
#define SHEADING "Select Inventory Item"
struct kit_part_rec kitsed_buff;
struct kit_part_rec comp_buff;
extern struct filestruct inventory_file;
extern int TermWidth;
extern int win_depth;
extern int BottomLine;
/*
capital(char *in_str)
{
strupr(in_str);
return(TRUE);
}
*/
int get_inventory_item ();
extern struct inventory_rec inventory_buff;
extern struct inventory_key0_rec inventory_listkey;
int inventory_lnth;
void inventory_trans ();
int inventory_keymatch ();
int select_inventory_item (struct kit_part_rec *);
void
slct_invent ()
{
select_inventory_item (&kitsed_buff);
}
struct cmndline_params cmnd_line[] = {
1, NULL, NULL, 0, NULL,
F1, "Inventory", NULL, 0, slct_invent
};
void invent_search ();
struct cmndline_params invent_cmndline[] = {
1, NULL, NULL, 0, NULL,
F1, "Search", NULL, 0, invent_search
};
/* *INDENT-OFF* */
#define LINEDLEN 5
struct scr_params kit_line[] = {
0,0,"",PROMPTCOL,UNFMT_STRING,kitsed_buff.part_code,FIELDCOL,10,get_inventory_item,cmnd_line,
0,10,"|",PROMPTCOL,UNFMT_STRING|NON_EDIT,kitsed_buff.description,FIELDCOL,28,NULL,NULL,
0,39,"|",PROMPTCOL,UNFMT_STRING|NON_EDIT,kitsed_buff.units,FIELDCOL,5,NULL,NULL,
0,45,"|%7.2f",PROMPTCOL,NUMERIC,&kitsed_buff.number,FIELDCOL,7,NULL,NULL,
0,53,"|",PROMPTCOL,UNFMT_STRING,kitsed_buff.ext_description,FIELDCOL,23,NULL,NULL
};
/* *INDENT-ON* */
void inventory_search_2 ();
int
select_inventory_item (struct kit_part_rec *crnt_line)
{
int ret, status;
unsigned long rec_num;
spawn_scroll_window (&inventory_file, 10, 68);
HeadLine (SHEADING, centre);
/*
rfa_copy(&inventory_file.rab.rab$w_rfa,File_Browse(&inventory_file,select));
if (!rfa_iszero((struct rfabuff *)&inventory_file.rab.rab$w_rfa)) {
inventory_file.rab.rab$b_rac = RAB$C_RFA;
inventory_file.rab.rab$l_ubf = (char *)inventory_file.fileio;
inventory_file.rab.rab$w_usz = inventory_file.fileiosz;
inventory_file.rab.rab$l_rop = RAB$M_NLK;
rms_status = sys$get(&inventory_file.rab);
if (!rmstest(rms_status,2,RMS$_NORMAL,RMS$_OK_RLK))
warn_user("$GET %s %s %s %u",filterfn(inventory_file.filename),rmslookup(rms_status),filterfn(__FILE__),__LINE__);
else {
close_window();
win_depth--;
Help(TEXACOHLP);
memcpy(crnt_line->part_code,inventory_buff.part_code,PARTKEYLEN);
exclreol(kit_line[0].row,kit_line[0].col,BLACK);
init_screen(kit_line,LINEDLEN);
return(TRUE);
}
}
*/
if (!rfa_iszero (File_Browse (&inventory_file, select)))
{
close_window ();
win_depth--;
Help (TEXACOHLP);
memcpy (crnt_line->part_code, inventory_buff.part_code, PARTKEYLEN);
unpad (crnt_line->part_code, PARTKEYLEN);
/*
strcpy(kitsed_buff.description,inventory_buff.description);
warn_user("Desc:%s",inventory_buff.description);
strcpy(kitsed_buff.units,inventory_buff.units);
*/
exclreol (kit_line[0].row, kit_line[0].col, BLACK);
init_screen (kit_line, LINEDLEN);
return (TRUE);
}
close_window ();
win_depth--;
Help (TEXACOHLP);
return (FALSE);
}
int
get_inventory_item (char *code)
{
int lnth, status;
struct inventory_key0_rec inventory_key;
strupr (code);
strncpy (inventory_listkey.part_code, code, PARTKEYLEN);
pad (inventory_listkey.part_code, PARTKEYLEN);
inventory_file.rab.rab$b_krf = 0;
inventory_file.rab.rab$l_kbf = (char *) &inventory_listkey;
inventory_file.rab.rab$b_ksz = sizeof (inventory_listkey);
inventory_file.rab.rab$b_rac = RAB$C_KEY;
inventory_file.rab.rab$l_ubf = (char *) inventory_file.fileio; /*inventory_buff; /*record; */
inventory_file.rab.rab$w_usz = inventory_file.fileiosz; /*sizeof inventory_buff; */
inventory_file.rab.rab$l_rop = RAB$M_NLK | RAB$M_EQNXT;
rms_status = sys$get (&inventory_file.rab);
if (!rmstest (rms_status, 3, RMS$_NORMAL, RMS$_RNF, RMS$_OK_RLK))
{
warn_user ("GETEQ %s %s %u", rmslookup (rms_status),
filterfn (__FILE__), __LINE__);
return (FALSE);
}
if (rms_status == RMS$_RNF
|| strncmp (code, inventory_buff.part_code, strlen (code)) != 0)
{
warn_user ("No Match Found");
*kitsed_buff.part_code = 0;
exclreol (kit_line[0].row, kit_line[0].col, BLACK);
init_screen (kit_line, LINEDLEN);
return (FALSE);
}
strncpy (kitsed_buff.part_code, inventory_buff.part_code, PARTKEYLEN);
unpad (kitsed_buff.part_code, PARTKEYLEN);
strcpy (kitsed_buff.description, inventory_buff.description);
strcpy (kitsed_buff.units, inventory_buff.units);
exclreol (kit_line[0].row, kit_line[0].col, BLACK);
init_screen (kit_line, LINEDLEN);
return (TRUE);
}
void *
lmalloc (size_t amnt)
{
struct line_rec *temp_ptr = NULL;
if ((temp_ptr = malloc (amnt + (sizeof (temp_ptr) * 2))) != NULL)
{
memset (temp_ptr->storage, 0, amnt);
temp_ptr->next = NULL;
temp_ptr->last = NULL;
}
return (temp_ptr);
}
extern struct filestruct *G_filedef;
int
kitsed (edtstr, row, col, lnth, attr, pos, control)
char *edtstr;
int col, row, lnth, attr, *pos;
unsigned int *control;
{
int i, edited = FALSE, ret;
static int strtfld = 0;
struct line_rec *curs;
memcpy (&kitsed_buff, edtstr, sizeof (kitsed_buff));
if (*control & INIT_ONLY)
{
for (i = 0; i < LINEDLEN; i++)
kit_line[i].row = row;
init_screen (kit_line, LINEDLEN);
return (TRUE);
}
else if (*control & ALLOCATE)
{
(*(char **) edtstr) = lmalloc (sizeof (kitsed_buff));
strtfld = 0;
return (TRUE);
}
else if (*control & COMP_LOAD)
{
memcpy (&comp_buff, &kitsed_buff, sizeof (kitsed_buff));
return (TRUE);
}
else if (*control & COMP_CHECK)
{
return (memcmp (&comp_buff, &kitsed_buff, sizeof (kitsed_buff)) != 0);
}
for (i = 0; i < LINEDLEN; i++)
kit_line[i].row = row;
init_screen (kit_line, LINEDLEN);
ret =
enter_screen (kit_line, LINEDLEN, &edited, breakout, G_filedef, &strtfld);
switch (ret)
{
case SMG$K_TRM_RIGHT:
case SMG$K_TRM_CTRLZ:
case SMG$K_TRM_CR:
case SMG$K_TRM_HT:
strtfld = 0;
break;
case SMG$K_TRM_UP:
curs = G_filedef->entry_screen[G_filedef->entry_comment].field;
if (curs->last == NULL)
strtfld = 0;
break;
}
memcpy (edtstr, &kitsed_buff, sizeof (kitsed_buff));
return (ret);
}