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.
34 #if defined(SYS5) || defined(XOS_2)
40 #if defined(INTERNATIONAL)
45 static void handler();
47 char *lowerCase( string )
53 for ( s = string; s != NULL && *s != '\0'; s++ )
59 char *convertTime( date, locale )
64 * A quick hack to convert the time from the format Quipu uses into
65 * a more normal representation.
69 static char result[BUFSIZ];
73 * Get local timezone information, we need to apply this to the
74 * zulu time that Quipu uses later.
77 tm = localtime(&time);
78 UTCOffset = tm->tm_gmtoff;
79 sscanf( date, "%2d%2d%2d%2d%2d%2dZ",
80 &tm->tm_year, &tm->tm_mon, &tm->tm_mday,
81 &tm->tm_hour, &tm->tm_min, &tm->tm_sec );
87 tm = localtime(&time);
88 #if defined(INTERNATIONAL)
89 setlocale(LC_TIME, locale);
90 strftime(result, sizeof(result), nl_langinfo(D_T_FMT), tm);
92 strftime(result, sizeof(result), "%c", tm);
97 static long interrupt;
99 char *getPassword( prompt )
103 #if defined(SYS5) || defined(XOS_2)
109 struct sigvec ovec, vec;
113 static char buffer[BUFSIZ + 1];
115 if ( ( input = fopen( "/dev/tty", "r" ) ) == NULL )
118 setbuf( input, (char *) NULL );
119 vec.sv_handler = handler;
121 vec.sv_flags = SV_INTERRUPT;
122 sigvec( SIGINT, &vec, &ovec );
124 #if defined(SYS5) || defined(XOS_2)
125 ioctl( fileno( input ), TCGETS, &ttyb );
126 flags = ttyb.c_lflag;
127 ttyb.c_lflags &= ~ ( ECHO | ECHOE | ECHOK | ECHONL );
128 ioctl( fileno( input ), TCSETSF, &ttyb );
130 ioctl( fileno( input ), TIOCGETP, &ttyb );
131 flags = ttyb.sg_flags;
132 ttyb.sg_flags &= ~ ECHO;
133 ioctl( fileno( input ), TIOCSETN, &ttyb );
135 fputs( prompt, stderr );
137 while ( !interrupt && ( c = getc( input ) ) != EOF ) {
138 if ( c == '\n' || c == '\r' )
147 #if defined(SYS5) || defined(XOS_2)
148 ttyb.c_lflag = flags;
149 ioctl( fileno( input ), TCSETSW, &ttyb );
151 ttyb.sg_flags = flags;
152 ioctl( fileno( input ), TIOCSETN, &ttyb );
154 putc( '\n', stderr );
155 sigvec( SIGINT, &ovec, (struct sigvec *) NULL );
156 if ( input != stdin )
159 kill( getpid(), SIGINT );
163 static void handler()