annotate Modules/cryptmodule.c @ 16798:258dcafe2d0b legacy-trunk

Gustavo Niemeyer <niemeyer@conectiva.com>: Fixed recno support (keys are integers rather than strings). Work around DB bug that cause stdin to be closed by rnopen() when the DB file needed to exist but did not (no longer segfaults). This closes SF tracker patch #403445. Also wrapped some long lines and added whitespace around operators -- FLD.
author Fred Drake <fdrake@acm.org>
date Tue, 27 Feb 2001 18:56:46 +0000
parents 8bd82cf361aa
children 3aa4bf7ac31e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 /* cryptmodule.c - by Steve Majewski
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 */
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
4 #include "Python.h"
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 #include <sys/types.h>
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 /* Module crypt */
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
13496
03bc51e43f7a ANSI-fication
Peter Schneider-Kamp <nowonder@nowonder.de>
parents: 11687
diff changeset
12 static PyObject *crypt_crypt(PyObject *self, PyObject *args)
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 {
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 char *word, *salt;
13667
a6c7bfdd6777 Even more ANSIfication: fix as many function pointers and declarations as
Thomas Wouters <thomas@python.org>
parents: 13651
diff changeset
15 extern char * crypt(const char *, const char *);
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
16
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
17 if (!PyArg_Parse(args, "(ss)", &word, &salt)) {
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 return NULL;
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 }
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
20 return PyString_FromString( crypt( word, salt ) );
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
21
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 }
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
23
11687
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
24 static char crypt_crypt__doc__[] = "\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
25 crypt(word, salt) -> string\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
26 word will usually be a user's password. salt is a 2-character string\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
27 which will be used to select one of 4096 variations of DES. The characters\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
28 in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
29 the hashed password as a string, which will be composed of characters from\n\
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
30 the same alphabet as the salt.";
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
31
47d70f4f635f Added docstring to crypt.crypt() based on the documentation.
Fred Drake <fdrake@acm.org>
parents: 9588
diff changeset
32
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
33 static PyMethodDef crypt_methods[] = {
13820
8bd82cf361aa Use METH_OLDARGS instead of numeric constant 0 in method def. tables
Andrew M. Kuchling <amk@amk.ca>
parents: 13667
diff changeset
34 {"crypt", crypt_crypt, METH_OLDARGS, crypt_crypt__doc__},
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 {NULL, NULL} /* sentinel */
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 };
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
37
9588
38023a425e48 Add DL_EXPORT() to all modules that could possibly be used
Guido van Rossum <guido@python.org>
parents: 4643
diff changeset
38 DL_EXPORT(void)
13651
8a063423e0b7 Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',
Thomas Wouters <thomas@python.org>
parents: 13496
diff changeset
39 initcrypt(void)
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 {
4643
8d909ae1f099 renamed grandly.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4600
diff changeset
41 Py_InitModule("crypt", crypt_methods);
1617
2b27553028aa crypt module (Steve M's)
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 }