summaryrefslogtreecommitdiffstats
path: root/Modules/rotormodule.c
diff options
context:
space:
mode:
authorPeter Schneider-Kamp <nowonder@nowonder.de>2000-07-10 13:05:29 (GMT)
committerPeter Schneider-Kamp <nowonder@nowonder.de>2000-07-10 13:05:29 (GMT)
commit7d0c71ac8c56de9d8547a37c3e6bbce4f8e943d3 (patch)
tree61e69475c61c20b518db2656ce20eda647e77919 /Modules/rotormodule.c
parent286da3b46a3647db07c422058381ac65e74e47a2 (diff)
downloadcpython-7d0c71ac8c56de9d8547a37c3e6bbce4f8e943d3.zip
cpython-7d0c71ac8c56de9d8547a37c3e6bbce4f8e943d3.tar.gz
cpython-7d0c71ac8c56de9d8547a37c3e6bbce4f8e943d3.tar.bz2
ANSI-fication
Diffstat (limited to 'Modules/rotormodule.c')
-rw-r--r--Modules/rotormodule.c96
1 files changed, 25 insertions, 71 deletions
diff --git a/Modules/rotormodule.c b/Modules/rotormodule.c
index d63ad74..6960acf 100644
--- a/Modules/rotormodule.c
+++ b/Modules/rotormodule.c
@@ -87,8 +87,7 @@ staticforward PyTypeObject Rotor_Type;
/* This defines the necessary routines to manage rotor objects */
static void
-set_seed(r)
- Rotorobj *r;
+set_seed(Rotorobj *r)
{
r->seed[0] = r->key[0];
r->seed[1] = r->key[1];
@@ -98,8 +97,7 @@ set_seed(r)
/* Return the next random number in the range [0.0 .. 1.0) */
static double
-r_random(r)
- Rotorobj *r;
+r_random(Rotorobj *r)
{
int x, y, z;
double val, term;
@@ -134,17 +132,13 @@ r_random(r)
}
static short
-r_rand(r, s)
- Rotorobj *r;
- short s;
+r_rand(Rotorobj *r, short s)
{
return (short)((short)(r_random(r) * (double)s) % s);
}
static void
-set_key(r, key)
- Rotorobj *r;
- char *key;
+set_key(Rotorobj *r, char *key)
{
unsigned long k1=995, k2=576, k3=767, k4=671, k5=463;
size_t i;
@@ -172,9 +166,7 @@ set_key(r, key)
/* These define the interface to a rotor object */
static Rotorobj *
-rotorobj_new(num_rotors, key)
- int num_rotors;
- char *key;
+rotorobj_new(int num_rotors, char *key)
{
Rotorobj *xp;
@@ -251,9 +243,7 @@ rotorobj_new(num_rotors, key)
/* Set ROTOR to the identity permutation */
static void
-RTR_make_id_rotor(r, rtr)
- Rotorobj *r;
- unsigned char *rtr;
+RTR_make_id_rotor(Rotorobj *r, unsigned char *rtr)
{
register int j;
register int size = r->size;
@@ -265,8 +255,7 @@ RTR_make_id_rotor(r, rtr)
/* The current set of encryption rotors */
static void
-RTR_e_rotors(r)
- Rotorobj *r;
+RTR_e_rotors(Rotorobj *r)
{
int i;
for (i = 0; i < r->rotors; i++) {
@@ -276,8 +265,7 @@ RTR_e_rotors(r)
/* The current set of decryption rotors */
static void
-RTR_d_rotors(r)
- Rotorobj *r;
+RTR_d_rotors(Rotorobj *r)
{
register int i, j;
for (i = 0; i < r->rotors; i++) {
@@ -289,8 +277,7 @@ RTR_d_rotors(r)
/* The positions of the rotors at this time */
static void
-RTR_positions(r)
- Rotorobj *r;
+RTR_positions(Rotorobj *r)
{
int i;
for (i = 0; i < r->rotors; i++) {
@@ -300,8 +287,7 @@ RTR_positions(r)
/* The number of positions to advance the rotors at a time */
static void
-RTR_advances(r)
- Rotorobj *r;
+RTR_advances(Rotorobj *r)
{
int i;
for (i = 0; i < r->rotors; i++) {
@@ -313,10 +299,7 @@ RTR_advances(r)
* see Knuth for explanation of algorithm.
*/
static void
-RTR_permute_rotor(r, e, d)
- Rotorobj *r;
- unsigned char *e;
- unsigned char *d;
+RTR_permute_rotor(Rotorobj *r, unsigned char *e, unsigned char *d)
{
short i = r->size;
short q;
@@ -338,8 +321,7 @@ RTR_permute_rotor(r, e, d)
* Set the advancement, position, and permutation of the rotors
*/
static void
-RTR_init(r)
- Rotorobj *r;
+RTR_init(Rotorobj *r)
{
int i;
set_seed(r);
@@ -359,8 +341,7 @@ RTR_init(r)
/* Change the RTR-positions vector, using the RTR-advances vector */
static void
-RTR_advance(r)
- Rotorobj *r;
+RTR_advance(Rotorobj *r)
{
register int i=0, temp=0;
if (r->size_mask) {
@@ -386,9 +367,7 @@ RTR_advance(r)
/* Encrypt the character P with the current rotor machine */
static unsigned char
-RTR_e_char(r, p)
- Rotorobj *r;
- unsigned char p;
+RTR_e_char(Rotorobj *r, unsigned char p)
{
register int i=0;
register unsigned char tp=p;
@@ -413,9 +392,7 @@ RTR_e_char(r, p)
/* Decrypt the character C with the current rotor machine */
static unsigned char
-RTR_d_char(r, c)
- Rotorobj *r;
- unsigned char c;
+RTR_d_char(Rotorobj *r, unsigned char c)
{
register int i = r->rotors - 1;
register unsigned char tc = c;
@@ -440,11 +417,7 @@ RTR_d_char(r, c)
/* Perform a rotor encryption of the region from BEG to END by KEY */
static void
-RTR_e_region(r, beg, len, doinit)
- Rotorobj *r;
- unsigned char *beg;
- int len;
- int doinit;
+RTR_e_region(Rotorobj *r, unsigned char *beg, int len, int doinit)
{
register int i;
if (doinit || r->isinited == FALSE)
@@ -456,11 +429,7 @@ RTR_e_region(r, beg, len, doinit)
/* Perform a rotor decryption of the region from BEG to END by KEY */
static void
-RTR_d_region(r, beg, len, doinit)
- Rotorobj *r;
- unsigned char *beg;
- int len;
- int doinit;
+RTR_d_region(Rotorobj *r, unsigned char *beg, int len, int doinit)
{
register int i;
if (doinit || r->isinited == FALSE)
@@ -474,8 +443,7 @@ RTR_d_region(r, beg, len, doinit)
/* Rotor methods */
static void
-rotor_dealloc(xp)
- Rotorobj *xp;
+rotor_dealloc(Rotorobj *xp)
{
if (xp->e_rotor)
PyMem_DEL(xp->e_rotor);
@@ -489,9 +457,7 @@ rotor_dealloc(xp)
}
static PyObject *
-rotorobj_encrypt(self, args)
- Rotorobj *self;
- PyObject * args;
+rotorobj_encrypt(Rotorobj *self, PyObject *args)
{
char *string = NULL;
int len = 0;
@@ -513,9 +479,7 @@ rotorobj_encrypt(self, args)
}
static PyObject *
-rotorobj_encrypt_more(self, args)
- Rotorobj *self;
- PyObject * args;
+rotorobj_encrypt_more(Rotorobj *self, PyObject *args)
{
char *string = NULL;
int len = 0;
@@ -537,9 +501,7 @@ rotorobj_encrypt_more(self, args)
}
static PyObject *
-rotorobj_decrypt(self, args)
- Rotorobj *self;
- PyObject * args;
+rotorobj_decrypt(Rotorobj *self, PyObject *args)
{
char *string = NULL;
int len = 0;
@@ -561,9 +523,7 @@ rotorobj_decrypt(self, args)
}
static PyObject *
-rotorobj_decrypt_more(self, args)
- Rotorobj *self;
- PyObject * args;
+rotorobj_decrypt_more(Rotorobj *self, PyObject *args)
{
char *string = NULL;
int len = 0;
@@ -585,9 +545,7 @@ rotorobj_decrypt_more(self, args)
}
static PyObject *
-rotorobj_setkey(self, args)
- Rotorobj *self;
- PyObject * args;
+rotorobj_setkey(Rotorobj *self, PyObject *args)
{
char *key;
@@ -612,9 +570,7 @@ rotorobj_methods[] = {
/* Return a rotor object's named attribute. */
static PyObject *
-rotorobj_getattr(s, name)
- Rotorobj *s;
- char *name;
+rotorobj_getattr(Rotorobj *s, char *name)
{
return Py_FindMethod(rotorobj_methods, (PyObject*)s, name);
}
@@ -638,9 +594,7 @@ statichere PyTypeObject Rotor_Type = {
static PyObject *
-rotor_rotor(self, args)
- PyObject * self;
- PyObject * args;
+rotor_rotor(PyObject *self, PyObject *args)
{
Rotorobj *r;
char *string;