Tcl Extension Architecture (TEA) Sample Extension

Check-in [5aa4c4c666]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sampleextension work with novem. Remove Tcl_PkgRequire() call, as the same check is already done by Tcl_InitStubs().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5aa4c4c666ee218345616020b2763cbefb1d6270
User & Date: jan.nijtmans 2014-04-02 10:28:45
Context
2014-10-01
18:11
Ticket [f72ade40ae]: Installer improvements check-in: 48389da729 user: jan.nijtmans tags: trunk
2014-04-02
10:28
Make sampleextension work with novem. Remove Tcl_PkgRequire() call, as the same check is already done by Tcl_InitStubs(). check-in: 5aa4c4c666 user: jan.nijtmans tags: trunk
09:51
update to latest TEA check-in: 569898e0f1 user: jan.nijtmans tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/sample.h.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39








40
41
42
43
44
45
46
..
47
48
49
50
51
52
53
54
55








56
 */

#ifndef _SAMPLE
#define _SAMPLE

#include <tcl.h>

/*
 * Windows needs to know which symbols to export.
 */

#ifdef BUILD_sample
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
#endif /* BUILD_sample */

#ifdef HAVE_INTTYPES_H
#   include <inttypes.h>
typedef uint32_t sha_uint32_t;
#else
#   if ((1<<31)<0)
typedef unsigned long sha_uint32_t;
#   else
typedef unsigned int sha_uint32_t;
#   endif
#endif









typedef struct {
    sha_uint32_t state[5];
    sha_uint32_t count[2];
    unsigned char buffer[64];
} SHA1_CTX;

void SHA1Init	(SHA1_CTX* context);
................................................................................
void SHA1Update	(SHA1_CTX* context, unsigned char* data, unsigned int len);
void SHA1Final	(SHA1_CTX* context, unsigned char digest[20]);

/*
 * Only the _Init function is exported.
 */

EXTERN int	Sample_Init(Tcl_Interp * interp);









#endif /* _SAMPLE */






<
<
<
<
<
<
<
<
<











>
>
>
>
>
>
>
>







 







|

>
>
>
>
>
>
>
>

13
14
15
16
17
18
19









20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 */

#ifndef _SAMPLE
#define _SAMPLE

#include <tcl.h>










#ifdef HAVE_INTTYPES_H
#   include <inttypes.h>
typedef uint32_t sha_uint32_t;
#else
#   if ((1<<31)<0)
typedef unsigned long sha_uint32_t;
#   else
typedef unsigned int sha_uint32_t;
#   endif
#endif

/*
 * For C++ compilers, use extern "C"
 */

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    sha_uint32_t state[5];
    sha_uint32_t count[2];
    unsigned char buffer[64];
} SHA1_CTX;

void SHA1Init	(SHA1_CTX* context);
................................................................................
void SHA1Update	(SHA1_CTX* context, unsigned char* data, unsigned int len);
void SHA1Final	(SHA1_CTX* context, unsigned char digest[20]);

/*
 * Only the _Init function is exported.
 */

extern DLLEXPORT int	Sample_Init(Tcl_Interp * interp);

/*
 * end block for C++
 */

#ifdef __cplusplus
}
#endif

#endif /* _SAMPLE */

Changes to generic/tclsample.c.

348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
    /*
     * This may work with 8.0, but we are using strictly stubs here,
     * which requires 8.1.
     */
    if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
	return TCL_ERROR;
    }
    if (Tcl_PkgRequire(interp, "Tcl", "8.1", 0) == NULL) {
	return TCL_ERROR;
    }
    if (Tcl_PkgProvide(interp, PACKAGE_NAME, PACKAGE_VERSION) != TCL_OK) {
	return TCL_ERROR;
    }
    Tcl_CreateObjCommand(interp, "sha1", (Tcl_ObjCmdProc *) Sha1_Cmd,
	    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);

    numcontexts = 1;
    sha1Contexts = (SHA1_CTX *) malloc(sizeof(SHA1_CTX));
    ctxtotalRead = (int *) malloc(sizeof(int));
    ctxtotalRead[0] = 0;

    return TCL_OK;
}






<
<
<













348
349
350
351
352
353
354



355
356
357
358
359
360
361
362
363
364
365
366
367
    /*
     * This may work with 8.0, but we are using strictly stubs here,
     * which requires 8.1.
     */
    if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
	return TCL_ERROR;
    }



    if (Tcl_PkgProvide(interp, PACKAGE_NAME, PACKAGE_VERSION) != TCL_OK) {
	return TCL_ERROR;
    }
    Tcl_CreateObjCommand(interp, "sha1", (Tcl_ObjCmdProc *) Sha1_Cmd,
	    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);

    numcontexts = 1;
    sha1Contexts = (SHA1_CTX *) malloc(sizeof(SHA1_CTX));
    ctxtotalRead = (int *) malloc(sizeof(int));
    ctxtotalRead[0] = 0;

    return TCL_OK;
}