Esempio n. 1
0
/*
 * define_attr_by_text
 *
 * define a new attribute with attribute definition passed as
 * string. The new attribute is assigned to the global attr-list
 * (by default, with a local scope)
 *
 * params: varname..name of new var
 *         flag.....flags: VF_ONLYONCE to avoid re-definition of a var
 * result: ptr to new var
 *
 * NOTE:
 *   The new attribute will be declared as if a corresponding
 *   <$define> showed up in the source. It will be assigned to
 *   the local scope; you will need to add a "/GLOBAL" to the
 *   description text if you want to avoid this
 *
 *   It's recommended not to setup a default value, if you are
 *   not sure that it can't contain data that will cause error
 *   messages to show up (like value=xy"zw'bl)
 *
 * definition syntax in input file:
 *   <varname>":"<vartype>[/flag]["="<deftext value>]
 *
 * EXAMPLE:
 *   define_attr_by_text(hp,"sepp:string/global='sepp'", 0)
 *
 * SEE ALSO:
 *   define_var()
 */
HSCATTR *define_attr_by_text(HSCPRC * hp, STRPTR attr_text, STRPTR default_value, ULONG unmasked_flags)
{
    /* NOTE: this functions works a bit strange */
    EXPSTR *define_text = init_estr(0);
    INFILE *old_inpf = hp->inpf;
    HSCATTR *attr = NULL;

    /* create attribute definition */
    set_estr(define_text, attr_text);
    app_estr(define_text, ">");

    hp->inpf = infopen_str(PARENT_FILE_ID "define_attr_by_text",
                           estr2str(define_text), 0);

    /* process attribute definition */
    if (hp->inpf)
    {
        attr = define_attr_by_hp(hp, default_value, unmasked_flags);
        infclose(hp->inpf);
    }

    /* cleanup */
    hp->inpf = old_inpf;
    del_estr(define_text);

    return (attr);
}
Esempio n. 2
0
File: hscprc.c Progetto: mbethke/hsc
/*
 * del_hscprc
 *
 * Remove HSC process and all its resources
 */
void del_hscprc(HSCPRC *hp)
{
    if (hp) {
        /* remove list */
        del_hsctree(hp->defstyle);
        del_dllist(hp->defent);
        del_hsctree(hp->deftag);
        del_dllist(hp->defattr);
        del_hsctree(hp->deflazy);
        del_dllist(hp->container_stack);
        del_dllist(hp->content_stack);
        del_dllist(hp->inpf_stack);
        del_dllist(hp->idrefs);
        del_dllist(hp->select_stack);
        del_dllist(hp->tag_styles);
        del_strlist(hp->include_dirs);

        /* remove precompiled regular expressions */
        hscregfreeall(hp->re_uri);

        /* remove strings */
        del_estr(hp->destdir);
        del_estr(hp->reldir);
        del_estr(hp->iconbase);
        del_estr(hp->server_dir);
        del_estr(hp->if_stack);
        del_estr(hp->tag_name_str);
        del_estr(hp->tag_attr_str);
        del_estr(hp->tag_close_str);
        del_estr(hp->tmpstr);
        del_estr(hp->curr_msg);
        del_estr(hp->curr_ref);
        del_estr(hp->whtspc);

        ufreestr(hp->filename_document);
        ufreestr(hp->strip_tags);

        ufree(hp->image_buffer);

        /* remove project-data */
        del_project(hp->project);

        /* close input files */
        infclose(hp->inpf);

        /* remove message arrays */
        ufree(hp->msg_ignore);
        ufree(hp->msg_class);

        ufree(hp);
    }
}
Esempio n. 3
0
/*
** include_hsc
**
** read from inpf, parse for hsc-commands and execute them,
** check for html-error,
** write all out to outf and close input file.
**
** params: inpfnm...input file name
**         outf.....output file structure, already opended
**
** result: TRUE, if all worked well, else FALSE
*/
BOOL include_hsc( STRPTR inpfnm, FILE *outf, ULONG optn )
{

    INFILE *inpf  = NULL;  /* input file */
    BOOL    ok;            /* result */

    inpf = infopen( inpfnm, MAXLINELEN );        /* open input file */
    ok   = (inpf!=NULL);

    if ( inpf ) {                                /* file opened? */

        while ( !infeof(inpf) && ok ) {          /*    parse file */

            if ( !(optn & IH_PARSE_MACRO) )
                status_infile( inpf, FALSE );    /*    status message */
            ok = parse_hsc( inpf );
        }

        if ( ok && (optn & IH_PARSE_END) ) {     /*    parse end */
                                                 /*    (unclosed tags etc) */
            ok = parse_end( inpf );

        }

        /* end of file status */
        if ( !(optn & IH_PARSE_MACRO) ) {

            status_infile( inpf, TRUE );         /*    status message */
            status_lf();                         /*    (display num of line) */

        }

        infclose( inpf );                        /*    close file */
                                                 
    } else {                                     /* N-> error message */

        message( ERROR_FILE_OPEN, NULL );
        errstr( "can not open " );
        errqstr( inpfnm );
        errstr( " for input: " );
        errstr( strerror( errno ) );
        errlf();
        ok = FALSE;
    }

    return ( ok );
}
Esempio n. 4
0
/*
 * del_hscprc
 *
 * remove hsc process and all it's resources
 */
VOID del_hscprc(HSCPRC * hp)
{
    if (hp)
    {
        /* remove list */
        del_dllist(hp->defent);
        del_dllist(hp->deftag);
        del_dllist(hp->defattr);
        del_dllist(hp->container_stack);
        del_dllist(hp->content_stack);
        del_dllist(hp->inpf_stack);
        del_dllist(hp->idrefs);
        del_dllist(hp->select_stack);
        del_strlist(hp->include_dirs);

        /* remove strings */
        del_estr(hp->destdir);
        del_estr(hp->reldir);
        del_estr(hp->iconbase);
        del_estr(hp->server_dir);
        del_estr(hp->if_stack);
        del_estr(hp->tag_name_str);
        del_estr(hp->tag_attr_str);
        del_estr(hp->tag_close_str);
        del_estr(hp->tmpstr);
        del_estr(hp->curr_msg);
        del_estr(hp->curr_ref);
        del_estr(hp->whtspc);

        ufreestr(hp->filename_document);
        ufreestr(hp->strip_tags);

        /* remove project-data */
        del_project(hp->project);

        /* close input files */
        infclose(hp->inpf);

        /* remove message arrays */
        ufree(hp->msg_ignore);
        ufree(hp->msg_class);

        ufree(hp);
    }
}
Esempio n. 5
0
/*
 * init_hsctags
 *
 * define hsc tags & attributes; assign tagCBs for them
 *
 * NOTE: this ones tricky, but a bit perverted somehow
 */
BOOL hsc_init_tagsNattr(HSCPRC * hp)
{
#define INCLUDE_ATTR " PRE:bool SOURCE:bool TEMPORARY:bool" \
                     " INDENT:num TABSIZE:num=\"4\" "
    BYTE i = 0;
    BOOL ok = TRUE;
    BOOL open_tag;
    HSCTAG *tag;

    /* define hsc internal tags */
    STRPTR hsc_prefs[] =
    {
        /* tags with special chars as name
         *
         * IMPORTANT: When adding new tags with names not starting with
         *   HSC_TAGID, make sure to update `tag.c:is_hsc_tag()'
         */
        HSC_COMMENT_STR " /SKIPLF /SPECIAL>",
        HSC_VERBATIM_STR" /SPECIAL>",
        HSC_INSEXPR_STR " /SPECIAL>",
        /* tags starting with HSC_TAGID */
        HSC_CONTENT_STR " /SKIPLF>",
        HSC_DEFENT_STR " /SKIPLF NAME:string RPLC:string NUM:num PREFNUM:bool NONSTD:bool>",
        HSC_DEFSTYLE_STR " /SKIPLF NAME:string/r VAL:string>",
        HSC_DEFICON_STR " /SKIPLF NAME:string/r>",
        HSC_DEFINE_STR " /SKIPLF /SPECIAL>",
        HSC_DEFTAG_STR " /SKIPLF /SPECIAL>",
        HSC_DEPEND_STR " /SKIPLF ON:string/r FILE:bool>",
        HSC_ELSE_STR " /SKIPLF /MBI=\"" HSC_IF_STR "\">",
        HSC_ELSEIF_STR " /SKIPLF /MBI=\"" HSC_IF_STR "\"" CONDITION_ATTR ":bool>",
        HSC_MESSAGE_STR " /SKIPLF TEXT:string/r CLASS:enum(\"note|warning|error|fatal\")='note'>",
        HSC_EXEC_STR " /SKIPLF COMMAND:string/r REMOVE:enum(\"on|off|auto\")=\"auto\" ATTRIBUTE:string INCLUDE:bool FILE:string " INCLUDE_ATTR ">",
        HSC_EXPORT_STR " /SKIPLF FILE:string/r DATA:string/r APPEND:bool>",
        HSC_IF_STR " /SKIPLF /CLOSE " CONDITION_ATTR ":bool>",
        HSC_INSERT_STR " /OBSOLETE TEXT:string TIME:bool FORMAT:string>",
        HSC_INCLUDE_STR " /SKIPLF FILE:string/r " INCLUDE_ATTR ">",
        HSC_LAZY_STR " /SKIPLF /SPECIAL>",
        HSC_LET_STR " /SKIPLF /SPECIAL>",
        HSC_MACRO_STR " /SKIPLF /SPECIAL>",
        HSC_SOURCE_STR " /SKIPLF PRE:bool>",
        HSC_MATCH_STR "/SKIPLF NOCASE:bool RE:string/r S:string/r "
        "C0:string C1:string C2:string C3:string C4:string "
        "C5:string C6:string C7:string C8:string C9:string>",
        HSC_STRIPWS_STR " TYPE:enum(\"" STRIPWS_ENUM "\")=\"" STRIPWS_BOTH "\">",
        NULL
    };

    STRPTR hsc_attribs[] =
    {
        /*
         * define hsc attributes
         */
        /* name                 : type     : default value */
        SYSTEM_ATTR         ":string/c" , SYSTEM_ATTR_ID,
        ANCHOR_ATTR         ":string"   , "this is a feature, not a bug",
        CONTENT_ATTR        ":string/c" , NULL,
        RESULT_ATTR         ":num=\"0\"", NULL, /* a bit strange */
        FILESIZEFORMAT_ATTR ":string"   , "%a%u",
        TIMEFORMAT_ATTR     ":string"   , "%d-%b-%Y, %H:%M",
        LINEFEED_ATTR       ":string>"  , NULL,
        HSCVERSION_ATTR     ":num/c="STRINGIFY(VERSION), NULL,
        HSCREVISION_ATTR    ":num/c="STRINGIFY(REVISION), NULL,
        NULL, NULL
    };

    /* temporarily disable debugging output */
    dbg_disable(hp);

    /* define hsc-tags */
    i = 0;
    while (!(hp->fatal) && hsc_prefs[i]) {
        STRARR infname[20];

        sprintf(infname, SPECIAL_FILE_ID "init%3d", i);
        hp->inpf = infopen_str(infname, hsc_prefs[i], 60);

        if (hp->inpf) {
            tag = def_tag_name(hp, &open_tag);
            ok = (tag && def_tag_args(hp, tag));
            infclose(hp->inpf);
        }
        i++;
    }

    /* init hsc-attributes */
    i = 0;
    while (!(hp->fatal) && hsc_attribs[i]) {
        define_attr_by_text(hp, hsc_attribs[i], hsc_attribs[i+1], 0);
        i+=2;
    }

    /* assign "\n" to linefeed-attribute */
    set_vartext(find_varname(hp->defattr, LINEFEED_ATTR), "\n");

    /* assign tag-callbacks to hsc-tags */
    if (ok) {
        hsc_set_tagCB(hp, HSC_COMMENT_STR, handle_hsc_comment, NULL);
        hsc_set_tagCB(hp, HSC_CONTENT_STR, handle_hsc_content, NULL);
        hsc_set_tagCB(hp, HSC_DEFSTYLE_STR, handle_hsc_defstyle, NULL);
        hsc_set_tagCB(hp, HSC_DEFENT_STR, handle_hsc_defent, NULL);
        hsc_set_tagCB(hp, HSC_DEFICON_STR, handle_hsc_deficon, NULL);
        hsc_set_tagCB(hp, HSC_DEFINE_STR, handle_hsc_define, NULL);
        hsc_set_tagCB(hp, HSC_DEFTAG_STR, handle_hsc_deftag, NULL);
        hsc_set_tagCB(hp, HSC_DEPEND_STR, handle_hsc_depend, NULL);
        hsc_set_tagCB(hp, HSC_ELSE_STR, handle_hsc_else, NULL);
        hsc_set_tagCB(hp, HSC_ELSEIF_STR, handle_hsc_elseif, NULL);
        hsc_set_tagCB(hp, HSC_EXEC_STR, handle_hsc_exec, NULL);
        hsc_set_tagCB(hp, HSC_EXPORT_STR, handle_hsc_export, NULL);
        hsc_set_tagCB(hp, HSC_IF_STR, handle_hsc_if, handle_hsc_cif);
        hsc_set_tagCB(hp, HSC_INCLUDE_STR, handle_hsc_include, NULL);
        hsc_set_tagCB(hp, HSC_INSERT_STR, handle_hsc_insert, NULL);
        hsc_set_tagCB(hp, HSC_INSEXPR_STR, handle_hsc_insert_expression, NULL);
        hsc_set_tagCB(hp, HSC_COMMENT_STR, handle_hsc_comment, NULL);
        hsc_set_tagCB(hp, HSC_LAZY_STR, handle_hsc_lazy, NULL);
        hsc_set_tagCB(hp, HSC_LET_STR, handle_hsc_let, NULL);
        hsc_set_tagCB(hp, HSC_MACRO_STR, handle_hsc_macro, NULL);
        hsc_set_tagCB(hp, HSC_MESSAGE_STR, handle_hsc_message, NULL);
        hsc_set_tagCB(hp, HSC_VERBATIM_STR, handle_hsc_verbatim, NULL);
        hsc_set_tagCB(hp, HSC_SOURCE_STR, handle_hsc_source, NULL);
        hsc_set_tagCB(hp, HSC_MATCH_STR, handle_hsc_match, NULL);
        hsc_set_tagCB(hp, HSC_STRIPWS_STR, handle_hsc_stripws, NULL);
    }

    /* restore debugging output */
    dbg_restore(hp);

    return (ok);
}
Esempio n. 6
0
/*
 * hsc_include
 *
 * read from inpf, parse for hsc-commands and execute them,
 * check for html-error,
 * write all out to outf and close input file.
 *
 * params: inpfnm...input file name
 *         outf.....output file structure, already opended
 *
 * result: TRUE, if all worked well, else FALSE
 */
static BOOL hsc_include(HSCPRC * hp, INFILE * inpf, ULONG optn, INFILEPOS * base_pos)
{
    BOOL ok;                    /* result */
    ok = (inpf != NULL);

    if (optn & IH_POS_PARENT)
    {
        panic("IH_POS_PARENT set");
    }

    if (inpf)                   /* file opened? */
    {                  
#if (defined MSDOS) /* HSC_YOUR */
        /* check input > 32K */
        if (estrlen(inpf->lnbuf) > (32*1024))
        {
            fprintf(stderr, "** input file too huge\n");
            exit(RC_FAIL);
        }
#endif
        /* push current input file on input-file-stack */
        if (hp->inpf)
        {
            ins_dlnode(hp->inpf_stack, hp->inpf_stack->first, (APTR) hp->inpf);
        }

        /* set new base position for input-file */
        /* (if called from a macro or after eg. <$source>) */
        if (base_pos)
        {
            set_infile_base(inpf, base_pos);
        }

        /* assign new input file to hsc-process */
        hp->inpf = inpf;

        /* hide status? */
        if ((optn & IH_PARSE_MACRO) || (optn & IH_PARSE_MACRO))
        {
            optn |= IH_NO_STATUS;
        }

        /* set char-parse methods */
        inpf->is_nc = hsc_normch;       /* set is_nc-methode */
        inpf->is_ws = hsc_whtspc;       /* set is_ws-methode */

        /* status message: reading new file */
        if (!(optn & IH_NO_STATUS) && !infeof(inpf))
        {
            hsc_status_file_begin(hp, infget_fname(hp->inpf));
        }

        /* parse file */
        while (!infeof(inpf) && ok)
        {
            if (!(optn & IH_NO_STATUS) &&
                (hp->prev_status_line != infget_y(hp->inpf))
                )
            {
                /* status message */
                hsc_status_line(hp);
                hp->prev_status_line = infget_y(hp->inpf);
            }

            /* parse next item */
            if (optn & IH_PARSE_SOURCE)
            {
                ok = hsc_parse_source(hp);
            }
            else
            {
                ok = hsc_parse(hp);
            }
        }

        /* parse at end: check for missing tags, .. */
        if (ok && (optn & IH_PARSE_END))
        {                       /* parse end (unclosed tags etc) */
            ok = hsc_parse_end(hp);

            if (ok && (optn & IH_UPDATE_PRJ))
            {
                /* update project file */
                ok = hsc_parse_end_id(hp);
            }
        }

        /* end of file status */
        if (!(optn & IH_NO_STATUS))
        {
            /* status message: file processed */
            hsc_status_file_end(hp);
        }

        /* close file */
        infclose(hp->inpf);

        /* pull previous input file from input-file-stack
         * or end hsc-process */
        if (hp->inpf_stack->first)
        {
            /* pull first item from stack */
            hp->inpf = (INFILE *) hp->inpf_stack->first->data;
            hp->inpf_stack->first->data = NULL;

            del_dlnode(hp->inpf_stack, hp->inpf_stack->first);
        }
        else
        {
            hp->inpf = NULL;
        }
    }
    else
    {
        panic("no input file");
    }

    return (ok);
}
Esempio n. 7
0
/*
** hsc_include
**
** read from inpf, parse for hsc-commands and execute them,
** check for html-error,
** write all out to outf and close input file.
**
** params: inpfnm...input file name
**         outf.....output file structure, already opended
**
** result: TRUE, if all worked well, else FALSE
*/
static BOOL hsc_include( HSCPRC *hp, INFILE *inpf, ULONG optn, INFILEPOS *base_pos )
{
    BOOL    ok;            /* result */
    ok   = (inpf!=NULL);

    if ( inpf ) {                                /* file opened? */

        /* push current input file on input-file-stack */
        if ( hp->inpf )
            ins_dlnode( hp->inpf_stack, hp->inpf_stack->first, (APTR) hp->inpf );

        /* set new base position for input-file */
        /* (if called from a macro or after eg. <$source>) */
        if ( base_pos )
            set_infile_base( inpf, base_pos );

        /* assign new input file to hsc-process */
        hp->inpf = inpf;

        /* hide status? */
        if ( (optn & IH_PARSE_MACRO) || (optn & IH_PARSE_MACRO) )
            optn |= IH_NO_STATUS;

        /* set char-parse methods */
        inpf->is_nc = hsc_normch;                /*    set is_nc-methode */
        inpf->is_ws = hsc_whtspc;                /*    set is_ws-methode */

        if ( !(optn & IH_NO_STATUS ) && !infeof(inpf) )
            hsc_status_file_begin( hp );         /*    status message: */
                                                 /*      new file */

        while ( !infeof(inpf) && ok ) {          /*    parse file */


            if ( !(optn & IH_NO_STATUS ) &&      /* status message */
                 ( hp->prev_status_line != infget_y( hp->inpf ) )
               )
            {
                hsc_status_line( hp );
                hp->prev_status_line = infget_y( hp->inpf );
            }

            /* parse next item */
            if ( optn & IH_PARSE_SOURCE )
                ok = hsc_parse_source( hp );
            else
                ok = hsc_parse( hp );
        }

        /* parse at end: check for missing tags, .. */
        if ( ok && (optn & IH_PARSE_END) ) {     /*    parse end */
                                                 /*    (unclosed tags etc) */
            ok = hsc_parse_end( hp );

            if ( ok && (optn & IH_UPDATE_PRJ ) )
                ok = hsc_parse_end_id( hp );     /* update project file */

        }

        /* end of file status */
        if ( !(optn & IH_NO_STATUS) ) {

            hsc_status_file_end( hp );           /*    status message: */
                                                 /*      file processed */
        }

        infclose( hp->inpf );                    /*    close file */

        /* pull previous input file from input-file-stack
        ** or end hsc-process
        */
        if ( hp->inpf_stack->first ) {

            /* pull first item from stack */
            hp->inpf = (INFILE *) hp->inpf_stack->first->data;
            hp->inpf_stack->first->data = NULL;

            del_dlnode( hp->inpf_stack, hp->inpf_stack->first );

        } else {

            hp->inpf = NULL;
        }

    } else
        panic( "no input file" );

    return ( ok );
}
Esempio n. 8
0
int main( int argc, char *argv[] )
{
    INFILE *inpf;
    INFILEPOS *pos1 = NULL;
    INFILEPOS *pos2 = NULL;

    char *fname;
    char ch;
    size_t i;
    char getstr[GETSTRLEN+1];
    char *wdbuf;

#if DEBUG_UGLY_MEMORY
    atexit( atexit_uglymemory );
#endif

    if ( argc == 1 )
        fname = "hugo.txt";
    else
        fname = argv[1];

    errno = 0;
    inpf = infopen( fname, 0 );

    if ( inpf ) {

#if 1
        /* info about first word */
        wdbuf = infgetw( inpf );
        printf( "word#0: \"%s\", \"%s\"\n",
                infgetcws( inpf ), infgetcw( inpf ) );


        /*
        ** get 10 chars, print them,
        ** and put them back again
        */
        ch = '*'; /* dummy */
        for ( i=0; i<GETSTRLEN; i++ )
            getstr[i] = infgetc( inpf );

        getstr[i] = '\0';
        printf( "got : \"%s\"\nback: \"", getstr );

        for ( ; i>0; i-- ) {
            ch = getstr[i-1];
            printf( "%c", ch );
            inungetc( ch, inpf );
        }
        printf( "\"\n" );
#endif

        /*
        ** read the first 3 words
        */
        for ( i=0; i<3; i++ ) {
            wdbuf = infgetw( inpf );
            printf( "word#%lu: [%lu] \"%s\"\n",
                     (ULONG) i, (ULONG) strlen(wdbuf), wdbuf );
        }

        /* info about current word */
        printf( "current word: \"%s\", \"%s\"\n",
                infgetcws( inpf ), infgetcw( inpf ) );

        /*
        ** unget last word
        */
        inungetcw( inpf );
        wdbuf = infgetw( inpf );
        printf( "reword: [%lu] \"%s\"\n", (ULONG) strlen(wdbuf), wdbuf );

        /* remember current position */
        pos1 = new_infilepos( inpf );

        /*
        ** read and print rest of file
        */

        while ( !infeof( inpf ) ) {

            ch = infgetc( inpf );

            if ( !infeof( inpf ) ) {
                printf( "%c", ch );
                fflush( stdout );      /* flush output -> slow */
            }

        }

        pos2 = new_infilepos( inpf );

        printf( "pos#1: %s (%lu,%lu)\n",
                ifp_get_fname( pos1 ),
                ifp_get_x( pos1 ),
                ifp_get_y( pos1 ) );
        del_infilepos( pos1 );

        infclose( inpf );

        printf( "pos#2: %s (%lu,%lu)\n",
                ifp_get_fname( pos2 ),
                ifp_get_x( pos2 ),
                ifp_get_y( pos2 ) );
        del_infilepos( pos2 );

    } else
        perror( "Can't open input file" );

    /* test a string file */
    inpf = infopen_str( "test string", "this is\n a string\n converted\n to an\n input file.", 0 );
    if ( inpf ) {

        wdbuf = infgetw( inpf );
        while ( wdbuf ) {

            printf( "%s%s", infgetcws( inpf ), infgetcw( inpf ));
            wdbuf = infgetw( inpf );
        }

        infclose( inpf );
    } else
        perror( "Can't open input file from string" );

    printf( "\n" );

    return( 0 );
}
Esempio n. 9
0
void main( int argc, char *argv[] )
{
    INFILE *inpf;
    char *fname;
    char ch;
    size_t i;
    char getstr[GETSTRLEN+1];
    char *wdbuf;

    if ( argc == 1 )
        fname = "hugo.txt";
    else
        fname = argv[1];

    errno = 0;
    inpf = infopen( fname, MAXLINELEN );

    if ( inpf ) {

#if 0
        /* info about first word */
        wdbuf = infgetw( inpf );
        printf( "word#0: \"%s\", \"%s\"\n",
                infgetcws( inpf ), infgetcw( inpf ) );


        /*
        ** get 10 chars, print them,
        ** and put them back again
        */
        ch = '*'; /* dummy */
        for ( i=0; i<GETSTRLEN; i++ )
            getstr[i] = infgetc( inpf );

        getstr[i] = '\0';
        printf( "got : \"%s\"\nback: \"", getstr );

        for ( ; i>0; i-- ) {
            ch = getstr[i-1];
            printf( "%c", ch );
            inungetc( ch, inpf );
        }
        printf( "\"\n" );
#endif

        /*
        ** read the first 3 words
        */
        for ( i=0; i<3; i++ ) {
            if ( i==1 )
                inflog_disable( inpf );
            else
                inflog_enable( inpf );
            wdbuf = infgetw( inpf );
            printf( "word#%d: [%d] \"%s\"\n", i, strlen(wdbuf), wdbuf );
        }

        inflog_disable( inpf );

        /* info about current word */
        printf( "current word: \"%s\", \"%s\"\n",
                infgetcws( inpf ), infgetcw( inpf ) );

        /*
        ** unget last word
        */
        inungetcw( inpf );
        wdbuf = infgetw( inpf );
        printf( "reword: [%d] \"%s\"\n", strlen(wdbuf), wdbuf );

        /*
        ** read and print rest of file
        */

        while ( !infeof( inpf ) ) {

            ch = infgetc( inpf );

            if ( !infeof( inpf ) ) {
                printf( "%c", ch );
                fflush( stdout );      /* flush output -> slow */
            }

        }

        /* print log */
        printf( "log: \"%s\"\n", infget_log( inpf ) );

    } else
        perror( "Can't open input file" );

    infclose( inpf );
}