]> andersk Git - moira.git/blob - lib/idno.c
second code style cleanup: void/void * usage, proper #includes. try to
[moira.git] / lib / idno.c
1 /* $Id $
2  *
3  * Routines to deal with MIT IDs
4  *
5  * Copyright (C) 1988-1998 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 <moira.h>
12
13 #include <ctype.h>
14 #include <string.h>
15
16 #ifdef USE_CRYPT_H
17 #include <crypt.h>
18 #else
19 #include <unistd.h>
20 #endif
21
22 /*      Function Name: RemoveHyphens
23  *      Description: Removes all hyphens from the string passed to it.
24  *      Arguments: str - the string to remove the hyphes from
25  *      Returns: none
26  */
27
28 void RemoveHyphens(char *str)
29 {
30   char *hyphen;
31
32   while ((hyphen = strchr(str, '-')))
33     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 EncryptID(char *sbuf, char *idnumber, char *first, char *last)
46 {
47   char salt[3];
48
49   RemoveHyphens(idnumber);
50   salt[0] = tolower(last[0]);
51   salt[1] = tolower(first[0]);
52   salt[2] = '\0';
53
54   strcpy(sbuf, crypt(&idnumber[2], salt));
55 }
56
This page took 0.051255 seconds and 5 git commands to generate.