HP3000-L Archives

June 1995, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Jim Wowchuk <[log in to unmask]>
Reply To:
Jim Wowchuk <[log in to unmask]>
Date:
Thu, 8 Jun 1995 11:51:52 +1000
Content-Type:
text/plain
Parts/Attachments:
text/plain (57 lines)
Oops...first time I'd done a reply direct instead of a reply all - normally
the other way round! :)
>To: marilyn Schoppet <[log in to unmask]>
>From: Jim Wowchuk <[log in to unmask]>
>Subject: Re: Turning off terminal echo in C
>
>At 02:03 PM 7/6/95 -0600, marilyn Schoppet wrote:
>> I am writing a C program that uses gets to read a password.
>>
>>The intrinsic FCONTROL with an item number of 13 should work,
>>but I don't know where to find the file number of the keyboard.
>
>stdin is the keyboard.  But if that is a stream, you will have to convert
it to a file descriptor, then to an mpe file number.
>
>Here's an c&n (cheap and nasty) example:
>    1     #include <stdio.h>
>    3     #pragma intrinsic fcontrol
>    4
>    5     main()
>    6     {
>    7         int iEcho;
>    8
>    9         char buff[72];
>   10
>   11         printf("Enter text with echo: ");
>   12         fgets(buff, 70, stdin);
>   13
>   14         fcontrol(_mpe_fileno(fileno(stdin)), 13, &iEcho);
>   15         printf("Enter text without echo: ");
>   16         fgets(buff, 70, stdin);
>   17
>   18         putc('\r', stdout); /* as our entered one was not echoed */
>   19
>   20         fcontrol(_mpe_fileno(fileno(stdin)), 12, &iEcho);
>   21         printf("Enter text with echo again: ");
>   22         fgets(buff, 70, stdin);
>   23         }
>
>Apologies for inconsistencies (printf w/ fgets), but I hate gets() as there
is no length control: that is the stuff of worms!
>
>I would also suggest a macro-function like:
>
>#define mpef(stream) _mpe_fileno(fileno(stream))
>
>Regards.
>
--- End Quote ---
----
Jim "seMPEr" Wowchuk           Internet:    [log in to unmask]
Vanguard Computer Services     Compu$erve:  100036,106
 _--_|\                        Post:        PO Box 18, North Ryde, NSW 2113
/      \                       Phone:       +61 (2) 888-9688
\.--.__/ <---Sydney NSW        Fax:         +61 (2) 888-3056
      v      Australia

ATOM RSS1 RSS2