]> andersk Git - moira.git/blob - lib/idno.c
POSIX, ANSI, sanity fixes
[moira.git] / lib / idno.c
1 /* $Header$
2  *
3  * Routines to encrypt ID's
4  *
5  *  (c) Copyright 1988 by the Massachusetts Institute of Technology.
6  *  For copying and distribution information, please see the file
7  *  <mit-copyright.h>.
8  */
9
10 #include <mit-copyright.h>
11 #include <string.h>
12 #include <ctype.h>
13 #ifdef POSIX
14 #include <unistd.h>
15 #endif
16 #ifdef USE_CRYPT_H
17 #include <crypt.h>
18 #endif
19
20 /*      Function Name: RemoveHyphens
21  *      Description: Removes all hyphens from the string passed to it.
22  *      Arguments: str - the string to remove the hyphes from
23  *      Returns: none
24  */
25
26 void
27 RemoveHyphens(str)
28 char *str;
29 {
30     char *hyphen;
31
32     while ((hyphen = strchr(str, '-')) != (char *)0)
33         (void) strcpy(hyphen, hyphen + 1);
34 }
35
36
37 /*      Function Name: EncryptMITID
38  *      Description: Encrypts an mit ID number. 
39  *      Arguments: sbuf - the buffer to return the encrypted number in.
40  *                 idnumber - the id number (string).
41  *                 first, last - name of the person.
42  *      Returns: none.
43  */
44
45 void
46 EncryptID(sbuf, idnumber, first, last)
47 char *sbuf, *idnumber, *first, *last;
48 {
49     char salt[3];
50
51     RemoveHyphens(idnumber);
52     salt[0] = tolower(last[0]);
53     salt[1] = tolower(first[0]);
54     salt[2] = 0;
55
56     (void) strcpy(sbuf, crypt(&idnumber[2], salt));
57 }
58
This page took 0.0399389999999999 seconds and 5 git commands to generate.