2
3
4
5
6
7
8
11
12
13
14
15
16
17
18
19
20
21
22
40char ff_tbl[][26] = {
"string",
"decimal_int",
"hex_int",
"float",
"double",
41 "currency",
"yyyymmdd",
"hhmmss",
"apr",
""};
51
52
53
54
55
56
57
58
60 bool f_insert =
FALSE;
63 WINDOW *win = form
->win;
73 char *fstart = accept_s;
74 char *fend = fstart + flen;
76 char *p = fstart = accept_s;
77 char *str_end = p + strlen(p);
89 mvwaddstr(win, flin, fcol, filler_s);
90 mvwaddstr(win, flin, fcol, accept_s);
98
133 x = fcol + (p - fstart);
137
138
204 if (p < fend && p < str_end) {
221 fend = fstart + flen;
222 str_end = fstart + strlen(fstart);
240
242 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.')
248
250 if ((in_key >=
'0' && in_key <=
'9') ||
251 (in_key >=
'A' && in_key <=
'F') ||
252 (in_key >=
'a' && in_key <=
'f'))
258
260 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
261 (in_key ==
'-' && p == fstart))
267
269 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
270 (in_key ==
'-' && p == fstart))
276
277
279 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.' ||
280 (in_key ==
'-' && p == fstart))
287 if (in_key >=
'0' && in_key <=
'9')
294 if (in_key >=
'0' && in_key <=
'9')
301 if ((in_key >=
'0' && in_key <=
'9') || in_key ==
'.')
307 Perror("field_editor() invalid format");
312 if (str_end < fend) {
326 }
else if (p == str_end) {
342
343
344
345
346
347
348
349
350
359
360
361
362
363
364
365
366
367
368
370 WINDOW *win = form
->win;
380
381
382
383
384
385
386
387
388
392 WINDOW *box = form
->box;
395 wmove(box, flin, fcol);
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
493 int decimal_int_n = 0;
496 double double_n = 0.0;
497 double currency_n = 0.0;
504 Date.yyyy = Date.mm = Date.dd = 0;
510 Time.hh = Time.mm = Time.ss = 0;
521 sscanf(input_s,
"%d", &decimal_int_n);
522 sprintf(accept_s,
"%d", decimal_int_n);
523 sprintf(display_s,
"%d", decimal_int_n);
527 sscanf(input_s,
"%x", &hex_int_n);
528 sprintf(accept_s,
"%d", hex_int_n);
529 sprintf(display_s,
"%x", hex_int_n);
533 sscanf(input_s,
"%f", &float_n);
534 sprintf(accept_s,
"%f", float_n);
535 sprintf(display_s,
"%f", float_n);
539 sscanf(input_s,
"%lf", &double_n);
540 sprintf(accept_s,
"%lf", double_n);
541 sprintf(display_s,
"%lf", double_n);
546 sscanf(field_s,
"%lf", ¤cy_n);
547 sprintf(accept_s,
"%.2lf", currency_n);
548 sprintf(display_s,
"%'.2lf", currency_n);
552 Date.yyyy = Date.mm = Date.dd = 0;
554 sscanf(field_s,
"%4d%2d%2d", &Date.yyyy, &Date.mm, &Date.dd);
555 sprintf(accept_s,
"%04d%02d%02d", Date.yyyy, Date.mm, Date.dd);
557 sprintf(display_s,
"%04d-%02d-%02d", Date.yyyy, Date.mm, Date.dd);
560 Time.hh = Time.mm = Time.ss = 0;
562 sscanf(field_s,
"%2d%2d%2d", &Time.hh, &Time.mm, &Time.ss);
563 sprintf(accept_s,
"%02d%02d%02d", Time.hh, Time.mm, Time.ss);
565 sprintf(display_s,
"%02d:%02d:%02d", Time.hh, Time.mm, Time.ss);
568 sscanf(input_s,
"%lf", &double_n);
569 sprintf(accept_s,
"%lf", double_n);
570 sprintf(display_s,
"%0.3lf", double_n);
574 Perror("form_fmt_field() invalid format");
583
584
585
586
587
601 if (strpbrk(p,
"*?[]") != 0) {
602 Perror("metacharacters not allowed");
609
610
611
612
613
614
615
616
627
628
629
630
631
632
633
636
637
638
639
640
641
642
643
644
645
662
663
664
665
666
667
668
669
670
671
673 if (yyyy < 1 || mm < 1 || mm > 12 || dd < 1)
675 int days_in_month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
676 if ((yyyy % 4 == 0 && yyyy % 100 != 0) || (yyyy % 400 == 0))
677 days_in_month[2] = 29;
678 if (dd > days_in_month[mm])
683
684
685
686
687
688
689
690
691
692
694 if (hh < 0 || hh > 23 || mm < 0 || mm > 59 || ss < 0 || ss > 59)
699
700
701
702
703
704
705
706
707
708
711 if (*s ==
'-' || *s ==
'.' || (*s >=
'0' && *s <=
'9'))
int form_yx_to_fidx(Form *, int, int)
#define min(x, y)
min macro evaluates two expressions, returning least result
void display_chyron(WINDOW *win, Chyron *chyron, int line, int col)
int xwgetch(WINDOW *, Chyron *, int)
Wrapper for wgetch that handles signals, mouse events, checks for clicks on the chyron line,...
void set_chyron_key_cp(Chyron *, int, char *, int, int)
Set chyron key.
void compile_chyron(Chyron *)
construct the chyron string from the chyron structure
int Perror(char *)
Display a simple error message window or print to stderr.
int form_fmt_field(Form *, char *)
Format field according to its format type.
int field_editor(Form *)
Accept input for a field.
void numeric(char *, char *)
Extract numeric characters from source string to destination string.
void right_justify(char *, int)
Right justify string by removing trailing spaces and adding leadingspaces.
bool is_valid_date(int, int, int)
Check if a given date is valid, including leap years.
void left_justify(char *)
Left justify string by removing leading spaces.
bool is_valid_time(int, int, int)
Check if a given time is valid.
int form_display_field_n(Form *, int)
Display field n.
void mk_filler(char *, int)
Create filler string for field.
int form_display_field(Form *)
Display current field.
int form_validate_field(Form *)
Validate current field based on flags.
int form_display_field_brackets(Form *)
Display brackets around current field if set.
size_t strnz__cpy(char *, const char *, size_t)
safer alternative to strncpy
size_t trim(char *)
Trims leading and trailing spaces from string s in place.
size_t strnz(char *, size_t)
terminates string at New Line, Carriage Return, or max_len
char display_s[FIELD_MAXLEN]
char accept_s[FIELD_MAXLEN]
char input_s[FIELD_MAXLEN]
char filler_s[FIELD_MAXLEN]
Field * field[FIELD_MAXCNT]