Skip to content

Commit

Permalink
More coding style changes.
Browse files Browse the repository at this point in the history
Fixed a few typos.
  • Loading branch information
wart committed Aug 24, 1999
1 parent a12c0c4 commit 6ba2f85
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 43 deletions.
8 changes: 4 additions & 4 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# "autoconf" program (constructs like "@foo@" will get replaced in the actual
# Makefile.
#
# RCS: @(#) $Id: Makefile.in,v 1.15 1999/08/23 23:05:45 wart Exp $
# RCS: @(#) $Id: Makefile.in,v 1.16 1999/08/24 16:40:47 wart Exp $

#========================================================================
# Edit the following few lines when writing a new extension
Expand Down Expand Up @@ -181,8 +181,8 @@ LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@

#========================================================================
# TEA TARGETS. Please note that the "libraries:" target refers to platform
# independant files, and the "binaries:" target inclues executable programs and
# platform-dependant libraries. Modify these targets so that they install
# independent files, and the "binaries:" target inclues executable programs and
# platform-dependent libraries. Modify these targets so that they install
# the various pieces of your package. The make and install rules
# for the BINARIES that you specified above have already been done.
#========================================================================
Expand All @@ -191,7 +191,7 @@ all: binaries libraries doc

#========================================================================
# The binaries target builds executable programs, Windows .dll's, unix
# shared/static libraries, and any other platform-dependant files.
# shared/static libraries, and any other platform-dependent files.
# The list of targets to build for "binaries:" is specified at the top
# of the Makefile, in the "BINARIES" variable.
#========================================================================
Expand Down
2 changes: 1 addition & 1 deletion aclocal.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ AC_DEFUN(SC_TCL_LINK_LIBS, [
# SC_MAKE_LIB --
#
# Generate a line that can be used to build a shared/unshared library
# in a platform independant manner.
# in a platform independent manner.
#
# Arguments:
# none
Expand Down
3 changes: 2 additions & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ fi
AC_SUBST(TCLSH_PROG)

#--------------------------------------------------------------------
# Some of our tool routines need native paths for these
# Some of our tool routines need native paths for these, in particular
# the mkIndex.tcl script for generating pkgIndex.tcl upon installing.
#--------------------------------------------------------------------

exec_prefix_NATIVE=`${CYGPATH} ${exec_prefix}`
Expand Down
54 changes: 31 additions & 23 deletions exampleA.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@
#include <string.h>
#include "exampleA.h"

#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
#define Rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))

/*
* blk0() and blk() perform the initial expand.
* Blk0() and Blk() perform the initial expand.
* I got the idea of expanding during the round function from SSLeay
*/

#ifdef LITTLE_ENDIAN
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
|(rol(block->l[i],8)&0x00FF00FF))
#define Blk0(i) (block->l[i] = (Rol(block->l[i],24)&0xFF00FF00) \
|(Rol(block->l[i],8)&0x00FF00FF))
#else
#ifdef BIG_ENDIAN
#define blk0(i) block->l[i]
#define Blk0(i) block->l[i]
#else

/*
Expand All @@ -55,22 +55,22 @@
* added by Dave Dykstra, 4/16/97
*/

#define blk0(i) (block->l[i] = (*(p = (unsigned char *) (&block->l[i])) << 24) \
#define Blk0(i) (block->l[i] = (*(p = (unsigned char *) (&block->l[i])) << 24) \
+ (*(p+1) << 16) + (*(p+2) << 8) + *(p+3))
#endif
#endif
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
#define Blk(i) (block->l[i&15] = Rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
^block->l[(i+2)&15]^block->l[i&15],1))

/*
* (R0+R1), R2, R3, R4 are the different operations used in SHA1
*/

#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+Blk0(i)+0x5A827999+Rol(v,5);w=Rol(w,30);
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+Blk(i)+0x5A827999+Rol(v,5);w=Rol(w,30);
#define R2(v,w,x,y,z,i) z+=(w^x^y)+Blk(i)+0x6ED9EBA1+Rol(v,5);w=Rol(w,30);
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+Blk(i)+0x8F1BBCDC+Rol(v,5);w=Rol(w,30);
#define R4(v,w,x,y,z,i) z+=(w^x^y)+Blk(i)+0xCA62C1D6+Rol(v,5);w=Rol(w,30);

/*
*----------------------------------------------------------------------
Expand All @@ -80,18 +80,18 @@
* Hash a single 512-bit block. This is the core of the algorithm.
*
* Results:
* Contents of context poineter are changed.
* None.
*
* Side effects:
* None.
* Contents of state pointer are changed.
*
*----------------------------------------------------------------------
*/

void
SHA1Transform(state, buffer)
unsigned long state[5];
unsigned char buffer[64];
unsigned long state[5]; /* State variable */
unsigned char buffer[64]; /* Modified buffer */
{
#if (!defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN))
unsigned char *p;
Expand Down Expand Up @@ -160,6 +160,8 @@ SHA1Transform(state, buffer)
*/

a = b = c = d = e = 0;

return;
}

/*
Expand All @@ -170,10 +172,10 @@ SHA1Transform(state, buffer)
* Initialize new context
*
* Results:
* Contents of context poineter are changed.
* None.
*
* Side effects:
* None.
* Contents of context pointer are changed.
*
*----------------------------------------------------------------------
*/
Expand All @@ -191,6 +193,8 @@ void SHA1Init(context)
context->state[3] = 0x10325476;
context->state[4] = 0xC3D2E1F0;
context->count[0] = context->count[1] = 0;

return;
}

/*
Expand All @@ -201,10 +205,10 @@ void SHA1Init(context)
* Updates a context.
*
* Results:
* Unknown.
* None.
*
* Side effects:
* Unknown.
* Contents of context pointer are changed.
*
*----------------------------------------------------------------------
*/
Expand Down Expand Up @@ -244,6 +248,8 @@ SHA1Update(context, data, len)
}

memcpy(&context->buffer[j], &data[i], len - i);

return;
}

/*
Expand All @@ -254,10 +260,10 @@ SHA1Update(context, data, len)
* Add padding and return the message digest.
*
* Results:
* Unknown.
* None.
*
* Side effects:
* Unknown.
* Contents of context pointer are changed.
*
*----------------------------------------------------------------------
*/
Expand Down Expand Up @@ -303,10 +309,12 @@ void SHA1Final(context, digest)
memset(&finalcount, 0, 8);

/*
* make SHA1Transform overwrite it's own static vars
* Make SHA1Transform overwrite it's own static vars.
*/

#ifdef SHA1HANDSOFF
SHA1Transform(context->state, context->buffer);
#endif

return;
}
7 changes: 6 additions & 1 deletion exampleA.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
*
*/

#ifndef _EXAMPLEA
#define _EXAMPLEA

#include <tcl.h>

/*
Expand All @@ -18,7 +21,7 @@
#ifdef BUILD_exampleA
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
#endif
#endif /* BUILD_exampleA */

typedef struct {
unsigned long state[5];
Expand All @@ -36,3 +39,5 @@ void SHA1Final _ANSI_ARGS_((SHA1_CTX* context, unsigned char digest[20]));
*/

EXTERN int Examplea_Init _ANSI_ARGS_((Tcl_Interp * interp));

#endif /* _EXAMPLEA */
2 changes: 1 addition & 1 deletion tcl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1756,7 +1756,7 @@ AC_DEFUN(SC_TCL_LINK_LIBS, [
# SC_MAKE_LIB --
#
# Generate a line that can be used to build a shared/unshared library
# in a platform independant manner.
# in a platform independent manner.
#
# Arguments:
# none
Expand Down
22 changes: 10 additions & 12 deletions tclexampleA.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@

#define TCL_READ_CHUNK_SIZE 4096

/*
* as itoa64 but with filename-safe charset
*/

static unsigned char itoa64f[] =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_,";

Expand All @@ -43,7 +39,7 @@ static int Sha1 _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp,
* Implements the new Tcl "sha1" command.
*
* Results:
*
* A standard Tcl result
*
* Side effects:
* None.
Expand Down Expand Up @@ -161,23 +157,24 @@ Sha1(clientData, interp, argc, argv)

if (descriptor != NULL) {
if ((sscanf(descriptor, "sha1%d", &contextnum) != 1) ||
(contextnum >= numcontexts) || (ctxtotalRead[contextnum] < 0)) {
(contextnum >= numcontexts) || (ctxtotalRead[contextnum] < 0)) {
Tcl_AppendResult(interp, "invalid sha1 descriptor \"",
descriptor, "\"", (char *) NULL);
return TCL_ERROR;
}
}

if (doinit)
if (doinit) {
SHA1Init(&sha1Context);
}

if (string != NULL) {
if (chan != (Tcl_Channel) NULL)
if (chan != (Tcl_Channel) NULL) {
goto wrongArgs;
}
totalRead = strlen(string);
SHA1Update(&sha1Context, (unsigned char *) string, totalRead);
}
else if (chan != (Tcl_Channel) NULL) {
} else if (chan != (Tcl_Channel) NULL) {
bufPtr = ckalloc((unsigned) TCL_READ_CHUNK_SIZE);
totalRead = 0;
while ((n = Tcl_Read(chan, bufPtr,
Expand Down Expand Up @@ -295,7 +292,7 @@ Sha1(clientData, interp, argc, argv)
(char *) NULL);
return TCL_ERROR;
}


/*
*----------------------------------------------------------------------
*
Expand All @@ -306,9 +303,10 @@ Sha1(clientData, interp, argc, argv)
* configure.in.
*
* Results:
* The Tclsha1 package is created.
* A standard Tcl result
*
* Side effects:
* The Tclsha1 package is created.
* One new command "sha1" is added to the Tcl interpreter.
*
*----------------------------------------------------------------------
Expand Down

0 comments on commit 6ba2f85

Please sign in to comment.