home *** CD-ROM | disk | FTP | other *** search
- /*
- fnsecure.c 10/24/86
-
- % secure_funcs
-
- Editting functions for fields which do not print
- out to the screen. (i.e.) passwords.
-
- When a letter is typed in a MASK character is printed to the screen.
- The Record maintains the correct value, however.
-
- Note: SED_ABORT will NOT affect this routine
-
- The RIGHT and LEFT keys don't do anything.
-
- C-scape 3.1
- Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 4/06/88 jmd added call to sed_DoSpecial
- 5/12/88 jmd added calls to sed_GetScratchPad()
- 6/23/88 jmd added casting to char * for sed_GetVar
- 9/17/88 jmd added std_ funcs
- 10/14/88 jdc added var_size element to field_funcs_struct
-
- 6/07/89 jmd added test for mouse code (later removed)
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
-
- #include "cscape.h"
- #include "fnfunc.h" /* for field functions */
- #include "scancode.h"
-
- #define MASK '*'
-
- OGLOBAL field_funcs_struct secure_funcs = {
- std_fenter,
- std_fexit,
- secure_fkey,
- secure_senter,
- FNULL,
- VAR_STRING
- };
-
- void secure_fkey(sed)
- sed_type sed;
- {
- int scancode, key;
-
- scancode = kb_Read();
-
- if (sed_DoSpecial(sed, scancode))
- return;
- if (special_key(sed, scancode))
- return;
- if (inter_field(sed, scancode))
- return;
- if (inter_page(sed, scancode))
- return;
-
- switch(scancode) {
- case BACKSPACE:
- if ( sed_DecChar(sed) ) {
- sed_PullRight(sed);
- ((char *) sed_GetCurrVar(sed))[sed_GetRecordPos(sed)] = '\0';
- }
- break;
- default:
- /*
- Don't allow typing in the last position or else BACKSPACE
- gets weird.
- */
-
- key = ascii(scancode);
- if (isprint(key) &&
- (sed_GetRecordPos(sed) < sed_GetCurrRecordLen(sed) -1) ){
- ((char *) sed_GetCurrVar(sed))[sed_GetRecordPos(sed)] = (char) key;
- ((char *) sed_GetCurrVar(sed))[sed_GetRecordPos(sed)+1] = '\0';
- sed_Overwrite(sed, MASK);
- sed_IncChar(sed);
- }
- break;
- }
-
- /* reset baton */
- sed_SetBaton(sed, -1);
- }
-
- void secure_senter(sed, fieldno)
- sed_type sed;
- int fieldno;
- /*
- Convert native type to string for record.
- */
- {
- char *p, *s;
-
- /* mask the record */
- s = sed_GetScratchPad(sed);
- strcpy(s, (char *) sed_GetVar(sed, fieldno));
-
- for (p = s + strlen(s) - 1; p >= s; p--) {
- if( *p != ' ') *p = MASK;
- }
-
- sed_SetRecord(sed, s, fieldno);
- }
-
-
-