예제 #1
0
static VOID append_docname(EXPSTR * prjstr, STRPTR docname)
{
    app_estr(prjstr, LINE_DOCUMENT_STR);
    app_estr(prjstr, " ");
    append_string(prjstr, docname);
    app_estr(prjstr, "\n");
}
예제 #2
0
static VOID append_id(EXPSTR * prjstr, STRPTR id)
{
    app_estr(prjstr, LINE_ID_STR);
    app_estr(prjstr, " ");
    append_string(prjstr, id);
    app_estr(prjstr, "\n");
}
예제 #3
0
/*
** handle_macro
**
** handle for macro: add local attributes to global attributes,
** include macro text, remove local attributes
**
** params: open_mac..TRUE, if called by an opening macro
**         inpf......input file
*/
BOOL handle_macro( BOOL open_mac, INFILE *inpf, HSCTAG *macro )
{
    BOOL    ok = FALSE;
    EXPSTR *text;       /* macro text */
    EXPSTR *fname;      /* pseudo-filename */
    DLLIST *args;
    ULONG   mci = get_mci();

    /* determine filename & args */
    args = macro->attr;
    if ( open_mac ) {
        text  = macro->op_text ;
    } else {
        text  = macro->cl_text ;
    }
    fname = init_estr( 0 );

    if ( fname ) {

        /* debugging message */
        DMC( {
            fprintf( stderr, "**-MACRO <" );
            if ( !open_mac )
                fprintf( stderr, "/" );
            fprintf( stderr, "%s> from %p\n", macro->name, text );
        } );

        /* create pseudo-filename */
        ok = set_estr( fname, "[macro " );
        ok &= app_estr( fname, macro->name );
        ok &= app_estr( fname, "]" );

    }
예제 #4
0
/* replace icon-entity by image */
static VOID replace_icon(HSCPRC * hp, STRPTR icon)
{
    INFILEPOS *base = new_infilepos(hp->inpf);
    EXPSTR *image = init_estr(0);
    STRPTR s = estr2str(hp->iconbase);

    /* create string like <IMG SRC=":icons/back.gif" ALT="back"> */
    set_estr(image, "<IMG SRC=\"");

    /* use iconbase with "*" replaced  by iconname as uri */
    while (s[0])
    {
        if (s[0] == '*')
            app_estr(image, icon);
        else
            app_estrch(image, s[0]);
        s++;
    }

    /* set ALT attribute to iconname */
    app_estr(image, "\" ALT=\"");
    app_estr(image, icon);
    app_estr(image, "\">");

    hsc_message(hp, MSG_RPLC_ICON, "replacing icon-%e", icon);

    hsc_include_string(hp, SPECIAL_FILE_ID "include icon",
                       estr2str(image),
                       IH_PARSE_HSC | IH_NO_STATUS | IH_POS_PARENT);
    del_estr(image);
    del_infilepos(base);
}
예제 #5
0
static VOID msg_idname(EXPSTR * msgstr, CONSTRPTR idname)
{
    app_estr(msgstr, "id ");
    app_estr(msgstr, "\"#");
    app_estr(msgstr, idname);
    app_estrch(msgstr, '"');
}
예제 #6
0
static VOID append_iddef(EXPSTR * prjstr, HSCIDD * iddef)
{
    app_estr(prjstr, LINE_ID_STR);
    app_estr(prjstr, " ");
    append_string(prjstr, iddef->name);
    append_caller(prjstr, iddef->caller);
    app_estr(prjstr, "\n");
}
예제 #7
0
static VOID append_title(EXPSTR * prjstr, STRPTR title)
{
    if (title)
    {
        app_estr(prjstr, LINE_TITLE_STR);
        app_estr(prjstr, " ");
        append_string(prjstr, title);
        app_estr(prjstr, "\n");
    }
}
예제 #8
0
static VOID append_sourcename(EXPSTR * prjstr, STRPTR sourcename)
{
    if (sourcename)
    {
        app_estr(prjstr, LINE_SOURCE_STR);
        app_estr(prjstr, " ");
        append_string(prjstr, sourcename);
        app_estr(prjstr, "\n");
    }
}
예제 #9
0
static VOID append_include(EXPSTR * prjstr, HSCINC * include)
{
    app_estr(prjstr, LINE_INCLUDE_STR);
    app_estr(prjstr, " ");
    append_string(prjstr, include->name);
    append_caller(prjstr, include->caller);
    app_estr(prjstr, "\n");
#if 0
    DP(fprintf(stderr, DHP "  include `%s'\n", include->name));
#endif
}
예제 #10
0
static VOID append_reference(EXPSTR * prjstr, HSCREF * reference)
{
#if 1
    app_estr(prjstr, LINE_REFERENCE_STR);
    app_estr(prjstr, " ");
    append_string(prjstr, reference->name);
    append_caller(prjstr, reference->caller);
    app_estr(prjstr, "\n");
#else
    DP(fprintf(stderr, DHP "  refers `%s'\n", reference->name));
#endif
}
예제 #11
0
/*
 * conv_uri2path
 *
 * convert a uri to a path for local (system-dependant)
 * file system
 */
VOID conv_uri2path(EXPSTR * dest, STRPTR uri, BOOL weenix)
{
    clr_estr(dest);

#ifdef AMIGA
    if (weenix)
    {
        /* convert leading "/" to ":" */
        /* convert leading "~" to ":" */
        if (!strncmp(uri, "/", 1)
            || !strncmp(uri, "~/", 2)
            || !strncmp(uri, "~", 1))
        {
            app_estr(dest, ":");
            uri++;
        }
    }

    /* convert leading "../" to "/" */
    while (!strncmp(uri, PARENT_URI, strlen(PARENT_URI)))
    {
        app_estr(dest, PARENT_DIR);
        uri += strlen(PARENT_URI);
    }

    /* convert inside "../" to "//" */
    while (uri[0])
    {
        if (!strncmp(uri, PARENT_URI, strlen(PARENT_URI)))
        {
            app_estrch(dest, '/');
            uri += strlen(PARENT_URI);
        }
        else
        {
            app_estrch(dest, uri[0]);
            uri++;
        }
    }

#elif defined RISCOS
    set_estr(dest, uri);

#elif defined MSDOS /* dos2 */
#elif (defined NEXTSTEP) || (defined BEOS) || (defined UNIX)
    set_estr(dest, uri);
#else
#error "system not supported: conv_uri2path"
#endif
}
예제 #12
0
/*
 * hsc_write_project_file
 *
 * write ids to file
 */
static VOID append_ulong(EXPSTR * dest, ULONG num)
{
    STRARR lenbuf[20];

    sprintf(lenbuf, "%lx ", num);
    app_estr(dest, lenbuf);
}
예제 #13
0
/*
 * hsc_read_prefs
 *
 * try to open (any) config file and read preferences
 * from it
 */
static BOOL hsc_read_prefs(HSCPRC * hp, STRPTR prefs_fname)
{
    BOOL ok = FALSE;
    EXPSTR *prefs_name_buffer = init_estr(32);

    /* find prefs file */
    if (!prefs_fname)
        prefs_fname = find_prefs_fname(hp, prefs_name_buffer);

    /* status message */
    if (prefs_fname) {
        dbg_disable(hp);

        hsc_status_file_begin(hp, prefs_fname);
        ok = hsc_include_file(hp, prefs_fname,
                              IH_PARSE_HSC | IH_NO_STATUS);
        dbg_restore(hp);

        if (ok) {
            EXPSTR *msg = init_estr(32);
            set_estr(msg, prefs_fname);
            app_estr(msg, ": preferences read");
            hsc_status_misc(hp, estr2str(msg));
            del_estr(msg);
        }
    } else hsc_message(hp, MSG_NO_CONFIG,
                           "can not open preferences file");

    del_estr(prefs_name_buffer);

    return (ok);
}
예제 #14
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);
}
예제 #15
0
/*
 * conv_path2uri
 *
 * convert a path for local (system-dependant)
 * file system to URI
 */
VOID conv_path2uri(EXPSTR * dest, STRPTR path)
{
    clr_estr(dest);

#ifdef AMIGA
    /* replace leading parent directories by "../" */
    while (!strncmp(path, PARENT_DIR, strlen(PARENT_DIR)))
    {
        app_estr(dest, PARENT_URI);
        path += strlen(PARENT_DIR);
    }

    while (path[0])
    {
        /* replace all "//" by "../" */
        if ((path[0] == '/') && (path[1] == '/'))
        {
            app_estr(dest, PARENT_URI);
            path += 2;
        }
        else
        {
            app_estrch(dest, path[0]);
            path++;
        }
    }

#elif defined MSDOS
    /* replace all "\" by "/" */
    while (path[0])
    {
        if ((path[0] == '\\'))
            app_estrch(dest, '/');
        else
            app_estrch(dest, path[0]);
        path++;
    }

#elif defined UNIX
    /* simply copy path */
    set_estr(dest, path);
#else
#error "system not supported: conv_path2uri"
#endif
}
예제 #16
0
/*
 * skip_until_eot
 *
 * skip until end of tag reached (">" found)
 *
 * params: inpf..input file
 * result: TRUE, if no fatal error
 * errors: return FALSE
 */
BOOL skip_until_eot(HSCPRC * hp, EXPSTR * logstr)
{
    INFILE *inpf = hp->inpf;
    STRPTR nw = NULL;

    do
    {
        nw = infgetw(inpf);
        if (nw && logstr)
        {
            app_estr(logstr, infgetcws(inpf));
            app_estr(logstr, infgetcw(inpf));
        }
    }
    while (nw && strcmp(nw, ">"));

    return ((BOOL) ! (hp->fatal));
}
예제 #17
0
/*
 * find_prefs_fname
 *
 * find preferences file: first check, if it is located
 * somewhere in the paths given via CONFIG_PATH (which
 * is a system depandent symbol); if not, check if it
 * is in the path described in the envvar HSCPREFS
 *
 * result: full path & filename of prefs or NULL if not found
 *
 */
static STRPTR find_prefs_fname(HSCPRC * hp, EXPSTR *cfgfn)
{
#define ENV_HOME "HOME"
    STRPTR prefs_fname = NULL;
    STRPTR paths[] =            /* paths to search for config file */
    {"", "", "", CONFIG_PATH,
     NULL, NULL};
    STRPTR path = NULL;
    UBYTE path_ctr = 0;
    FILE *cfgf = NULL;          /* prefs file */
    EXPSTR *hscpathstr = init_estr(32);         /* buffer to read $HSCPATH */
    EXPSTR *homepathstr = init_estr(32);        /* buffer to read $HOME */

    /* add "$HSCPATH/hsc.prefs" to files-to-be-checked */
    if (link_envfname(hscpathstr, ENV_HSCPATH, NULL, NULL))
    {
        /* add envval to paths */
        paths[1] = estr2str(hscpathstr);
    }

    /* add "$HOME/lib/hsc.prefs" to files-to-be-checked */
    if (link_envfname(homepathstr, ENV_HOME, "lib", NULL))
    {
        /* add envval to paths */
        paths[2] = estr2str(homepathstr);
    }

    /* try to open any prefs-file */
    do
    {                           /* loop: */
        path = paths[path_ctr]; /*   get next path */
        if (path)
        {                       /*   is it the last one? */
            set_estr(cfgfn, path);        /*   N->generate filename */
            app_estr(cfgfn, CONFIG_FILE);

            DC(fprintf(stderr, DHL "try \"%s\"\n", estr2str(cfgfn)));

            cfgf = fopen(estr2str(cfgfn), "r");   /*      try to open file */
        }
        path_ctr++;             /*   process next path */
    }
    while (path && (!cfgf));    /* until no path left or file opened */

    if (cfgf)
    {
        prefs_fname = estr2str(cfgfn);
        fclose(cfgf);
    }

    del_estr(homepathstr);
    del_estr(hscpathstr);

    return (prefs_fname);
}
예제 #18
0
/*
** skip_until_eot_args
**
** skip until end of tag reached,
** with user definable status vars
**
** params: inpf.....input file
**         quote....status for quote (TRUE=inside quote)
**         dquote...status for double quote
**         argattr..status for quote
** result: TRUE, if no fatal error
** errors: return FALSE
*/
BOOL skip_until_eot_state( INFILE *inpf, BYTE *state, EXPSTR *logstr )
{
    while( !eot_reached( inpf, state ) )
        if ( logstr ) {

            app_estr( logstr, infgetcws( inpf ) );
            app_estr( logstr, infgetcw( inpf ) );

        }

    /* append ">" */
    if ( logstr ) {

        app_estr( logstr, infgetcws( inpf ) );
        app_estr( logstr, infgetcw( inpf ) );

    }

    return( (BOOL) !fatal_error );
}
예제 #19
0
/*
 * skip_until_eot_args
 *
 * skip until end of tag reached,
 * with user definable status vars
 *
 * params: inpf.....input file
 *         quote....status for quote (TRUE=inside quote)
 *         dquote...status for double quote
 *         argattr..status for quote
 * result: TRUE, if no fatal error
 * errors: return FALSE
 */
static BOOL skip_until_eot_state(HSCPRC * hp, BYTE * state, EXPSTR * logstr)
{
    INFILE *inpf = hp->inpf;

    while (!eot_reached(hp, state))
        if (logstr)
        {
            app_estr(logstr, infgetcws(inpf));
            app_estr(logstr, infgetcw(inpf));
        }

    /* append ">" */
    if (logstr)
    {
        app_estr(logstr, infgetcws(inpf));
        app_estr(logstr, infgetcw(inpf));
    }

    return ((BOOL) ! (hp->fatal));
}
예제 #20
0
/*
** handle_hsc_exec
**
** exec a sub file
*/
BOOL handle_hsc_exec( INFILE *inpf, HSCTAG *tag )
{
    STRPTR cmd = get_vartext( tag->attr, "COMMAND" );

    if ( cmd ) {

        int     result;
        EXPSTR *msg = init_estr( 0 );

        if ( msg
             && app_estr( msg, "execute: " )
             && app_estr( msg, cmd ) )
        {

            /* status message */
            status_msg( estr2str( msg ) );
            if ( verbose )
                status_lf();

            /* call command */
            result = system( cmd );

            /* check for non-zero-result */
            if ( result ) {

                 message( MSG_SYSTEM_RETURN, inpf );
                 errstr( "Calling external command returned " );
                 errstr( long2str( (LONG) result ) );
                 errlf();

            }

        } else
            err_mem( inpf );

        del_estr( msg );

    }

    return (TRUE);
}
예제 #21
0
/*
 * append groups of data
 */
static VOID append_header(EXPSTR * prjstr)
{
    time_t now = time(NULL);    /* get current time */

    /* create string for current time */
    strftime(timebuf, TIMEBUFSIZE,
             "%d-%b-%Y %H:%M:%S", localtime(&now));

    /* append key-sequence, file-format-version and comment */
    app_estr(prjstr,
             FILEID_HSCPRJ "\n" LINE_VERSION_STR " ");
    append_ulong(prjstr, VERSION_HSCPRJ);
    app_estr(prjstr, "\n");
    app_estr(prjstr,
             LINE_REM_STR " Contains all data relevant for project.\n"
             LINE_REM_STR " Maintained by hsc, DO NOT MODIFY!\n");
    app_estr(prjstr,
             LINE_REM_STR " updated: ");
    app_estr(prjstr, timebuf);
    app_estrch(prjstr, '\n');
}
예제 #22
0
static VOID append_caller(EXPSTR * dest, CALLER * caller)
{
#if 0
    if (caller)
    {
        app_estr(dest, " " ID_CALLER_STR " ");
        append_string(dest, caller->name);
        append_ulong(dest, caller->posx);
        append_ulong(dest, caller->posy);
    }
#endif
}
예제 #23
0
파일: hscprc.c 프로젝트: mbethke/hsc
/*
 * output text function
 *
 * output text to host process
 *
 * params: hp....hsc process to perform ouput with
 *         wspc..white spaces
 *         text..other text
 * result: true, if text has been outputted
 */
BOOL hsc_output_text(HSCPRC * hp, STRPTR wspc, STRPTR text) {
    BOOL written = FALSE;
    if ((hp)->CB_text && !((hp)->suppress_output)) {
        /* add current white spaces to white space
         * buffer; if hp->compact is enabled, reduce
         * white spaces */
        if (wspc)
            app_estr(hp->whtspc, wspc);
        if (hp->compact && (!hp->inside_pre))
            /* reduce white spaces */
            wspc = compactWs(hp, estr2str(hp->whtspc));
        else
            wspc = estr2str(hp->whtspc);

        /* strip white spaces if requested */
        if (hp->strip_next_whtspc) {
            D(fprintf(stderr, DHL "bad white spaces stripped\n"));
            hp->strip_next_whtspc = FALSE;
            wspc = "";
        } else if (hp->strip_next2_whtspc) {
            hp->strip_next2_whtspc = FALSE;
            hp->strip_next_whtspc = TRUE;
        } else if ((hp->tag_next_whtspc) && strlen(wspc)) {
            hsc_message(hp, MSG_SUCC_WHTSPC,
                        "succeeding white-space for %T",
                        hp->tag_next_whtspc);
        }
        hp->tag_next_whtspc = NULL;

#if DEBUG_HSCLIB_OUTPUT
        if (hp->debug)
            if (text)
                if (strcmp(text, "\n"))
                    fprintf(stderr, DHL "ouput: `%s', `%s'\n", wspc, text);
                else
                    fprintf(stderr, DHL "ouput: `%s', `\\n'\n", wspc);
#endif
        if ((wspc && wspc[0]) || (text && text[0])) {
            /* convert NULL values to empty strings */
            if (!wspc)
                wspc = "";
            if (!text)
                text = "";

            /* output text */
            (*((hp)->CB_text)) ((hp), wspc, text);
            written = TRUE;
        }
        /* reset white space buffer */
        clr_estr(hp->whtspc);
    }
    return (written);
}
예제 #24
0
/*
 * try_set_attr
 *
 * if attribute exists and it's value is empty, set
 * new value and update tag-attribute-string
 */
static VOID try_setattr(HSCPRC * hp, HSCVAR * attr, ULONG value)
{
    if (attr)
    {
        STRPTR old_value = get_vartext(attr);
        STRPTR new_value = long2str(value);
        if (!old_value)
        {
            /* set new value */
            set_vartext(attr, new_value);

            /* append attribute name and "=" */
            app_estr(hp->tag_attr_str, " ");
            app_estr(hp->tag_attr_str, attr->name);
            app_estr(hp->tag_attr_str, "=");

            /* append quotes and value */
            if ((hp->quotemode == QMODE_KEEP) || (hp->quotemode == QMODE_DOUBLE))
                app_estrch(hp->tag_attr_str, '\"');
            else if (hp->quotemode == QMODE_SINGLE)
                app_estrch(hp->tag_attr_str, '\'');
            app_estr(hp->tag_attr_str, long2str(value));        /* append value */
            if ((hp->quotemode == QMODE_KEEP) || (hp->quotemode == QMODE_DOUBLE))
                app_estrch(hp->tag_attr_str, '\"');
            else if (hp->quotemode == QMODE_SINGLE)
                app_estrch(hp->tag_attr_str, '\'');

        }
        else
        {
            /* validate old value */
            if (strcmp(old_value, new_value))
            {
                hsc_message(hp, MSG_UNEX_ATTR_VALUE,
                            "unexpected value for %A: expected %q, found %q",
                            attr, new_value, old_value);
            }
        }
    }
}
예제 #25
0
/* set_source_attribs */
static VOID set_source_attribs(HSCPRC * hp, STRPTR sourcepath, STRPTR sourcename)
{
    app_estr(fileattr_str, "<$define HSC.SOURCE.NAME:string/c=\"");
    if (sourcename)
        app_estr(fileattr_str, sourcename);
    app_estr(fileattr_str, "\">\n<$define HSC.SOURCE.PATH:string/c=\"");
    if (sourcename)
        app_estr(fileattr_str, sourcepath);
    app_estr(fileattr_str, "\">\n<$define HSC.SOURCE.FILE:string/c=\"");
    if (sourcename)
        app_estr(fileattr_str, sourcepath);
    if (sourcename)
        app_estr(fileattr_str, sourcename);
    app_estr(fileattr_str, "\">\n");
}
예제 #26
0
static VOID send_arexx_command(HSCPRC * hp, STRPTR arexx_command)
{
    /* Hex-escaped Arexx command */
    EXPSTR *escaped_arexx_command = init_estr(256);
    STRPTR command_character = NULL;
    BOOL insert_concatenation;

    set_estr(escaped_arexx_command, "RX >nil: \"cmd='");

    /* Hex-escape nasty characters in command before sending it via RX.
     * Probably more characters then neccessary are escaped, but extending
     * this list is faster then finding out if a character is nasty or not.
     */
    command_character = arexx_command;
    insert_concatenation = TRUE;
    while (command_character[0] != '\0')
    {
        STRARR hex_buffer[10];

        if (insert_concatenation)
        {
            app_estr(escaped_arexx_command, "'||'");
        }
        switch (command_character[0])
        {
        case '\'':
        case '\"':
        case '*':
        case '`':
            sprintf(hex_buffer, "'||'%x'x'", command_character[0]);
            app_estr(escaped_arexx_command, hex_buffer);
            insert_concatenation = TRUE;
            break;

        default:
            app_estrch(escaped_arexx_command, command_character[0]);
            insert_concatenation = FALSE;
            break;
        }

        command_character += 1;
    }
    app_estr(escaped_arexx_command,"';");
#if DEBUG_MSGBROWSER
    app_estr(escaped_arexx_command,"call open(f,'console:'); call writeln(f,cmd);");
#endif
    app_estr(escaped_arexx_command,"address " SC_SCMSG " cmd");
    app_estr(escaped_arexx_command, "\"");

#if DEBUG_MSGBROWSER
    fprintf(stderr, "sending arexx: %s\n",
            estr2str(escaped_arexx_command));
#endif
    system(estr2str(escaped_arexx_command));

    del_estr(escaped_arexx_command);
}
예제 #27
0
/*
 * try_set_attr
 *
 * if attribute exists and it's value is empty, set
 * new value and update tag-attribute-string
 */
static VOID try_setattr(HSCPRC * hp, HSCVAR * attr, ULONG value)
{
    if (attr && !get_vartext(attr))
    {
        set_vartext(attr, long2str(value));

        /* append attribute name and "=" */
        app_estr(hp->tag_attr_str, " ");
        app_estr(hp->tag_attr_str, attr->name);
        app_estr(hp->tag_attr_str, "=");

        /* append quotes and value */
        if ((hp->quotemode == QMODE_KEEP) || (hp->quotemode == QMODE_DOUBLE))
            app_estrch(hp->tag_attr_str, '\"');
        else if (hp->quotemode == QMODE_SINGLE)
            app_estrch(hp->tag_attr_str, '\'');
        app_estr(hp->tag_attr_str, long2str(value));    /* append value */
        if ((hp->quotemode == QMODE_KEEP) || (hp->quotemode == QMODE_DOUBLE))
            app_estrch(hp->tag_attr_str, '\"');
        else if (hp->quotemode == QMODE_SINGLE)
            app_estrch(hp->tag_attr_str, '\'');

    }
}
예제 #28
0
/*
 * set/define_dest_attribs, define_source_attribs
 *
 * set and define attributes for destiantion uri
 */
static VOID set_dest_attribs(HSCPRC * hp, STRPTR destpath, STRPTR destname)
{
    set_estr(fileattr_str, "<$define HSC.DOCUMENT.NAME:string/c=\"");
    if (destname)
        app_estr(fileattr_str, destname);
    app_estr(fileattr_str, "\">\n<$define HSC.DOCUMENT.PATH:string/c=\"");
    if (destname)
        app_estr(fileattr_str, destpath);
    app_estr(fileattr_str, "\">\n<$define HSC.DOCUMENT.URI:string/c=\"");
    if (destname)
        app_estr(fileattr_str, destpath);
    if (destname)
        app_estr(fileattr_str, destname);
    app_estr(fileattr_str, "\">\n");
}
예제 #29
0
/*
 * conv_uri2path
 *
 * convert a uri to a path for local (system-dependant)
 * file system
 */
VOID conv_uri2path(EXPSTR * dest, STRPTR uri)
{
    clr_estr(dest);

#ifdef AMIGA
    /* convert leading "../" to "/" */
    while (!strncmp(uri, PARENT_URI, strlen(PARENT_URI)))
    {
        app_estr(dest, PARENT_DIR);
        uri += strlen(PARENT_URI);
    }

    /* convert inside "../" to "//" */
    while (uri[0])
    {
        if (!strncmp(uri, PARENT_URI, strlen(PARENT_URI)))
        {
            app_estrch(dest, '/');
            uri += strlen(PARENT_URI);
        }
        else
        {
            app_estrch(dest, uri[0]);
            uri++;
        }
    }

#elif defined MSDOS
    /* convert all "/" to "\" */
    while (uri[0])
    {
        if (uri[0] == '/')
            app_estrch(dest, '\\');
        else
            app_estrch(dest, uri[0]);
        uri++;
    }

#elif defined UNIX
    set_estr(dest, uri);
#else
#error "system not supported: conv_2path"
#endif
}
예제 #30
0
/*
 * hsc_parse
 *
 * parse input chars with full hsc support
 *
 * params: inpf...input file
 *
 * result: TRUE, if no error
 */
BOOL hsc_parse(HSCPRC * hp)
{
    if (!hp->fatal)
    {
        STRPTR nxtwd = infgetw(hp->inpf);
        STRPTR cws = infgetcws(hp->inpf);       /* current WhtSpcs */

        /* add white spaces to buffer */
        if (cws)
        {
            app_estr(hp->whtspc, cws);
        }

        /* parse text */
        if (nxtwd)
        {
            if (!strcmp(nxtwd, "<"))
            {
                /* parse tag */
                hsc_parse_tag(hp);
            }
            else if (!strcmp(nxtwd, "&"))
            {
                /* parse entity */
                hsc_parse_amp(hp);
            }
            else
            {
                /* handle text */
                hsc_parse_text(hp);
            }
        }
        else
        {
#if 0                           /* TODO: remove, this is now done in hsc_parse_end() */
            /* output last white spaces at eof */
            hsc_output_text(hp, "", "");
#endif
        }
    }

    return (BOOL) (!hp->fatal);
}