Index: external.c =================================================================== --- external.c (revision 14) +++ external.c (working copy) @@ -23,13 +23,15 @@ char *ext_mode = NULL; static c_int ext_word[PLAINTEXT_BUFFER_SIZE]; +static c_int ext_word_chksum; -static struct c_ident ext_globals = { - NULL, - "word", - ext_word +static struct c_ident ext_globals[] = { +{ NULL, "word", ext_word }, +{ NULL, "_chksum", &ext_word_chksum }, +{ NULL, NULL, NULL }, }; + static struct c_ident *f_generate; struct c_ident *f_filter; @@ -58,12 +60,22 @@ void ext_init(char *mode) { + int idx_ext_globals = 0; + if (!(ext_source = cfg_get_list(SECTION_EXT, mode))) { fprintf(stderr, "Unknown external mode: %s\n", mode); error(); } - if (c_compile(ext_getchar, ext_rewind, &ext_globals)) { + /* initialize globals linked list from the ext_globals array */ + while (ext_globals[ idx_ext_globals ].name != NULL) { + ext_globals[ idx_ext_globals ].next = + &ext_globals[ idx_ext_globals + 1 ]; + ++idx_ext_globals; + } + + + if (c_compile(ext_getchar, ext_rewind, &ext_globals[0] )) { if (!ext_line) ext_line = ext_source->tail; fprintf(stderr, "Compiler error in %s at line %d: %s\n", @@ -76,6 +88,7 @@ c_execute(c_lookup("init")); f_generate = c_lookup("generate"); + /* otheus: presumably, user's generate() can make its own chksum */ f_filter = c_lookup("filter"); ext_mode = mode; @@ -88,8 +101,11 @@ internal = (unsigned char *)in; external = ext_word; - while (*internal) + ext_word_chksum = 0; /* initialize chksum every time */ + while (*internal) { + ext_word_chksum += ( *internal % 256 ); /* compute chksum */ *external++ = *internal++; + } *external = 0; c_execute(f_filter);