home *** CD-ROM | disk | FTP | other *** search
- /* g4.c (c)Copyright Sequiter Software Inc., 1987-1990. All rights reserved.
-
- GET Routines
- */
-
- #include "w4.h"
- #include "d4all.h"
- #include "g4char.h"
- #include "p4misc.h"
-
- #include <string.h>
- #include <stdlib.h>
- #include <ctype.h>
-
- #ifndef UNIX
- #include <io.h>
- #include <dos.h>
- #endif
-
- #ifdef LANGUAGE
- #define YES_CHAR 'J'
- #define YES_CHAR_LC 'j'
- #else
- #define YES_CHAR 'Y'
- #define YES_CHAR_LC 'y'
- #endif
-
- extern CB_WINDOW *v4window_ptr ;
- extern int v4cur_window ;
-
- extern GET *v4get ;
- static int insert = 0 ;
- static long prev_attribute = 7 ;
-
- static void g4check_get( GET * ) ;
- static int g4from_data( GET *, char * ) ;
- static void g4display_get( GET * ) ;
- static int g4fill_data( GET *, char *, char * ) ;
- static int g4right_pos( int, int, char * ) ;
- static int g4num_pos( int, int, char * ) ;
-
-
- /* Allocates some get memory */
-
- GET * g4alloc( int row, int col, void *data_ptr, char type )
- {
- GET * get_ptr ;
-
- if (v4get == (GET *) 0)
- if ( h4create( (char **) &v4get, 20, sizeof(GET), 10) < 0) return( (GET *) 0 ) ;
-
- v4window_ptr->last_get = h4get( (char **) &v4get, v4window_ptr->last_get ) ;
- if ( v4window_ptr->last_get < 0 ) return( (GET *) 0 ) ;
-
- if ( v4window_ptr->first_get < 0 )
- v4window_ptr->first_get = v4window_ptr->last_get ;
-
- get_ptr = v4get+ v4window_ptr->last_get ;
- get_ptr->window_ref = v4cur_window ;
- get_ptr->num_decimals = -1 ; /* Not Yet Set Flag */
- get_ptr->attribute = v4window_ptr->get_attribute ;
- memcpy( get_ptr->delimiter, v4window_ptr->get_delimiter,
- sizeof(get_ptr->delimiter) ) ;
-
- get_ptr->row = row ;
- get_ptr->col = col ;
- get_ptr->type = type ;
- get_ptr->data = data_ptr ;
-
- return( get_ptr ) ;
- }
-
-
- void g4( int row, int col, char *buffer )
- {
- g4alloc( row, col, (void *) buffer, 'C' ) ;
- }
-
-
- long g4attribute( long attribute )
- {
- v4window_ptr->get_attribute = attribute ;
- return ( v4window_ptr->get_attribute ) ;
- }
-
-
- void g4call( GET_ROUTINE *routine, int call_data )
- {
- v4get[ v4window_ptr->last_get].call = routine ;
- v4get[ v4window_ptr->last_get].call_data = call_data ;
- }
-
-
- void g4date( int row, int column, char *date_ptr )
- {
- g4alloc( row, column, date_ptr, 'D' ) ;
- }
-
-
- void g4delimiter( char *delimiter )
- {
- memcpy( v4window_ptr->get_delimiter, delimiter, 2 ) ;
- }
-
-
- void g4double( int row, int column, double *double_ptr )
- {
- g4alloc( row, column, (void *) double_ptr, 'd' ) ;
- }
-
-
- void g4int( int row, int column, int *int_ptr )
- {
- g4alloc( row, column, int_ptr, 'i' ) ;
- }
-
-
- void g4logical( int row, int column, int *logical_ptr )
- {
- g4alloc( row, column, (void *) logical_ptr, 'L' ) ;
- }
-
- void g4long( int row, int column, long *long_ptr )
- {
- g4alloc( row, column, (void *) long_ptr, 'l' ) ;
- }
-
-
- void g4message( char *message )
- {
- if ( v4window_ptr->last_get < 0 ) return ;
- v4get[ v4window_ptr->last_get].message = message ;
- }
-
-
- void g4numeric( int row, int column, char *num_ptr )
- {
- g4alloc( row, column, num_ptr, 'N' ) ;
- }
-
-
- void g4picture( char *picture )
- {
- if ( v4window_ptr->last_get < 0 ) return ;
- v4get[ v4window_ptr->last_get].picture = picture ;
- }
-
-
- void g4upper()
- {
- v4get[ v4window_ptr->last_get].upper_convert = 1 ;
- }
-
-
- #ifdef KR
- void g4valid( routine )
- int (*routine)() ;
- #else
- void g4valid( int (*routine)(GET *) )
- #endif
- {
- if ( v4window_ptr->last_get < 0 ) return ;
- v4get[ v4window_ptr->last_get].valid = routine ;
- }
-
-
- void g4width( int width_data, int width_scr )
- {
- GET *get_ptr ;
- if ( v4window_ptr->last_get < 0 ) return ;
-
- get_ptr = v4get+ v4window_ptr->last_get ;
-
- if ( width_data > 0 )
- get_ptr->width_data = width_data ;
- if ( width_scr > 0 )
- v4get[ v4window_ptr->last_get].width_scr = width_scr ;
- }
-
-
- static void g4check_get( GET *get_ptr )
- {
- int picture_len, i ;
- char *ptr ;
-
- if ( get_ptr->picture == (char *) 0)
- picture_len = 0 ;
- else
- {
- picture_len = (int) strlen( get_ptr->picture) ;
- }
-
- switch( get_ptr->type )
- {
- case 'C':
- case 'N':
- case 'D':
- if ( get_ptr->width_data <= 0)
- get_ptr->width_data = picture_len ;
- if ( get_ptr->width_data <= 0)
- {
- if ( get_ptr->type == 'D' )
- get_ptr->width_data = (int) strlen(v4default_date) ;
- else
- get_ptr->width_data = (int) strlen( (char *) get_ptr->data ) ;
- }
- if ( get_ptr->width_data <= 0 )
- get_ptr->width_data = 1 ;
- if ( get_ptr->width_scr <= 0 || get_ptr->width_scr > get_ptr->width_data)
- get_ptr->width_scr = get_ptr->width_data ;
-
- if ( get_ptr->type == 'N' )
- {
- if ( picture_len > 0 )
- ptr = get_ptr->picture ;
- else
- ptr = (char *) get_ptr->data ;
-
- for ( i=1; i<= get_ptr->width_data && *ptr != '\000'; i++, ptr++ )
- if ( *ptr == '.' )
- {
- get_ptr->num_decimals = get_ptr->width_data - i ;
- break ;
- }
-
- if ( get_ptr->num_decimals < 0 ) get_ptr->num_decimals = 0 ;
- }
- break ;
-
- case 'L':
- get_ptr->width_data = get_ptr->width_scr = 1 ;
- break ;
-
- case 'l':
- case 'i':
- if ( get_ptr->width_scr <= 0)
- {
- if ( picture_len > 0 )
- get_ptr->width_scr = picture_len ;
- else
- {
- if ( get_ptr->type == 'l' )
- get_ptr->width_scr = 8 ;
- else
- get_ptr->width_scr = 4 ;
- }
- }
- get_ptr->width_data = get_ptr->width_scr ;
- break ;
-
- case 'd':
- if ( picture_len > 0 )
- {
- ptr = strchr( get_ptr->picture, '.' ) ;
- if ( ptr == (char *) 0)
- get_ptr->num_decimals = 0 ;
- else
- get_ptr->num_decimals =
- picture_len - (int) (ptr-get_ptr->picture) -1;
-
- get_ptr->width_scr = picture_len ;
- }
- else
- {
- if ( get_ptr->width_scr <= 0) get_ptr->width_scr = 8 ;
- if ( get_ptr->num_decimals < 0)
- get_ptr->num_decimals = 2 ;
- if ( get_ptr->num_decimals >= get_ptr->width_scr)
- get_ptr->num_decimals = 0 ;
- }
-
- get_ptr->width_data = get_ptr->width_scr ;
- break ;
- }
- }
-
-
- #define PICTURE_CHRS "!9#ALNYXCMD"
-
- static int g4from_data( GET *get_ptr, char *chr_buf )
- {
- char *ptr, pict_char ;
- int i, len ;
-
- if ( get_ptr->type == 'd' )
- {
- ptr = c4dtoa( * ((double *) get_ptr->data), get_ptr->width_scr,
- get_ptr->num_decimals);
- memcpy( chr_buf, ptr, (size_t) get_ptr->width_scr ) ;
- return( get_ptr->width_scr ) ;
- }
-
- if ( get_ptr->type == 'l' )
- {
- c4ltoa( * ((long *) get_ptr->data), chr_buf, get_ptr->width_scr ) ;
- return( get_ptr->width_scr ) ;
- }
-
- if ( get_ptr->type == 'i' )
- {
- c4ltoa((long) (* ((int *)get_ptr->data)), chr_buf, get_ptr->width_scr) ;
- return( get_ptr->width_scr ) ;
- }
-
- if ( get_ptr->type == 'D' )
- {
- if ( get_ptr->picture == (char *) 0 )
- {
- ptr = c4dt_format( (char *) get_ptr->data, v4default_date ) ;
- len = (int) strlen(v4default_date ) ;
- }
- else
- {
- ptr = c4dt_format( (char *) get_ptr->data, get_ptr->picture ) ;
- len = (int) strlen( get_ptr->picture ) ;
- }
-
- memcpy( chr_buf, ptr, (size_t) len ) ;
- return( len ) ;
- }
-
- if ( get_ptr->type == 'L' )
- {
- if ( get_ptr->picture == (char *) 0 )
- pict_char = 'L' ;
- else
- pict_char = get_ptr->picture[0] ;
-
- if ( * ((int *) get_ptr->data) )
- {
- if ( pict_char == 'L' )
- chr_buf[0] = 'T' ;
- else
- chr_buf[0] = YES_CHAR ;
- }
- else
- {
- if ( pict_char == 'L' )
- chr_buf[0] = 'F' ;
- else
- chr_buf[0] = 'N' ;
- }
- return 1 ;
- }
-
- if ( get_ptr->type == 'N' && get_ptr->num_decimals > 0 )
- {
- ( (char *)get_ptr->data )
- [ get_ptr->width_data - get_ptr->num_decimals - 1] = '.' ;
- }
-
- memcpy( chr_buf, get_ptr->data, (size_t) get_ptr->width_data ) ;
-
- ptr = get_ptr->picture ;
- if ( ptr != (char *) 0)
- for ( i= 0; *ptr != '\000'; i++, ptr++ )
- {
- if ( strchr( PICTURE_CHRS, *ptr) == (char *) 0 )
- chr_buf[i] = get_ptr->picture[i] ;
- #ifdef LANGUAGE
- if ( *ptr == 'Y' || *ptr == 'L' )
- {
- if ( chr_buf[i] == 'Y' )
- chr_buf[i] = YES_CHAR ;
- if ( chr_buf[i] == 'y' )
- chr_buf[i] = YES_CHAR_LC ;
- }
- #endif
- }
-
- return( get_ptr->width_data ) ;
- }
-
-
- static void g4display_get( GET *get_ptr )
- {
- char buf[MAX_GET_WIDTH] ;
-
- g4from_data( get_ptr, buf ) ;
-
- if ( get_ptr->delimiter[0] != '\000' )
- {
- w4attribute( prev_attribute ) ;
- w4num( get_ptr->row, get_ptr->col-1, get_ptr->delimiter, 1 ) ;
- }
-
- w4attribute( get_ptr->attribute ) ;
- w4num( get_ptr->row, get_ptr->col, buf, get_ptr->width_scr ) ;
-
- if ( get_ptr->delimiter[1] != '\000' )
- {
- w4attribute( prev_attribute ) ;
- w4num( get_ptr->row, get_ptr->col+get_ptr->width_scr,
- get_ptr->delimiter+1, 1 ) ;
- }
- }
-
-
- void g4display()
- {
- GET *get_ptr ;
- int on_get ;
-
- prev_attribute = v4window_ptr->attribute ;
-
- on_get = v4window_ptr->last_get ;
-
- while ( on_get >= 0 )
- {
- get_ptr = v4get+ on_get ;
-
- g4check_get( get_ptr ) ;
- g4display_get( get_ptr ) ;
-
- on_get = get_ptr->prev ;
- }
-
- v4window_ptr->attribute = prev_attribute ;
- }
-
-
- static g4fill_data( GET *get_ptr, char *buffer, char *picture )
- {
- /* Transfer Back to get_ptr->data */
- switch ( get_ptr->type )
- {
- case 'd':
- *((double *)get_ptr->data) =
- c4atod( buffer, get_ptr->width_scr ) ;
- break ;
-
- case 'N':
- memcpy( get_ptr->data,
- c4dtoa( c4atod(buffer, get_ptr->width_data),
- get_ptr->width_data, get_ptr->num_decimals),
- (size_t) get_ptr->width_data ) ;
- break ;
-
- case 'i':
- *((int *)get_ptr->data) =
- (int) c4atoi( (char *) buffer, get_ptr->width_scr ) ;
- break ;
-
- case 'l':
- buffer[get_ptr->width_scr] = '\000' ;
- *((long *)get_ptr->data) = (long) atol( (char *) buffer ) ;
- break ;
-
- case 'D':
- memcpy( get_ptr->data, c4dt_unformat((char *) buffer, picture), 8) ;
- break;
-
- case 'L':
- if ( buffer[0] == (int) YES_CHAR || buffer[0] == (int) 'T' ||
- buffer[0] == (int) 't' || buffer[0] == (int) YES_CHAR_LC )
- *((int *)get_ptr->data) = 1 ;
- else
- *((int *)get_ptr->data) = 0 ;
- break ;
-
- default:
- memcpy( get_ptr->data, buffer, (size_t) get_ptr->width_data ) ;
- #ifdef LANGUAGE
- if ( picture != 0 )
- {
- int i ;
- for ( i = 0; picture[i] != 0 ; i++ )
- if ( get_ptr->picture[i] == 'Y' || get_ptr->picture[i] == 'L' )
- if ( buffer[i] == YES_CHAR )
- {
- char *temp_ptr ;
- temp_ptr = (char *) get_ptr->data ;
- temp_ptr[i] = 'Y' ;
- }
- }
- #endif
- break ;
- }
-
- return 0 ;
- }
-
-
- static g4right_pos( int buffer_pos, int width_data, char *picture )
- {
- buffer_pos++ ;
-
- while ( buffer_pos < width_data )
- if ( strchr(PICTURE_CHRS,picture[buffer_pos]) == 0)
- buffer_pos++ ;
- else
- break ;
-
- if ( buffer_pos == width_data)
- {
- buffer_pos-- ;
- while (buffer_pos > 0 &&
- strchr(PICTURE_CHRS,picture[buffer_pos]) == 0) buffer_pos-- ;
- }
-
- return buffer_pos ;
- }
-
-
- /* Counts the Number of Positions to the Next Picture Data Character */
-
- static g4num_pos( int buffer_pos, int width_data, char *picture )
- {
- int on_pos ;
-
- on_pos = buffer_pos ;
-
- while ( on_pos < width_data )
- if ( strchr(PICTURE_CHRS,picture[on_pos]) == 0)
- break ;
- else
- on_pos++ ;
-
- return ( on_pos - buffer_pos ) ;
- }
-
-
- static int bell_flag = 0 ;
-
- int g4bell_set( int set_flag )
- {
- if ( set_flag >= 0 ) bell_flag = set_flag ;
-
- return ( bell_flag ) ;
- }
-
-
- void g4bell()
- {
- if ( bell_flag ) write( 1, "\7", 1 ) ;
- }
-
-
- g4read()
- {
- int get_on, get_new, first, buffer_pos, buffer_off, buffer_width ;
- int cur_pos, num, ok, i ;
- int rc ;
- GET *get_ptr ;
- char chr ;
- char buffer[MAX_GET_WIDTH], picture[MAX_GET_WIDTH] ;
-
- g4display() ;
- prev_attribute = v4window_ptr->attribute ;
-
- first = 1 ;
- get_on = v4window_ptr->first_get ;
- if ( get_on < 0 ) return 0 ;
-
- for (;;)
- {
- if ( first ) /* First time for this 'get' */
- {
- first = 0 ;
- buffer_pos = buffer_off = 0 ;
-
- get_ptr = v4get + get_on ;
- g4message_do( get_ptr->message ) ;
-
- /* Buffer is filled and the width is returned by 'g4from_data' */
- buffer_width = g4from_data( get_ptr, buffer ) ;
- buffer[buffer_width] = '\000' ;
-
- memset( picture, 0, (size_t) sizeof(picture) ) ;
- if ( get_ptr->picture != (char *) 0 )
- strncpy( picture, get_ptr->picture, sizeof(picture) ) ;
- else
- {
- switch( get_ptr->type )
- {
- case 'D':
- strcpy( picture, v4default_date ) ;
- break ;
-
- case 'N':
- case 'd':
- case 'i':
- memset( picture, (int) '#', (size_t) get_ptr->width_scr ) ;
- if ( get_ptr->num_decimals > 0)
- {
- i = get_ptr->width_scr - get_ptr->num_decimals - 1 ;
- buffer[i] = picture[i] = '.' ;
- }
- break ;
-
- case 'L':
- picture[0] = 'L' ;
- picture[1] = '\000' ;
- break ;
- }
- }
- }
-
- w4attribute( get_ptr->attribute ) ;
-
- if ( buffer_pos >= buffer_width )
- {
- rc = RETURN ;
- w4num( get_ptr->row, get_ptr->col, buffer, get_ptr->width_scr ) ;
- }
- else
- {
- rc = 0 ;
-
- if ( strchr( PICTURE_CHRS, picture[buffer_pos] ) == (char *) 0 &&
- (int) picture[buffer_pos] >= 0x20 &&
- (int) picture[buffer_pos] <= 0xFF)
- {
- buffer[buffer_pos] = picture[buffer_pos] ;
- buffer_pos++ ;
- continue ;
- }
-
- if ( buffer_off <= buffer_pos - get_ptr->width_scr )
- buffer_off = 1+ buffer_pos - get_ptr->width_scr ;
- if ( buffer_pos < buffer_off ) buffer_off = buffer_pos ;
- w4num(get_ptr->row,get_ptr->col,buffer+buffer_off,get_ptr->width_scr);
- w4cursor( get_ptr->row, get_ptr->col+ buffer_pos - buffer_off ) ;
-
- if ( ! u4ptr_equal( (void *) get_ptr->call, (void *) 0) )
- {
- buffer[buffer_width] = '\000' ;
- rc = (*get_ptr->call)( get_ptr, buffer, get_ptr->call_data);
- get_ptr = v4get + get_on ;
- if ( rc == -1 ) continue ;
- }
- if ( rc == 0 )
- rc = g4char() ;
- if ( (get_ptr->upper_convert || picture[buffer_pos] == '!') && rc >= 0x20 && rc <= 0xFF )
- rc = u4toupper( rc ) ;
- }
-
- switch ( rc )
- {
- case INS:
- case CTRL_V:
- insert = ! insert ;
- if ( insert )
- w4cursor_size( 4, 7 ) ;
- else
- w4cursor_size( 6, 7 ) ;
- continue ;
-
- case BACK_SPACE:
- case LEFT:
- case CTRL_S:
- cur_pos = buffer_pos - 1 ;
-
- while (cur_pos >= 0)
- if ( strchr(PICTURE_CHRS,picture[cur_pos]) == 0 )
- cur_pos-- ;
- else
- break ;
-
- if ( cur_pos < 0 ) continue ;
-
- buffer_pos = cur_pos ;
- if ( rc == LEFT || rc == CTRL_S ) continue ;
-
- /* BACK_SPACE is a LEFT and a DEL */
-
- case DEL:
- case CTRL_G:
-
- num = g4num_pos( buffer_pos, get_ptr->width_data, picture) ;
- if ( num == 0 ) continue ;
- memcpy( buffer+ buffer_pos, buffer + buffer_pos+1, (size_t) num ) ;
- buffer[buffer_pos+num-1] = ' ' ;
- continue ;
-
- case CTRL_Y:
- cur_pos = buffer_pos ;
- memset( buffer + buffer_pos, (int) ' ',
- (size_t) g4num_pos( buffer_pos, get_ptr->width_data, picture));
- continue ;
-
- case RIGHT:
- case CTRL_D:
- buffer_pos =
- g4right_pos( buffer_pos, get_ptr->width_data, picture);
- continue ;
-
- case HOME:
- case CTRL_A:
- buffer_pos = 0;
- continue;
-
- case END:
- case CTRL_F:
- buffer_pos = get_ptr->width_data - 1;
- while ( buffer_pos >= 0 )
- if (buffer[buffer_pos] == ' ' || buffer[buffer_pos] == '\000')
- buffer_pos-- ;
- else
- break ;
-
- buffer_pos =
- g4right_pos( buffer_pos, get_ptr->width_data, picture);
- continue ;
- }
-
- if ( rc < 0x20 || rc > 0xFF )
- {
- switch( rc )
- {
- case CTRL_HOME:
- first = 1 ;
- get_new = v4window_ptr->first_get ;
- g4bell() ;
- break ;
-
- case CTRL_END:
- first = 1 ;
- get_new = v4window_ptr->last_get ;
- g4bell() ;
- break ;
-
- case UP:
- case SHIFT_TAB:
- case CTRL_Z:
- first = 1 ;
- get_new = get_on ;
- if ( get_ptr->prev >= 0 ) get_new = get_ptr->prev ;
- g4bell() ;
- break ;
-
- case DOWN:
- case RETURN:
- case TAB:
- case CTRL_B:
- first = 1 ;
- buffer_pos = 0 ;
- get_new = get_ptr->next ;
- g4bell() ;
- break ;
-
- /* Also Return if a Function Key was Pressed */
- default:
- if (rc == CTRL_W || rc == CTRL_Q ||
- rc == ESC || rc > 0xFF || rc < 0 )
- {
- get_new = first = -1 ;
- g4bell() ;
- }
- break ;
- }
-
- w4attribute( prev_attribute ) ;
-
- if ( first )
- {
- g4fill_data( get_ptr, buffer, picture ) ;
-
- if ( ! u4ptr_equal( (void *) get_ptr->valid, (void *) 0) &&
- rc != ESC && rc != CTRL_Q )
- {
- if ( (*get_ptr->valid)( get_ptr ) )
- {
- get_ptr = v4get + get_on ;
- first = 0 ; /* Not Valid */
- continue ;
- }
- get_ptr = v4get + get_on ;
- }
-
- if ( get_ptr->type == 'D' && rc != ESC && rc != CTRL_Q )
- {
- double temp_data ;
- int date_rc ;
-
- /* Date Check */
- date_rc = c4dt_julian( (char *) get_ptr->data, &temp_data ) ;
- if ( date_rc == -1 )
- {
- first = 0 ;
- get_ptr = v4get + get_on ;
- buffer[buffer_width] = '\000' ;
- w4display( " Illegal Date: ", buffer, (char *) 0) ;
- continue ;
- }
- }
-
- get_on = get_new ;
-
- g4display_get( get_ptr ) ;
- }
-
- if ( get_on < 0 )
- {
- if ( v4window_ptr->release ) g4release(1) ;
-
- w4attribute( prev_attribute ) ;
- g4message_do( "" ) ;
- w4cursor( -1,-1 ) ;
- return rc ;
- }
-
- continue ;
- }
-
- /* Check the Picture Template */
-
- if ( picture[buffer_pos] != '\000' )
- {
- ok = 0 ;
- chr = (char) rc ;
-
- switch( picture[buffer_pos] )
- {
- case '9':
- case '#':
- if ( chr >= '0' && chr <= '9' ) ok = 1 ;
- if ( (chr == '+' || chr == '-' || chr == ' ') &&
- picture[buffer_pos] == '#')
- ok = 1 ;
-
- if ( chr == '.' && get_ptr->num_decimals > 0 )
- {
- int num_shift ;
-
- num_shift = get_ptr->width_scr - get_ptr->num_decimals -
- buffer_pos - 1 ;
-
- if ( --buffer_pos < 0 ) buffer_pos = 0 ;
-
- if ( num_shift > 0 && buffer[buffer_pos] != ' ' )
- {
- memmove( buffer+ num_shift, buffer,
- (size_t) (get_ptr->width_scr - num_shift) ) ;
- memset( buffer, (int) ' ', (size_t) num_shift ) ;
- }
-
- buffer_pos = get_ptr->width_scr - get_ptr->num_decimals-1;
- memset( buffer+ buffer_pos+1, (int) '0',
- (size_t) get_ptr->num_decimals);
- ok = 1 ;
- }
- break ;
-
- case 'A':
- if ( chr >= 'A' && chr <= 'Z' ||
- chr >= 'a' && chr <= 'z' ) ok = 1 ;
- break ;
-
- case 'L':
- rc = (char) u4toupper( rc ) ;
- if ( rc == YES_CHAR || rc == 'N' || rc == 'T' || rc == 'F' )
- ok = 1;
- break ;
-
- case 'N':
- if ( chr >= 'A' && chr <= 'Z' ||
- chr >= 'a' && chr <= 'z' ||
- chr >= '0' && chr <= '9' ) ok = 1 ;
- break ;
-
- case 'Y':
- if ( get_ptr->type == 'D' ) /* Date Type: 'Y' for year */
- {
- if ( chr >= '0' && chr <= '9' || chr == ' ' ) ok = 1 ;
- }
- else
- {
- rc = (char) u4toupper( rc ) ;
- if ( rc == YES_CHAR || rc == 'N' ) ok = 1 ;
- }
- break ;
-
- case 'X':
- case '!':
- ok = 1 ;
- break ;
-
- case 'C':
- case 'D':
- if ( get_ptr->type == 'D' &&
- (chr >= '0' && chr <= '9' || chr == ' ') )
- ok = 1 ;
- break ;
-
- case 'M':
- if ( get_ptr->type == 'D' )
- {
- if ( chr == ' ' )
- {
- ok = 1 ;
- break ;
- }
-
- for ( num= i=0; picture[i] != '\000'; i++ )
- if ( picture[i] == 'M' ) num++ ;
-
- if ( num > 2 )
- {
- if ( chr >= 'A' && chr <= 'Z' ||
- chr >= 'a' && chr <= 'z') ok = 1 ;
- } else
- {
- if ( chr >= '0' && chr <= '9') ok = 1 ;
- }
- }
- break ;
- }
- }
- else
- ok = 1 ;
-
- if ( ok )
- {
- if ( insert )
- {
- /* Insert the Character */
- num = g4num_pos( buffer_pos, get_ptr->width_data, picture) ;
- if ( num > 1 )
- memmove( buffer+buffer_pos+1, buffer+buffer_pos, (size_t) num-1) ;
- }
-
- buffer[buffer_pos++] = (char) rc ;
- }
- else
- write( 1, "\7", 1 ) ; /* Sound the Bell */
- }
- }
-
-
- g4release( int do_release )
- {
- v4window_ptr->release = do_release ;
-
- if ( do_release )
- {
- h4free_chain( (char **) &v4get, v4window_ptr->last_get ) ;
- v4window_ptr->last_get = -1 ;
- v4window_ptr->first_get = -1 ;
- }
-
- return 0 ;
- }
-