Mercurial > freewnn
comparison Wnn/etc/pwd.c @ 0:bbc77ca4def5
initial import
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 13 Dec 2007 04:30:14 +0900 |
parents | |
children | ed4bb01eb317 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bbc77ca4def5 |
---|---|
1 /* | |
2 * $Id: pwd.c,v 1.6 2004/07/12 17:53:02 hiroo Exp $ | |
3 */ | |
4 | |
5 /* | |
6 * FreeWnn is a network-extensible Kana-to-Kanji conversion system. | |
7 * This file is part of FreeWnn. | |
8 * | |
9 * Copyright Kyoto University Research Institute for Mathematical Sciences | |
10 * 1987, 1988, 1989, 1990, 1991, 1992 | |
11 * Copyright OMRON Corporation. 1987, 1988, 1989, 1990, 1991, 1992, 1999 | |
12 * Copyright ASTEC, Inc. 1987, 1988, 1989, 1990, 1991, 1992 | |
13 * Copyright FreeWnn Project 1999, 2000, 2002 | |
14 * | |
15 * Maintainer: FreeWnn Project <freewnn@tomo.gr.jp> | |
16 * | |
17 * This program is free software; you can redistribute it and/or modify | |
18 * it under the terms of the GNU General Public License as published by | |
19 * the Free Software Foundation; either version 2 of the License, or | |
20 * (at your option) any later version. | |
21 * | |
22 * This program is distributed in the hope that it will be useful, | |
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 * GNU General Public License for more details. | |
26 * | |
27 * You should have received a copy of the GNU General Public License | |
28 * along with this program; if not, write to the Free Software | |
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
30 */ | |
31 | |
32 /* | |
33 eval(crypt(PWD, "HA")) routine. | |
34 */ | |
35 #ifdef HAVE_CONFIG_H | |
36 # include <config.h> | |
37 #endif | |
38 | |
39 #ifndef JS | |
40 #include <stdio.h> | |
41 #if STDC_HEADERS | |
42 # include <string.h> | |
43 #elif HAVE_STRINGS_H | |
44 # include <strings.h> | |
45 #endif /* STDC_HEADERS */ | |
46 #if HAVE_UNISTD_H | |
47 # include <unistd.h> | |
48 #endif | |
49 #include "commonhd.h" | |
50 #include "jslib.h" | |
51 #include "wnn_os.h" | |
52 #endif /* !JS */ | |
53 | |
54 #ifdef JS | |
55 # define JS_STATIC static | |
56 #else /* !JS */ | |
57 # define JS_STATIC | |
58 #endif /* !JS */ | |
59 | |
60 /* etc/pwd.c */ | |
61 JS_STATIC void new_pwd (char* src, char* encd); | |
62 JS_STATIC int check_pwd (char* src, char* encd); | |
63 | |
64 JS_STATIC void | |
65 new_pwd (char* src, char* encd) | |
66 { | |
67 int i, x, c; | |
68 char xx[3]; | |
69 char *cr; | |
70 | |
71 if (encd == NULL) | |
72 encd = src; | |
73 if (strcmp (src, "") == 0) | |
74 { | |
75 bzero (encd, WNN_PASSWD_LEN); | |
76 return; | |
77 } | |
78 x = time (NULL); | |
79 xx[0] = x & 0x3f; | |
80 xx[1] = (x & 0x3f00) >> 8; | |
81 xx[2] = '\0'; /* for MD5 (that requires terminator) */ | |
82 for (i = 0; i < 2; i++) | |
83 { | |
84 c = xx[i] + '.'; | |
85 if (c > '9') | |
86 c += 7; | |
87 if (c > 'Z') | |
88 c += 6; | |
89 xx[i] = c; | |
90 } | |
91 cr = crypt (src, xx); | |
92 bzero (encd, WNN_PASSWD_LEN); | |
93 strncpy (encd, cr, WNN_PASSWD_LEN); | |
94 } | |
95 | |
96 JS_STATIC int | |
97 check_pwd (char* src, char* encd) | |
98 { | |
99 if (strcmp (encd, "") == 0) | |
100 return (1); /* No passwd */ | |
101 return (!strncmp (encd, crypt (src, encd), WNN_PASSWD_LEN)); | |
102 } |