2 static char copyright[] = "Copyright 1992 The University of Adelaide";
8 * Author: Mark R. Prior
9 * Communications and Systems Branch
10 * Information Technology Division
11 * The University of Adelaide
12 * E-mail: mrp@itd.adelaide.edu.au
16 * Some routines that I use in most my LDAP playthings :-)
18 * Redistribution and use in source and binary forms are permitted
19 * provided that the above copyright notice and this paragraph are
20 * duplicated in all such forms and that any documentation,
21 * advertising materials, and other materials related to such
22 * distribution and use acknowledge that the software was developed
23 * by the University of Adelaide. The name of the University may not
24 * be used to endorse or promote products derived from this software\
25 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
27 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
28 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
36 #if defined(SYS5) || defined(XOS_2)
42 #if defined(INTERNATIONAL)
46 #include <ac/unistd.h>
48 static void handler(int sig);
51 lowerCase( char *string )
55 for ( s = string; s != NULL && *s != '\0'; s++ )
56 if ( isupper( (unsigned char) *s ) )
57 *s = tolower( (unsigned char) *s );
62 convertTime( char *date, char *locale )
65 * A quick hack to convert the time from the format Quipu uses into
66 * a more normal representation.
70 static char result[BUFSIZ];
74 * Get local timezone information, we need to apply this to the
75 * zulu time that Quipu uses later.
78 tm = localtime(&time);
79 UTCOffset = tm->tm_gmtoff;
80 sscanf( date, "%2d%2d%2d%2d%2d%2dZ",
81 &tm->tm_year, &tm->tm_mon, &tm->tm_mday,
82 &tm->tm_hour, &tm->tm_min, &tm->tm_sec );
88 tm = localtime(&time);
89 #if defined(INTERNATIONAL)
90 setlocale(LC_TIME, locale);
91 strftime(result, sizeof(result), nl_langinfo(D_T_FMT), tm);
93 strftime(result, sizeof(result), "%c", tm);
98 static long interrupt;
101 getPassword( char *prompt )
103 #if defined(SYS5) || defined(XOS_2)
109 struct sigvec ovec, vec;
112 static char buffer[BUFSIZ + 1];
114 if ( ( input = fopen( "/dev/tty", "r" ) ) == NULL )
117 setbuf( input, (char *) NULL );
118 vec.sv_handler = handler;
120 vec.sv_flags = SV_INTERRUPT;
121 sigvec( SIGINT, &vec, &ovec );
123 #if defined(SYS5) || defined(XOS_2)
124 ioctl( fileno( input ), TCGETS, &ttyb );
125 flags = ttyb.c_lflag;
126 ttyb.c_lflags &= ~ ( ECHO | ECHOE | ECHOK | ECHONL );
127 ioctl( fileno( input ), TCSETSF, &ttyb );
129 ioctl( fileno( input ), TIOCGETP, &ttyb );
130 flags = ttyb.sg_flags;
131 ttyb.sg_flags &= ~ ECHO;
132 ioctl( fileno( input ), TIOCSETN, &ttyb );
134 fputs( prompt, stderr );
136 while ( !interrupt && ( c = getc( input ) ) != EOF ) {
137 if ( c == '\n' || c == '\r' )
146 #if defined(SYS5) || defined(XOS_2)
147 ttyb.c_lflag = flags;
148 ioctl( fileno( input ), TCSETSW, &ttyb );
150 ttyb.sg_flags = flags;
151 ioctl( fileno( input ), TIOCSETN, &ttyb );
153 putc( '\n', stderr );
154 sigvec( SIGINT, &ovec, (struct sigvec *) NULL );
155 if ( input != stdin )
158 kill( getpid(), SIGINT );