Article View: gnu.gcc.help
Article #50111Help with Low-Level IO needed!
From: Icedtea
Date: Sat, 13 Nov 1993 17:49
Date: Sat, 13 Nov 1993 17:49
141 lines
4559 bytes
4559 bytes
Hi, all! I need your help once again. I'm working on an application
that will require a password of excessive lengths (like 100 or 200
characters for each password). The getpass function in Unix is
insufficient as it limits password input to a mere 8 characters.
The nice thing about getpass, though, is that it does disable terminal
echoing of input characters so passwords don't show up on the screen.
Well, I think I pretty much have the code worked out that will disable
terminal echoing of input characters, but I have some compilation
problems and this is where I need your help.
The following 130 some odd lines area script of what happens when I
try to compile on a System V SunOs system with gcc. The source code,
the compilation syntax, and the errors are all included in the script.
I'd really appreciate any help any of you more experienced programmers
can give me on what the cause of the errors are because I'm clueless
at this point after having struggled with it for a good while.
Thanks in advance for your help. I really appreciate it!
Sincerely,
Steven B. Afrin
Computer Science Department
Clemson University
Clemson, South Carolina
Script started on Wed Nov 10 11:19:33 1993
tecnet5% cat test4.c
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#define MAX_LENGTH 70
#ifndef TCSASOFT
#define TCSASOFT 0
#endif
char *getpasswd ( const char *prompt );
main ()
{
char string [ MAX_LENGTH ];
strcpy ( string, getpasswd ("Enter password: ") );
printf ("\n\nYour password as entered is %s.\n\n", string );
}
char *getpasswd ( const char *prompt )
{
FILE *in, *out;
struct termios t;
int echo_off;
static char *buf = NULL;
static size_t bufsize = 0;
ssize_t nread;
in = fopen ("/dev/tty", "w+");
if ( in == NULL )
{
in
out = stderr;
}
else
out = in;
if ( tcgetattr ( fileno ( in ), &t ) == 0 )
{
if ( t.c_lflag & ECHO )
{
t.c_lflag &= ~ECHO;
echo_off = tcsetattr ( fileno ( in ), TCSAFLUSH|TCSASOFT,
&t ) == 0;
t.c_lflag |= ECHO;
}
else
echo_off = 0;
}
else
echo_off = 0;
fputs ( prompt, out );
fflush ( out );
nread = _getline ( &buf, &bufsize, in );
if ( ( nread < 0 ) && ( buf != NULL ) )
buf [ 0 ] = '\0';
else if ( buf [ read - 1 ] == '\n' )
buf [ nread ] = '\0';
if ( echo_off )
( void ) tcsetattr ( fileno ( in ), TCSAFLUSH|TCSASOFT, &t );
if ( in != stdin )
fclose ( in );
return buf;
}
tecnet5% alias gcc
gcc -O -g -DDEBUG -o !* !*.c
tecnet5% gcc test4
/usr/local/lib/gcc-include/termios.h:44: warning: parameter name starts with a digit in #define
/usr/local/lib/gcc-include/termios.h:44: badly punctuated parameter list in #define
tecnet5% vi +44 /usr/local/lib/gcc-include/termios.h
42:
43: #ifndef _POSIX_SOURCE
44: #define _CTRL('c') ('c'&037)
45:
46: /*
47: * default control chars.
48: * guarded for ttychars.h.
49: */
50: #ifndef CINTR
51: #define CINTR _CTRL('c')
52: #define CQUIT 034 /* FS, ^\ */
53: #define CERASE 0177 /* DEL, ^? */
54: #define CKILL _CTRL('u')
55: #define CEOF _CTRL('d')
56: #define CEOT CEOF
script done on Wed Nov 10 11:20:31 1993
Technical Details
Message-ID:
<1993Nov13.174909.29282@hubcap.clemson.edu>Path:
arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!mcsun!howland.reston.ans.net!usenet.ins.cwru.edu!agate!headwall.Stanford.EDU!hubcap!safrinShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,7d7f1ee92e30b707,start X-Google-Attributes: gid11318c,public X-Google-Thread: 1014db,7d7f1ee92e30b707,start X-Google-Attributes: gid1014db,public X-Google-ArrivalTime: 1993-11-13 18:35:25 PST Newsgroups: gnu.gcc.help,comp.lang.c Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!mcsun!howland.reston.ans.net!usenet.ins.cwru.edu!agate!headwall.Stanford.EDU!hubcap!safrin From: safrin@hubcap.clemson.edu (Icedtea) Subject: Help with Low-Level IO needed! Message-ID: <1993Nov13.174909.29282@hubcap.clemson.edu> Organization: Clemson University Date: Sat, 13 Nov 1993 17:49:09 GMT Lines: 141