hsc-0.934.orig/0040700000175000001440000000000010015376350012143 5ustar loryusershsc-0.934.orig/amiga/0040700000175000001440000000000007776512740013240 5ustar loryusershsc-0.934.orig/amiga/msgbrowser.c0100600000175000001440000001736607770472341015606 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * amiga/msgbrowser.c * * implements throwback functions for SAS/c message browser */ #ifndef AMIGA /* Avoid that anything is attempted to be compiled on none-Amiga systems. * A dummy symbol is declared to keep the linker from whining. */ char amiga_message_browser_dummy = 0; #else #include "hsc/global.h" #include "ugly/fname.h" #include #define DEBUG_MSGBROWSER 0 /* Name of SAS/c message browser's ARexx port */ #define SC_SCMSG "SC_SCMSG" /* Buffer that is hopefully big enough to take the result of sprintf() when * creating ARexx commands in it. C sucks. */ static STRARR arexx_command[2048]; /* Command used to invoke VSend if VBrowse is used */ static STRPTR vsend_command = arexx_command; /* Temporary file to where VBrowse messages should be directed */ static STRPTR vbrowse_filename = NULL; static FILE *vbrowse_file = NULL; /* Name of the "compilation unit" for SAS/c; this usually is the name * of the main (last) hsc source passed in the command line */ static STRPTR compilation_unit = NULL; 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); } BOOL init_msg_browser(HSCPRC * hp, STRPTR filename) { BOOL success = FALSE; if (!upstrcmp(msg_browser, "SCMSG")) { /* SAS message browser */ compilation_unit = strclone(filename); /* Start browser, if it is not already running */ if (1) { int return_code = 0; system("RX 'if ~show(p," SC_SCMSG ") then address command \"run <>nil: sc:c/scmsg hidden\""); return_code = system("WaitForPort " SC_SCMSG ""); if (return_code != 0) { D(fprintf(stderr, "could not start message browser.")); } } /* Clear all messages for this document */ sprintf(arexx_command, "DelComp \"%s\"", compilation_unit); send_arexx_command(hp, arexx_command); success = TRUE; } else if (!upstrcmp(msg_browser, "VBROWSE")) { /* VBrowse */ vbrowse_filename = tmpnamstr("t:vbrowse-"); if (vbrowse_filename != NULL) { vbrowse_file = fopen(vbrowse_filename, "w"); if (vbrowse_file != NULL) { size_t fill_counter = strlen(filename);; /* Write a title line */ fprintf(vbrowse_file, "---- %s ", filename); while (fill_counter < 77) { fputc('-', vbrowse_file); fill_counter += 1; } fputc('\n', vbrowse_file); /* Remember temporary filename in own buffer as the buffer * returned by tmpnamstr() is static and will be overwritten * next time it is called. */ vbrowse_filename = strclone(vbrowse_filename); success = TRUE; } } if (!success) { status_error("unable to open VBrowse redirection file"); } } return success; } VOID del_msg_browser(HSCPRC * hp) { if (!upstrcmp(msg_browser, "SCMSG")) { ufreestr(compilation_unit); } else if (!upstrcmp(msg_browser, "VBROWSE")) { /* Evaluate the command for VSend */ sprintf(arexx_command, "vsend <%s", vbrowse_filename); /* Close the temporary message file, pipe it into VSend and * remove it. */ fclose(vbrowse_file); system(vsend_command); #if 1 remove(vbrowse_filename); #endif ufreestr(vbrowse_filename); } } VOID send_msg_browser(HSCPRC * hp, HSCMSG_CLASS msg_class, HSCMSG_ID msg_id, STRPTR fname, ULONG x, ULONG y, STRPTR msg_text) { if (!upstrcmp(msg_browser, "SCMSG")) { STRPTR msg_class_str = "*unknown*"; /* Convert hsc-message class to ScMsg class */ switch (msg_class) { case MSG_NOTE: msg_class_str = "Note"; break; case MSG_STYLE: case MSG_PORT: case MSG_WARN: msg_class_str = "Warning"; break; default: msg_class_str = "Error"; break; } /* NewMsg "compunit" "file" line 0 "" 0 */ sprintf(arexx_command, "NewMsg \"%s\" \"%s\" %ld 0 \"\" 0 %s %lu %s", compilation_unit, fname, y, msg_class_str, msg_id, msg_text); send_arexx_command(hp, arexx_command); } else if (!upstrcmp(msg_browser, "VBROWSE")) { STRPTR msg_class_str = "*unknown*"; /* Convert hsc-message class to VBrowse class. Note that VBrowse * requires the class to be lower case. */ switch (msg_class) { case MSG_NOTE: case MSG_STYLE: case MSG_PORT: case MSG_WARN: msg_class_str = "warning"; break; default: msg_class_str = "error"; break; } /* Brutally append it to the VBrowse message file without any * error checking. */ if (vbrowse_file != NULL) { /* As hsc does not display the offending source line, write * an empty line instead */ fprintf(vbrowse_file, ">\n"); /* Write the line with all the error information */ fprintf(vbrowse_file, "%s %ld in line %ld of \"%s\": %s\n", msg_class_str, msg_id, y, fname, msg_text); } } } #endif /* AMIGA */ hsc-0.934.orig/docs/0040700000175000001440000000000010010442132013056 5ustar loryusershsc-0.934.orig/docs-source/0040700000175000001440000000000010010437435014366 5ustar loryusershsc-0.934.orig/docs-source/exmpl/0040700000175000001440000000000007776512740015535 5ustar loryusershsc-0.934.orig/docs-source/exmpl/anchor.hsc0100600000175000001440000000023007642675506017502 0ustar loryusersFor updates, take a look at the hsc-support-page at <(HSC.ANCHOR)>. hsc-0.934.orig/docs-source/exmpl/exec.hsc0100600000175000001440000000041007642675506017154 0ustar loryusers<$if COND=(HSC.SYSTEM="AMIGA")> <$exec COMMAND="list DIRS" TEMPORARY INCLUDE SOURCE PRE> <$elseif COND=(HSC.SYSTEM="UNIX")> <$exec COMMAND="ls -ld" TEMPORARY INCLUDE SOURCE PRE> <$else> <$message text="operating system not supported" class="warning"> hsc-0.934.orig/docs-source/exmpl/expression.hsc0100600000175000001440000000040107642675506020427 0ustar loryusers <$let name:string="hugo"> <$let here:string="here"> (name+" <$if (name="hugo")> This is hugo! <$else> Maybe it's sepp? AmigaOS version: <$insert text=(GetEnv "KickStart")> hsc-0.934.orig/docs-source/exmpl/macro_addr.hsc0100600000175000001440000000006007642675506020324 0ustar loryusers<$macro Hugo-Address> hugo@some.where hsc-0.934.orig/docs-source/exmpl/macro_cnt2nest.hsc0100600000175000001440000000022207642675506021152 0ustar loryusers<$macro hinz /close> hinz=( <$content> ) <$macro kunz /close> kunz=( <$content> ) ...some text... hsc-0.934.orig/docs-source/exmpl/macro_cntnest.hsc0100600000175000001440000000030707642675506021074 0ustar loryusers<$macro sepp /close hugo:string> sepp : hugo=<(hugo)> <$content> sepp : hugo=<(hugo)> <$define hugo:string="content's hugo"> content: hugo=<(hugo)> hsc-0.934.orig/docs-source/exmpl/macro_file.hsc0100600000175000001440000000006007642675506020331 0ustar loryusers<$macro FILE /Close><$content> hsc-0.934.orig/docs-source/exmpl/macro_locale.hsc0100600000175000001440000000027307642675506020657 0ustar loryusers<$macro outer-sepp> now in outer sepp <* define inner-sepp *> <$macro inner-sepp> now in inner sepp <* use inner-sepp *> hsc-0.934.orig/docs-source/exmpl/macro_next.hsc0100600000175000001440000000014607642675506020375 0ustar loryusers<$macro Button.Next NxtRef:uri> Next hsc-0.934.orig/docs-source/exmpl/operators.hsc0100600000175000001440000000036407642675506020256 0ustar loryusers <$define name:string="hugo"> <$define here:string="here"> (name+" <$if (name="hugo")> This is hugo! <$else> Maybe it's sepp? hsc.prefs: <(GetEnv ("HSCPREFS"))> hsc-0.934.orig/docs-source/features/0040700000175000001440000000000010010115234016172 5ustar loryusershsc-0.934.orig/docs-source/features/assign.hsc0100600000175000001440000001732107701664211020201 0ustar loryusers When assigning new values to attributes, you can use string constants, like in html. Furthermore, you can also use expression to compute a new value depending on certain things. And there you can make the assignment of a value depend on the value of another attribute.

String Constants

As usual with html, you can use an assignment like <$source pre>hugo to set the attribute SRC to hugo.gif and ALT to hugo. The first assignment uses double quotes to denote the string boundaries, the second one uses single quotes. There is no difference in the functionality between these to kinds of quotes.

Again, like in html, one kind of quotes might show up inside a string, as long as it is quoted with other kind, for example:

<$source pre>"

Now ALT contains a double quote as value.

Numeric Constants

As you can see in the description of attribute types, distinguisches between string attributes and numeric attributes. Different from most other languages, it requires these to be quoted just like strings. The reason for this seemingly strange convention is that HTML allows attribute names to start with a number, so while other languages can just assume that anything starting with a digit is not a variable name, can not. If an operator requires a numeric argument, it will just take the ``string'' (i.e. quoted) argument and try to convert it to an integer.

Constants Without Quotes

If only certain characters are used, you even can omit the quotes at all. For example, <$source pre>hugo is also legal. As this can cause problems with (very) old browsers, it might result in , if is configured to. However, the following is not allowed according to the specifications of html: <$source pre>hugo

Because of the in the value of SRC, it would have been required to put it inside quotes. As this is not the case, will show up. Although most browsers can cope with this, and will use a white space or a as delimiter, this behavior is not standard.

Compute Expressions

When the assigned value starts with a , it denotes an expression to be computed before its result is used as new value. There are several operators you can use for that, and of course you also can refer to other attributes.

A very basic example would be <$source PRE>(name) If the attribute name has been set to sepp before, this will result in <$source PRE>sepp

The + is used to concatenate two values together.

For more details on this, see the chapter about .

Using Quotes Inside Quoted Strings

There are two kind of quotes you can use for string constants, namely single quotes (') and double quotes ("). You can use the one inside of the other just as a normal character:

<$source pre> a single (') quote a double (") quote

Note that this is no escape mechanism, the other quote just is treated as a normal character. For the normal user, this should be all you want to know about quotes inside quotes. Freaky ones, read on.

Because of the limitations of html, it is not possible to use both kind of quotes in one value. However, in hsc you could use string concatenation to push both quotes into one value:

<$source pre><$define sepp:string=("a single (') quote"+' and a double quote (") together')>

The value of sepp then would be >>a single (') quote and a double quote (") together<<. Different to html, hsc doesn't mind about that internally. The trouble starts when you assign the value later on to an attribute of an HTML tag:

<$source pre>(sepp)

Now hsc can't use neither single nor double quotes to assign the value of sepp to ALT. To solve that problem, it uses double quotes to embed the value in and replaces all double quotes inside by its entity &quot;, thus resulting in:

<$source pre>a single (') quote and a double quote (") together

Note that several browsers are too stupid to display this correctly.

Conditional Assignments

This paragraph deals with a feature you probably do not want to use (and understand) before you understood how those macros work. You can skip this part for now and return later.

You can easily let an attribute obtain it's value from another attribute. For example, within a tag call you can use an assignment like
sepp=(hugo)
However, if hugo has not been defined and assigned a value before, this will result in an error message. Conditional assignments now only assign a value to the target attribute, if the source attribute has been set; in any case, the source attribute must have been defined before (using $macro or $define). Simply use a ?= instead of the = assignment operator:
sepp?=hugo
This becomes handy for such macros which are more or less only extensions of real HTML tags: <$source PRE> <$macro MY-BODY BackGround:uri>

The macro MY-BODY just inserts a BODY tag. But optionally it can also handle the attribute BackGround.

But there has not necessarily a BackGround attribute to be set when calling MY-BODY. If you do not specify any, there also will not be one in the call to BODY after the macro has been processed.

Two examples should point out this behavior: <$source PRE> will result in <$source PRE> but a <$source PRE> will lead to <$source PRE> thus in the second case also adding the attribute BackGround to the BODY-tag.

If MY-BODY would have been declared without conditional assignment, it could have looked something like: <$source PRE> <$macro MY-BODY BackGround:uri> If you would try to call it without a BackGround passed, this attribute would have been unset, and the attempt to copy the value of BackGround/MY-BODY to BackGround/BODY using BackGround=(BackGround) would result in

Complex Conditions

On the first sight, it might seem that there is only the simple condition if attribute is set.. possible. But no one prevents you from using code like this: <$source PRE> <$define TEXT:color> <$if COND=(awfully complex condition))> <$let TEXT='#123456'> This also works for : <$source PRE> <$define sepp:string> <$define hugo:string> <$if COND=(awfully complex condition)> <$let hugo="hugo-value"> <$let sepp?=hugo> and you can also use to compute the source attribute. For instance, the last line of the above example also could have been <$source PRE><$let sepp?=("hu"+"go")> hsc-0.934.orig/docs-source/features/checkuri.hsc0100600000175000001440000000154707701663550020522 0ustar loryusers

One of the most annoying thing within creating HTML pages is to find out if all your links work. Concepts superior to HTML and HTTP usually maintain a database, which is automatically updated if a document is moved or deleted. (And they already did that in they seventies.)

For local URIs (those which only refer to files), checks existence of documents in your HTML project. When you refer to a non-existing local URI within your source, will view .

This can not only be caused by documents which are referred to using A HREF=.., but also other resources being embedded or linked by means of for instance IMG or LINK.

For absolute URIs, no checks are performed.

hsc-0.934.orig/docs-source/features/css.hsc0100600000175000001440000000240507642675506017517 0ustar loryusers

Since V0.929, has had some limited support for CSS. Limited because it doesn't have a full stylesheet parser yet, which would allow syntax checks of STYLE sections. However, CSS specifications in STYLE attributes can be parsed, checked and merged already. The following features support CSS:

  • The tag allows to define a new style property and optionally a list of legal values therefor. Properties specified in STYLE attributes will be checked against this list.
  • The attributes added by the GETSIZE/S function are CSS by default if you use XHTML mode.
  • Multiple STYLE attributes in a single tag will be merged into one. This can simplify the writing of macros where you want to supply a few default styles and let the user pass in additional ones: <$source pre>

  • If the same CSS attribute was specified more than once for a single tag, will issue a warning and use the value encountered last.
<* vi: set ts=4 expandtab: *> hsc-0.934.orig/docs-source/features/exec.hsc0100600000175000001440000001771207701663703017652 0ustar loryusers

You can invoke shell-commands during processing of a hsc source. The output of the command can be assigned to an special attribute or immediately being included into the document. This can be useful to include data from external applications (like databases), prepared by scripts (eg. Rexx), which of course you have to write yourself.

This functionality is provided by the hsc tag $exec

Possible Attributes

COMMAND:string/required
Specifies command to be executed. This attribute is required
INCLUDE:bool
If this attribute occurs, the output the command sends to (or the filename specified with FILE) is included in the document.
ATTRIBUTE:string
Using this attribute, you can select an attribute you've created before using to store the data the command sends to .
FILE:string
Specifies filename where the command is expected to store the output. The filename is relative to the source-directory. If this attribute is not set, will assume the command to output to and will redirect the output to a temporary file. This attribute is only useful if you have also set at least one of INCLUDE or ATTRIBUTE
TEMPORARY:bool
This attribute has the same meaning as within . Note that it can be reasonable to specify it, even if you set a specific output-file, and not only for temporary-files created by .
REMOVE:enum("auto|on|off")="auto"
This attribute tells what to do with the output-file after all data have been read. If you set it to REMOVE="off", the file will be left untouched. If no one else is going to remove it, it will continue to exist until doomsday or the next head-crash.

If you didn't specify an output filename (using FILE), this can clutter your temporary-directory (usually "t:") with loads of files having strange names like "hsc0x321764.tmp".

To avoid this, you can set REMOVE="on", so the output-file will always be removed.

By default, REMOVE="auto" is set. This will remove the file, if TEMPORARY has been enabled, and - if INCLUDE has been activated, too - no messages showed up during including the file.

Note: Never trust freeware-programmers when they start removing your files. So never use $exec on important data without any backup, and always use REMOVE="off" if your data are not really completely temporary.

Additionally, you can use all attributes of $include that change the appearance of the included data, like PRE, SOURCE etc. - Of course, this only makes sense if the INCLUDE-attribute has been set.

You can set both INCLUDE and ATTRIBUTE with one call to $exec.

Examples

$exec COMMAND="dpaint"
Invokes Deluxe-Paint. Now you can paint whatever you like. When you quit the program, will continue to process it's source. Note that this is not a very useful example.
$exec COMMAND="list #?.hsc" TEMPORARY INCLUDE SOURCE PRE
List all hsc-sources in the current directory and include this list into the current document. The output of the list-command is redirected to a temporary file, which is removed afterwards.
$exec COMMAND="echo Hello! >echo.tmp" TEMPORARY INCLUDE FILE="echo.tmp"
List all hsc-sources in the current directory and include this list into the current document. The output of the list-command is obviously redirected to a file called echo.tmp, which tries to read because of the FILE-attribute.
$define output:string
$exec COMMAND="list #?.hsc" ATTRIBUTE="output"
List all *.hsc-files in current directory and assign output to the attribute output; no data are included into the current document.

A More Complex Example

If you want to create a portable hsc source to insert a listing of a directory, you could try something like this: <$include FILE="exmpl/exec.hsc" SOURCE PRE> And the data created by this code sequence would look like this: <$include FILE="exmpl/exec.hsc">

Computing Complex Data

<$define snc.rex:string="StripNastyChars.rexx"> <$define snc.hsc:string="StripNastyChars.hsc"> <$macro snc.rex><(snc.rex)> <$macro snc.hsc><(snc.hsc)>

As is only a simple preprocessor, but not a programming language, it can not do certain things. For example, there are no string functions. But you can use external commands to gain the same result.

The Rexx-script together with shows how to strip all but alpha numeric characters from a given string.

To better understand what , you can first try to call it from the command line. Set your working directory to , and type:
rx <(snc.rex)> bla:sülz:fasel
results in
blaslzfasel
If you tried this yourself, you maybe noticed that the Rexx-script does not output a linefeed at the end of line. This is done by avoiding to use
SAY stripped
to display the converted data. Instead, you will find a
call WriteCH(stdout, stripped)
This simply is because assigns the output of this script to a target attribute called clean-data by means of <$source pre> <$exec command=("rx StripNastyChars.rexx " + nasty-data) ATTRIBUTE=clean-data> Because of obvious reasons, the linefeed character created by SAY would be unwanted in the value of the target attribute. Therefor, the interesting part of the created HTML document will look like:
Converted "This#Text|Contains!Ñâ§ïÿ/Characters"
to        "ThisTextContainsCharacters".
It should be easy for you to put this functionality in a macro.

Problems

Technically speaking, redirects the output of you command by appending a " >filename" to the command-string. For example, if you called

<$source PRE> <$exec COMMAND="list #?.hsc" INCLUDE>

will invoke the command like

<$source PRE> list #?.hsc >hsc0x321764.tmp

with hsc0x321764.tmp chosen as temporary output file by . If you specify the FILE attribute, you tell where to expect the output. But now you are responsible to redirect it yourself. For example,

<$source PRE> <$exec COMMAND="list #?.hsc >list.tmp" INCLUDE FILE="list.tmp"> <$exec COMMAND="list #?.hsc TO list.tmp" INCLUDE FILE="list.tmp">

will both create an output in list.tmp, where will also look for it. But the next one will fail:

<$source PRE> <$exec COMMAND="list #?.hsc >list.tmp" FILE="tmp.list">

The reason is obvious: The command outputs to list.tmp, but tries to read tmp.list, which most likely will not exist.

Another problem will occur, if you redirect the output yourself within the command call, but do not specify the FILE-attribute: will try to redirect the output twice: For example,

<$source PRE> <$exec COMMAND="list #?.hsc >list.tmp" INCLUDE>

will try to invoke something like

<$source PRE> list #?.hsc >list.tmp >hsc0x321764.tmp

The behavior of this call is system dependent, but there's a general statement on this topic: it most likely won't work.

hsc-0.934.orig/docs-source/features/expressions.hsc0100600000175000001440000003252510010115234021261 0ustar loryusers

In addition to simple strings, you can use expressions to set the value of an attribute. Within expressions, you can refer to other attributes to obtain their value, and you can also use various operators.

General Syntax

Usually, expressions have to be enclosed in parentheses (``(...)'') and may appear after the of an assignment (see below for an exception!).

String constants must be enclosed inside any kind of quotes - different to values outside expressions, where the quotes can be omitted under certain circumstances. As a difference from most ``real'' programming languages, the same is true of numeric constants!

To refer to the value of another attribute, simply use its name, without any enclosing quotes. The source attribute must exist, either defined via or by being part of a macro declaration.

Furthermore, it must have been assigned a value, for example using , or by setting it within a macro call. Attributes defined without a default value or not being set within a macro call do not contain any data and therefore will have to be updated using before using them.

Example:
<$source PRE> <$define image:string="hugo.gif"> image

will be converted to

<$source PRE>image

Operators

Unary Operators

not expression
Negate (boolean) expression
set attribute
True, if attribute has been set (read: passed a value) within macro call.
defined attribute
True, if attribute was defined with $macro or $define
Exists(local uri)
True, if document at local URI exists (bool). This can also be specified as a .
Exists("index.html"), Exists(":image/next.gif")
fExists(filename)
True, if a file exists (bool). If you do not specify a full filename (including a device name), it will be relative to the source root directory.
fExists("sepp:hugo/resi.hsc"), fExists("///child.txt"), fExists("include/global.hsc")
chr(number)
Yields the character whose ASCII code is number. If number is greater than 255, it will be taken modulo 256. An empty value, zero or a non-numeric value yields an empty string.
ord(character)
Yields the numeric ASCII code of character. If the expression passed to ord() is a string of more than one character, all but the first are ignored. An empty string yields zero.
GetEnv(environment-variable)
Get value of an environment variable.
GetEnv("Workbench")
GetFileSize(local uri)
Get size of a specific document. You can use the attribute HSC.Format.FileSize to change the appearance of the result.
GetFileSize("../../download/hugo.lha"), GetFileSize(":nudes/resi.jpg")
GetGMTime()
Get current Greenwich Mean time. You can use the attribute HSC.Format.Time to change the appearance of the result.
GetTime()
Get current local time. You can use the attribute HSC.Format.Time to change the appearance of the result.
GetFileDate()
Get the modification time of a file You can use the attribute HSC.Format.Time to change the appearance of the result.
To show the time of the last change to a page, this is often a more logical choice than GetTime(), especially if you include a lot of macros and use only a few in a certain document.
Last change: (GetFileDate(hsc.source.file))
basename
Returns the part of a string before the last period. If the name has no extension, returns the entire input string.
extension
Returns the extension of a filename, i.e. the part after the last period, or the empty string if there is no extension.
urikind
Returns the kind or URI for its argument as a three-character string:
  • abs: Absolute URI, i.e. relative to your project root (starts in ':')
  • ext: External URI, not on your server.
  • rel: Relative URI
  • rsv: Server-relative URI
Unfortunately, these are sort of internal terms that are not quite compatible with what the docs on project-relative URIs say, but you can easily find out of what kind an URI is using the expression (urikind (myuri)).

Binary Operators

Integer arithmetics

These operators are fairly simple. Division by zero is caught, but no overflows or stuff like that. But as long as you don't do scientific maths in your HTML macros, you should be fine.
Empty strings count as 0, any text not consisting only of digits counts as 1 (no warnings). This seems to make sense for auto-casting BOOL.
expression & expression
Addition. Weird operator, but using '+' for string concatenation seems to make sense as it is the far more frequent operation.
expression - expression
Subtraction. As - is also a legal character in attribute names, you must enclose it in whitespace, lest it be interpreted as part of the next or previous word.
expression * expression
Multiplication. Straightforward...
expression / expression
Division.
expression MOD expression
Modulo (the remainder of an integer division).
expression < expression
Less than.
expression > expression
Greater than.
expression <= expression
Less than or equal.
expression >= expression
Greateer than or equal.

The latter four operators were present in HSC V0.917 already, but their semantics have changed (that's why they were undocumented in the first place)! They used to compare strings, now they compare numbers -- but they still have a string equivalent each, see below.

String operators

expression = expression
string comparison (case insensitive)
expression == expression
string comparison (case sensitive)
expression + expression
string concatenation
little IN big
search for substring littel in big (case insensitive)
expression LT expression
Less than.
expression GT expression
Greater than.
expression LE expression
Less than or equal.
expression GE expression
Greater than or equal.

These comparison operators, added in V0.920 to do the job of what are now integer operators, all work case-insensitively. Maybe that's not such a smart choice after all and they should be case-sensitive while you get a unary upstr operator to upcase strings yourself. Then again, who needs case-sensitive comparisons in HTML? Perhaps I'll change them, so don't complain later ;)

Example:
<$source PRE> <$define name:string="hugo"> <$define here:string="here"> (name+" <$if cond=(name="hugo")> This is hugo! <$else> Maybe it's sepp? <$if cond=("SePp" IN "hugo,sepp and resi")> Sepp is among them. AmigaOS version: <(GetEnv ("KickStart"))>

will be converted to

IMG SRC="hugo.png" ALT="hugo was here"
This is hugo!
Sepp is among them.
AmigaOS version: 40.70 <* 2b compiled on Linux... *>

At least on my machine.

Boolean Expressions

If you pass an expression to a boolean attribute, the expression is evaluated as before. If the expression returned an empty string, the boolean attribute is interpreted as false. This will cause the attribute to be removed from the tag/macro-call.

Any none-empty string will set the attribute to true, resulting in a value equal to the name of attribute. (In HTML, writing ISMAP is short for ISMAP="ISMAP", while in XHTML the latter has to be, and automatically is, spelled out.)

Example: <$source PRE>nufin

will be converted to

<$source PRE>nufin

if name has been set to "hugo.gif", or to

<$source PRE>nufin

if name has been set to "map.gif". Note that only the second call enables the boolean attribute ISMAP, while it gets stripped for the first call.

The following operators yield a boolean (TRUE or FALSE) result and/or can be used to manipulate boolean values.

expression1 AND expression2
TRUE if both expression1 and expression2 are TRUE.
expression1 OR expression2
TRUE if expression1 or expression2 or both are TRUE.
expression1 XOR expression2
TRUE if either expression1 or expression2, but not both, are TRUE.

Priorities

Important: Different to most programming languages, does not support priorities for different operators. Therefor, expressions are simply processed sequentially (Programmer's lazyness rules).

But you can use nested brackets within complex expressions.

Symbolic References

Starting with V0.926, HSC can also handle a special kind of expressions called symbolic references (in PERL-speak), which are a bit of an exception to the above syntax. A symbolic reference is an expression whose value will be taken as the name of a variable. The following macro employs this mechanism: <$source pre> <$macro NAMES SELECT:num> <$define NAME1:string="Hugo"> <$define NAME2:string="Resi"> This is <( {"NAME" + SELECT} )>

NAMES SELECT=1 yields ``This is Hugo'', while NAMES SELECT=2 yields ``This is Resi''.

A symbolic reference is an expression enclosed in ``curly braces'' (``{...}''). HSC takes its value as the name of an attribute, and the value of this attribute is the value of the entire expression. The above just concatenates the string "NAME" and the ``selector'' number and returns the value of the appropriate variable. This may not seem very useful, but for things like emulating arrays it can come in quite handy.

One major difference between a symbolic reference and a normal expression is that the former may be used on the left hand side of an expression, it yields a so-called lvalue. So you can not only read an attribute whose name is determined at compilation time, but also write to it:

<$source pre> <$let {"foo" + "bar"}='1'>

is the same as:

<$source pre> <$let foobar='1'>
<* vi: set ts=4 expandtab: *> hsc-0.934.orig/docs-source/features/getsize.hsc0100600000175000001440000001333307701663664020401 0ustar loryusers

Specifying the desired size of an image in its IMG tag can speed up the browser's layout because the browser doesn't have to wait for the image to be transfered or needs to re-layout the page after the transfer. can either add WIDTH and HEIGHT attributes to the tag or use Cascading Stylesheet specifications to add the size information.

Usage

As you usually don't know the exact size of your images, let your stupid computer handle this dull task by enabling the switch when invoking . This tells to analyse the image the attribute SRC refers to, and either append the attributes WIDTH and HEIGHT with the dimensions obtained from the image data, oder add the properties width: and height: to a STYLE attribute, which will be created if it didn't exist yet.

If you have already set these attributes yourself, will only validate the values, and warn about mismatches.

Example

Take a look at this nice picture of some nice guy:

Picture of some nice guy

This can usually be included in a document using something like <$source PRE>Picture of some nice guy but if a document called niceguy.hsc containing such a tag is converted using

hsc niceguy.hsc TO niceguy.html GETSIZE
the IMG-tag seen above will be extended to <$source PRE>Picture of some nice guy in the HTML object. If you do not like the double quotes assigned to the size values, use the CLI-option to change this behavior.

The use of STYLE attributes is currently tied to the XHTML mode, i.e. XHTML output will use CSS while traditional HTML uses the WIDTH and HEIGHT attributes. The above example would look like this after running it through with XHTML enabled: <$source PRE>Picture of some nice guy

Supported Image Formats

In the recent years several formats to store image data have been established — mostly because none of these was really useful. Only a few of them are supported by . However, these should be enough for w3-authoring.

gif — Graphics Interchange Format

In the early times of w3, this was the only format supported by most browsers. It features only indexed-color (16 or 256 colors) and an ugly looking progressive display option. It became very popular in a negative sense because of it's compression algorithm and the associated copyright.

Bye the way, did you know that "The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark property of CompuServe Incorporated."? So now you do; if it makes them happy...

jfif/jpeg

Essentially, this format does a good job as an idiot indicator. This already starts with the name: jfif is short for JPEG File Interchange Format (because it uses jpeg compression for image data). Nevertheless jfif-pictures will have a file extension set to .jpg or .jpeg.

The main feature about jpeg compression is that it is lossy, which means that the output image is not identical to the input image. Documents about software using jpeg compression usually claim that you can obtain good compression levels with no visible change. As long as you do not start to rotate or apply other complex image processing operations on pictures, this might even be true. Otherwise, an ugly grid will appear soon.

Most important, jfif is commonly used to encode images of more or less undressed people. To store as many such pictures as possible in as little space as possible, the compression rate is usually set to a high value. This makes these people look as if they suffered from leprosy, or just a drawing by Egon Schiele.

Furthermore many people outside English speaking countries pronounce jpeg (jay-peg) as GPEG (gee-peg), even if they are normally capable of a proper English pronunciation.

PNG — Portable Network Graphics

The PNG Specification (<(HSC.Anchor)>) claims this format to be
...an extensible file format for the lossless, portable, well-compressed storage of raster images. PNG provides a patent-free replacement for the GIF format and can also replace many common uses of TIFF format. Indexed-color, grayscale, and truecolor images are supported, plus an optional alpha channel. Sample depths range from 1 to 16 bits [and] it is fully streamable with a progressive display option.

Above all, PNG supports most obvious things several other formats failed to include. There is nothing really remarkable about it, but today one has to be glad even about this. So it can be said that PNG is one of the few positive things that happened in the last ten years.

But even despite there being free source code available to read PNG-images, and the word Network is part of it's name (to conform to the hype), it was only supported by very few applications and w3-browsers for a long time. This slowly changes, so maybe you will want to give it a try.

Bye the way, has always supported it — actually it was the first working image format because it took some releases to end up with a bugfree scanner for gif...

hsc-0.934.orig/docs-source/features/if.hsc0100600000175000001440000000713207642675506017327 0ustar loryusers

General Syntax

Conditionals looks like that:
<$if COND=expression>

  code to be processed if condition matches

<$elseif COND=expression>

  (optional) code to be processed if alternative condition matches;
     this can occur multiple times

<$else>

  (optional) code to be processed if none of the previous conditions matched

</$if>

Both $if and $elseif require a boolean attribute COND; false is represented by an empty string, true by any non-empty string. Normally, you will like to set COND using expressions.

Some Simple Examples

Now let's see how this works in practice: <$SOURCE PRE> <$if COND=(NAME="sepp")> You must be sepp!

This one inserts the text "You must be sepp!", if the attribute NAME has the value "sepp". Note that the "="-operator performs a case-insensitive string-comparison, so setting NAME="SEPP" would lead to the same result.

Now let's extend this: <$SOURCE PRE> <$if COND=(NAME="sepp")> You must be sepp! <$else> I don't know you.

Setting NAME="sepp" will create the same text as above. Any other value for NAME will insert "I don't know you.".

Nesting Conditionals

Nesting them is also possible, of course:

<$SOURCE PRE> <$if COND=(NAME="sepp")> You must be sepp! <$if COND=(HOME="austria")> Hollareiduliö! An Austrian! <$else> <(HOME)>? Never been there. <$else> A strange guy from a strange place.

Conditionals And Macros

You should not compare 's $if with the primitive and clumsy #if of the C-preprocessor. The main difference is that you can use $if inside macros and that expressions are recalculated for every new call of the macro.

<$SOURCE PRE> <$macro TRY-A HREF:uri/r TITLE:string/r> <$if COND=(Exists(HREF))> <(TITLE)> <* insert link to HREF *> <$else> <(TITLE)> <* insert plain title *>

This macro inserts a link to an URI specified with HREF, using TITLE as link text; but only, if the destination (local) URI can be accessed. If the required document is not available, only the plain text without a link will be inserted.

The "/r" behind the declaration of the macro-attributes is short for "/required" and means that the macro needs both of these attributes to be set during the macro-call.

For example, you can utilize this macro using

<$SOURCE PRE> You should read the document about recent if there are any.

This leads to the text

    You should read the document about recent bugfixes if there are any.

with a anchor around the term "bugfixes" if the document "../bugfixes.html" exists.

hsc-0.934.orig/docs-source/features/prefs.hsc0100600000175000001440000002533207701670650020041 0ustar loryusers

Everything knows about HTML, it retrieves from a file named at startup. This file contains information about all tags, entities and icon entites. Additionally, some special attributes are set up there also.

The main advantage of this concept is that it's rather easy to add new syntax elements. For this purpose the tags , , and can be used.

Default Preferences

It is a serious problem about HTML that no one can give you competent answer to the question Now which tags are part of HTML?. On the one hand, there is w3c, which you meanwhile can ignore, on the other hand, there are the developers of popular browsers, which implement whatever they just like.

The coming with this distribution should support most elements needed for everyday use. With the V0.923 release, the prefs have been updated to HTML 4.01; since V0.925 there has also been support for automatic distinction between classic HTML and XHTML. If you run in XHTML mode, some obsolete attributes will not be known any more, and new ones added.

Searching For The Preferences

If you do not explicitly specify certain preferences by means of the commandline option , will look in several places when trying to open :
  • the current directory
  • $HOME/lib
  • the directory specified in the environment variable
    • AmigaOS: the directory PROGDIR:, which is automatically assigned to the same directory where the binary resides when is invoked
    • Unixoid: /usr/lib and /usr/local/lib

If it is unable to find anywhere, it will abort with an error message.

If you want to find out where has read from, you can use STATUS=VERBOSE when invoking . This will display the preferences used.

Special Tags To Modify Syntax Definition

<$macro SPCTAG NAME:string/r TITLE:string/r>

<(NAME)>: <(title)>

All the tags below should be used within only.

This tag defines a new entity. The (required) attribute NAME declares the name of the entity, RPLC the character that should be replaced by this entity if found in the hsc-source and NUM is the numeric representation of this entity. NUM may be in the range 128-65535, allowing for any Unicode (UCS-2 to be exact) character to be assigned a corresponding entity. Definitions in the range 128-255 are done in the prefs-file to allow users with character sets other than ISO-8859-1 (Latin-1) to change the replacement characters; some other characters such as mathematical symbols or typographical entities are predefined internally by . They reside at fixed positions in the Unicode charset and are unlikely to ever change.

Example: $defent NAME="uuml" RPLC="ü" NUM="252"

The ENTITYSTYLE commandline option affects the way will render entities in the resulting HTML file. Setting the PREFNUM attribute for an entity will make it use the numeric representation if ENTITYSTYLE=replace, no matter what representation was used in the source text.

Unlike previous versions, 0.931 and later allow redefinition of entities. In this case, symbolic and numeric representation must match the previous definition; only the PREFNUM flag and the RPLC character will be updated. This allows to change the default rendering/replacement of internally defined entities. Warning #92 will be issued and should be ignored if you really want to do this.

This tag defines a new icon-entity. The only (required) attribute is NAME which declares the name of the icon.

Example: $deficon NAME="mail"

This tag defines a new tag, and is used quite similar to , exept that a tag-definition requires no macro-text and end-tag to be followed.

Example: $deftag IMG SRC:uri/x/z/r ALT:string ALIGN:enum("top|bottom|middle") ISMAP:bool WIDTH:string HEIGHT:string

To fully understand the above line, you might also want to read the sections about attributes and options for tags and macros.

For those, who are not smart enough or simply to lazy, here are some simple examples, which should also work somehow, though some features of might not work:

<$source PRE> <$deftag BODY /CLOSE BGCOLOR:string> <$deftag IMG SRC:uri ALT:string ALIGN:string ISMAP:bool>

This tag lets you define a new CSS property and optionally a list of values that are allowed for it. If you omit the VAL attribute, any value will be permitted. Otherwise it should be a list in the same style as for enum parameters: words (which may include spaces) separated by vertical bars.

<$source pre> <$defstyle name="text-indent"> <$defstyle name="text-align" val="left|center|right|justify">

The value for text-indent is numeric, so the possible values can't be listed exhaustively and val is omitted. text-align on the other hand has a short list of four possible values.

This tag defines an attribute list shortcut to support your laziness when editing the prefs file. It allows to collect an arbitrary number of attribute declarations under a single name that you can use later in $deftag or $macro tags by putting the shortcut name in square brackets.

Example:
$varlist HVALIGN ALIGN:enum("left|center|right|justify|char") VALIGN:enum("top|middle|bottom|baseline")
$deftag THEAD /AUTOCLOSE /LAZY=(__attrs) /MBI="table" [HVALIGN]

This is the same as:

$deftag THEAD /AUTOCLOSE /LAZY=(__attrs) /MBI="table" ALIGN:enum("left|center|right|justify|char") VALIGN:enum("top|middle|bottom|baseline")

Why It Can Not Read DTDs

DTD is short for Document Type Definition. One of the early concept of HTML was that the first line of a document should contain a line that tells which DTD has been used to create this document. This could look like <$source PRE>

Browsers should read that line, obtain the DTD and parse the source according to it. The problem about DTDs: they are written in SGML. And the problem about SGML: It's awful. It's unreadable. It's a pure brain-wanking concept born by some wireheads probably never seriously thinking about using it themselves. Even when there is free code available to SGML-parse text.

As a result, only less browsers did support this because it was too easy to write a browser spitting on the SGML-trash, simply parsing the code tag-by-tag, developers decided to spend more time on making their product more user-friendly than computer-friendly (which is really understandable).

These browsers became even more popular when they supported tags certain people liked, but were not part of DTDs. As DTDs were published by w3c, and w3c did not like those tags, they did not made it into DTDs for a long time or even not at all (which is really understandable, too).

This did work for a certain degree until HTML-2.0. Several people (at least most of the serious w3-authoring people) did prefer to conform to w3c than use the funky-crazy-cool tags of some special browsers, and the funky-crazy-cool people did not care about DTDs or HTML-validators anyway.

However, after HTML-2.0, w3c fucked up. They proposed the infamous HTML-3.0 standard, which was never officially released, and tried to ignore things most browsers did already have implemented (which not all of them were useless crap, I daresay.). After more than a year without any remarkable news from w3c, they finally canceled HTML-3.0, and instead came out with the pathetic HTML-0.32.

Nevertheless, many people were very happy about HTML-0.32, as it finally was a statement after that many things became clear. It became clear that you should not expect anything useful from w3c anymore. It became clear that the browser developers rule. It became clear that no one is going to provide useful DTDs in future, as browser developers are too lazy and incompetent to do so. It became clear that anarchy has broken out for HTML-specifications.

<$macro even-sgml> even without reading three books about SGML and analysing 20 example sources So, as a conclusion, reasons not to use DTDs but an own format are:
  • It's more readable, and users can change it easier, .
  • It has been easier for me to implement, .
  • One does not depend on w3c. (Sad, that this is a reason.)
  • The format for contains some information, which makes is possible to for example evaluate image-sizes or strip tags with absolute URIs. This is realised with special attribute modifiers which have no equivalent in DTDs.

Quite unexpected, with HTML-4.0 this has changed for some extent, as the DTDs are quite readable and well documented. The general syntax of course still sucks, error handling is unbearable for normal users and so on. Although it will take them more than this to get back the trust they abused in the recent years, at least it is a little signal suggesting there are some small pieces of brain intact somewhere in this consortium.

Problems

There is also a disadvantage of this concept: reading every time on startup needs an awful lot of time. Usually, processing your main data takes shorter than reading the preferences. You can reduce this time, if you create your own with all tags and entities you don't need removed. But I recommend to avoid this because you might have to edit your preferences again with the next update of , if any new features have been added.

hsc-0.934.orig/docs-source/features/rplcent.hsc0100600000175000001440000000241707701662254020371 0ustar loryusers" +"Paradise is there
" +"You'll have all that you can eat
" +"Of milk & honey over there") QAUTHOR='Natalie Merchant, "San Andreas Fault"'>

Once upon a time, some guys invented ASCII. As these guys were Americans, they did not care (or probably not even know) about the rest of the world and said: 128 different characters are enough. So, nowadays you still can't copy a simple German umlaut from one computer system to another and be sure it will come out the same.

But, thank god, the guys who perpetrated html, after about 30 years of a computer world without working umlauts, provided a solution to this tricky problem: Instead of typing Ü, simply write &Uuml;. Congratulations, what a great idea! 7 bit rulez!

So as consequence of this prehistoric crap, can replace special characters in the hsc-source with its entities in the html-object. You just need to enable the RPLCENT switch.

Note:This only works for special characters that have been defined with in

hsc-0.934.orig/docs-source/features/spcattr.hsc0100600000175000001440000003671607701664617020420 0ustar loryusers

adds some special attributes, which can be quite useful to include special data or configure the parser.

<* insert heading for another special attribute *> <$macro SPCATTR NAME:string/r TITLE:string/r>

<(title)>

Attributes Containing Special Data

<**********************************************************> <* Hsc.Anchor *> <**********************************************************>

This attribute is defined internally during startup and is maintained by . It contains the URI of the last anchor referenced to.

Example: <$include FILE="exmpl/anchor.hsc" SOURCE PRE> will be converted to:
<$include FILE="exmpl/anchor.hsc">
<**********************************************************> <* Hsc.Content *> <**********************************************************>

This attribute is defined internally during startup and is maintained by . It contains the the text which will be inserted if a $content shows up, and is updated at every call to a container macro.

<**********************************************************> <* Hsc.Opts.XHTML *> <**********************************************************>

This BOOL attribute is defined and set to TRUE (i.e. "1") whenever HSC was called with the XHTML commandline switch. It allows macros to check the current mode and adapt their code, for example with respect to doctypes or attributes used. Test it using

$if COND=(defined Hsc.Opts.XHMTL)
... XHTML code ...
$else
... old-style HTML code ...
/$if

<**********************************************************> <* Hsc.Opts.Entitystyle *> <**********************************************************>

This is a STRING attribute, which is always defined and reflects the current entity rendering style, i.e. one of keep, replace, numeric, symbolic or utf-8. It is set by the ENTITYSTYLE and XHMTL options. The only use of this attribute will probably be in a macro for the automatic generation of an appropriate charset declaration.

<**********************************************************> <* Hsc.Document *> <**********************************************************>

These attributes are defined internally during startup and are read-only. They contain the filename, the directory, the whole relative URI of the HTML object to be created and the path from the current directory to the HTML object's destination, respectively.

For example, <$source PRE> hsc FROM people/hugo.hsc TO html:my_project/ will lead to
attribute value
Hsc.Document.Name "hugo.html"
Hsc.Document.Path "people/"
Hsc.Document.URI "people/hugo.html"
Hsc.DestPath html:my_project/people/
Note that Hsc.Document.Path does not contain the whole destination directory, but only the relative path. If you need the latter, use Hsc.DestPath. This attribute contains the return-code of the command invoked using . It is updated after every call of this hsc-tag. <**********************************************************> <* Hsc.LF *> <**********************************************************> This attribute contains a single linefeed-character (\n) and can be used to include linefeeds into attribute-values without whining about them. <**********************************************************> <* Hsc.Source... *> <**********************************************************>

These attributes are defined internally during startup and are read-only. They contain the filename, the directory and the full path and filename of the hsc-source you have specified when invoking .

For example, <$source PRE>hsc FROM people/hugo.hsc TO html:my_project/ will lead to
attribute value
Hsc.Source.Name "hugo.hsc"
Hsc.Source.Path "people/"
Hsc.Source.File "people/hugo.hsc"
<**********************************************************> <* Hsc.System *> <**********************************************************>

This attribute is defined internally during startup and is read-only. It contains a value depending on the operating system is running on.

<*
    OS      | Hsc.System
    --------+-----------
    AmigaOS | AMIGA
    RiscOS  | RISCOS
    Unixoid | UNIX
*>
OS Hsc.System
AmigaOS AMIGA
RiscOS RISCOS
BeOS BEOS
NextStep NEXTSTEP
Unixoid UNIX
This can be useful if you are executing a shell-command during conversion. See for an example how to include a listing of the current directory, working with more then only a specific OS. <**********************************************************> <* Hsc.TMP... *> <**********************************************************>

For several tasks, declares it's own temporary attributes for internal use. Most of them you can not use inside your own expressions. The only reason why I list them here is, that some of them might show up in messages.

For example, if you are using the special tag <(...)> (insert expression), creates an attribute Hsc.TMP.insert.expression to assign the value of the expression you passed between the brackets. If this expression contains errors, you will achieve a message mentioning the attribute Hsc.TMP.insert.expression.

Attributes for configuration

<**********************************************************> <* Hsc.Color-Names *> <**********************************************************>

This attribute is defined in and can be altered to the user's needs. However, it's value is scanned only once (immediately after processing and later changes will not be recognised by .

For attributes of type COLOR, you can not only use the cryptic #rrggbb-style, but also use some predefined values. With this attribute you can declare which values should know about, each separated by a .

Example: <$source><$define Hsc.Color-Names:string/c="aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow">

This one contains all values recommended for HTML-0.32 and is in the that came with this distribution.

<**********************************************************> <* Hsc.Click-Here *> <**********************************************************>

This attribute is defined in and can be altered to the user's needs. However, it's value is only scanned once and later changes will not be recognised by .

Inside an anchor tag (A HREF="..."), the normal text is scanned for special keywords indicating a click here-syndrome. With this attribute you can declare these keywords, each separated by a . Example: <$source PRE><$define Hsc.Click-Here:string/c="click|here">

When processing German documents, probably this one would fit better:

<$source PRE><$define Hsc.Click-Here:string/c="klicken|hier"> <**********************************************************> <* Hsc.Format.filesize *> <**********************************************************> This attribute contains a template that descibes how the result of should be rendered. Conversion specifications:
    %b    is replaced by the filesize in bytes.
    %k    is replaced by the filesize in kilobytes.
    %m    is replaced by the filesize in megabytes.
    %g    is replaced by the filesize in gigabytes.
    %a    is replaced by the filesize, with a reasonable unit computed automatically
    %u    is replaced by the unit for %a
This attribute is defined internally during startup, and contains the value "%a%u", leading to results like "123K" or "12M". It can be changed by the user at any time. <**********************************************************> <* Hsc.Format.Time *> <**********************************************************> This attribute contains a template that describes how the result of and should be rendered. Conversion specifications (Techn. Note: These are the same as for ANSI-C's strftime()):
    %A    is replaced by the full weekday name.
    %a    is replaced by the abbreviated weekday name, where the abbreviation
           is the first three characters.
    %B    is replaced by the full month name.
    %b or %h
           is replaced by the abbreviated month name, where the abbreviation
           is the first three characters.
    %C    is equivalent to %a %b %e %H:%M:%S %Y
    %c    is equivalent to %m/%d/%y.
    %D    is replaced by the date in the format mm/dd/yy.
    %d    is replaced by the day of the month as a decimal number (01-31).
    %e    is replaced by the day of month as a decimal number (1-31); single
           digits are preceded by a blank.
    %H    is replaced by the hour (24-hour clock) as a decimal number
           (00-23).
    %I    is replaced by the hour (12-hour clock) as a decimal number
           (01-12).
    %j    is replaced by the day of the year as a decimal number (001-366).
    %k    is replaced by the hour (24-hour clock) as a decimal number (0-23);
           single digits are preceded by a blank.
    %l    is replaced by the hour (12-hour clock) as a decimal number (1-12);
           single digits are preceded by a blank.
    %M    is replaced by the minute as a decimal number (00-59).
    %m    is replaced by the month as a decimal number (01-12).
    %n    is replaced by a newline.
    %p    is replaced by either AM or PM as appropriate.
    %R    is equivalent to %H:%M
    %r    is equivalent to %I:%M:%S %p.
    %t    is replaced by a tab.
    %S    is replaced by the second as a decimal number (00-60).
    %s    is replaced by the number of seconds since the Epoch, UCT.
    %T or %X    
           is equivalent to %H:%M:%S.
    %U    is replaced by the week number of the year (Sunday as the first day
           of the week) as a decimal number (00-53).
    %W    is replaced by the week number of the year (Monday as the first day
           of the week) as a decimal number (00-53).
    %w    is replaced by the weekday (Sunday as the first day of the week) as
           a decimal number (0-6).
    %x    is equivalent to %m/%d/%y %H:%M:%S.
    %Y    is replaced by the year with century as a decimal number.
    %y    is replaced by the year without century as a decimal number
           (00-99).
    %Z    is replaced by the time zone name.
    %%    is replaced by %.
This attribute is defined internally during startup, and contains the value %d-%b-%Y, %H:%M, leading to results like "<(GetTime())>".
hsc-0.934.orig/docs-source/features/spctags.hsc0100600000175000001440000003402507701664204020363 0ustar loryusers" +"Don't panic, it's not really worth your while") QAUTHOR='Blur, "Bang"'>

adds several special tags to process macros, handle conditionals, include files and lots of other things.

List Of Special Tags

<$macro SPCTAG NAME:string/r TITLE:string/r TAGNAME:string>
<$if COND=(not set TagName)><$let TagName=("$"+Name)>

<<(TagName)>> - <(title)>

<$macro POSSATTR /CLOSE>

Possible attributes:

<$content>
<* attribute definition title/data *> <$macro DTA>
<$macro /DTA>

One of the basic concepts of every computer language is that the user should be able to add comments. The machine will ignore them, but they usually help the programmer to understand his intention when looking at his source code later.

As yet another proof of the incompetence of the HTML creators, there is no reasonable way to add comments to your source code. Early versions of HTML did not offer any possibility to do that at all. Later ones support comments comparable to sgml. But as the way sgml handles comments is so messy and weird, nearly no one knows how they are really supposed to work (including myself and - more remarkable - most developers of w3-browsers).

In general, there is no way to use sgml-comments so they will work with all browsers. Many browsers are unable to find out when a comment ends, independent of whether you did it right or wrong.

Furthermore, such comments also waste bandwidth, as usually the reader will not see them (except he views the document source). And internal notes of w3-authors are usually not interesting for the public...

It is really remarkable that they managed to fuck up such a simple and usually strait forward concept like comments; even most assembler languages are smarter with this.

Anyway, with you can insert a comment like

<$source PRE><* This is a <* nested *> hsc-comment *>

As you can see, such comments can also be nested - yes, this is a documented behaviour.

And you can comment out sections of HTML source without any problems for the browser. This simply is possible because comments in the hsc-source are not written to the HTML object. So they also will not waste bandwidth.

Of course, if you need the standard comments, you can still use <$source PRE> as usual. But think twice before doing so. The tag $content can be only used inside a container macro and inserts the content the user specified inside the start and end tag for the macro. Conditionals are used to decide whether some part of the text should be processed or not. As there is a lot to tell about them, there exists a whole chapter dealing with conditionals. If your source should not only be updated if an included file has been modified, you can use the tag $depend to add an additional dependency which will be noted in the project data. ON:string URI to depend on (relative to destination directory) FILE:bool If this attribute is set, ON is no more interpreted as an URI, but as a local filename relative to the source directory. <$source PRE> <$depend ON="work:dings.dat" FILE> <$exec COMMAND="convdings FROM work:dings.dat" INCLUDE TEMPORARY>

In this example, dings.dat contains some data maintained by an external application. A script called convdings converts dings.dat to legal HTML data end send them to , which are inserted into the current document.

Obviously, dings.dat is not maintained or included by hsc, so the current document does not depend on it. But by specifying the above $depend, the current source will be updated if dings.dat has been modified. Text files can be included using $include. FILE:string/required This specifies the input file to be included SOURCE:bool by default, include files are interpreted as normal *.hsc files. Therefor, they may defines macros or contain HTML tags to render the text. But if you for example want to include an excerpt of a source code, it is handy if a less-than character (<) is not interpreted as an escape character, but converted to an entity.
This attribute enables such a conversion for less than, greater than and ampersand (&). PRE:bool The included data will be enclosed inside a PRE ... /PRE, and the whole section will be rendered as pre-formatted. TEMPORARY:bool Normally, keeps track of all files included and stores the names in the project file. Later, they can be used by to find out dependencies.
But if a file that is to be removed after the conversion ends up in the dependency list of your , it can cause trouble for . If the attribute is enabled, the input file will not be added to the dependency list.
You should consider to enable this attribute, if invoking returns something like
make: *** No rule to make target `hsc0x395bf7e0001.tmp', needed by `/html/hugo.html'. <* " INDENT:num TABSIZE:num=\"4\" " *>
$include FILE="macro.hsc"
This can be used to include some macro definitions
$include FILE="hugo.mod" SOURCE PRE
This is reasonable to include a source code that has been written using some programming language like Oberon, Pascal or E.
<* You can insert several stuff using the tag
$insert what [options]

Insert Current Date And Time

You can insert the current date and time simply by $insert TIME using a default format.

Optionally, you can pass a format-string, that discribes the time. As just calls the ANSI-C function strftime() to perform that task, you can use the same format specifications.

$insert TIME FORMAT="%b %d %y" inserts current date with the strange ANSI-C __TIME__-format.

Insert text

As an required argument, you must give a string that contains the text. $insert TEXT="hugo was here!" inserts the text "hugo was here". Of course, this does not make much sense.$insert TEXT="..." is suggested to be used with attribute values. $insert TEXT=(href) inserts the value of the macro-attribute href. *> You can create an attribute and pass a value to it via
$define attribute-declaration

If you define an attribute using $define inside a macro, it is of local existence only and is removed after processing the macro. You can suppress this with the attribute modifier /GLOBAL: in this case, the attribute exists until the end of conversion.

You can use the modifier /CONST to make the attribute read-only. That means it can not be updated with $let.

For an example, see $let. The tag $let can be used to update an attribute with a new value. It has its own syntax and expects the name of the attribute and after an equal sign the new value, for instance: <$source PRE> <$define hugo:string="hugo"> <* create hugo and set to "hugo" *> <$let hugo=(hugo+" ist doof.")> <* update it to "hugo ist doof." *> If you do not specify a value, the attribute will be unset (but still remains defined): <$source PRE> <$let hugo> <* unset hugo *> You can also use for updating: <$source PRE> <$let hugo?=sepp> <* if sepp has any value, copy it to hugo *> Macros can be used to define your own short-cuts and templates. As there is a lot to tell about this feature, there exists a whole chapter dealing with macros.

During conversion, messages might show up. But not only creates messages, also the user is able to do so using $message. Messages created by means of this tag will always show up as , but the user can set text and class of it.

For instance this can be useful, if he wants to perform some plausibility checks of macro arguments, or for debugging purpose (still alive messages).

TEXT:string/required Specifies message text CLASS:enum("note|warning|error|fatal")='note' Specifies message class <$source PRE> <$message TEXT="shit happens..." CLASS="fatal"> <$message TEXT="something's wrong" CLASS="warning"> TYPE:enum("both|prev|succ|none")="both" This specifies which white space at the current location should be removed.
Prev will remove all white spaces, which have occured between the previous word and the < of this tag, succ will skip all blanks between the > and the next text or visible tag.
Both will act like if both prev and succ would have been specified, and none has no effect on your data.
<$source PRE> prev <$stripws type=both> succ prev <$stripws type=prev> succ prev <$stripws type=succ> succ prev <$stripws type=none> succ results in
prevsucc
prev   succ
prev  succ
prev     succ
Note that the word prev is succeeded by two blanks, whereas the word succ is preceded by three spaces. FILE:string/required Name of file where to write output. If the file already exists, it will be overwritten without any warning. DATA:string/required Data to store in the file APPEND:bool If the output file already exists, the new data will be appended, leaving the old contents intact. The tag (expression) is used to insert data of attributes and expressions.
<$source PRE> <$define hugo:string="hugo"> <* create hugo and set it to "hugo" *> <(hugo+" ist doof.")> <* insert text "hugo ist doof." *> If you created some perverted HTML code or use features can't handle (which is theoretically impossible), you can keep from parsing this section by surrounding it with | ... |. Of course, this is a dirty hide-out and should be used only for special cases. <$source PRE><|some &<> bull >> shit|> This can be useful when you want to use other HTML extensions together with .
hsc-0.934.orig/docs-source/features/strip.hsc0100600000175000001440000000527507701663360020067 0ustar loryusers" +"She thinks she's Brenda Star
" +"Her nose job is real atomic
" +"All she needs is an old knife scar") QAUTHOR='Blondie, "Rip Her to Shreds"'>

SGML Comments

Usually there should be no need to use sgml-comments, so why not remove them at all? You can perform this by enabling the switch when invoking .

Because of the numerous problems sgml-comments cause, you better use hsc-comments anyway (see there also for a discussion of these problems).

Specific Tags

..can be passed to the option , separated by a . For example, to remove all physical styles, use STRIPTAG="B|I|U|TT" when invoking .

You can't strip tags, which have the tag modifier /SPECIAL set. But this only concerns the !-tag (use the above switch instead) and some of 's internal tags, which you should not strip anyway.

Tags With External References

These can be removed if you want to create a No-Net-version of your document. Use the switch for this task. Tags which are affected by this must have an URI-type attribute, which has the attribute modifier /STRIPEXT set within .

Currently, this affects only the tags A, IMG and LINK. This can be useful if you want to create a no-net-version of your documents.

Unneeded Linefeeds And White Spaces

These can be removed, if you heavy use them to structure your source, but don't want to waste bandwidth for them. You only need to enable the switch .

If now someone performs a View Source on your HTML object,it will be less readable for him, but browsers won't care and display it the same way. For example,

<$source PRE> This is a complete waste of space... will turn into <$source PRE> This is a complete waste of space... In particular, does:
  • replace tabs by a single blank
  • replace multiple blanks by a single one
  • replace multiple linefeeds by a single one
  • remove blanks preceeding a linefeed
  • remove blanks at beginning of line

Linefeeds and white spaces inside a tag call are also affected by this option. The tag PRE temporarily suppresses this option, until a /PRE occures.

hsc-0.934.orig/docs-source/features/syntax.hsc0100600000175000001440000000156507701662076020255 0ustar loryusers

When parsing your input, performs a syntax check on it. It tests for things like missing end-tags, illegal tag nesting or missing required tags.It also tests attributes for tags, e.g. allowed values for the ALIGN option of IMG.

However, the syntax check of is not very powerful compared to tools that only handle this task.

( Most errors handles are of the kind Well, now a have to program this if (..) to avoid an enforcer hit/segmentation fault, why not display an error message now...)

So if does not report any syntax errors, it doesn't mean that your source is 100% correct. For a more complete and strict test, take a look at tools mentioned at .

hsc-0.934.orig/docs-source/features/uris.hsc0100600000175000001440000001121107701663617017700 0ustar loryusers This chapter shortly describes how far the different kind of URIs are supported by , and also introduces a new kind.

Local URIs

Local URIs refer to objects which are located on the same machine as the document currently processed by . Internally they are simply remapped to filenames, which will be access by to for example validate links or to add attributes for image sizes.

Relative URIs

This kind of URI specifies a local object relative to the current directory (unless you have set a BASE HREF=.., which is not recommended; see below). If you want to refer to an object located in the parent directory, you can use ../ as prefix.

Project Relative URIs

Sometimes, when your project starts to become rather complex, you create subdirectories to structure the whole thing. As example, I prefer to create a directory image/, where all images for buttons and logos are placed.

Creating a link to an image from a document in the project root directory is no problem, it's URI simply is image/logo.gif. But if your current page is somewhere deeper in your project path, eg. people/hugo/hugo.html, you need to refer to the same image using ../../image/logo.gif. So you always have to know the directory level of your current page.

One solution would be to define a BASE HREF="path to main document". But then, all your links have to be relative to the directory you have specified with the HREF attribute. This is very annoying if you need to refer to files located in the same directory.

But, thanks to , here's the solution to this problem: if you do not define a BASE-URI, all relative links are processed as usual. Only if the URI starts with a , it refers to a file relative to the root directory of your project.

For example, an IMG SRC=":image/back.png" ALT="back" will always refer to the same image, regardless whether this tag is called from a file called welcome.hsc or people/hugo/hugo.hsc. The difference can only be recognised in the HTML objects: for the first case, an IMG SRC="image/back.png" ALT="back" will be created. For the second one, it will be IMG SRC="../../image/back.png" ALT="back".

For the HTML document, these URIs will be translated to relative URIs as described above.

Server Relative URIs

Different to the project relative URIs described above, server relative URIs are not a feature of , but of the standard URI schema. As they usually only cause problems (especially when reading documents locally with an off-line browser), you will not find any further information about them here. Although the idea behind them would not be so bad at all, you should try to avoid them within ridiculous linking model like the one of the w3, as this more or less only defines a filecopy operation across networks.

For those who really can not live without them, the CLI-option adds some basic support. With this option set to a valid directory, such URIs will be converted to relative URIs internally, and most features of will work with them as usual. However they will show up in the HTML document with their original value, with all problems remaining for other applications.

Absolute URIs

These are used to refer to objects which are located on different servers. Examples are http://www.playboy.com/ or ftp://wuarchive.wustl.edu/pub/aminet/. As acts only on objects which can be found on the local disk and does not establish any network connections, several features like like link validation or the CLI-option will not work on such URIs.

Fragment Identifers

For html, they point to a specific location in a document and can be created using A NAME=.. and are referenced liked A HREF="file.html#id". Normally, will only validate references within the current document. If you refer to an ID within another document, only the existence of the corresponding file at all will be validated.

This changes if you start to utilize the project management capabilities. On demand, can remember which IDs have been specified within a document, and will utilise these data to validate references to IDs, too.

hsc-0.934.orig/docs-source/image/0040700000175000001440000000000007776512740015472 5ustar loryusershsc-0.934.orig/docs-source/image/.xvpics/0040700000175000001440000000000007776512740017064 5ustar loryusershsc-0.934.orig/docs-source/image/.xvpics/hsc.png0100600000175000001440000000767507642675506020367 0ustar loryusersP7 332 #IMGINFO:81x73 Indexed (864 bytes) #END_OF_COMMENTS 66 60 255 I$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIIÛ¶¶¶I$IIÛ¶¶Û$I$IÛ¶Ú·$IH%Û¶Ú·$II$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIIÛ¶¶¶I$IIÛ¶¶Û$I$IÛ¶Ú·$IH%Û¶Ú·$II$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIIÛ¶¶¶I$IIÛ¶¶Û$I$IÛ¶Ú·$IH%Û¶Ú·$II$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII%Ú·¶H%IHÛ¶·Ú$I%HÛ¶·Ú$II$Û¶Û¶$IIH·Ú·¶$IÛ¶¶¶I$IIÛ¶¶Ú%H%IÛ¶Ú¶%HI%Û$$I%ÚÛ¶¶$III¶mÛ$III¶Û¶¶H%IIÚ·¶¶HI%IÚ·Û¶¶¶I$IIÛÛ¶$IIHÛ¶·¶H%IIÚ·Ú¶$IIIIH%Û¶Ú·$IHI·Ú¶·$IHIÛ¶Û¶¶¶I$IIIHI%‘J‘¶·H% DEÚ·lI)EHÛ¶·ºDI)DÛ¶»Ö$II)Ö»Û¶¶¶I$I$%I$ÛHd¨!(Û ¨D$I)EÚ·Ú¶$II)ÖÛ¶¶(EIIº×I$IIÛ¶Iìd$ $è¨Ì Û¶ ÌÈȨ¨d)Ú×¶(EI(۶׺$IEIº×º¶D)I$IIÛ¶èh¨ÈìÈÈÌ$׺¶ ìȨˆEÚ·ºÖ$I)IÖ»Ö¶$II)Ú×¶¶(EI$IIÛ¶èh@ìÈ(%„ˆÈì$Û¶@ÌȨ MEº×º¶$IIEÚ·º¶D)IIÖ»¶Ö(EI$IIÛ¶èh@ìÈm» ¨Ì„Û¶„ÌÈ$IIH׺·¶D)IIÚ·¶Ö(E)IÚ·Öº$IÛ¶¶¶I$$è¨dDìÈnH%$¨ÈIˆÈÈÛº·Ö$II(Û¶×¶(EIH»Ö·º$IEHÛ¶Û¶¶¶I$ÌÈèÌ@DìÈÈrD)I„ȈI„ÌȄ۶ֺ%HE)ÛÖ¶»$IHE»Öº·D)HI׺۶¶¶I$ÌÈèÌÈÈÌÈÈnHIIȨ ˆÈì„$ÛÖº¶%HIEÛº¶¶E(II׺¶Ö)D)IÛ¶Û¶¶¶I$ÌÈèh@ÌèÌÈnHn$ìÈD@¬èȨEÛ¶ºE(IEÛ¶ºÖ%H)I׺¶Ö%HI)Û¶I$IIÛ¶¨èh@ìÈÌmiˆèÌDÈÈÌÈ$ I)EÚ·ºÖ$II)Ö$%»DI(EÛ¶º×$II$IIÛ¶¨èdDìȨÈÌÈdÛ¬èÈÌ IH·Ú·¶H%IHI%IHÛ¶·Ö(II$IIÛ¶¨ÈD@ìˆ@D¨ÈÌÈÈhÛ$$ ˆ¨„dII»Ö¶ºE(IIEH»Ö·º$II$IIÛ¶@¬@ì ¬ÈèÌÈȨ$Û$I$ )HIÛ¶¶×(IIÖ»¶¶H%Û¶¶¶I$n¨Dè$ ìÈd $ IH»Ö·Û¶ºÖ%HI)EI(EM »D)IH׺۶¶¶I$I$DDjÚ%HII»Ö¶¶I$IIIIH%$Û$I%HÛ(EHIÛ¶Û¶¶¶I$I$%Û$m·¶HIIÛ$IIH·Ú·¶$mIIH%Û$I$IIIH%IIÚ·Û¶¶¶I$II$Û¶ImIÛ¶Ú%H%IÛ¶Ú¶%HI%Û¶Ú¶$I%mÛ$IIH%IH%IÛ¶I$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HI%)M)%HI)׺ֶ$Û¶·ºD)I$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HI).M*M%HE)Û¶Öº$Û¶·Ö(EI$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIM.M*M-IHII·Ú¶¶%$Û¶Ú·$II$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HI.I-N-)N-IIE)Ú·Ú¶IÛ¶¶Ö)DÛ¶¶¶I$IIÛ¶¶Ú%H%IÛ¶Ú¶%HI%Û¶Ú¶%HII·Ú)I.-M.I-N-II»Ö(EIÛ$IIDÛ¶Û¶¶¶I$IIÛ¶¶Ú%H%IÛ¶Ú¶%HI%Û¶Ú¶%HII·Ú)M*-M*M-N)M$%$IÛ$IH%Û¶Û¶¶¶I$IIÛ¶¶Ú%H%IÛ¶Ú¶%HI%Û¶Ú¶%HII·ÚI-I)*)M.M)N׺D)IDÛ¶Û¶¶¶I$IIÛ¶¶Ú%H%IÛ¶Ú¶%HI%Û¶Ú¶%HII·Ú¶%-J-M.$IÛ¶»D)DIÛ¶I$IIÛ¶¶¶IH%IÛH%HJÚ$I%IÚ·¶Ú%l&$.M-N)m׺¶×(E(IÛ¶¶Û$II$IIÛ¶¶¶IH%n$$%$I$%$%$mnmI-N)M.IÖ»¶¶DI)IÚ·¶Ö(EI$IIÛ¶¶¶IH%$%m’’H%$%$¶n‘’’H.M.IIº×¶¶(IEIÚ·¶ºD)I$IIÛ¶¶¶IHIImn’‘’’‘n$II$I%Hn‘’n‘’’m$M*M-IÖ»¶Ö$I)IÚ·Ö¶(EÛ¶¶¶I$IIÛ$m’m’’‘’n‘’‘’nlJln’‘’n‘’’‘nH%)-N)MÛ$I%HÛ¶·Ú$II$Û¶Û¶¶¶I$IIÛI’¶ÿÚ’’‘n‘’’‘n’‘’‘n’‘’’mm$(*M.M)NÛ$I$IÛ¶º×$IH%Û¶Û¶¶¶I$II$n‘’ÿÿÿÿ’m’‘’’m’’‘’m’’‘’mI%N-N-I.$Û$I%HÛ¶Û¶$II$ÛÚÛ¶¶¶I$II$%¶m¶ÿÿÿÿn‘’‘n’‘’’m’‘’’mm%JM.-N)M.»D)IDÛ¶»¶DI)H׺I$IIÛ¶¶¶$%¶m¶ÿÿÿÿn‘’‘n’‘’’m’‘’m%$%H$N-N)N--%‘%Û¶¶Ú%HI%Û¶Ú¶%HI$IIÛ¶¶m%µn’Úÿÿ’’‘’n‘’‘’’m’’‘$ÛI%N-M)H)EÛºÖ¶%HI)׺ֶ)DI$IIÛ¶¶H%¶n‘’’‘n‘’’‘n’‘’‘n’‘$%I$ÛÚI)EHIÛ¶¶»D)DIÛ¶¶Û$II$IIÛ¶¶H%¶n‘’‘n’‘’’m’‘’’m’’mm%HIÛ¶¶IHJH%IHÛ¶·Ú$I%HÛ¶·Ú$IÛ¶¶¶I$III‘’’m’’‘’m’’‘’n‘’‘’$ÚÛ¶¶$IIIÚ·¶¶I$IIÛ¶¶Ú%H%IÛ¶Ú¶%HI%Û¶Û¶¶¶I$II$%’‘’‘’n‘’’‘n‘’’‘n’l$Û¶·Ú$II$Û¶Û¶$IIH·Ú·¶$IIHÛ¶·¶H%IIÚ·Û¶¶¶I$II$%’‘’‘n’‘’’m’‘’’m’’HIÛ¶¶·H%HIÛ¶¶Û$I$IÛ¶Ú·$IH%Û¶Ú·$IHI·ÚÛ¶¶¶I$IImI’‘’n‘’‘’’m’’‘’m’IIÚ·¶Ú$I%IÚ·¶Ú$II%Ú·Ú¶$III¶Û¶¶%HIIÛ¶I$IIÛ¶¶¶I$n’‘’‘n’‘’’‘n‘’’m$Û$II%Ú·Ú¶$III¶Û¶¶$IIIÚ·¶¶H%IIÚ·¶Ú$II$IIÛ¶¶¶IH%$’’‘’n‘’’‘n‘’’IÛ¶H%IHÛ¶·Ú$I%HÛ¶Û¶$II$ÛÚ·¶$IIH·Ú·¶H%I$IIÛ¶¶¶IH%$%’‘’’m’‘’’m’mÛ¶H%IIÚ·¶Ú$I%IÚ·Ú¶%HI%ÛÚ¶¶%HII·Ú¶¶I$I$IIÛ¶¶¶IH%ImI’‘n’‘’‘nIH·Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIIÛ¶¶¶I$IIÛ¶¶Ú%HÛ¶¶¶I$IIÛ¶¶Ú%mIHJHIII$%HII·Ú¶·$IHIÛ¶¶·H%HIÛ¶¶Û$I$IÛ¶Ú·$IH%ÛÚÛ¶¶¶I$IIÛ¶¶Ú%Hn$II%HÛ¶·Ú$II$Û¶Û¶$IIH·Ú·¶$IIHÛ¶·¶H%IHÛ¶Û¶¶¶I$IIÛ¶¶Ú%H%II$$Û·¶H%IHÛ¶·Ú$I%HÛ¶·Ú$II$Û¶Û¶$IIH·Ú·¶$IIHÛ¶Û¶¶¶I$IIÛ¶¶Ú%H%IÛ¶Ú¶%HI%Û¶Ú¶%HII·Ú¶¶I$IIÛ¶¶·HI$IÛ¶¶Û$IH%Û¶Ú·$IHI·ÚI$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIIÛ¶¶¶I$IIÛ¶¶Û$I$IÛ¶Ú·$IH%Û¶Ú·$II$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIIÛ¶¶¶I$IIÛ¶¶Û$I$IÛ¶Ú·$IH%Û¶Ú·$II$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIIÛ¶¶¶I$IIÛ¶¶Û$I$IÛ¶Ú·$IH%Û¶Ú·$II$IIÛ¶¶¶IH%IÛ¶¶Ú%HI%Û¶Ú¶%HII·Ú¶¶%HIIÛ¶¶¶I$IIÛ¶¶Û$I$IÛ¶Ú·$IH%Û¶Ú·$Ihsc-0.934.orig/docs-source/image/austria.png0100600000175000001440000000013507642675506017650 0ustar loryusers‰PNG  IHDRÿ~ŽPLTEª ÿÿÿÜŸ‚QIDATxœc`Àþÿÿƒ‚±M³ éÑ4É@IEND®B`‚hsc-0.934.orig/docs-source/image/back.png0100600000175000001440000000020207642675506017073 0ustar loryusers‰PNG  IHDRFÖ—áý PLTE–––ÿÿÿŽVD4IDATxœcX…–†¢iæ³æŒQÉo„ºsr é¤e,g€åìÍQ`ÃP9œ\êò.‘ÐYK˾oþŽÅ¾8W±, ëã3Ȳ ö°M ,b÷Ð*C°]{ͬªïù&?/Â#¡ÉôZ4æ³-ùSšîÌ×*÷êpý‚”†KÙS¥J¹‹y<~H\®øÈ B fÈ`R¶g.nª,@·)0äž×ê=y· ÚÅB=FÝÏ^Œ ¼BWôê\”‹^÷‹r×êÃ]•[çOUnåpÛ­¨|a;í ”hë¨Tê'º’iVŒRL¾CY¾>!·‹r JÔÍž† ›RÂèAÅý¡/)¢™¼h% ÿGð&tDL~ÞúúÑZ¹)Ih¦9t΃ÙÇMÖõÏE¿¾á¾AæˆI¾sçàUÛãuêççÍ"I9"nÅæ·H(j6™#S…(¦žè’ߊ„¹­Aðrª_8œÉ£_ К%Òk=66K¼•¦ûºm4*ókÕÚ7›¦©=€KoO»ˆEHT¨¿æé†dÐ^;Ò£J“°¨Ü?‰Uê(jŸÙ1ûPEkMÓî³L„ÚrºS› |ÿú:ã=Ñ OÈ5MnÎ92ë—Õ U “0ãàyòm†|ØÌFäŠÇ=æU¤C·ú¬“¹Þs©þ…æü*î/ÊÀ°ˆý'‚µIEND®B`‚hsc-0.934.orig/docs-source/image/index.png0100600000175000001440000000023407642675506017307 0ustar loryusers‰PNG  IHDRFÖ—áý PLTE–––ÿÿÿŽVDNIDATxœcX…–†¢œB¢¡¡„…DCDE]‘…D]]]E‘…B]]BÑ„X1„\CÑ5ÍB5>ÃFâ<„*ÔÀ€žÚY=ÿ_¾ÎIEND®B`‚hsc-0.934.orig/docs-source/image/main.png0100600000175000001440000000026107642675506017124 0ustar loryusers‰PNG  IHDRFÖ—áý PLTE–––ÿÿÿŽVDcIDATxœ1 À@m®OáþÇöwàý'ŸI“Wf›HNdÁEeU®ªCÎY$ÈÀn°"¼"6»ul]‘ªÃ½Ñ^(ˆ c.Èë}z&æ¢ç]À“øó¡Š©ºMTæ EÐIIEND®B`‚hsc-0.934.orig/docs-source/image/next.png0100600000175000001440000000025707642675506017163 0ustar loryusers‰PNG  IHDRFÖ—áý PLTE–––ÿÿÿŽVDaIDATxœ± À Ý0@$~ð/á}X&M¦Œ$(råéÿ-˳2ä¶9«’6¥<¨–Q‚ª$p)Ð1·”ÔL¬Î”«Ö:æ± L½SÎw«'²‡‹ÿÚÔ•?UýiíÞIEND®B`‚hsc-0.934.orig/docs-source/image/niceguy.png0100600000175000001440000000052707642675506017650 0ustar loryusers‰PNG  IHDR@@§ãPLTEÊÊÊsû¾3 IDATxœÑ±NÃ0`C†Œ™‘y$füLL Hµ7ƼÏÀ à  YLŒ µÅ/ªƒSŽãîì !ÕÓ'ç|±ÿSX–:ÑÍ÷+½d@´u+¸U§F>]U}F_OZ L’št‚Ø0x¿gŒÔmÝ6„‘waúƒ “! p@ü´˘Ó9òq¿t.L'HÍo´ñµq¶už±µ˜1[“±Œ Œµ`ý¼ÈÀ¸ÉXã%wötÅ'ÆÇŸ®évìÃÎ6‚#À`·_/ ÐÉO)‰¥ñ9¨w¹<4ø-à0䥸B9®9¤”%UeªÈ_þC •ö^ :Ö¥%ˆÒ'‹³Ôx6¬ðºˆcqà¶¢ãÖ4S+Z7¼¿,SáHž­LÓšf $Cò}ý?nT¹‘N8X8d#IEND®B`‚hsc-0.934.orig/docs-source/image/nonext.png0100600000175000001440000000026107642675506017513 0ustar loryusers‰PNG  IHDRFÖ—áý PLTE–––ÿÿÿŽVDcIDATxœÏ± €0 DQ#Åx Dºô.<Ã@Ô\ˆ8â×O'[ŽÜ*[¤DöžªZfÕ&‡cõ¥˜êÒU¡÷œÐÃ,ê³Õíd׃bãVçTýºþÏ«äNÕÌOSs§ÌIEND®B`‚hsc-0.934.orig/docs-source/image/noprev.png0100600000175000001440000000026007642675506017510 0ustar loryusers‰PNG  IHDRFÖ—áý PLTE–––ÿÿÿŽVDbIDATxœ¹ À@ e:PA:ØË¨ c'®ÒJüœŒ'†]:*+mQ Ú{Ò2ž­6Yp(kb/+YºH·«OÑC5ønµ@Hìi¥…€Æ`%c+Ø3e_ëÿ|\©rõ¥OL×;rIEND®B`‚hsc-0.934.orig/docs-source/image/prev.png0100600000175000001440000000025607642675506017160 0ustar loryusers‰PNG  IHDRFÖ—áý PLTE–––ÿÿÿŽVD`IDATxœÏ» À0 P5 àÛÇ«÷µ—I“)ãÆà_‘+Ç É»¦ÊãKäLQ72(â@7 \xî[FZ 7ÒÞj”R ûDnð©Õ2o%ËpñßCUYó­V90B§ IEND®B`‚hsc-0.934.orig/docs-source/image/teutsch.png0100600000175000001440000000014407642675506017657 0ustar loryusers‰PNG  IHDRV_^ PLTEª ïºF±%ãIDATxœc` BA ;µ à£Ý Ÿ% \ôIEND®B`‚hsc-0.934.orig/docs-source/image/up.png0100600000175000001440000000022607642675506016625 0ustar loryusers‰PNG  IHDR ’g PLTE`pÀððð͈"HIDATxœ­Î± À DÑOÁÞ‡\8û° R”)Ì5¿¹WB{3®Ì Lð*´"ÀB€%j¢AIð5öǹ‡:[/6ÅTÖ†fIEND®B`‚hsc-0.934.orig/docs-source/inc/0040700000175000001440000000000007776671211015160 5ustar loryusershsc-0.934.orig/docs-source/inc/html.hsc0100600000175000001440000000014207642675506016622 0ustar loryusers<$macro html-only /CLOSE><$content> <$macro postscript-only /CLOSE><* empty *> hsc-0.934.orig/docs-source/inc/macro.hsc0100600000175000001440000001752707653325573016774 0ustar loryusers <* macro defs (short cuts) *> <$macro stdin>stdin <$macro stdout>stdout <$macro stderr>stderr <$macro dtd CAP:bool><$if cond=(CAP)>D<$else>dtd <$macro mb_address/CLOSE><$content> <$macro mdash>— <$macro ndash>– <$macro qq /CLOSE>``<$content>'' <$macro qqc /CLOSE>``<$content>'' <$macro bracket>bracket (() <$macro closing-bracket>bracket ()) <$macro hash>hash character (#) <$macro vbar>vertical bar (|) <$macro colon>colon (:) <$macro semicolon>semicolon (;) <$macro asterisk>asterisk (*) <$macro underscore>underscore (_) <$macro period>period (.) <$macro hyphen>hyphen (-) <$macro slash>slash (/) <$macro backslash>backslash (\) <$macro equal-sign>equal-sign (=) <$macro greater-than>greater-than (>) <$macro less-than>less-than (<) <$macro TG /CLOSE><<$content>> <$macro EXEC /CLOSE><$content> <$macro FILE /CLOSE><$content> <$macro hsc CAP:bool><$if cond=(CAP)>H<$else>hsc <$macro hscdepp LINK:bool CAP:bool><$if cond=(LINK)><$if cond=(CAP)>H<$else>hscdepp<$if cond=(LINK)> <$macro hscpaltrow LINK:bool CAP:bool><$if cond=(LINK)><$if cond=(CAP)>H<$else>hscpaltrow<$if cond=(LINK)> <$macro hscpitt LINK:bool CAP:bool><$if cond=(LINK)><$if cond=(CAP)>H<$else>hscpitt<$if cond=(LINK)> <$macro makefile>Makefile <$macro makefile.agi>Makefile.agi <$macro make>make <$macro UBQ>
<$content>
<$macro WebLint>WebLint <$macro Aminet FILE:string TEXT:string><$if COND=(not set TEXT)><$let TEXT=("aminet:"+FILE)><(text)> <$macro AminetReadMe FILE:string TEXT:string><$if COND=(not set TEXT)><$let TEXT=("aminet:"+FILE)><(text)> <$macro EMAIL address:string/required><* <(address)> *><(address)> <$macro hsc-support>hsc-support-w3-page <$macro riscos-support><(hsc.Anchor)> <$macro hsc.prefs>hsc.prefs <$macro ExampleNote>Example: <$macro TechNote>Technical note: <$macro NextStep>NeXTStep <$macro ln-msg id:num/required>message #<(id)> <$macro ln-bugs>Known Bugs, Problems And Limitations <$macro ln-define>$define <$macro ln-defent>$defent <$macro ln-deficon>$deficon <$macro ln-deftag>$deftag <$macro ln-defstyle>$defstyle <$macro ln-varlist>$varlist <$macro ln-content>$content <$macro ln-exec>$exec <$macro ln-include>$include <$macro ln-skip-verbatim>| .. | (skip verbatim data) <$macro ln-insert-expression>( .. ) (insert expression) <$macro ln-let>$let <$macro ln-macro>$macro <$macro ln-make> <$macro ln-makefile> <$macro ln-expression CAP:bool PLURAL:bool><$if cond=(cap)>E<$else>expression<$if cond=(plural)>s <$macro ln-related>Related Stuff <$macro ln-cond-assigns>Conditional Assignments <$macro ln-syntax>Syntax Definition <$macro ln-getenv>GetEnv() <$macro ln-getfilesize>GetFileSize() <$macro ln-getgmtime>GetGMTime() <$macro ln-gettime>GetTime() <$macro ln-existing-ports>Existing Ports <* features *> <$macro fe_prjuri>Project Relative URI <$macro fe_chkuri>Check Existence <* options *> <$macro op-compact>Compact <$macro op-extension>Extension <$macro op-from>From <$macro op-getsize>GetSize <$macro op-iconbase>IconBase <$macro op-pipein>PipeIn <$macro op-prjfile>PrjFile <$macro op-prefsfile>PrefsFile <$macro op-ignore>Ignore <$macro op-includedir>IncludeDir <$macro op-quotestyle>QuoteStyle <$macro op-rplcent>RplcEnt <$macro op-stripcomment>StripComment <$macro op-stripexternal>StripExternal <$macro op-striptags>StripTags <$macro op-serverdir>ServerDir <* environment variables *> <$macro env-home>HOME <$macro env-hscsalary>HSCSALARY <$macro env-hscpath>HSCPATH <* misc references *> <$macro jerk>jerk <$macro uri>URI <* create reference to grafflwerk-stuff *> <$macro grafflwerk href:string nolink:bool> <$stripws> <$if cond=(set href)> <$define name:string=("grafflwerk/"+href)> <$if cond=(nolink)> <(name)> <$else> <(name)> <$else> grafflwerk <$stripws> hsc-0.934.orig/docs-source/inc/ps.hsc0100600000175000001440000000014207642675506016300 0ustar loryusers<$macro html-only /CLOSE><* empty *> <$macro postscript-only /CLOSE><$content> hsc-0.934.orig/docs-source/inc/webpage.hsc0100600000175000001440000000651007776671211017272 0ustar loryusers<************************************** * WEBPAGE_NAVIGATION * * this is a local macro that is * * allowed to be used from inside of * * (see below) * * it inserts a navigation bar at * * current position * ***************************************> <$macro WEBPAGE_NAVIGATION /MBI="WEBPAGE"> <** main button **> <$if COND=(NOT SET NoMain)> Contents <$else> ---- <** insert "index" button **> <$if COND=(NOT SET NoIndex)> Index <$else> ----- <** copyright button **> <$if COND=(NOT SET NoCopy)> Copyright <$else> --------- <** insert "back" (up) button **> <$if COND=(SET Back)> Up <$else> -- <** insert "previous" button **> <$if COND=(SET Prev)> Previous <$else> -------- <** insert "next" button **> <$if COND=(SET Next)> Next <$else> ---- <***************************** * WEBPAGE * ******************************> <$macro WEBPAGE /CLOSE /OnlyOnce Title:string/r Chapter:string="" Next:uri prev:uri Back:uri=":index.html" NoIndex:bool="true" NoCopy:bool NoMain:bool QTEXT:string QAUTHOR:string> <html-only><(Chapter)></html-only><(Title)> <$if COND=(SET next)> <$if COND=(SET NoMain)> <$if COND=(SET prev)> <* * This will tell w3-robots not to index any sub-documents, * as the main document index.html should contains all information * required to create a decent description for the robot. * * As a result, the robot will not scan the whole manual, and * therefore the waste of bandwidth is reduced. * * Assuming the robot supports this , of course... *> <* * insert navigation bar and quote * (not for PostScript-version) *>
<* insert quote *> <$if COND=(SET QTEXT)>

<(QTEXT)>
<$if COND=(SET QAUTHOR)> (<(QAUTHOR)>)

<(Title)>

<$content> <*
<$let HSC.FORMAT.TIME="%d-%b-%Y">
Thomas Aglassinger (agi@giga.or.at), <(GetTime())>
*> hsc-0.934.orig/docs-source/macro/0040700000175000001440000000000007776512740015511 5ustar loryusershsc-0.934.orig/docs-source/macro/attrib.hsc0100600000175000001440000000720107642675506017476 0ustar loryusers <$macro LITYPE TYPE:string/r>
<(type)>
<$macro LIATTR SHORT:string/r LONG:string/r>
/<(long)> (short: /<(short)>)
<* ** macro to format an example *> <$macro exmpl exmpl:string/r>
<(exmpl)>

Attributes are comparable to function arguments in programming languages like Pascal, Oberon or E. So attributes are arguments passed to a tag or macro.

Additionally, you can create/update attributes using and therefor use them just like variables.

General Syntax

Within , and , an attribute is declared using
name ":" type [ "/" modifiers ] [ "=" default value ]

Attribute Types

any text references to an URI. Is affected by CLI options like . boolean flag enumerator type; accepts only given values (eg the ALIGN attribute of IMG). id for current position in document; can be refered with A HREF="#id" decimal integer value a color-value matching the template "#rrggbb" or one of the values defined using HSC.COLOR-NAMES.

Attribute Modifiers

Attribute is read-only; you can't set a new value using . This option is only allowed within Attribute is global. Useful if you want to define an attribute inside a macro, that is not removed after macro has been processed. This option is only allowed within . Attribute is only used by a .
Within and , URIs also can have the following options:
Attribute must be set with a value when macro/tag is called. If the attribute references to a local file, try to evaluate the "size" of the file, search for attributes called WIDTH and HEIGHT within the same tag and set them with these values (if they have not been set before). At they moment, only tags like IMG support this. Strip whole tag, if the attribute references to an external URI and option has been enabled. Attribute is obsolete. Makes little sense for macros, but is used in hsc.prefs to mark attributes obsoleted by CSS etc.

Default Value

The default value initialises the attribute every time the macro is called. If the attribute is not set within the macro call, the default value is used. Otherwise, the value passed to the macro will be used as new value.

Examples

defines a boolean attribute defines an URI attribute and sets it's default value to ":main.html". The ":" indicates that the default value is a . defines an enumerator type; allowed values are ascii, bin and hex.
hsc-0.934.orig/docs-source/macro/flag.hsc0100600000175000001440000001147307771036021017112 0ustar loryusers <$macro LIFLAG SHORT:string/r LONG:string/r ONLYDEFTAG:bool>
/<(long)> (short: /<(short)>)

Within and , you can use several modifiers to tell how to handle this macro/tag.

Allowed modifiers for both and are:
macro/tag is a container and requires a corresponding end tag. macro/tag is required at the most once within a document macro/tag is required to appear at least once within a document macro/tag ought to appear at least once within a document Needs a string as argument, that contains a list of container tags, that must be started before tag is allowed to be used.
Example:
The tag LI must be used inside some sort of lists only, therefore /MBI="ul|ol|dir|menu" is used. The is used as a separator for multiple tags.
In XHTML mode, this modifier is stricter than for traditional HTML: it means ``directly inside'' instead of ``somewhere inside''. I.e. the following would be legal in HTML, but not in XHTML (the actual definition is different, this is just an example!): <$source PRE> <$deftag P /MBI="BODY">

Blah

Like /MBI, but this time tags that must not be used before. For example, a nested usage of A is not allowed, therefore /NAW="a" is used.
Additionally, the following modifiers can be used with
Used for P and LI, which can be used as container or single tag depending on the HTML version. Tags marked with this modifier can not be nested. Marks tags with the SGML content model EMPTY, like BR, IMG, HR etc. In HTML mode, they simply must not have a closing tag. In XHTML mode, they should have a trailing slash or a closing tag immediately following. The latter is not supported yet, but HSC can complete these tags with a slash if you forget it (or want to produce HTML4 and XHTML documents from one source - not that I understood what for...). Warning 88 will be issued when this happens. tag is only used by jerks This modifier is just there for our laziness and defines some often needed attributes with a single letter; c for CLASS:string, d for DIR:enum("ltr|rtl"), h for HREF:uri, i for ID:id, k for CLEAR:bool, l for LANG:string, m for MD:string, s for SRC:uri, t for TITLE:string. y for STYLE:string. v for events.
For example, use /LAZY="cil".
"Events" is special in that it declares several scripting-related attributes at once: onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup. These are the most frequent attributes, collected under an entity in HTML 4.01. tag is obsolete and should not be used any more. This e.g. concerns LISTING. skip a linefeed ("\n") that comes immediately after the tag. This is only useful for some of 's special tags and only avoids some unnecessary empty lines. This one marks tags which are no normal tags with some attributes, but have their own syntax. The only HTML tag which has this modifier set is ! (for SGML comments). If this modifier is set, any occurrence of the container is checked for succeeding/preceding white spaces. By default, this concerns the tags A, TITLE, headings and physical/logical styles like B or strong.
<* vi: set ts=4 et: *> hsc-0.934.orig/docs-source/macro/macros.hsc0100600000175000001440000002126707701662710017472 0ustar loryusers Macros are a powerful feature which enables you to create shortcuts for often used text. As you can also pass arguments to macros, it is even possible to create templates for whole pages. <**********************************************************>

General Syntax

<**********************************************************> Macros can be defined like
<$macro MacroName [ modifiers ] [ attributes ] >

...macro text...

/$macro
Here are some examples of macro definitions: <**********************************************************>

Use As Shortcuts

<**********************************************************> You can define a macro called Hugo-Address that only is a shortcut for your email-address like <$INCLUDE FILE="exmpl/macro_addr.hsc" SOURCE PRE> <* show macro *> <$INCLUDE FILE="exmpl/macro_addr.hsc"> <* define macro *> So every time, you insert the macro-tag Hugo-Address in your hsc-source, it will be replaced by

in the HTML-object. <**********************************************************>

Container Macros

<**********************************************************>

Container macros allow you to create a macros with a text before and after the content. While the preceding/succeeding text is specified with the macro declaration, the content is assigned during the macro call.

To declare a macro as container, you have to specify the modifier /CLOSE. To insert the contents, use the special tag $content. Alternatively, you can access the content with the special attribute HSC.Content.

You can use $content multiple times inside the same macro, too.

To call a container macro, act the same as with the simple macro you have seen in the above example. But different to before, now also a end-tag has to show up. Everything between the corresponding start- and end-tag will be interpreted as content.

You should be aware of the fact that , when scanning for the end-tag for the macro, does not in process other macros or $include-tags, but only looks at the text. Therefore, the end-tag has to show up within the same input file as the start-tag.

Ok, that was a bit much. Probably a good time for an example...

<**********************************************************>

Declare Your Own Logical Styles

<**********************************************************>

One of the most laughable stories about HTML is the one about physical and logical styles: It is possible to render text in bold or italic letters using tags like B or I, which are known as physical styles. Furthermore, you can also use some logical styles like CODE or KBD, which should be used to mark sequences of code or user input. Both are usually rendered same as the physical style TT (typewriter font).

As everyone with a brain implemented could have told from the beginning, the number of physical styles increased with every new HTML release. In the draft to (never released) HTML-3.0 tags appeared to render names of authors, acronyms, persons etc. The lack behind these concepts became that obvious that even w3c found out it sucks. And so, probably only soon before tags like Tim-Berners-Lee-s-favourite-tag-to-render-his-name made it into the specifications, this concepts has been abandoned.

However, it has not been replaced by anything more useful, and this has not changed much until today; except that many people are waiting for a new holy cow called Style Sheets to be implemented in a functioning way in at least some of the available browsers.

So it makes sense to use container macros as substitute for logical styles, which will do nothing but enclose the content in a physical style. Below a macro FILE will be created, which can be used to render filenames:

<$INCLUDE FILE="exmpl/macro_file.hsc" SOURCE PRE> <* show macro *> <* is already defined within "inc/macro.hsc", ** so there is no need to include redefine it here *> Your new style can be used like all other styles: <$source PRE> ..open the file hugo.txt and.. In this case, filenames will be rendered italic:
..open the file hugo.txt and..

It should be rather obvious how this one works: When calling the macro using FILEhugo.txt/FILE, hsc will scan the input until it reaches a /FILE. Anything between the corresponding start and end tag will be used as content, in this case hugo.txt.

Now the macro text will be interpreted: The first part is easy, a simple I will be inserted. After that, a $content shows up, and the content read before will be inserted. In this case, this is a simple plain text, but of course you could also use tags or even other (container) macros. At the end of the macro, a closing /I is appended, and the macro call exits.

<**********************************************************>

Nesting Container Macros

<**********************************************************>

You should be aware that the macro content (the text specified between the corresponding start and end macro tag) can not access attributes which have been declared for the macro text (the text which is assigned to the macro while declaring it using $macro).

For example: <$include FILE="exmpl/macro_cntnest.hsc" SOURCE PRE> will result in <$include FILE="exmpl/macro_cntnest.hsc" PRE> The line <$source PRE>content: hugo=<(hugo)>

does not - as some might have expected - access the attribute hugo passed to the container macro sepp just before, but still reads the attribute hugo declared above using $define.

The reason for this shows up soon when you start using container macros inside container macros: every time a $content shows up while just processing a $content, it does not make much sense to include the same content as just before. Instead, the parser uses the content passed to the previous but one container macro. For example: <$include FILE="exmpl/macro_cnt2nest.hsc" SOURCE PRE> will result in <$include FILE="exmpl/macro_cnt2nest.hsc" PRE> <**********************************************************>

Macros With Attributes

<**********************************************************> Take a look at this example: <$INCLUDE FILE="exmpl/macro_next.hsc" SOURCE PRE> <* show macro *> <$INCLUDE FILE="exmpl/macro_next.hsc"> <* define macro *> This defines a macro that defines a button that references to the next page. As every page has its own next page, you can set one attribute for this macro: NXTREF, which is the URI that should be referenced as the next page.

So an example usage of this macro would be: <$source PRE> which will give the button seen below:

Note that the value of NXTREF is passed to the HREF attribute within the A tag when the macro is extracted.

If you wonder, what HREF=(NxtRef) (see above) should mean: This sets HREF with the value stored in NxtRef. For details, read the section about expressions. <**********************************************************>

Macros Inside Macros

<**********************************************************> Currently, locale macros are not supported. If you declare a macro inside a macro, the inner macro will be declared when the outer macro is called. For example: <$include FILE="exmpl/macro_locale.hsc" SOURCE PRE> will result in <$include FILE="exmpl/macro_locale.hsc" PRE>

At the moment you can call inner-sepp even outside of outer-sepp, as it is defined globally. When calling outer-sepp another time, you will receive a , as this tries to redefine inner-sepp.

Obviously this behaviour doesn't make sense, but local macros are not supported in this release. <*

See Also

To make your macros more powerful and flexible, you can use expressions and conditional conversion.

*> hsc-0.934.orig/docs-source/project/0040700000175000001440000000000007776512740016056 5ustar loryusershsc-0.934.orig/docs-source/project/hscdepp.hsc0100600000175000001440000000531307642675506020206 0ustar loryusers <* ** macro to format an explanation *> <$MACRO explan TITLE:string/r NAME:string>

<$stripws> <** create named reference **> <$IF COND=(SET NAME)> <$ELSE> <$stripws> <(Title)>
hsc DEPendency Procreator

extracts dependencies from 's project-file and stores them in a . But not all parts of the are overwritten: the relevant dependencies for are marked with taglines, so the next time only this part is manipulated and the rest is left untouched.

is part of the hsc-distribution and therefor the same legal issues apply.

is dedicated to Johnny Depp.

Options

Display short help message and exit. Display a short version of Copyright and exit. Specifies makefile to be manipulated. If none given, searches for GNUmakefile, makefile or Makefile. If it doesn't succeed in any of these, a new one named Makefile will be created. Specifies project-file to be scanned for dependencies. If none given, hsc.project is used. All document rules are collected together in a rule by default called all_hsc. This is used to update all documents using a simpe make all_hsc, or, even more useful, to be part of your all rule, which usually depends on all other things that are maintained by the . This option changes the name of this rule. Verbose output Do not create backup of original . Do not write taglines that identify beginning/ending of dependencies. This should only be used if you keep the dependencies in a separate file.

Examples

hscdepp HELP
Displays help and exits.
hscdepp FILE=hsc_makefile PRJFILE=my_hsc_project VERBOSE
Reads the file hsc_makefile, reads project-information from file my_hsc_project, creates a backup of the original makefile in hsc_makefile.bak and writes the updated makefile to hsc_makefile.usr/bin/vim
hscdepp
Does the same as above, but uses makefile and hsc.project as default.
hsc-0.934.orig/docs-source/project/hscpaltrow.hsc0100600000175000001440000000252207642675506020745 0ustar loryusers hscPitt's ALternative ThROW-out

is a sample ARexx-Script which explains how to utilize the output of so that you can retrieve all information stored in the project file.

is placed in the public domain. Use at your own risk.

is dedicated to Gwynneth Paltrow.

Options

There is only a single required option which denotes the project file to examine. If you pass no arguments, a short usage information will be displayed.

Usage

This script starts with COMMAND=EXTRAXT, stores the output in a temporary file, and parses it so you can access all data from the script. For future compatibility, unknown data are ignored.

Basically, you just have to invoke
    hscpaltrow hsc.project
This script is not designed to do anything useful with the data obtained, it just displays them.

Feel free to modify it, but don't forget to rename it after that, or it will be overwritten when updating your hsc-directory with a new release.

You can find this script in grafflwerk/hscpaltrow.rexx.
hsc-0.934.orig/docs-source/project/hscpitt.hsc0100600000175000001440000001532107701664300020220 0ustar loryusers <* ** macro to format an explanation *> <$MACRO explan TITLE:string/r NAME:string> <** create named reference **>
<$stripws> <$IF COND=(SET NAME)> <$ELSE> <$stripws> <(Title)>
<*** render heading and link for pitt-command ***> <$macro pittCmd NAME:string/required>

<(Name)>

<$macro pittCmdNote NAME:string/required NOTE:string/required> <(Name)> - <(Note)> hsc Project Interfering And Trashing Tool

can be used to extract and manipulate data stored in 's project file. It lists all documents stored in the project and removes entries and corresponding files for documents.

is part of the hsc-distribution and therefor the same legal issues apply.

is dedicated to Brad Pitt.

Important: should be used with caution. It assumes that the user knows what he is doing and does not ask back before performing any action. Using it is rather easy to remove information within seconds that required hours being implemented.

Options And Switches

Display short help message and exit. Display a short version of Copyright and exit. Command to be applied to project. Supported commands are:
    <*
  • *>
For a more detailed explanation of these commands see below. Arguments for command. Depends on the value of COMMAND. Specifies project file to be examined/manipulated. If none given, hsc.project is used. Act quietly, do not display progress and status messages. Certain commands refuse to overwrite already existing data. Nevertheless with this switch enabled the will. Enable debug mode; only useful if compiled in debug mode.

Commands

This command will create a new project file containing no documents. If the project file already exists, this command will refuse to overwrite it. You have to enable the switch FORCE to accomplish this. Setting COMMAND=COUNT will output the number of documents currently stored in the project file.

Setting COMMAND=LIST will output a short list of documents to . Every line contains the name of an HTML object.

Setting COMMAND=ADD will add a new document with it's corresponding main source to the project. The first ARG contains the full relative filename of the HTML object, the second ARG contains the name of the main hsc-source that will be used to create the document.

If the document already is part of the project, an error message will be displayed and the old document will be left untouched. To replace a document, you will have to enable the switch FORCE before. Setting COMMAND=DELETE will remove the entries specified in ARG from the project file. The document and the corresponding source remains untouched. Setting COMMAND=ERASE will remove the entries specified in ARG from the project file. Different to COMMAND=DELETE, it will also remove the files for document and source. This command should be used with caution.

Setting COMMAND=EXTRACT will output a detailed list of documents to . This command is mend to be used if you want to utilize the information stored in the project file. Just redirect the output of and scan it by your program.

All lines match the template

identifier="value"
You must not make any assumptions about the sequence of identifiers. Your program should be able to skip unknown identifiers. At the end of data about a document, an EOF occurs or an empty line with another document succeeding.

Currently, possible identifers are:

DOCUMENT
URI of document, relative to current directory
SOURCE
Filename of main source file used to create document, relative to current directory
INCLUDE
Name of a file that has been included during processing the document. This identifier can show up more then once, if multiple files have been included.
See also to learn how you can utilize this command.

Examples

hscpitt HELP
Displays help and exits.
hscpitt PRJFILE=sepp.project COMMAND=NEW
Create a new project and store data in sepp.project.
hscpitt PRJFILE=sepp.project LIST
List all documents currently stored in project file sepp.project.
hscpitt ADD ../docs/sepp.html sepp.hsc
Adds document sepp.html, which is created from sepp.hsc. Note that ../docs/ denotes the relative path, where the HTML objects are located. This usually is the same value you used as TO argument to invoke .
hscpitt EXTRACT
List information about all documents currently stored in project file hsc.project.
hscpitt COMMAND=DELETE www:index.html www:sepp/hugo.html
Remove entries for the documents www:index.html and www:sepp/hugo.html from the project file. The HTML object and hsc-sources for these documents will not be removed.
hsc-0.934.orig/docs-source/project/index.hsc0100600000175000001440000002224307701664055017661 0ustar loryusers

As the amount of documents you are processing grows, so does the amount of work required to maintain the whole bunch of your (wannabe-)information. To reduce waste of time for stupid project management tasks, is able to maintain a project file and to utilize some additional tools.

Overview

There are several tools and concepts involved in project management. Within the next paragraphs, the basic ideas will be roughly described. If you already worked with a command line based compiler environment and know how s and a dependency creator work, there should not be many new things.

If you did not, there is quite some work in front of you. For details about the aforementioned things, you can refer to the chapters listed below, but this is not meant to be an idiot-proof tutorial to .

  • Project Files - where stores the required information.
  • - 's project interfering and trashing tool
  • - a general purpose tool for project management
  • s - how to adept them for
  • - 's dependency procreator
  • - utilizing the output of .

Creating A New Project

The first step is to create a project-file. This can simply be done by
hscpitt new
This will create an empty project in the current directory with no documents in it. To see which documents are part of your project, you can use
hscpitt list
or, if you do not want to see the header displayed:
hscpitt quiet list

All these commands will use a default name, hsc.project for the project-file. If you want to use a different name, you can use the CLI-option PRJFILE, for example:

hscpitt prjfile=sepp.project new
But note that then you will have to specify this option every time you invoke or .

Adding New Documents To The Project

There are two ways to add a document to the project: the first is , because is will automatically add or update document entries in the project-file after it successfully wrote a document to the storage.

To make keep the project-file up-to-date, you have to use the CLI-option PRJFILE=projec_file. For example,you can invoke using

hsc FROM=sepp.hsc TO=html:sepp-pages/ PRJFILE=hsc.project

Maintaining The Makefile

Another possibility for adding documents is . For example:
hscpitt add html:sepp-pages/sepp.html sepp.hsc
will add the same document and main source file as before to the project. This can be handy if you have a big and fat pattern rule with many options that will take care of invoking after a new dependency has been added to the . This relieves you from typing in a long sequence of command line options.

Nevertheless leaves the untouched. Actually you do not need a at all to use - it only stores information in project-file.

So if you invoke right after , nothing will have changed. To translate the contents of the project-file into a list of dependencies, you will have to use . This tool simply creates a dependency line for every document it finds in the project-file, and stores this information in a .

For example, after the call to done before, will create the dependency
html:sepp-pages/sepp.html : sepp.hsc
Or, if you would have used relative paths on a system like
hscpitt add ../../sepp-pages/sepp.html sepp.hsc
the dependency would look like:
../../sepp-pages/sepp.html : sepp.hsc
However, does not care about the rules and options for hsc you use in the . It only takes care of the dependencies, and everything else is up to you.

When To Call Hscdepp

As you just learned, and are completely independent from , and only provides an optional link between them. In other words: does not care if it is invoked from a or not. And does not care about the project-file, but only about its own .

Therefore, every time something changed in the project-file, it is left to the user to invoke and also reflect these changes in the .

In general, it is a good idea to call ...
  • after adding a new document using or
  • after successfully processing new a document with the first time after adding it with , because then it not only depends on its main source, but also on the files included during processing.
  • after changing the include files of your pattern rule in the
  • once in a while.

Of course sometimes it can be convenient not to call , for example when you add multiple documents by calling several times, without invoking or meanwhile. Nevertheless, invoking too often should not cause any harm.

Checking IDs

The usage of the project-file also improves the functionality of . Now it even can remember which IDs for link targets inside a document have been defined (for example using HTML code like A NAME="id").

Now will not only whine about code like <$source PRE> but also <$source PRE> with in both cases the ID unknown not being defined within the document, but the document existing.html being in place.

Until all documents have been added to the project (either by or ), ("no entry for document .. to check id") might show up some times. This can be ignored.

Until all documents have been processed by with a PRJFILE set at least once (not only been added by ) to the project-file), there will also be some occurrences of ("unknown id") you can ignore. This is because even if the IDs are actually defined in the document, does not yet know about them because it did not store them in the project-file, too.

Alternative Approaches

It should be emphasized that all of the above tools and concepts are optional to . You do not have to use to maintain your dependencies, but can also do manually, without any pattern rules in the .

You even do not have to use , but a different tool for project management. Although then you will have too find a substitute for , if you still want to maintain the dependencies automatically. Maybe can help you with this.

Of course you can use without a project-file at all, and for example use a simple Shell- or Rexx-script to convert all your documents, if there are only few of them.

Example Projects

<* macro to insert name and link to example file *> <$macro example-file dir:string/required name:string/required>
<(name)> There are some example project included, with most of them consisting of only a few sample documents. To try them out, open a Shell and change into the corresponding directory with the . View the README if there are some preparations needed.

Maybe you will also have to change the variables HSC to point to the hsc-executable and DESTDIR to contain the name of the parent directory, which differs from system to system. Use / for AmigaOS or ../ for most other systems.

Fetzenschädl
This project is located in examples/fetzenschaedl/. There you will also find a and a . Both HTML document and hsc-source will be located in the same directory, which makes maintenence easier, but has several obstacles shortly discussed there. It uses a , but no project-file, so only and are required to try is out.
Simple
This project is located in examples/simple/. There you will also find a and a . These are the same documents as before, but now HTML objects will be located in a different directory you will have to create manually. Only a few changes to the are required to accomplish this.
Advanced
This project is located in docs/source/ and contains the source code used to create this manual. See docs-source/README. The used for this utilizes and contains a pattern rule to also validate the created document with an external HTML checker.
hsc-0.934.orig/docs-source/project/make.hsc0100600000175000001440000001272507701664026017471 0ustar loryusers

This chapter shortly describes a popular, but nearly unusable tool called , which can be used to solve project management tasks when using . This is not the only tool which is able to do so, but it should exist on most platforms.

What is Make?

Let's start with a quote from the documentation to GNUmake:

The `make' utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them. [...]

You can use `make' with any programming language whose compiler can be run with a shell command. Indeed, `make' is not limited to programs. You can use it to describe any task where some files must be updated automatically from others whenever the others change. [...]

To prepare to use `make', you must write a file called the "makefile" that describes the relationships among files in your program and provides commands for updating each file.

As of it's general purpose design, also fits to be used in combination with . So far for the good part.

Which Make to Use

One of the worst things about is that - as far as I know - it comes from the fossil Unix world, with the usual results. There are several programs with the same name, but different features. Furthermore, you will have to bother with many occurrences of cryptic looking characters.

This documentation will always refer to a version of make commonly known as GNUmake, as it is freely distributable, exists as source code and has been ported to most platforms.

(For Amigoids: A tool called smake has become very popular under this system. Not because it is so powerful - on the contrary - but because it was shipped with the SAS/c package. You can put away this tool for , probably not a single example given within this manual or the supporting material will work.)

Why Make Sucks

One thing nearly all -tools have in common is the inability to produce useful error messages - if any at all.

Most of them are very picky about blanks and tabs (which can be created by pressing the TAB key). Tabs in plain text file are one of the most brain-damaged concept the (so called) modern computer industry has established. Of course it is easy for a machine to distinguish between spaces and tabs by their ASCII code. But the user will see a blank space on the screen in both cases.

This becomes even worse, as many editor applications do not care about tabs and replace them by spaces, normally without notifying the user about that. This can not only be annoying, as these editors in most cases are not sure if they should replace a tab by four or eight space characters, often resulting in an unexpected looking display. Even worse, picky tools (like most tools) will interpret the as trashed. So make sure you are using a decent editor. For example, memacs coming with the standard Workbench does a good job on this.

Makefiles and Pattern Rules

As already mentioned above, you will have to write a so called . This is by far the funniest part of (apart from interpreting esoteric error messages). Basically, you have to specify rules how a target depending on specifics source is created. For , the target is usually the HTML document, and the sources are all those files with the .hsc extension needed to create the document.

As it would be dull to tell exactly what to do for every single target, you can specify so called pattern rules, which tell how to generally handle whole groups of files.

Ancient versions of often only support a rather impotent way for such pattern rules. An example of such an outdated rule:

<$source PRE> .c.o: $(CC) $(CFLAGS) -c $<

The first line tells that now a rule will follow how to create a target with a .o extension from a file with a .c extension. You shouldn't bother too much about the second line. The only thing you will have to know: You can forget these kind of rules for . They did a good job for the ridiculous bunch of C-programmers and their ridiculous compilers, but they are useless for everything more sophisticated. However, many -tools still only support such rules.

The equivalent pattern rule in a more reasonable syntax look like this: <$source PRE> %.o : %.c $(CC) $(CFLAGS) -c $<

This should give you a clue which sections of the manual of should be relevant for you. Within the next chapter, you will find some remarks about how to write a for , but there probably still will be no way around at least giving a glimpse to the manual of .

So Why Make?

After reading the above, one might think no one uses as long there any alternative left. See, and there is the problem: If you want to have something quite powerful and flexible, which is available for most platforms and is freeware, there currently is no alternative.

If you know of any, tell me and I will kick the whole chapter about and s immediately.

Where to Get Make

See also the section about where to obtain the version of recommended for use with .

hsc-0.934.orig/docs-source/project/makefile.hsc0100600000175000001440000000645407701664274020340 0ustar loryusers Inside the starter-project-drawer, you can find an rather empty to be used for new projects. This will be a short explanation of the symbols and rules defined in this .

Symbols

DESTDIR   =
HSCMESSAGE=MsgMode=normal Ignore=46
HSCPROJECT=hsc.project
HSCINCLUDE=include/standard.hsc include/page.hsc
HSCMISC   =RplcEnt

DESTDIR describes the destination-directory for your html-objects and is relative to the path where you invoke (and usually your hsc-sources are located, too). IGNORE specifies which messages should be ignored, HSCPROJECT is the project-file to be used both by and . HSCINCLUDE specifies include files which should be processed within the command-call invoking from the ; these files will be included for all hsc-sources. HSCMISC contains all other options and switches that should be passed to .

HSC     =hsc
HSCFLAGS=$(HSCMISC) $(HSCMESSAGE) prjfile=$(HSCPROJECT) to=$(DESTDIR) $(HSCINCLUDE)

HSC is the command to be used to invoke ; if it isn't already in your search-path, you can also enter the full path here. HSCFLAGS is computed from the values above and contains all parameters for , exept the main hsc-source.

HSCDEPP =hscdepp

This is the command to be used to invoke .

Rules

<$source PRE> $(DESTDIR)%.html : %.hsc $(HSC) $(HSCFLAGS) $<

This is a pattern rule that will create an HTML object in DESTDIR using the corresponding hsc-source and the options you specified above. The automatic variable "$<" contains the name of the first dependency, normally this is the main hsc-source.

<$source PRE> depend : $(HSCDEPP) file=Makefile prjfile=$(HSCPROJECT) verbose

This rule will invoke and update your dependencies; this will modify your .

Pre- And Post Processing

A fine thing about the pattern rule used above to create your html-object is that it can be extended to do several things before or after performes its task.

For example, extending it to

<$source PRE> $(DESTDIR)%.html : %.hsc $(HSC) $(HSCFLAGS) $< chmod 644 $@

will make sure that the file-permission-bits are set to the usual value required by w3-documents. This, of course, works only for Unixoid systems.

If you are using AmigaOS and have an ARexx capable w3 browser installed, you can use

<$source PRE> $(DESTDIR)%.html : %.hsc $(HSC) $(HSCFLAGS) $< OpenURL FILE $@

to immediately display updated documents in your browser. OpenURL is available from Aminet.

You can also use a better syntax checker than on your newly created document:

<$source PRE> $(DESTDIR)%.html : %.hsc $(HSC) $(HSCFLAGS) $< CheckHTML $@

Note that errors found during the second check are reported from the HTML object and might be a bit difficult to backtrace in the hsc source.

hsc-0.934.orig/docs-source/project/prjfile.hsc0100600000175000001440000000362707701664066020214 0ustar loryusers

Contents

The project-file, stores some information about the document it just processed. This includes
  • name of the document (html-object) created
  • name of the main hsc-source used
  • names of all files include (both via user arguments or )
  • local IDs defined in this document (using A NAME="id" or tag ID="id")

This enables to check references to local IDs in other documents of your project. Additionally, you can now use to maintain the dependencies between hsc-source and HTML object, and update a according to them.

Another tool called allows you to examine, add and remove documents from the project-file.

Naming The Project-File

It doesn't matter which name you give the project-file, but I suggest to call it hsc.project; this is the default name both and assume, and you do not have to specify another command line option when invoking them.

But it's very important to use the same name for the project-file every time you invoke . Otherwise, and won't be able to find all required information and will launch warnings or create incomplete dependencies.

Using The Project-File

To create an empty project-file, you have to with the command NEW. To make maintain it, you have to specify the CLI-option PRJFILE when invoking it.

If you want to utilize the information stored in the project-file outside , you can use with the command extract and for instance parse it with a short program written in some scripting language. See for an example.

hsc-0.934.orig/docs-source/script/0040700000175000001440000000000007776512740015714 5ustar loryusershsc-0.934.orig/docs-source/script/extract-changes.rexx0100600000175000001440000000564707642675506021721 0ustar loryusers/* * extract-changes.rexx * * Extract the descriptions of the differences from the ASCII-files * CHANGES and NEWS. * * Usage: rx extract-changes.rexx * * Note: If the variable includeVersions contains a value greater * than 1, for every version a heading will be included. */ PARSE ARG filename /* Number of recent versions to include */ includeVersions = 1 /* Constants for state variable */ st_skip = 0 /* still skipping intro */ st_ruler = 1 /* after horizontal ruler */ st_heading = 2 /* in "Version ..." heading */ st_text = 3 /* normal text */ /* State variable */ state = state_skip /* Counter how many separators (lines starting with "---..") * have already occurred. */ sepCounter = 0 IF (Open('file', filename, 'R')) THEN DO DO WHILE ((sepCounter <= includeVersions) & (~EOF('file'))) /* Read next line and check if it is a separator line */ line = ReadLn('file') is_separator = (LEFT(line,10) = '----------') IF (is_separator) THEN DO /* Translate the clumsy hyphen-sequence into a more * elegant horizontal ruler */ sepCounter = sepCounter + 1 IF (sepCounter > 1) THEN DO SAY '' END state = st_heading END ELSE DO IF (state ~= state_skip) THEN DO /* kipped the intro text */ IF (sepCounter > 0) THEN DO line = ReplaceAllBy(line, '&', '&') line = ReplaceAllBy(line, '<', '<') line = ReplaceAllBy(line, '>', '>') IF (state = st_heading) THEN DO IF (line ~= '') THEN DO /* Insert version heading */ IF (includeVersions > 1) THEN DO SAY '

' || line || '

' END /* Start preformatted context */ SAY '
'

                            /* Skip until next empty line */
                            DO WHILE (line ~= '')
                                line = ReadLn('file')
                            END
                            state = st_text
                        END
                    END
                    ELSE DO
                        SAY line
                    END
                END
            END
        END 
    END /* while */
    Call CLOSE('file')
END
ELSE DO /* Open() */
    /* Error message */
    SAY 'error opening "' || filename || '" for input'
END

EXIT 0

ReplaceAllBy: PROCEDURE
    PARSE ARG string, all, by
    result = ''
    DO UNTIL (i=0)
        i = POS(all, string)
        IF (i > 0) THEN DO
            result = result || LEFT(string, i-1) || by
            string = DELSTR(string, 1, i)
        END
        ELSE DO
            result = result || string
        END
    END /* until */

    RETURN result

hsc-0.934.orig/docs-source/Makefile0100600000175000001440000002650510000473027016031 0ustar  loryusers#
# Makefile for the hsc manual
#

#
# DESTDIR  - destination directory (relative)
# IGNORE   - messages to be ignored
# PRJFILE  - project file
# STDINC   - standard includes for all sources
# HSCMISC  - miscellaneous flags and options
# 
# HSC      - shell command that invokes hsc
# HSCFLAGS - hsc options
#
# HSCDEPP  - shell command to invoke hscdepp
# HSCPITT  - shell command to invoke hscpitt
#

#
# To compile the whole manual unders non-Amiga-OS, you have to perform the 
# following steps before the Unix parent directories are treated correctly
# by this Makefile:
#
# - Go to the part where the dependencies created by hscdepp start (quite 
#   at the end of this file) and replace all " /" by " /../". Note the
#   blanks at the biginning of these two search/replace expressions.
# - Activate the "PARENT = ../" symbol below.
# - In the shell, enter "hscpitt new" to clear the project file
# - For your convenience, change the IGNORE symbol below to
#   "IGNORE = ign=46 ign=51" as the project data can not yet be
#   validated by hsc.
#

#PARENT	= /
PARENT	= ../

DESTDIR = $(PARENT)docs/
IGNORE  =ign=46 ign=51
PRJFILE =hsc.project
STDINC  =inc/macro.hsc inc/webpage.hsc
HSCMISC	=rplcent getsize compact msgmode=pedantic prefsfile=$(PARENT)hsc.prefs quotestyle=double maxmsg=0 maxerr=0 lowercasetags

HSCFLAGS=$(HSCMISC) $(IGNORE) $(STDINC) $(HSCEXTRAOPTS) status=quiet
HSC	=hsc

HSCDEPP =hscdepp
HSCPITT =hscpitt

.PHONY: all all_hsc depend rebuild

#
# rule to update whole docs
#
all : dirs images all_hsc

#
# pattern rule for html-files
#
# The lines below will do the following:
# - View name of document currently processing
# - Create html-document
# - Validate document just created using CheckHTML 
#
# If the symbols `PS' has been defined, a version prepared for
# html2ps will be created.
#
$(DESTDIR)%.html : %.hsc
ifdef PS
	@echo ps:$@
	@$(HSC) inc/ps.hsc   $(HSCFLAGS) to=$(DESTDIR) $<
else
ifdef VERBOSE
	$(HSC) inc/html.hsc $(HSCFLAGS) to=$(DESTDIR) prjfile=$(PRJFILE) $<
	chmod ugo+r $<
else
	@echo $@
	@$(HSC) inc/html.hsc $(HSCFLAGS) to=$(DESTDIR) prjfile=$(PRJFILE) $<
	@chmod ugo+r $<
endif
endif
#	@CheckHTML $@ QUIET

#
# update dependencies
#
depend :
	$(HSCDEPP) file=Makefile prjfile=$(PRJFILE) verbose

#
# rebuild all documents
#
rebuild :
	$(MAKE) -W inc/macro.hsc

#
# rebuild PostScript-version
#
rebuild_ps :
	$(MAKE) -W inc/macro.hsc PS=1

#
# create PostScript documentation
#
ps :
	ksh -c "perl /bin/html2ps -W l -f html2ps.config -o ../../hsc.ps ../docs/index.html"
#	ksh -c "perl /bin/html2ps -O -f html2ps.config -o ../../hsc.ps ../docs/features/getsize.html"

# Create all destination directories
dirs:
	for d in `find * -type d`; do test -d $(DESTDIR)$$d || mkdir $(DESTDIR)$$d; done

# Copy images over to destination if required
IMAGES=$(addprefix $(DESTDIR), $(wildcard image/*))

$(IMAGES): $(DESTDIR)image/%: image/%
	cp $< $@

images: $(IMAGES)

# --- DO NOT MODIFY THIS LINE -- hsc-dependencies follow ---

# dependencies updated: Thursday 03-Apr-2003 01:36:36

all_hsc : ../docs/distrib.html ../docs/macro/flag.html \
    ../docs/macro/flag.html ../docs/macro/flag.html ../docs/macro/flag.html \
    ../docs/macro/flag.html ../docs/macro/attrib.html \
    ../docs/macro/flag.html ../docs/questions.html ../docs/macro/flag.html \
    ../docs/options.html ../docs/message-list.html \
    ../docs/message-list.html ../docs/message-list.html \
    ../docs/message-list.html ../docs/options.html \
    ../docs/macro/attrib.html ../docs/macro/flag.html ../docs/index.html \
    ../docs/questions.html ../docs/features/expressions.html \
    ../docs/about.html ../docs/project/make.html ../docs/examples.html \
    ../docs/future.html ../docs/copy.html ../docs/project/hscpitt.html \
    ../docs/features/getsize.html ../docs/features/strip.html \
    ../docs/teutsch.html ../docs/others.html ../docs/install.html \
    ../docs/features/if.html ../docs/source.html ../docs/features/exec.html \
    ../docs/features/syntax.html ../docs/features/assign.html \
    ../docs/features/spcattr.html ../docs/ports.html ../docs/envvar.html \
    ../docs/message-list.html ../docs/options.html ../docs/fileargs.html \
    ../docs/macro/attrib.html ../docs/features/rplcent.html \
    ../docs/features/uris.html ../docs/project/prjfile.html \
    ../docs/project/index.html ../docs/features/checkuri.html \
    ../docs/macro/macros.html ../docs/macro/flag.html \
    ../docs/features/prefs.html ../docs/features/spctags.html \
    ../docs/messages.html ../docs/bugs.html ../docs/project/hscpaltrow.html \
    ../docs/related.html ../docs/updates.html ../docs/project/makefile.html \
    ../docs/require.html ../docs/usecases.html ../docs/author.html \
    ../docs/index.html ../docs/questions.html ../docs/changes.html \
    ../docs/project/hscdepp.html ../docs/features/expressions.html \
    ../docs/undocumented.html ../docs/features/css.html

../docs/distrib.html : distrib.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/attrib.html : macro/attrib.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/questions.html : questions.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/options.html : options.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/options.html : options.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/attrib.html : macro/attrib.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/index.html : index.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/questions.html : questions.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/expressions.html : features/expressions.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/about.html : about.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/project/make.html : project/make.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/examples.html : examples.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/future.html : future.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/copy.html : copy.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/project/hscpitt.html : project/hscpitt.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/getsize.html : features/getsize.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/strip.html : features/strip.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/teutsch.html : teutsch.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/others.html : others.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/install.html : install.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/if.html : features/if.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/source.html : source.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/features/exec.html : features/exec.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc exmpl/exec.hsc exmpl/exec.hsc

../docs/features/syntax.html : features/syntax.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/assign.html : features/assign.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/spcattr.html : features/spcattr.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc exmpl/anchor.hsc exmpl/anchor.hsc

../docs/ports.html : ports.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/envvar.html : envvar.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/options.html : options.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/fileargs.html : fileargs.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/attrib.html : macro/attrib.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/rplcent.html : features/rplcent.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/uris.html : features/uris.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/project/prjfile.html : project/prjfile.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/project/index.html : project/index.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/checkuri.html : features/checkuri.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/macro/macros.html : macro/macros.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc exmpl/macro_addr.hsc exmpl/macro_addr.hsc \
    exmpl/macro_file.hsc exmpl/macro_cntnest.hsc exmpl/macro_cntnest.hsc \
    exmpl/macro_cnt2nest.hsc exmpl/macro_cnt2nest.hsc exmpl/macro_next.hsc \
    exmpl/macro_next.hsc exmpl/macro_locale.hsc exmpl/macro_locale.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/prefs.html : features/prefs.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/spctags.html : features/spctags.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/messages.html : messages.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/bugs.html : bugs.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/project/hscpaltrow.html : project/hscpaltrow.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/related.html : related.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/updates.html : updates.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/project/makefile.html : project/makefile.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/require.html : require.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/usecases.html : usecases.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/author.html : author.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/index.html : index.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/questions.html : questions.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/changes.html : changes.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc ../CHANGES

../docs/project/hscdepp.html : project/hscdepp.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/expressions.html : features/expressions.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/undocumented.html : undocumented.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/css.html : features/css.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

# --- DO NOT MODIFY THIS LINE -- hsc-dependencies precede ---
hsc-0.934.orig/docs-source/Makefile.bak0100600000175000001440000002630607642675506016614 0ustar  loryusers#
# Makefile for the hsc manual
#

#
# DESTDIR  - destination directory (relative)
# IGNORE   - messages to be ignored
# PRJFILE  - project file
# STDINC   - standard includes for all sources
# HSCMISC  - miscellaneous flags and options
# 
# HSC      - shell command that invokes hsc
# HSCFLAGS - hsc options
#
# HSCDEPP  - shell command to invoke hscdepp
# HSCPITT  - shell command to invoke hscpitt
#

#
# To compile the whole manual unders non-Amiga-OS, you have to perform the 
# following steps before the Unix parent directories are treated correctly
# by this Makefile:
#
# - Go to the part where the dependencies created by hscdepp start (quite 
#   at the end of this file) and replace all " /" by " /../". Note the
#   blanks at the biginning of these two search/replace expressions.
# - Activate the "PARENT = ../" symbol below.
# - In the shell, enter "hscpitt new" to clear the project file
# - For your convenience, change the IGNORE symbol below to
#   "IGNORE = ign=46 ign=51" as the project data can not yet be
#   validated by hsc.
#

#PARENT	= /
PARENT	= ../

DESTDIR = $(PARENT)docs/
IGNORE  =ign=46 ign=51
PRJFILE =hsc.project
STDINC  =inc/macro.hsc inc/webpage.hsc
HSCMISC	=rplcent getsize compact msgmode=pedantic prefsfile=$(PARENT)hsc.prefs quotestyle=double maxmsg=0 maxerr=0 lowercasetags

HSCFLAGS=$(HSCMISC) $(IGNORE) $(STDINC) $(HSCEXTRAOPTS) status=quiet
HSC	=hsc

HSCDEPP =hscdepp
HSCPITT =hscpitt

.PHONY: all all_hsc depend rebuild

#
# rule to update whole docs
#
all : dirs images all_hsc

#
# pattern rule for html-files
#
# The lines below will do the following:
# - View name of document currently processing
# - Create html-document
# - Validate document just created using CheckHTML 
#
# If the symbols `PS' has been defined, a version prepared for
# html2ps will be created.
#
$(DESTDIR)%.html : %.hsc
ifdef PS
	@echo ps:$@
	@$(HSC) inc/ps.hsc   $(HSCFLAGS) to=$(DESTDIR) $<
else
	@echo $@
	@$(HSC) inc/html.hsc $(HSCFLAGS) to=$(DESTDIR) prjfile=$(PRJFILE) $<
endif
#	@CheckHTML $@ QUIET

#
# update dependencies
#
depend :
	$(HSCDEPP) file=Makefile prjfile=$(PRJFILE) verbose

#
# rebuild all documents
#
rebuild :
	$(MAKE) -W inc/macro.hsc

#
# rebuild PostScript-version
#
rebuild_ps :
	$(MAKE) -W inc/macro.hsc PS=1

#
# create PostScript documentation
#
ps :
	ksh -c "perl /bin/html2ps -W l -f html2ps.config -o ../../hsc.ps ../docs/index.html"
#	ksh -c "perl /bin/html2ps -O -f html2ps.config -o ../../hsc.ps ../docs/features/getsize.html"

# Create all destination directories
dirs:
	for d in `find * -type d`; do test -d $(DESTDIR)$$d || mkdir $(DESTDIR)$$d; done

# Copy images over to destination if required
IMAGES=$(addprefix $(DESTDIR), $(wildcard image/*))

$(IMAGES): $(DESTDIR)image/%: image/%
	cp $< $@

images: $(IMAGES)

# --- DO NOT MODIFY THIS LINE -- hsc-dependencies follow ---

# dependencies updated: Thursday 03-Apr-2003 01:36:03

all_hsc : ../docs/distrib.html ../docs/macro/flag.html \
    ../docs/macro/flag.html ../docs/macro/flag.html ../docs/macro/flag.html \
    ../docs/macro/flag.html ../docs/macro/attrib.html \
    ../docs/macro/flag.html ../docs/questions.html ../docs/macro/flag.html \
    ../docs/options.html ../docs/message-list.html \
    ../docs/message-list.html ../docs/message-list.html \
    ../docs/message-list.html ../docs/options.html \
    ../docs/macro/attrib.html ../docs/macro/flag.html ../docs/index.html \
    ../docs/questions.html ../docs/features/expressions.html \
    ../docs/about.html ../docs/project/make.html ../docs/examples.html \
    ../docs/future.html ../docs/copy.html ../docs/project/hscpitt.html \
    ../docs/features/getsize.html ../docs/features/strip.html \
    ../docs/teutsch.html ../docs/others.html ../docs/install.html \
    ../docs/features/if.html ../docs/source.html ../docs/features/exec.html \
    ../docs/features/syntax.html ../docs/features/assign.html \
    ../docs/features/spcattr.html ../docs/ports.html ../docs/envvar.html \
    ../docs/message-list.html ../docs/options.html ../docs/fileargs.html \
    ../docs/macro/attrib.html ../docs/features/rplcent.html \
    ../docs/features/uris.html ../docs/project/prjfile.html \
    ../docs/project/index.html ../docs/features/checkuri.html \
    ../docs/macro/macros.html ../docs/macro/flag.html \
    ../docs/features/prefs.html ../docs/features/spctags.html \
    ../docs/messages.html ../docs/bugs.html ../docs/project/hscpaltrow.html \
    ../docs/related.html ../docs/updates.html ../docs/project/makefile.html \
    ../docs/require.html ../docs/usecases.html ../docs/author.html \
    ../docs/index.html ../docs/questions.html ../docs/changes.html \
    ../docs/project/hscdepp.html ../docs/features/expressions.html \
    ../docs/undocumented.html ../docs/features/css.html

../docs/distrib.html : distrib.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/attrib.html : macro/attrib.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/questions.html : questions.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/options.html : options.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/options.html : options.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/attrib.html : macro/attrib.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/index.html : index.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/questions.html : questions.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/expressions.html : features/expressions.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/about.html : about.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/project/make.html : project/make.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/examples.html : examples.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/future.html : future.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/copy.html : copy.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/project/hscpitt.html : project/hscpitt.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/getsize.html : features/getsize.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/strip.html : features/strip.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/teutsch.html : teutsch.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/others.html : others.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/install.html : install.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/if.html : features/if.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/source.html : source.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/features/exec.html : features/exec.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc exmpl/exec.hsc exmpl/exec.hsc

../docs/features/syntax.html : features/syntax.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/assign.html : features/assign.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/spcattr.html : features/spcattr.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc exmpl/anchor.hsc exmpl/anchor.hsc

../docs/ports.html : ports.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/envvar.html : envvar.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/message-list.html : message-list.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/options.html : options.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/fileargs.html : fileargs.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/macro/attrib.html : macro/attrib.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/rplcent.html : features/rplcent.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/uris.html : features/uris.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/project/prjfile.html : project/prjfile.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/project/index.html : project/index.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/checkuri.html : features/checkuri.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/macro/macros.html : macro/macros.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc exmpl/macro_addr.hsc exmpl/macro_addr.hsc \
    exmpl/macro_file.hsc exmpl/macro_cntnest.hsc exmpl/macro_cntnest.hsc \
    exmpl/macro_cnt2nest.hsc exmpl/macro_cnt2nest.hsc exmpl/macro_next.hsc \
    exmpl/macro_next.hsc exmpl/macro_locale.hsc exmpl/macro_locale.hsc

../docs/macro/flag.html : macro/flag.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/prefs.html : features/prefs.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/spctags.html : features/spctags.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/messages.html : messages.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/bugs.html : bugs.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/project/hscpaltrow.html : project/hscpaltrow.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/related.html : related.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/updates.html : updates.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/project/makefile.html : project/makefile.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/require.html : require.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/usecases.html : usecases.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/author.html : author.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/index.html : index.hsc inc/html.hsc inc/macro.hsc inc/webpage.hsc

../docs/questions.html : questions.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/changes.html : changes.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc ../CHANGES

../docs/project/hscdepp.html : project/hscdepp.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/features/expressions.html : features/expressions.hsc inc/html.hsc \
    inc/macro.hsc inc/webpage.hsc

../docs/undocumented.html : undocumented.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

../docs/features/css.html : features/css.hsc inc/html.hsc inc/macro.hsc \
    inc/webpage.hsc

# --- DO NOT MODIFY THIS LINE -- hsc-dependencies precede ---
hsc-0.934.orig/docs-source/README0100600000175000001440000000066407642675506015277 0ustar  loryusersDocumentation Source Directory
==============================

This directory contains the hsc sources for the documentation to this
package.

They have been included to provide a rather complex example. Feel free
to examine the sources and the Makefile.

For some binary distributions (AmigaOS, RiscOS), you might only find
this README. Please refer to "hsc/README" (see parent directory) where
you can obtain the source archive from.
hsc-0.934.orig/docs-source/about.hsc0100600000175000001440000001012707726760221016213 0ustar  loryusers

The main purpose of this chapter is to help you deciding whether you
should go on reading this documentation or not.

Motivation

If you read this, it's quite likely that you tried to design an HTML page. And you probably found out that HTML is a very clumsy thing: No macros, no include files and several other features lacking.

And what can you do after your page is ready? View it with a browser and test-click all links? Pfuahahaha! Most browser are designed to handle as many errors as possible and display a readable page, but don't mention your errors! And link-testing is a very stupid task...

Of course, there are several tools around: You can use a macro languages like m4 to define macros and include files, use some of the various HTML validators, replace your special characters with recode and run a link validation tool on your page.

So, after installing several tools, compilers and interpreters, you are ready to go — and can start five programs after a simple change to one of your pages.

What It Is

tries to summarize the functionality of all these tools in one program: it performs a (basic) syntax check, validates your (local) links, replaces special characters by entities and provides a way to define macros which resembles HTML.

It also supports several features you probably will not find in most other tools, like project relative URIs, stripping useless whitespace and automatically setting the attributes for images size.

Furthermore it provides some concepts to maintain your project with popular tools like .

How It Works

simply acts as a preprocessor: You give it an extended HTML-source (later in this document referred as hsc source) containing special commands, and interprets it and produces a pure HTML output as object file. This output file can be viewed with your browser.

Normally you will create your hsc sources using a simple text editor, maintain them in a and process them with . At least I consider this the recommended way of using this tool.

What It Is Not

Obviously, there is no fancy GUI, no (pseudo-)WYSIWYG, no drag&drop — there are other programs which provide these functionalities. But a common shortcoming of these programs usually is that they give less support for large projects and are limited in configurability.

If you just want to create your own personal homepage, write a short HTML document with information about your three freeware-proggies, include a picture of your cat, send greets to Sepp and Hugo or something like that, there are probably other tools which are easier to handle and will serve your needs more or less well.

It should also be stated that you will require various skills usually not needed for W3-authoring (or better: not expected to be needed by most people). This includes a basic understanding of macro creation, writing s and playing around with scripting languages like Rexx. If you have never done such things before, I recommend you forget this package soon and come back in a few years.

This also is no install-and-run package. You will need several other tools to fully use it, and it is not within the scope of this documentation which one you choose. However, it contains some comments and suggestions on that in various places.

Despite the general HTML- and W3-hype of the recent years, both this tool and its author consider many concepts introduced with it ridiculous, braindead and sometimes even pure crap. So this manual contains opinions and language you might consider offensive. If you want to hear the usual Oh how great are all those things!, you will have to look for something else.

hsc-0.934.orig/docs-source/author.hsc0100600000175000001440000000761607642675506016424 0ustar loryusers" +"Through confusion
" +"With a smile on my face") QAUTHOR='Ride, "Natural Grace"'>

Since HSC V0.920, this has turned into a "maintainer" page. It's still mostly Agi's original text though, as much as it is still his code with just a few extra bits and pieces by me. --Matthias Bethke

The main reason why this topic is one of the first, if you are reading this documentation sequentially, is not because I want to receive as much email as possible. Actually this chapter is designed to keep my email traffic as low as possible.

Before You Contact Me

I know I can't expect you to read the whole manual, but make sure you have at least read the sections about Questions And Answers, Related Stuff (and tools), Future improvements and Known Bugs, Problems And Limitations before you contact me.

There are also chapters about compiling and installing, and you should at least give a glimpse at them. For non-Amiga users, there is a chapter about all those existing ports to other systems describing differences.

Maybe there is already a bugfix available at the , so check this, too.

About Bug Reports

If you think you've found a bug that is not already mentioned or discussed in the chapter about , you should include some information in your bug-report:
  • Which version of did you use? You can find this out if you invoke without any arguments or simply type hsc HELP in your shell. Always include version number and exact date, do not use terms like the latest version. The CLI option HELP also exists for all other tools coming with this package.
  • Under which operating system did you use ? (e.g. AmigaOS or RiscOS)
  • Include a single command call or batch-script and hsc source (or at least part of) that reproduces the bug.
  • Do not send me all your sources for your whole site, try to trace the bug back to a single input-file and macro, if possible.

Exceptions of these are internal error messages, as they usually leave you without a clue. Try to include the information described above as long as it does not require any effort, read: program version and name of system.

You don't have to provide information about the exact hardware or version of the operating system or compiler used, as is supposed to be rather system independent, but I might asked you for that in a reply, so keep this at hand.

The more specific and smaller your bug-report is, the more likely I might fix it; although I can't promise that I will fix all bugs reported to me in reasonable time.

If your bug-report fails to include the above informations, I might completely ignore it.

...And Finally

You can reach me via email using Matthias.Bethke@gmx.net. The mailing address on my homepage at <(hsc.anchor)> should usually work, too. But who uses snailmail these days?

If you include binary data, MIME- or, if you think you have to be traditional or something, uuencode-attachments are accepted. Preferred archives are .tar.bz2 and .lha.

You can use English, German or Portuguese for communication.

You can still reach Thomas Aglassinger, the original author, at or . Don't get on his nerves though, he seems a busy guy ;-)

hsc-0.934.orig/docs-source/bugs.hsc0100600000175000001440000001334107701663755016051 0ustar loryusers" +"And then we feel the pain of loss") QAUTHOR='James, "Stripmining"'> Every program sucks. Read why this program sucks, too.

Known Bugs

Below you can find a list of currently known bugs. Feel free to fix them yourself.
  • Sometimes the file position for messages does not make sense. One of those bugs when you fix it in one place, it shows up in another.
  • Skipping macros with complex $if conditions occasionally leads to an unexpted end of context. This can probably be solved by improving skip_expression() in hsclib/skip.c.

Internal Error Messages

This is a special kind of messages which does not fit into the schema of all those messages described at another chapter. When processing it's input, does not only check whether the user made a mistake, but also the authors of these tools. In several places of the source code, tests for things that must not happen. If they do, assumes it has completely fucked up. In this case, it simply displays a message on the screen and aborts.

An example message could look like this:
** internal error at "hugo.c" (123): sepp is not at home

These messages are not really meant to be interpreted by the user, but by the programmer. When prints an internal error message, you should contact the author and report this bug, including the complete text of the panic message and possibly the source you were processing when it happened. In such a case, you are not expected to create a sophisticated bug report, as such problems are hard to trace.

Known Problems

The problems described below probably won't ever be fixed.
  • URI checking is performed via trying to open a file. As AmigaOS is case-insensitive dealing with filenames, problems might occur when copying the HTML object-tree to a case-sensitive file system. I recommend to rebuild the whole project at the target system.
  • If you specify a BASE HREF="..", is unable to find out how the base is related to the destination directory and will treat all local URIs like external ones. Therefore, no link validation will be performed. Project relative URIs are not possible with a base-URI set, of course.
  • The obsolete tags LISTING and XMP might not be treated correctly, as the behavior of these two seems so be not very strictly defined. You should avoid them anyway and use PRE or $source instead.
  • With CLI-option STRIPBADWS enabled, source code like <$source>hello is not converted to <$source>hello. That means that the blank after hello will remain, but does not display a , as the !.. caused all white spaces preceding it to be flushed. I already said it several times, and I say it again: Do not use those bloody sgml-comments!
  • doesn't care much about the maximum length of filenames. If a filename gets too long, it depends on fopen() of your compiler whether an error is reported or the filename is truncated. If you insist on filenames containing 46587643 characters, can cope with it - but your OS probably won't.
  • You should try to avoid using a project file and pipes together; although should now be able to cope with this without enforcer hits (AKA segfaults outside the AmigaOS world),d it might still behave unreasonably and end up with funny project files and dependencies.
  • Out-of-memory conditions can cause small memory leaks on AmigaOS. This is because uses a special malloc()-function which just displays an error message and quits using exit(). As keeps track of all allocated resources, it will release everything that could be fully initialised and made it into its supposed resource list. For out-of-memories during partially initialising complex structures, this fails and can cause memory-leaks (normally approx. 100-500 bytes). Usually, these are handled by your OS or, as for AmigaOS, by the malloc()-function of the run-time-library, so you shouldn't bother too much about that. Blame K&R (or whoever perpetrated malloc())for their brain-damaged memory management concepts.
  • GetFileSize() probably won't work correctly on files greater than 2 GB. This usually caused by the limited abilities of fseek() and ftell().

Limitations

is fully dynamic and it's input size, number of syntax-elements and etc. is only limited by memory and disk space. Only some less important status messages are created in classic, braindead zero-terminated C-character-arrays and are truncated if they become too long.

However, for projects much larger than 100 documents (on a 68060 or equivalent), scanning the project file on every run takes an awful lot of time; due the lack of any portable concept of keeping data resident after a program exits, there is no workaround for this (same problem like with ); you will have to get rid of the project-file and for such projects.

hsc-0.934.orig/docs-source/changes.hsc0100600000175000001440000000125307642675506016521 0ustar loryusers" +"Repression says depravity is cute
" +"I'll feed you lines to make you smile
" +"You're so easy to dehumanise") QAUTHOR='Maniac Street Preachers, "So Dead"'> <* * little macro to insert name and a link to one of * these two changes-files. *> <$macro support-link file:string/required> <(file)> <$depend on=(":../"+file)> The file lists the differences and incompatibilities compared to the previous versions.
hsc-0.934.orig/docs-source/copy.hsc0100600000175000001440000000251407642675506016064 0ustar loryusers" +"bis auffi wosd brunzt
" +"leck mi do aum oasch sogd sie
" +"daun siagsd as umasunst") QAUTHOR='Attwenger, "kosz"'> Now for the boring part - fortunately it's pretty short.

Freedom To Distribute

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Freedom Of Price

This package is not crippled, and you don't have to send me any money.

Bla, Sülz & Fasel

Other product names mentioned herein are the trademarks of their respective owners.
hsc-0.934.orig/docs-source/cvpro.pl0100600000175000001440000000025707642675506016103 0ustar loryusers while(<>) { if(/^DOCUMENT\s+[\da-f]+\s+\/.*/oi) { ($num, $rest) = /DOCUMENT\s+([\da-f]+)\s+(.*)/oi; printf "DOCUMENT %x ..$rest",((hex $num)+2); } else { print; } } hsc-0.934.orig/docs-source/distrib.hsc0100600000175000001440000000550507701663226016545 0ustar loryusers <$macro ArcH NAME:string/r>

<(name)>

(size: <(GetFileSize((":../../"+name)))>)

This is a short explanation of the files and directories coming with these archives:
IMPORTANT        where to start and what to read
README           short introduction
CHANGES          program history
NEWS             tells about incompatibilites to older versions
COPYING          the GNU General public license
hsc              executable for preprocessor
hscdepp          executable for hsc's dependency procreator
hscpitt          executable for hsc's project interfering and trashing tool
hsc.prefs        contains syntax definition
source/          source code
docs/            documentation drawer; start browsing index.html
docs-source/     hsc sources for documentation drawer; as example
examples/        some small example projects for tutorial purpose
grafflwerk/      miscellaneous stuff that might be useful
starter-project/ template to start a new project with
This one is the complete distribution of the AmigaOS-version and includes the binaries, documentation in HTML format and all supporting material. But it does not contain the source code.

This archive is available from the and .

Contains everything like the above, except the AmigaOS-executables and -icons. It also includes the ANSI-C source code to compile all tools of this package. The most important files and directories in source/ are:
README           tells you to read docs/source.html
Makefile         makefile to compile the whole thing
Makefile.agi     makefile used by author
hsclib/          parser functions
hscprj/          project functions
hsc/             hsc, the preprocessor
hsctools/        hscdepp and hscpitt
ugly/            function library; don't try this at home

Additionally, the hsc-sources for this documentation are included in docs-source for example purpose.

This archive is available from the and .

This archive contains the documentation in Postscript format and is only needed if you want to have a printed manual. But before you send it to the shared printer of your computer center or something like that, note that these are more than 100 pages which will require some resources (read: time, paper and ink).

It is generated from the HTML version by using a conversion utility, and only differs in a few aspects mostly concerning navigability.

It is available from the and .

hsc-0.934.orig/docs-source/envvar.hsc0100600000175000001440000000457507771770073016422 0ustar loryusers This section describes several environment variables that affect how operates. <$macro env TITLE:string/required NAME:string/required>
<(TITLE)>

If this variable is set, its content will be interpreted as path to the user's home directory. When looking for , a lib/hsc.prefs will be added to this value, and before this also a directory separator (e.g. a ), if necessary.

This variable specifies the directory where (see also ) is located.
Example: After a

    setenv HSCPATH work:hsc
will look for work:hsc/hsc.prefs.

Within several messages, refers to the user as a . This happens if you are using features which are only supported by some special browsers. Some people say they are forced by their employer to use those features, and therefore feel insulted by .

As a solution, you can store the amount of your monthly payment in this variable:
    setenv HSCSALARY 1000
After this, will stop calling you a jerk. Instead, it will now use the term prostitute.
These variables specify the address of a proxy if you want to use one for external URI checking. It is definitely a good idea to do so, because otherwise FTP and Gopher URIs cannot be checked at all, and also because it reduces network load and can considerably speed up the checking process if the proxy is allowed to cache responses. Note the lowercase variable names—at least on Unixoid OSs case is significant!
The syntax for these variables is compatible with the Lynx webbrowser: the must specify a full URI starting in http://, followed by a hostname, optionally followed by a colon and a port, plus an optional final slash. E.g.
ftp_proxy=http://my.proxy.org:8080/ (Bourne-Shell), or
setenv ftp_proxy http://192.168.1.42 (AmigaShell).
hsc-0.934.orig/docs-source/examples.hsc0100600000175000001440000000301407701663126016713 0ustar loryusers <* macro to format an example *> <$MACRO example EXMP:string>
<(exmp)>

Command Line Examples

Simply performs a syntax check on hugo.html and passes the output to the null-device.

Same as above, but does not display status messages during conversion. A dummy-output is created in the temporary directory Additionally, all special characters like Ü or ß are replaced by its entities (&Uuml; and &szlig;).

Process subfile people/hugo.hsc. The current directory is the main directory of the project. The HTML object is created in /pub_html/people/hugo.html.

Note: Also mind that the hsc-source ends with .hsc, but the HTML object automatically gets the extension .html. Therefor, all references must end with .html.

Project Examples

There also is an example drawer, which contains some small example projects. Every project includes a file called README, which will explain further details.

All example projects are supposed to be performed from the command line.

hsc-0.934.orig/docs-source/fileargs.hsc0100600000175000001440000001154207642675506016707 0ustar loryusers There are several CLI-options to specify where should take the input from and where the output should be placed. This section describes the differences and (dis-)advantages.

Converting Single Files

This one uses a single file for input and output:
    hsc FROM hugo.hsc TO hugo.html
It will use hugo.hsc and outputs to hugo.html. Both input and output will be located in the current directory. This can be useful if you only want to quickly process a single file trough , and do not want to set up a complete project.

Using Different Directories For Input And Output

One of the features of is that your object can be located at a totally different place from the source. This enables you to place your sources at a different disk as the one the w3-Server has access to, saving server space.

For instance, you can use
hsc FROM hugo.hsc TO www:sepp/hugo.html

to use hugo.hsc, located in the current directory, and create www:sepp/hugo.html. Note that all images, other documents etc. you reference from out hugo.hsc using relative URIs have to be located at the corresponding place within the directory www:sepp/.

For example, if hugo.hsc contains a tag <$source pre>back the image file back.gif will have to be located at www:sepp/image/back.gif.

Using A Destination Directory

The same as above can be performed using
hsc FROM hugo.hsc TO www:sepp/

Note the trailing slash that tells that it should now output to a directory and determine the filename by itself. Usually, it will use (input filename, without .hsc, but a .html appended), resulting into www:sepp/hugo.html as before. You can change the default extension using the CLI option .

Using Sub Directories

For complex project, usually not all documents are located in the same directory. For example, hugo.hsc is no more placed in the current directory, but in people/hugo.hsc.

Invoking hsc like
hsc FROM people/hugo.hsc TO www:sepp/

will now output to www:sepp/people/hugo.html. Note that you have to take care that the directory www:sepp/people/ exists, will not create any new directories by itself.

If you now want to embed an image located at www:sepp/image/back.gif into this document, you have to use <$source pre>back Alternatively, you can use a : <$source pre>back Another way to obtain the same result is using
hsc FROM people/hugo.hsc TO www:sepp/people/hugo.html

In this case, is smart enough to figure out that the destination directory is www:sepp/, and you are using people/ as subdirectory.

But if you try to use
hsc FROM people/hugo.hsc TO www:sepp/stuff/hugo.html
can not figure out what to use as destination- or subdirectory, and will show up an error message:
unmatched corresponding relative directories:
  input  `people/'
  output `stuff/'
In this case, you will have to rename your directories.

Using Pipes

Short: It is possible to use pipes with , but it should be avoided in most cases; isn't really pipable. It does not continuously read data from the input and write parts of the output.

(It reads the whole input file with a single call to fread(), creates the output in memory and writes it with (more or less) a single fwrite(). The main reasons why it works this way are: I hate to check for I/O errors, fungetc() usually does not work after a linefeed and memory mapped files are not supported by the standard ANSI library.)

Additionally, it is impossible for to maintain a project file without knowledge of the filenames for document and source, so several features will be disabled.

If needs to access relative URIs, it will have to use the current directory as starting point.

Therefor, pipes should only be used if you quickly want to test a feature on a single file or something like that.

Anyway, here is an example:
hsc STDIN
This specifies the (case sensitive) pseudo-filename STDIN as input, which will use . Missing a TO option, the output will be written to . Now using this like <$source PRE>hsc STDIN hugo.html would be equal to
hsc hugo.hsc TO hugo.html
Again: Try to avoid this.
hsc-0.934.orig/docs-source/future.hsc0100600000175000001440000001742107776670716016435 0ustar loryusers" +"It's already had it") QAUTHOR='Sonic Youth, "Schizophrenia"'>

"Except for bufixes, there will not be any further updates for ."...

...said Agi in 1998. Despite his hopes, I have taken up this project and developed it a little further. Just out of necessity, because I needed some of the features for developing a site of my own. There are still bugs that I'm not likely to ever fix, but what the heck - maybe it's still useful for somebody. Don't expect great news from me either. I'll still leave Agi's original—'xcuse!—rant in here...

--MB

Ok, that was a bit rude, so now less brutal: I've abandoned this project, but basically I'm still around and read your email. So minor bugfixes will still happen, although more complicated problems will simply end up on the known bugs list. Possible minor fixes relate especially to the quite a lot of Amiga-specific features introduced in version 0.917.

For the religious part: I still use my crappy Amiga 2000, I still don't own a PC and I still have a Macintosh rotting in the attic. This is not going to change in near future. Especially because none of the ultra-alternative systems like pOS ever left alpha stage or stalled like the BeBox, which meanwhile degenerated to BeOS, mostly used as toy by Windiots who want to pretend they are different. If somebody would create a reasonable computer, I would buy it. Currently it doesn't look like this is going to happen in near future, therefore: Amiga forever. (Shit! How I hate this outdated piece of crap, but still it is the least useless I know.)

As comes with full source code, somebody else might take over the project. However, I hope this is not going to happen. It's probably more efficient to start such a project from the scratch, trying to learn from the mistakes that were made in . You better leave the source as it is, because the plain ANSI-C portability is one of its main features - at least in my opinion.

Currently I don't think about starting to code a new .

Anyway, as also HTML and browser development has stalled, should remain useful for quite some time to come.

<*

Basically, I consider finished. However, some people have convinced me that there are some things that should be implemented before I release the final version.

Minor Enhancements

  • Improve hscpitt: Add a copy/move command.
  • Rename some message classes: message classes bad style and fatal error will probably be renamed to flaw and failure, so the class name will also consists of only one word. Furthermore, fatal sounds too hard.
  • Rename internal attributes and filenames: currently, internal attributes are named like HSC.XY, and for filenames there are no templates at all. I will probably use the prefix hsc and a as separator, resulting into attributes like hsc-click-here and filenames like hsc-XXXX.tmp.

Major Enhancements

  • New project database: instead of a single project file, should store it's data in separate files for every document. A document data file is only loaded during parsing if some information about a specific document is needed. This should speedup huge projects with more than 100 documents.
  • Additional document data: Without remarkable changes, could also collect useful information about a document, like document title, URIs referenced etc. Of course, some access functions will be provided, too.
  • Index document creation: A new tag $index will allow the user to attach some private information to the document data, which later can be retrieved using . A script the user will have to write can use these to create an HTML object. Easy to implement for me, awfully cryptic and complicated, but rather flexible for the user.
  • Functions with multiple arguments: Functions like Exists() or GetFileSize should use the same attribute syntax like tags, for example GetEnv(VAR="HOME").

Only If I'm Bored

  • More conditionals: $select, $when and $otherwise as an extended version of $if
  • Indention: Add option INDENT for $include and $source to indent preformatted text
  • Plausibility checking of external URIs: unknown protocol, missing domain etc.
  • Improve expression parser: the current implementation is an embarrassment for a student of computer science, but.. well, it does it's job for now.
  • GUI-Version for AmigaOS: I ought to play around with MUI sometimes anyway
  • Filename compatibility mode: this mostly means that a .. should act as parent directory on all systems without having to run additional system patches.

Things Someone Else Can Do

  • Autoconf-support: In the unix-world, a cryptic tool package called autoconf has become quite popular, as it tries to compensate the lack that even at the end of the 20th centaury, no one knows in which header file to expect strftime() on this ridiculous system (ANSI has specified this in the early 80ies, by the way). Although I don't care much about outdated unix-versions, and I don't like unreadable and badly documented macro languages, I might include the required changes if someone else wastes his time with setting up a working autoconf-installation.
  • Improve hscdepp: As I do not consider dependency generators a reasonable concept, someone else will have to add things like excluding specific documents or pattern matching stuff. Hey, it's only about 700 lines of code..
  • Document relation editor: It would be nice, if one could edit all those next/prev/up/.. relations with a program, and include these into hsc-sources later. It would make sense to store these relations in the document data file.

No Future

For the thinggies below, from my point of view, there is no need to ever be implemented.
  • xml-support: The good thing about xml is that it confesses that HTML is impotent crap and sgml is unuseable. The bad thing is that xml is both.
  • Precompiled include files: This would also speed up reading ; I experimented around a bit with this, and it seems that more time is wasted scanning those bloody linked lists then by checking the data. It's more likely that some sort of balanced binary tree will make it into the source.
  • Undefine macros or attributes: I do not consider undefining a clean concept, but a result of mental impotence.
  • Type checking for attributes: Anything more then the current (very relaxed) checking would not fit into the rather typeless concept if plain HTML.
  • Move around in text using $goto and $label: This one's perverted to the core.
  • Support other output-formats like texinfo or AmigaGuide: There are converters around for this task, and several people smarter than me have already failed to introduce the ultimate hypertext authoring tool.
*>
hsc-0.934.orig/docs-source/hsc.project0100600000175000001440000004313510010440007016525 0ustar loryusersHSC_PROJECT VERSION 3 # Contains all data relevant for project. # Maintained by hsc, DO NOT MODIFY! # updated: 05-Feb-2004 21:07:19 DOCUMENT ../docs/useÿ TITLE DOCUMENT ../docs/macro/flag.html SOURCE macro/flag.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/flag.html SOURCE macro/flag.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/flag.html SOURCE macro/flag.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/flag.html SOURCE macro/flag.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/flag.html SOURCE macro/flag.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/message-list.html SOURCE message-list.hsc TITLE ID message.1 ID message.2 ID message.3 ID message.4 ID message.6 ID message.7 ID message.9 ID message.10 ID message.11 ID message.12 ID message.13 ID message.14 ID message.15 ID message.16 ID message.17 ID message.18 ID message.19 ID message.20 ID message.21 ID message.22 ID message.23 ID message.24 ID message.25 ID message.26 ID message.27 ID message.28 ID message.29 ID message.30 ID message.31 ID message.33 ID message.35 ID message.36 ID message.37 ID message.38 ID message.39 ID message.40 ID message.41 ID message.42 ID message.43 ID message.44 ID message.45 ID message.46 ID message.47 ID message.48 ID message.49 ID message.50 ID message.51 ID message.53 ID message.54 ID message.55 ID message.57 ID message.58 ID message.59 ID message.60 ID message.61 ID message.62 ID message.63 ID message.64 ID message.65 ID message.66 ID message.67 ID message.68 ID message.69 ID message.70 ID message.71 ID message.72 ID message.74 ID message.75 ID message.76 ID message.77 ID message.78 ID message.79 ID message.81 ID message.82 ID message.84 ID message.85 ID message.86 ID message.87 ID message.88 ID message.89 ID message.90 ID message.91 ID message.92 ID message.93 ID message.94 ID message.95 INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/flag.html SOURCE macro/flag.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/questions.html SOURCE questions.hsc TITLE ID lha ID lha.corrupt ID unknown ID ignore ID pipe ID tool ID make ID slow ID uri ID piss ID jerk INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/options.html SOURCE options.hsc TITLE ID general.rules ID exitcodes ID from ID to ID extension ID ignore ID enable ID msgmode ID msgfile ID msgformat ID nonesterr ID nvcs ID define ID includedir ID prefsfile ID prjfile ID serverdir ID checkexternal ID getsize ID iconbase ID quotestyle ID entitystyle ID rplcent ID rplcquote ID lowercasetags ID xhtml ID compact ID stripbadws ID stripcomment ID stripexternal ID striptags ID help ID license ID -debug ID status INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/message-list.html SOURCE message-list.hsc TITLE ID message.1 ID message.2 ID message.3 ID message.4 ID message.6 ID message.7 ID message.9 ID message.10 ID message.11 ID message.12 ID message.13 ID message.14 ID message.15 ID message.16 ID message.17 ID message.18 ID message.19 ID message.20 ID message.21 ID message.22 ID message.23 ID message.24 ID message.25 ID message.26 ID message.27 ID message.28 ID message.29 ID message.30 ID message.31 ID message.33 ID message.35 ID message.36 ID message.37 ID message.38 ID message.39 ID message.40 ID message.41 ID message.42 ID message.43 ID message.44 ID message.45 ID message.46 ID message.47 ID message.48 ID message.49 ID message.50 ID message.51 ID message.53 ID message.54 ID message.55 ID message.57 ID message.58 ID message.59 ID message.60 ID message.61 ID message.62 ID message.63 ID message.64 ID message.65 ID message.66 ID message.67 ID message.68 ID message.69 ID message.70 ID message.71 ID message.72 ID message.74 ID message.75 ID message.76 ID message.77 ID message.78 ID message.79 ID message.81 ID message.82 ID message.84 ID message.85 ID message.86 ID message.87 ID message.88 ID message.89 ID message.90 ID message.91 ID message.92 ID message.93 ID message.94 ID message.95 INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/flag.html SOURCE macro/flag.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/attrib.html SOURCE macro/attrib.hsc TITLE ID type ID modifier INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/questions.html SOURCE questions.hsc TITLE ID lha ID lha.corrupt ID unknown ID ignore ID pipe ID tool ID make ID slow ID uri ID piss ID jerk INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/options.html SOURCE options.hsc TITLE ID general.rules ID exitcodes ID from ID to ID extension ID ignore ID enable ID msgmode ID msgfile ID msgformat ID nonesterr ID nvcs ID define ID includedir ID prefsfile ID prjfile ID serverdir ID checkexternal ID getsize ID iconbase ID quotestyle ID entitystyle ID rplcent ID rplcquote ID lowercasetags ID xhtml ID compact ID stripbadws ID stripcomment ID stripexternal ID striptags ID help ID license ID -debug ID status INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/message-list.html SOURCE message-list.hsc TITLE ID message.1 ID message.2 ID message.3 ID message.4 ID message.6 ID message.7 ID message.9 ID message.10 ID message.11 ID message.12 ID message.13 ID message.14 ID message.15 ID message.16 ID message.17 ID message.18 ID message.19 ID message.20 ID message.21 ID message.22 ID message.23 ID message.24 ID message.25 ID message.26 ID message.27 ID message.28 ID message.29 ID message.30 ID message.31 ID message.33 ID message.35 ID message.36 ID message.37 ID message.38 ID message.39 ID message.40 ID message.41 ID message.42 ID message.43 ID message.44 ID message.45 ID message.46 ID message.47 ID message.48 ID message.49 ID message.50 ID message.51 ID message.53 ID message.54 ID message.55 ID message.57 ID message.58 ID message.59 ID message.60 ID message.61 ID message.62 ID message.63 ID message.64 ID message.65 ID message.66 ID message.67 ID message.68 ID message.69 ID message.70 ID message.71 ID message.72 ID message.74 ID message.75 ID message.76 ID message.77 ID message.78 ID message.79 ID message.81 ID message.82 ID message.84 ID message.85 ID message.86 ID message.87 ID message.88 ID message.89 ID message.90 ID message.91 ID message.92 ID message.93 ID message.94 ID message.95 INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/distrib.html SOURCE distrib.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/flag.html SOURCE macro/flag.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/attrib.html SOURCE macro/attrib.hsc TITLE ID type ID modifier INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/questions.html SOURCE questions.hsc TITLE ID lha ID lha.corrupt ID unknown ID ignore ID pipe ID tool ID make ID slow ID uri ID piss ID jerk INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/options.html SOURCE options.hsc TITLE ID general.rules ID exitcodes ID from ID to ID extension ID ignore ID enable ID msgmode ID msgfile ID msgformat ID nonesterr ID nvcs ID define ID includedir ID prefsfile ID prjfile ID serverdir ID checkexternal ID getsize ID iconbase ID quotestyle ID entitystyle ID rplcent ID rplcquote ID lowercasetags ID xhtml ID compact ID stripbadws ID stripcomment ID stripexternal ID striptags ID help ID license ID -debug ID status INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/message-list.html SOURCE message-list.hsc TITLE ID message.1 ID message.2 ID message.3 ID message.4 ID message.6 ID message.7 ID message.9 ID message.10 ID message.11 ID message.12 ID message.13 ID message.14 ID message.15 ID message.16 ID message.17 ID message.18 ID message.19 ID message.20 ID message.21 ID message.22 ID message.23 ID message.24 ID message.25 ID message.26 ID message.27 ID message.28 ID message.29 ID message.30 ID message.31 ID message.33 ID message.35 ID message.36 ID message.37 ID message.38 ID message.39 ID message.40 ID message.41 ID message.42 ID message.43 ID message.44 ID message.45 ID message.46 ID message.47 ID message.48 ID message.49 ID message.50 ID message.51 ID message.53 ID message.54 ID message.55 ID message.57 ID message.58 ID message.59 ID message.60 ID message.61 ID message.62 ID message.63 ID message.64 ID message.65 ID message.66 ID message.67 ID message.68 ID message.69 ID message.70 ID message.71 ID message.72 ID message.74 ID message.75 ID message.76 ID message.77 ID message.78 ID message.79 ID message.81 ID message.82 ID message.84 ID message.85 ID message.86 ID message.87 ID message.88 ID message.89 ID message.90 ID message.91 ID message.92 ID message.93 ID message.94 ID message.95 INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/index.html SOURCE index.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/expressions.html SOURCE features/expressions.hsc TITLE ID operators ID not ID set ID defined ID exists ID fexists ID chr ID ord ID getenv ID getfilesize ID getgmtime ID gettime ID getfiledate ID basename ID extension ID urikind ID boolean ID priorities ID symref INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/about.html SOURCE about.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/project/make.html SOURCE project/make.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/examples.html SOURCE examples.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/future.html SOURCE future.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/copy.html SOURCE copy.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/project/hscpitt.html SOURCE project/hscpitt.hsc TITLE ID HELP=-h=?/S ID LICENSE/S ID command ID ARG/M ID prjfile ID QUIET/S ID FORCE/S ID -DEBUG/S ID NEW ID COUNT ID LIST ID ADD ID DELETE ID ERASE ID EXTRACT INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/getsize.html SOURCE features/getsize.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/strip.html SOURCE features/strip.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/teutsch.html SOURCE teutsch.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/others.html SOURCE others.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/install.html SOURCE install.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/if.html SOURCE features/if.hsc TITLE ID general ID simple ID nesting ID macros INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/source.html SOURCE source.hsc TITLE ID debug INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/exec.html SOURCE features/exec.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc INCLUDE exmpl/exec.hsc INCLUDE exmpl/exec.hsc DOCUMENT ../docs/features/syntax.html SOURCE features/syntax.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/assign.html SOURCE features/assign.hsc TITLE ID numconst ID expressions ID cond-assign INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/spcattr.html SOURCE features/spcattr.hsc TITLE ID anchor ID content ID opts-xhtml ID opts-entitystyle ID documentattr ID exec.result ID lf ID sourceattr ID system ID tmp ID colornames ID clickhere ID format.filesize ID format.time INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc INCLUDE exmpl/anchor.hsc INCLUDE exmpl/anchor.hsc DOCUMENT ../docs/ports.html SOURCE ports.hsc TITLE ID riscos ID nextstep ID amiga-ppc ID amixemul ID beos ID unix ID windoze ID msdos ID others INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/envvar.html SOURCE envvar.hsc TITLE ID home ID hscpath ID hscsalary ID http_proxy ID ftp_proxy ID gopher_proxy INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/fileargs.html SOURCE fileargs.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/rplcent.html SOURCE features/rplcent.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/uris.html SOURCE features/uris.hsc TITLE ID prjrel ID serrel ID abs ID id INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/project/prjfile.html SOURCE project/prjfile.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/project/index.html SOURCE project/index.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/checkuri.html SOURCE features/checkuri.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/macro/macros.html SOURCE macro/macros.hsc TITLE ID container INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc INCLUDE exmpl/macro_addr.hsc INCLUDE exmpl/macro_addr.hsc INCLUDE exmpl/macro_file.hsc INCLUDE exmpl/macro_cntnest.hsc INCLUDE exmpl/macro_cntnest.hsc INCLUDE exmpl/macro_cnt2nest.hsc INCLUDE exmpl/macro_cnt2nest.hsc INCLUDE exmpl/macro_next.hsc INCLUDE exmpl/macro_next.hsc INCLUDE exmpl/macro_locale.hsc INCLUDE exmpl/macro_locale.hsc DOCUMENT ../docs/features/prefs.html SOURCE features/prefs.hsc TITLE ID default ID search ID tags ID defent ID deficon ID deftag ID defstyle ID varlist INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/spctags.html SOURCE features/spctags.hsc TITLE ID comments ID content ID if ID depend ID include ID define ID let ID macro ID message ID stripws ID export ID expression ID dontparse INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/messages.html SOURCE messages.hsc TITLE ID elements ID classes ID msg_note ID msg_style ID msg_port ID msg_warn ID msg_err ID msg_ferr ID options ID ignore ID msgformat ID msgbrowser ID limit INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/bugs.html SOURCE bugs.hsc TITLE ID internal INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/project/hscpaltrow.html SOURCE project/hscpaltrow.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/related.html SOURCE related.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/updates.html SOURCE updates.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/project/makefile.html SOURCE project/makefile.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/require.html SOURCE require.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/usecases.html SOURCE usecases.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/author.html SOURCE author.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/project/hscdepp.html SOURCE project/hscdepp.hsc TITLE ID HELP=-h=?/S ID LICENSE/S ID file ID prjfile ID nameall ID VERBOSE/S ID NOBACKUP/S ID NOTAGLINES/S INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/undocumented.html SOURCE undocumented.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/features/css.html SOURCE features/css.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/message-list.html SOURCE message-list.hsc TITLE ID message.1 ID message.2 ID message.3 ID message.4 ID message.5 ID message.6 ID message.7 ID message.8 ID message.9 ID message.10 ID message.11 ID message.12 ID message.13 ID message.14 ID message.15 ID message.16 ID message.17 ID message.18 ID message.19 ID message.20 ID message.21 ID message.22 ID message.23 ID message.24 ID message.25 ID message.26 ID message.27 ID message.28 ID message.29 ID message.30 ID message.31 ID message.33 ID message.35 ID message.36 ID message.37 ID message.38 ID message.39 ID message.40 ID message.41 ID message.42 ID message.43 ID message.44 ID message.45 ID message.46 ID message.47 ID message.48 ID message.49 ID message.50 ID message.51 ID message.53 ID message.54 ID message.55 ID message.57 ID message.58 ID message.59 ID message.60 ID message.61 ID message.62 ID message.63 ID message.64 ID message.65 ID message.66 ID message.67 ID message.68 ID message.69 ID message.70 ID message.71 ID message.72 ID message.74 ID message.75 ID message.76 ID message.77 ID message.78 ID message.79 ID message.81 ID message.82 ID message.84 ID message.85 ID message.86 ID message.87 ID message.88 ID message.89 ID message.90 ID message.91 ID message.92 ID message.93 ID message.94 ID message.95 INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc DOCUMENT ../docs/changes.html SOURCE changes.hsc TITLE INCLUDE inc/html.hsc INCLUDE inc/macro.hsc INCLUDE inc/webpage.hsc INCLUDE ../CHANGES hsc-0.934.orig/docs-source/hsc.project_amiga0100600000175000001440000002446007642675506017722 0ustar loryusersHSC_PROJECT VERSION 2 # Contains all data relevant for project. # Maintained by hsc, DO NOT MODIFY! # updated: 21-Sep-1998 10:40:44 DOCUMENT 10 /docs/about.html SOURCE 9 about.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 17 /docs/project/make.html SOURCE 10 project/make.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 13 /docs/examples.html SOURCE c examples.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 11 /docs/future.html SOURCE a future.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT f /docs/copy.html SOURCE 8 copy.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 12 /docs/distrib.html SOURCE b distrib.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1a /docs/project/hscpitt.html SOURCE 13 project/hscpitt.hsc TITLE 0 ID b HELP=-h=?/S ID 9 LICENSE/S ID 7 command ID 5 ARG/M ID 7 prjfile ID 7 QUIET/S ID 7 FORCE/S ID 8 -DEBUG/S ID 3 NEW ID 5 COUNT ID 4 LIST ID 3 ADD ID 6 DELETE ID 5 ERASE ID 7 EXTRACT INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1b /docs/features/getsize.html SOURCE 14 features/getsize.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1a /docs/project/hscdepp.html SOURCE 13 project/hscdepp.hsc TITLE 0 ID b HELP=-h=?/S ID 9 LICENSE/S ID 4 file ID 7 prjfile ID 7 nameall ID 9 VERBOSE/S ID a NOBACKUP/S ID c NOTAGLINES/S INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 19 /docs/features/strip.html SOURCE 12 features/strip.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 12 /docs/teutsch.html SOURCE b teutsch.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 11 /docs/others.html SOURCE a others.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 12 /docs/install.html SOURCE b install.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 16 /docs/features/if.html SOURCE f features/if.hsc TITLE 0 ID 7 general ID 6 simple ID 7 nesting ID 6 macros INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 11 /docs/source.html SOURCE a source.hsc TITLE 0 ID 5 debug INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 18 /docs/features/exec.html SOURCE 11 features/exec.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc INCLUDE e exmpl/exec.hsc INCLUDE e exmpl/exec.hsc DOCUMENT 1a /docs/features/syntax.html SOURCE 13 features/syntax.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1a /docs/features/assign.html SOURCE 13 features/assign.hsc TITLE 0 ID b expressions ID b cond-assign INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1b /docs/features/spcattr.html SOURCE 14 features/spcattr.hsc TITLE 0 ID 6 anchor ID 7 content ID c documentattr ID b exec.result ID 2 lf ID a sourceattr ID 6 system ID 3 tmp ID a colornames ID 9 clickhere ID f format.filesize ID b format.time INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc INCLUDE 10 exmpl/anchor.hsc INCLUDE 10 exmpl/anchor.hsc DOCUMENT 10 /docs/ports.html SOURCE 9 ports.hsc TITLE 0 ID 6 riscos ID 8 nextstep ID 9 amiga-ppc ID 8 amixemul ID 4 beos ID 4 unix ID 5 msdos ID 6 others INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 11 /docs/envvar.html SOURCE a envvar.hsc TITLE 0 ID 4 home ID 7 hscpath ID 9 hscsalary INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 17 /docs/message-list.html SOURCE 10 message-list.hsc TITLE 0 ID 9 message.1 ID 9 message.2 ID 9 message.3 ID 9 message.4 ID 9 message.6 ID 9 message.7 ID 9 message.9 ID a message.10 ID a message.11 ID a message.12 ID a message.13 ID a message.14 ID a message.15 ID a message.16 ID a message.17 ID a message.18 ID a message.19 ID a message.20 ID a message.21 ID a message.22 ID a message.23 ID a message.24 ID a message.25 ID a message.26 ID a message.27 ID a message.28 ID a message.29 ID a message.30 ID a message.31 ID a message.33 ID a message.35 ID a message.36 ID a message.37 ID a message.38 ID a message.39 ID a message.40 ID a message.41 ID a message.42 ID a message.43 ID a message.44 ID a message.45 ID a message.46 ID a message.47 ID a message.48 ID a message.49 ID a message.50 ID a message.51 ID a message.53 ID a message.54 ID a message.55 ID a message.57 ID a message.58 ID a message.59 ID a message.60 ID a message.61 ID a message.62 ID a message.63 ID a message.64 ID a message.65 ID a message.66 ID a message.67 ID a message.68 ID a message.69 ID a message.70 ID a message.71 ID a message.72 ID a message.74 ID a message.75 ID a message.76 ID a message.77 ID a message.78 ID a message.79 ID a message.81 ID a message.82 ID a message.84 ID a message.85 ID a message.86 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 12 /docs/options.html SOURCE b options.hsc TITLE 0 ID d general.rules ID 9 exitcodes ID 4 from ID 2 to ID 9 extension ID 6 ignore ID 6 enable ID 7 msgmode ID 7 msgfile ID 9 msgformat ID 6 define ID a includedir ID 9 prefsfile ID 7 prjfile ID 9 serverdir ID 7 getsize ID 8 iconbase ID a quotestyle ID 7 rplcent ID 9 rplcquote ID 7 compact ID a stripbadws ID c stripcomment ID d stripexternal ID 9 striptags ID 4 help ID 7 license ID 6 -debug ID 6 status INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 13 /docs/fileargs.html SOURCE c fileargs.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 17 /docs/macro/attrib.html SOURCE 10 macro/attrib.hsc TITLE 0 ID 4 type ID 8 modifier INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1b /docs/features/rplcent.html SOURCE 14 features/rplcent.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 18 /docs/features/uris.html SOURCE 11 features/uris.hsc TITLE 0 ID 6 prjrel ID 6 serrel ID 3 abs ID 2 id INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1a /docs/project/prjfile.html SOURCE 13 project/prjfile.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 18 /docs/project/index.html SOURCE 11 project/index.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1c /docs/features/checkuri.html SOURCE 15 features/checkuri.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 17 /docs/macro/macros.html SOURCE 10 macro/macros.hsc TITLE 0 ID 9 container INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc INCLUDE 14 exmpl/macro_addr.hsc INCLUDE 14 exmpl/macro_addr.hsc INCLUDE 14 exmpl/macro_file.hsc INCLUDE 17 exmpl/macro_cntnest.hsc INCLUDE 17 exmpl/macro_cntnest.hsc INCLUDE 18 exmpl/macro_cnt2nest.hsc INCLUDE 18 exmpl/macro_cnt2nest.hsc INCLUDE 14 exmpl/macro_next.hsc INCLUDE 14 exmpl/macro_next.hsc INCLUDE 16 exmpl/macro_locale.hsc INCLUDE 16 exmpl/macro_locale.hsc DOCUMENT 15 /docs/macro/flag.html SOURCE e macro/flag.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1f /docs/features/expressions.html SOURCE 18 features/expressions.hsc TITLE 0 ID 9 operators ID 3 not ID 3 set ID 7 defined ID 6 exists ID 7 fexists ID 6 getenv ID b getfilesize ID 9 getgmtime ID 7 gettime ID 7 boolean ID a priorities INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 19 /docs/features/prefs.html SOURCE 12 features/prefs.hsc TITLE 0 ID 7 default ID 6 search ID 4 tags ID 6 defent ID 7 deficon ID 6 deftag INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1b /docs/features/spctags.html SOURCE 14 features/spctags.hsc TITLE 0 ID 8 comments ID 7 content ID 2 if ID 6 depend ID 7 include ID 6 define ID 3 let ID 5 macro ID 7 message ID 7 stripws ID a expression ID 9 dontparse INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 13 /docs/messages.html SOURCE c messages.hsc TITLE 0 ID 8 elements ID 7 classes ID 8 msg_note ID 9 msg_style ID 8 msg_port ID 8 msg_warn ID 7 msg_err ID 8 msg_ferr ID 7 options ID 6 ignore ID 9 msgformat ID a msgbrowser ID 5 limit INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT f /docs/bugs.html SOURCE 8 bugs.hsc TITLE 0 ID 8 internal INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1d /docs/project/hscpaltrow.html SOURCE 16 project/hscpaltrow.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 12 /docs/related.html SOURCE b related.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 12 /docs/updates.html SOURCE b updates.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 1b /docs/project/makefile.html SOURCE 14 project/makefile.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 17 /docs/undocumented.html SOURCE 10 undocumented.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 12 /docs/require.html SOURCE b require.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 13 /docs/usecases.html SOURCE c usecases.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 11 /docs/author.html SOURCE a author.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 10 /docs/index.html SOURCE 9 index.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 14 /docs/questions.html SOURCE d questions.hsc TITLE 0 ID 3 lha ID b lha.corrupt ID 7 unknown ID 6 ignore ID 4 pipe ID 4 tool ID 4 make ID 4 slow ID 3 uri ID 4 piss ID 4 jerk INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc DOCUMENT 12 /docs/changes.html SOURCE b changes.hsc TITLE 0 INCLUDE c inc/html.hsc INCLUDE d inc/macro.hsc INCLUDE f inc/webpage.hsc INCLUDE 8 /CHANGES INCLUDE 5 /NEWS hsc-0.934.orig/docs-source/html2ps.config0100600000175000001440000000176507642675506017202 0ustar loryusers/* * html2ps.config * * This is the configuration used to convert the manual of hsc * to Postscript */ @html2ps { header { /* Running page header */ odd-center: "$T"; /* Document title */ even-center: "$H"; /* Current main heading */ } footer { /* Running page footer */ center: "- $N -"; /* Page number */ } option { toc: h; /* Generate a table of contents, based on headings */ } showurl: 0; /* Show URL:s for external links */ seq-number: 1; /* Automatic numbering of headings */ toc { heading: "hsc - html sucks completely"; } } /* Standard style sheet definitions */ BODY { font-family: Times; } P { text-align: justify } H1, H2, H3, H4, H5, H6 { font-family: Helvetica; font-weight: bold; } H1 { font-size: 19pt; } H2, H3 { font-size: 16pt } H3, H5 { font-style: oblique } H4, H5 { font-size: 13pt } H6 { font-size: 11pt } ADDRESS { text-align: right } PRE { font-family: Courier; } hsc-0.934.orig/docs-source/index.hsc0100600000175000001440000003021310010154102016155 0ustar loryusers <$define Version:string="0.934"> <$define pre-release:string="0"> <$define release-date:string="04-Feb-2004"> <$define DESCRIPTION:string=("This is the documentation to hsc, a " +"developer tool for HTML projects. It acts as a preprocessor " +"and supports macros, expressions, conditionals, include files, " +" replaces special characters, performs a structure check, tests " +" existence of local links and several other things." +" Optionally it can keep track of documents being processed and" +" maintain the dependencies between them, making it relatively" +" easy to integrate it into existing developer environments." )> Hsc - Manual <* pseudo-navigation-bar *> ---- ----- Copyright -- -------- Next
<*************************************************************************** * * Contents of header * * This includes: * - silly quote * - headings * - version information * **************************************************************************>

Don't believe the hype
Take a look at the small print
Ignore the bold type
(Carter U.S.M, "Do Re Me, So Far So Good")

<* heading *>

Hsc

<* version info *>

(Version <(Version)> <$if cond=(pre-release<>"0")> (pre-release#<(pre-release)>) <$stripws type="both"> , <(release-date)>)

[german]Es gibt keine deutschsprachige Dokumentation.

Preface

About The Program

<(DESCRIPTION)>

..SUCK SUCK SUCK..

A current version of this program and manual should always be available from <(HSC.ANCHOR)>, both as hypertext (html) and printable (Postscript) document (well...don't count on the latter 8-) -mb).

<*************************************************************************** * * Contents of Postscript-version * **************************************************************************>

The version of the program described herein is version <(version)>, released <(release-date)>.

About This Manual

This manual was generated from the online documentation, however there are a few minor differences:
  • This first chapter looks totally different.
  • There is no tool-bar for navigation, as this apparently does not make sense in a printed document.
  • The table of contents is at the end of the manual - not because I think that is very smart, but because the conversion is easier for me that way. But as these pages are numbered using Roman digits, you can easily grab them and put them to the beginning of the manual without getting confused.
  • Several plain text files, like CHANGES, NEWS, but also some example scripts in , are not part of this manual, but can be viewed in the hypertext version by means of links.
  • Instead of images, you will only see their ALT-text. (Maybe I get this EPS-stuff to work some day, but do not count on it.)

As this is the first release with a printable manual, it might contain some quirks, where a specific rendering or a certain phrase does not make sense. Although I tried to avoid this of course - at least there should not be any shitty Click here!. If you feel like, you might considers these to be bugs and report them (with page number, please). Hopefully no whole chapters are missing.

To those who are now going to mock And it took you more than two years to convert the manual to Postscript? (the first public release of was in October 1995) I'd like to say: No, but it took more than two years for somebody to provide an at least rudimentarily bearable application to do this. See the chapter about Use-Cases for details.

(Can you imagine a w3-browser, where you can push Print all, and it automatically analyzes the document for stuff like LINK REL="next" HREF=.., gets all related documents and prints them in correct sequence? Can you imagine getting rid of these crappy html2insert-your-favourite-print-format-here converters? Even if you can, the browser developers can't. At least not in 1998, several years after this HTML-and-W3-disaster was initiated.)

Furthermore I have to admit that I never really read this flavour of the manual myself. Partially, because Ghostscript for Amiga has a painful user interface, therfore I just gave a glimpse to a few randomly selected pages.

Partially because I am a dedicated Postscript hater, as you can not do much with files in this format: you can not in search it, you can not quickly display it, you can not link around in it and you can hardly convert it to something more reasonable. — Hey, you can convert it to PDF! - Yeah, great! That changes everything.

And finally, because you will have to reprint most of it after the next release and throw away all the paper. — Who cares, I printed it for free at my university! - Oh really, and who pays back the tree they had to cut?

(Note for Americans: paper usually is made from trees. - Can't be, in my town we have a so called paper factory! - Oh, sorry for confusing you. Forget what I said.)

So this is dedicated to those who prefer to waste paper instead of bandwidth or disk storage,

<$let hsc.format.time="%B %Y"> Thomas Aglassinger
Oulu, <(gettime())>

<*************************************************************************** * * Contents of HTML version * **************************************************************************>

About The Program

Before You Begin

Usage

Features

Advanced Topics

Miscellaneous


<$let hsc.format.time="%d-%b-%Y">
Matthias Bethke (Matthias.Bethke@gmx.net) <(gettime())>
hsc-0.934.orig/docs-source/install.hsc0100600000175000001440000000757607642675506016575 0ustar loryusers This chapter will explain where all the files coming with the archive should end up. <*; it least for AmigaOS. For other systems, refer to .*>

AmigaOS

Because there is not much to do, there is no installer script. You will have to perform some simple steps the first time you install . If the descriptions below are not sufficient for you to figure out what to do, you do not want to use this tool anyway.

Simple Installation

It's recommended to leave the whole directory in one piece. Therefor extract the archive somewhere to your hard disk, for example to work:hsc.

You now have to add this directory to your workbench search path. This can be performed adding a line like the one you can find below to your user-startup
Path work:hsc ADD
After rebooting, you can open a CLI and type in hsc help, and should come up with a short information message.

Minimum Installation

For a minimum installation, only hsc and hsc.prefs are required. If you want to utilize the project management capabilities of , also and are needed.

Copy the binaries to somewhere in your workbench search path (for example, to c:) and anywhere else and set according to this.

Making It Resident

All binaries should already have the the pure bit set. If not, you can do this by entering

protect hsc/hsc add p
protect hsc/hscdepp add p
protect hsc/hscpitt add p

in CLI.

To make the binaries resident on every startup, add the lines

resident hsc
resident hscdepp
resident hscpitt

to the user-startup.

Important: For resident programs, PROGDIR: is not defined. You will have to take care that is able to find before it tries to scan PROGDIR: for it. This can be done by by setting the environment variable or by placing in the current directory for every project. Otherwise you will notice an annoying requester, which will ask you to insert volume PROGDIR: into any drive.

RiscOS

For the RiscOS distribution, you can find a file called ReadMe in the directory riscos explaining these details.

, AmigaOS/ixemul, BeOS, Unixoid Systems

Maybe you will have to compile the sources yourself. Refer to the chapter about the Source Code for details.

For installation, the first few lines of this are interesting for you. They define two symbols you might want to change. INSTALL specifies the install program to be used. Normally the default should be fine.

An exception of this is when you want to compile for AmigaOS/ixemul. In this case you maybe want to set INSTALL=/bin/install or otherwise sys:c/install will be used, which does a completely different job - it makes a disk bootable.

The default for INSTDIR will attempt to to copy the binaries to /usr/bin/ and some other data to /usr/lib/. This will only work if you have write access to these directories.

If you are normal luser, you can modify this symbol to for instance
INSTDIR = $(HOME)/
Make sure that you also have created $HOME/bin/ and $HOME/lib/ before starting the installation process. Or maybe you prefer
INSTDIR = /usr/local
because of philosophical reasons I never really understood. In any case, a
make install
should copy all files to the desired locations.
hsc-0.934.orig/docs-source/main_index.hsc0100600000175000001440000001115207701664167017220 0ustar loryusers<$include FILE="inc/macro.hsc"> hsc - HTML sucks completely - Support <*hsc - Another stupid HTML preprocessor*> ---- ----- Copyright -- -------- Next

hsc - HTML Sucks Completely

<$macro ArcH NAME:string/r> <(name)> (<(GetFileSize("../"+(name)))>) <$define MinorUpdate:string="">

..SUCK SUCK SUCK..

This is the support w3-page for , an HTML preprocessor. It provides both introductory and detailed information about the purpose and the usage of the program. You can also download the archives containing the current version or pre-releases and bugfixes (if there are any).

You can access this information at the following locations:

[Austria] <(HSC.Anchor)>

[Germany] <(HSC.ANCHOR)>

Current Version

The current version of is version 0.917 and should always be available from .
  • View for a short overview. <$if COND=(not (MinorUpdate))>
  • Documentation for more details
  • Download , the binary-archive for AmigaOS. This one includes binary, preferences and documentation in HTML format.
  • Download , the source-archive including the whole ANSI-C sources and the Makefile needed to compile all tools.
  • Download . This one includes the documentation in Postscript format and is only required if you want to print the manual.

Minor Updates

<$if COND=(MinorUpdate)> Version 0.917, pre-release#2 is now available. It contains some very experimental fixes and improvements. The archives below are only available from this support-page: <$else> Currently, there are no minor updates available. The archives below are identical to those available from Aminet:
  • Download - documentation and binaries for AmigaOS
  • Download - documentation and source code
  • Download - documentation in Postscript format

Additional Material

<*

In , there is a collection of shabby ARexx-scripts available which can be used to convert a DTD to . But better view <(hsc.Anchor)> before expecting too much from it.

*>
  • Download . This archive contains everything you need to use VBrowse, a public domain message browser by Volker Barthelmann, with hsc. It normally is part of the VBCC compiler distribution, the full archive can be obtained from .
  • Download , an Amiga port of GNUmake, includes binary and documentation in AmigaGuide format. You do not have to use this particular , but it is the one that works for me (at least most of the time). It supports Amiga filenames and does not required ixemul.library.
  • Download (84K) if you don't know how to cope with *.lha-files. This contains the sources for a portable version of lha. <*

    Users who are unfamiliar to make can download , which contains the manual to GNUmake in AmigaGuide format.

    *>

<$let hsc.format.time="%d-%b-%Y">
Thomas Aglassinger (agi@giga.or.at), <(GetTime())>
hsc-0.934.orig/docs-source/message-list.hsc0100600000175000001440000005666710010437422017501 0ustar loryusers" +"What happened to the attitude when you broke all the rules") QAUTHOR='The Farm, "Groovy Train"'> <$macro msg id:string/r name:string class:enum("note|style|port|warning|error|fatal") undoc:bool>
<$if COND=(undoc)>message <(id)>:
Unused or undocumented. <$else><$if COND=(class="style")>bad style <$elseif COND=(class="port")>portability problem <$elseif COND=(class="fatal")>fatal error <$else><(class)> <(id)>: <(name)>
<$MACRO insattr>attribute attrib <$MACRO insent>entity entity <$MACRO instag>tag <tag> <$MACRO insendtag>end tag <tag> <$MACRO insval>value value <$MACRO insid>id id <$MACRO inssval>value <*** insert quick-link to messages ***>

[ 1-10 | 11-20 | 21-30 | 31-40 | 41-50 | 51-60 | 61-70 | 71-80 | 81-90 | 91-.. ]

Below you can find a list of messages that can show up when processing hsc sources. Most of them also include a short explanation what could have caused the problem and how to fix it. However, this is not an HTML tutorial. Fully understanding these messages requires some experience from the user.

The project-file specified could not be opened. This indicates no problem if you specified a project file using for the first time; it will be created automatically after the HTML object has successfully been processed. The data found in the project file are not of the required format. Most likely, the file version is outdated. Remove the old file, will create a new one next time it is invoked. There are still characters to be read from input, but the file is already at the end; tells you what it still expected to read. On attempting to read from an input file, an error has occured. This usually is on a hardware level, and can only be fixed by one of those tools to validate and repair a disk structure common on every platform. There were more messages/errors than specified via MAXERR/MAXMSG. will abort. An input file could not be opened. A more detailed description that tells you why is displayed, too. Notifies user that a tag has been removed. This usually happens because the user requested this with one of the CLI-options. While looking for size information inside a picture file, found something about the format it could not understand. It is likely that this image is corrupted and will not display correctly in a browser, so this is considered an error. If you are sure the image is OK, you should mail it to the author to get fixed. A heading should not be more than one level below the heading which preceded it. That is, an H3 element should not follow an H1 element directly. The first heading showing up in a document should be H1. A keyword defined with the special attribute HSC.CLICK-HERE has been found within the text inside an anchor specification. I.e. you used some term like Click here inside the text describing a link. This is very clumsy and should be avoided; see Composing Good HTML or the W3C Recommendations for details. You refered to an unknown tag or macro. A tag that is expected to occure only once appeared at least twice. Remove all unneccessary occurences of the tag. You called a end-tag without using the corresponding start-tag before. A end-tag appeared where a different end-tag was expected to appear before. Example: instead of <$SOURCE PRE> bold and italic you should write <$SOURCE PRE> bold and italic Note the different location of /I in both cases. A tag that is required for every document is missing. You called an start-tag, but didn't end it. Insert the required end-tag. You have used an unknown modifier to define the characteristics of an tag or macro. You used an entity, that doesn't know. This can happen if you made a typo, or the entity has not been defined within . Entities require a to end them. For instance, if you try to use &uuml instead of &uuml; (to get an ü, this message will show up. Simply append the ; to fix it. You tried to access an attribute which has not been defined before. An attribute refers to a local resource (like another document or image) that doesn't exist. Common reasons for that are typos, a case-sensitive file system or indeed a missing file. You passed a value to an attribute, but did not embed it into single or double quotes. This can lead to problems with older browsers. An attribute refers to an attribute that has been defined, but no value has been set for. Usually, you try to refer to an attribute inside a macro, that no value has been passed to within the call of the macro. You have used an option to define the characteristics of an attribute, which is not allowed to appear at this location. Some browser support the non-html-tag BLINK. It is used to make text blinking, which annoys many users. Additionally, most of them don't know how to configure their browser that it doesn't blink, so you really should avoid it. You tried to assign more than one default value within an attribute declaration. For instance, like in <$source PRE> <$define HUGO:string="hugo"="or sepp?"> Remove the part corresponding to ="or sepp?". You tried to assign a new value to an attribute declared as constant. That is, the attribute option /CONST has been specified when defining it earlier. You tried to call outside any container macro. An anchor tag has been specified without one of the required attributes HREF or NAME. A greater than sign appeared inside the text. You should write "&gt;" instead. This can also happen, if you made an error calling a tag, and 's parser couln't recover. A syntax element did not occur where it has been expected. You tried to set an enumerator to a value it doesn't support.

An URI-attribute started with a (like for example /image/next.png), denoting a so called server relative URI. This is a really braindead concept, which might help to save a few bytes in your HTML object, but will make your documents unreadable if stored on your local disk, as they depend on a specific server structure.

Normally, is unable to validate links or obtain image sizes of data referenced using server relative URIs because of reasons that should be obvious to everyone.

If you because of some obscure reasons (or simply stupidity) insist on using URIs of such kind, you can set the CLI option to specifiy the root directory for server relative URIs.

The tag was defined within some old HTML version, but should not be used any more (eg. LISTING). This tag is no legal HTML tag and is only supported by special browsers. This text and class of this message can be controlled by the user using $message. The file could not be found at any of the expected locations. The function could not access the environment variable specified an returned an empty value. Non-boolean attributes require an value set. You defined a new attribute, but used an option that is unknown. An attribute that is required has not been set within the call of a tag or macro. This message can show up if you have specified when invoking , and have set the attribute WIDTH and/or HEIGHT by hand. It denotes that the values you have used differ from those has evaluated from the image data. Informs you that a special character (non-7-bit-ASCII) has been replaced by it's corresponding entity. A white space occurred at a place where it was not supposed to. The messages#48 to #50 point out problems that are known bugs of several browsers. A general comment on sgml-comments: Try to avoid them, use the * comment * tag instead. This message is active only if you specified a project file when invoking using the option . It tells you that a reference to an ID inside another document could not be checked because the document linked to is not mentioned in the project file.

Usually, this happens when you did not process the above mentioned document with a project file specified before. Do not worry about that too much, after processing all documents of your project at least once, this message usually does not show up any more.

If it still is there, then you are refering to documents that are part of none or another project using another project-file; if so, there is no work-around for this case. An $else tag has been at an unexpected position. Usually a single preceding $if has two or more corresponding $else tags assigned. You have invoked a shell-command using and it returned a value unequal to zero, which usually denotes an error while processing the command. For error analysis, look at the output that the command (hopefully) has made. This message often shows up, if you are not using an even number of hypens (-) as delimters inside your source. For example, <$source PRE> (8 hyphens) works fine, whereas <$source PRE> (9 hyphens) will cause problems. <* A sgml-comment consisting of a single word, for instance !--sepp--, has been detected. Note that there are no blanks preceding/succeeding sepp) *> An end tag has been detected without it's corresponding start tag occuring before. Icon-entities are not (yet) widely supported. You have just redefined a tag or macro that has already been declared before. The previous declaration will be thrown away. Before you are allowed to use the first tag, the second tag has to occur before. Example: INPUT may only occur inside FORM. A tag occurs inside another tag that does not allow this. For example, you can't recursively use A inside A. You tried to pass values to a end-tag or macro. If you need an attribute for a end-macro only, you still have to define and pass it within the start-macro; the end-macro will have access to all these attributes and its values. You redefined an alredy existing attribute. If this occures during the definition of a new macro, you just tried to give two arguments the same name. You have tried to use an attribute name which contains characters not allowed for that. Legal characters for attribute names are letters, digits, , and . Within an , you have used an binary operator that is not one of those mentioned in the list of operators. You tried to use a simple tag as a container, for example /IMG A tag that ought to appear is missing. could not determine the size of a link destination. Something is wrong with a or call. You have tried to strip one of 's special tags using the CLI-option . This does not make much sense, because all these tags will not show up in the output anyway. A numeric value must only consist of digits. Only integer values are allowed, therefor even a must not be used. A color value must fit the template #rrggbb or be one of the values declared in the special attribute HSC.COLOR-NAMES defined in You forgot to specify the ID mentioned using A NAME=.., or just made a typo. You tried to redefine an ID that has already been declared before within the current document. This message should need no comment; anyway, read Why Frames Suck (Most of the Time) or Why Frames Suck for more details. A icon-entity has been found is was replaced by an IMG. This message will only show up if you have passed the CLI option . See below. These two messages point out that instead of (read the ) as a blank)
STRONG__important__/STRONG
you better should use
STRONGimportant/STRONG

It only affects tags like A, TITLE, headings and physical/locigal styles.

This message might seem unreasonable, as according to the specifications for HTML readers such white spaces should be skipped. However, some browsers fail to do so. If a attribute value contains any characters other then letters, digits, or , it needs to be quoted. The quote style has been changed for a specific attribute. This message will only show up if you have passed the CLI option . A tag call contains an unknown attribute, which was not defined with the corresponding . This does not denote a serious problem, as HTML provides a vast selection of esoteric attributes and browsers usually ignore unknown attributes, but you should confirm you did not make a typo. A macro call contains an unknown attribute, which was not defined with the corresponding . As it would not make sense to pass unknown attributes to macros, this is considered an error. Look at the macro declaration which attribute you meant. After processing an with REMOVE enabled, the file could not be deleted. This can happen if you for example declared macros or opened container tags without closing them in the file created by an external command and included it afterwards; keeps a lock on files that might need to be referred to later in messages. This attribute is considered obsolete, most likely because its function should now be implemented using Cascading Style Sheets (CSS). You may still want to use it (and ignore this message) to stay compatible with older browsers. A tag with empty content model was not closed in XHTML mode. Tags that are not containers may be minimized to TAG / in XHTML. Actually, TAG/TAG would be legal, too, but doesn't support this, both for technical reasons and because the first form is both equivalent and shorter. The reason for not allowing the form TAG/ (note the missing blank!) is mainly a technical one, apart from the fact that it should be avoided so older browsers can deal with it. If you forget the closing slash in a tag such as br /, will complain about it with this message. This message shows up if you put any attributes after the closing slash in an empty tag in XHTML mode (see msg. #88 above), as in img src="foo.gif" / alt="bar". A STYLE attribute contained CSS specifications could not understand. There will usually be a message hinting at the reason (such as missing value) displayed with this message. A CSS property appeared more than once in a tag. This can happen when tries to merge several STYLE attributes into one, or if you specify a width or height property while running with the GETSIZE commandline option. A call was found that might not do what you wanted. Either you specified a RPLC code for an entity with a numeric code >255, or you tried to redefine an entity. Both may indeed be intended, in which case you should tell to ignore this warning. An external URI was found nonexistant, i.e. the server returned a 5xx or 4xx error code. An external URI was checked and could not be successfully retrieved, i.e. the server returned something that was neither a success nor an error code. This includes temporarily or permanently moved resources for which the server will issue a redirect. This can usually be ignored, but for best performance you should still check and possibly adjust your link. External URIs cannot currently be checked. On Unices, this is a fairly severe condition, as it means failed to create a network socket. On AmigaOS, it can simply mean you don't have bsdsocket.library and should get a TCP stack before asking to use one.

hsc-0.934.orig/docs-source/messages.hsc0100600000175000001440000002634207701664007016714 0ustar loryusers <$macro MSG_NOTE>Note <$macro MSG_STYLE>Bad-style <$macro MSG_PORT>Portability-problem <$macro MSG_WARN>Warning <$macro MSG_ERR>Error <$macro MSG_FERR>Fatal error

is able to produce lots of different warnings and errors when parsing hsc-sources. The are divided into several classes, and there is a possibility to filter out specific messages or whole message classes. There are also possibilities to change the appearance of messages and redirect them to a file, making it easy to integrate into existing developer environments.

Message Elements

For example, a typical message could be: <$source PRE>hugo.hsc (17,23): Warning 11: unknown tag with being..
  • ..hugo.hsc the name of the input file that caused the message.
  • ..17 and 23 the position in input file. 17 denotes the line, and 23 the column of the item that caused the message
  • ..Warning the message class. There are several other messages classes: , , , or . See below for details about those message classes.
  • ..11 the number of the message. You can use this to quickly find the description in the list of message or to suppress it in further runs using .
  • ..unknown tag <SEPP> the message text, which describes what went wrong.

The message about would suggest to load the file hugo.hsc in your editor and go to line 17, column 23.

Message Classes

Note is a message only for the user's information. It can be suppressed using .

Bad-style informs the user that his although legal HTML code includes constructs that indicate a bad style. It can be suppressed using .

Portability-problem informs the user that his although legal HTML code includes constructs can lead to problems on old or buggy browsers. It can be suppressed using .

Warning tells you that your source includes some problematic parts that can lead to problems with several browsers. It can be suppressed using .

Error indicates that there is something wrong with your HTML source. Conversion will continue, but no output will written be written after finishing it.

Fatal error tells you that something serious is wrong and there is no way for to recover and continue the conversion. No output will be written.

There is also another class called internal error messages, which are used by to report that hsc itself is broken. Normally this should not happen, but if you found a bug. To find out more what to do in such a case, look at the chapter about .

Message Options

There are several CLI options to modify the behavior of 's messages. You can suppress messages you are not interested in, you can redirect them to a file and change the output format (e.g. to pipe them to an external message browser). On some systems, you can even send them to some selected message browsers without messy piping and scripting.

Ignore/Enable Certain Messages and Classes

If you think that reports too much or too less about problems in your source code, you can specify several options to change its behavior.

The first one - and also the one with the most impact - is MSGMODE. This switches into one of three possible basic modes for the syntax check:

  • PEDANTIC - Whine about nearly everything, including the whole bunch of bad style and portability problems. Also minor changes to the output like the replacing of entities is reported in this mode.
  • NORMAL - This is the default that should give a reasonable cocktail of messages, reporting most problems the average users should understand.
  • RELAXED - Perform only a very basic check and ignore nearly everything that might cause problems. This should only be used if you do not care much about your HTML code (Read: you are a jerk).

These modes however give only very rough possibility to control the amount of messages. For the fine-tuning, the more sophisticated IGNORE and ENABLE exist.

Unless MSGMODE=NORMAL is ok for you, you have to specify MSGMODE in the command line before IGNORE or ENABLE is used the first time as it resets several of the internal data structures.

IGNORE can be used to suppress single messages or whole message classes, if you are not interested in them. This option can show up in the command line call multiple times, for example:

IGNORE=18 IGN=21 IGN 22 - ignore warnings #18, #21, #22

You can also specify a whole list of messages, separated by a , for instance:

IGNORE=18|21|22 - same as the above example

(If the vertical bar is used as piping character, you have to quote this value: IGNORE "18|21|22")

There are some special, non-numeric values you can use to ignore whole groups or classes of messages:

  • ALL - Ignore all non-error messages
  • JERK - Ignore all stuff perpetrated by jerks only
  • NOTE - Ignore all notes
  • PORTABILITY - Ignore all portability problems
  • STYLE - Ignore all bad style warnings

If you don't care about portability problems and some other messages, but still want to have a quite exhaustive check, you could use something like this:

MSGMODE=pedantic IGNORE=portability|46|51

If on the other hand you are quite satisfied with the NORMAL check but want to see one particular message (e.g. replaced icon entities), this should do the trick:

MSGMODE=normal ENABLE=77

You can combine these options to even more complex rules:

MSGMODE=pedantic IGNORE=note ENABLE=77

This first enables all messages, then disables all notes but finally enables again one specific note for .

To find out the number of a certain message to enable, look at the list of messages. To ignore a message, simple get the number from the console once an unwanted message shows up the first time.

Redirecting Messages and Changing the Message Format

MSGFORMAT specifies the appearance of messages, for example concerning the sequence of the elements described before. The message format can contain several placeholders that are replaced by the message elements described above:
%f filename
%x, %y location in file (column, line)
%c message class
%i message id (numeric)
%m message text
%n inserts a linefeed
%% inserts percent sign (%)

To for example get GCC-like messages, use MSGFORMAT="%f:%y: %c %i: %m".

To disable output to the console, specify an empty string: MSGFORMAT=. This is probably useful only if you use a message browser (see below).

MSGFILE can be used to redirect messages to a file, from where they can be processed for example by some message parser that controls your editor.

For an example script that invokes hsc, redirects its messages and sends them to a message browser, see grafflwerk/hScMsg.rexx.

Using a Message Browser

By default, writes messages to the console where it was started from. For the user this means to read the filename and position, switch to his editor and go to the line told. Because this is pretty troublesome, many people use message browser where all messages are listed nicely sorted by file. Clicking on a message puts the editor to front and makes it jump to the requested position.

With the CLI-option MSGBROWSER you can specify one of the following browsers (case insensitive):

  • ScMsg: The message browser coming with the SAS/c compiler for AmigaOS. As ARexx is used to communicate with the browser, RexxMast has to be running. The browser is expected to be in sc:c/scmsg and will be started automatically if it is not already running.
  • VBrowse: This uses public domain VBrowse message browser for AmigaOS coming with the freely distributable VBCC compiler. On the hsc support page there is an archive containing this browser and describing how to use it together with . But you better keep your expectations low - keep in mind that it is public domain and the compiler is the main application of this package.
  • ThrowBack: This uses the throwback mechanism popular under RiscOS.
  • ANSI: This is no browser but only uses some ANSI codes when sending the message to the console. Your console has to support ANSI escape sequences (most do nowadays). This is only useful if you can not find any more comfortable way to read the messages.

So to to use ScMsg, specify MSGBROWSER=SCMSG, for throwback set MSGBROWSER=Throwback.

If you specify a message browser on a system that does not support it, e.g. attempting to Throwback under NeXTStep, no browser will be used. That means you do not have to change your if you want to work on another system for a short time.

Note that status messages and non-input related error messages are still viewed in the console.

Limiting Messages

By default, stops to parse once more than 40 messages or 20 errors have show up. In such a case, you should either start to messages or fix errors.

If you don't like these numbers, you can change them using MAXMSG respectively MAXERR. The value 0 represents an "infinite" amount of messages.

Note that nested messages with all those location of previous call texts still count as one, independent of the nesting level.

hsc-0.934.orig/docs-source/options.hsc0100600000175000001440000004331607771767271016616 0ustar loryusers" +"forearm, thumb, wrist, knuckle, palm
" +"middle, pinky, index, ring
" +"dinner bell dinner bell ding") QAUTHOR='They Might Be Giants, "Dinner Bell"'> <* ** macro to format an explanation *> <$MACRO explan /close TITLE:string/r NAME:string ONLYDEFTAG:bool> <** create named reference **>
<$stripws> <$IF COND=(SET NAME)> <$ELSE> <$stripws> <(title)> <$IF COND=(ONLYDEFTAG)> (for use within only)
<$content>
This chapter explains which options and switches you can pass to , and which exit codes it might return to the shell. For easier understanding, related options are collected in groups.

Although for most descriptions there are short examples available, this is intended to be a reference only. For several options, you can find more detailed explanations in other sections of this manual.

General Rules For Options

As is an tool developed under AmigaOS and I never liked the cryptic "cmd -cvf -osepp.x"-way of invoking commands coming from Unix, uses a syntax like most commands of AmigaOS; even for ports on other operating-systems. ( AmigaOS provides an OS-function called ReadArgs() for argument-parsing.)

All options and switches are case-insensitive. If you start without any options, a short help message will be displayed.

Options can be followed by modifiers, which specify things such as the type of the option. Modifiers are specified by following the option with a '/' and a single character modifier. Multiple modifiers can be specified by using multiple '/'s. Valid modifiers are:

/S - Switch.
This is considered a boolean variable, and will be set if the option name appears in the command-line.
/K - Keyword.
This means that the option will not be filled unless the keyword appears. For example if the template is Name/K, then unless Name={string} or Name {string} appears in the command line, Name will not be filled.
/N - Number.
This parameter wants a decimal number. If an invalid number is specified, an error will be returned. <* /T - Toggle. This is similar to a switch, but when specified causes the boolean value to "toggle". Similar to /S.*>
/A - Required. (think: ``Always''!)
This keyword must be given a value during command-line processing, or an error is returned. <* /F - Rest of line. If this is specified, the entire rest of the line is taken as the parameter for the option, even if other option keywords appear in it.*>
/M - Multiple strings.
This means the argument will take any number strings. Any arguments not considered to be part of another option will be added to this option.

Exit Code

The exit-code returns to the shell depends on the messages and errors that have been displayed during runtime.

The version for AmigaOS returns

  • 0 on success,
  • 5 if warnings occurred,
  • 10 if errors showed up (also for errors in arguments) and
  • 20 if fatal errors happened (also for out-of-resources).
For other systems, values like 0/0/1/2 are used instead.

Specifying Input and Output

Specifies the input filename. To use as input file, the pseudo filename STDIN (case sensitive) should be specified, or alternatively the unixoid -. If you specify more than one file, the last file is taken as main source, and all previous files are included before it. This is useful to include macro-definitions within the command-line instead of an in the hsc-source. Specifies the output filename or the destination directory. If the argument ends with a "/" (or also ":"), it is interpreted as a directory. In this case, the name of the output file is created from the name of the input file, with an extension specified (see below). If no output file is set, is used instead.
For details, read the section about File Options
If you specify a directory for output, the output-filename will depend on the input-filename and the extension specified with this options. If you do not set an extension, html will be used. A will be added automatically. Setting EXTENSION=. will omit this and result into exactly the same filename as the input. If you specify a complete filename for output, this option has no effect.
<**************************************************************************>

Message Options

<**************************************************************************>
Ignore message number or class. Usually, IGNORE needs a numeric argument and can occur multiple times in the command line. Additionally, you can specify some special values, which will ignore whole groups of messages: ALL, NOTE, STYLE, PORTABILITY and JERK. See Ignore/Enable Certain Messages and Classes for more information. This is the opposite to IGNORE and can be used to enable certain messages. You can also use the same special values as with IGNORE. See Ignore/Enable Certain Messages and Classes for more information. Set base mode for syntax check. Legal values are PEDANTIC, NORMAL and RELAXED. Default is NORMAL. See Ignore/Enable Certain Messages and Classes for more information. Redirects messages to a file. By default, is used. See Redirecting Messages and Changing the Message Format for more information. Describes how messages should be displayed. See Redirecting Messages and Changing the Message Format for more information. Suppresses the location of last call messages that usually provide a traceback when errors/warnings are displayed. If you use deeply nested macros, these confuse more than they clarify, so you can use this switch to see only the place where an error was detected. Disables the checking of CSS style specifications. See CSS support for further information. In XHTML mode, CSS checking cannot be disabled, trying this will yield a warning.
<**************************************************************************>

Configuration

<**************************************************************************>
Defines a global attribute. The syntax is equal to , exept that you need no quotes surrounding the value.
Example: DEFINE "hugo:string=hugo was here"
By default, only the current directory and the main source's directory are scanned for files to be included (using the commandline option or the special tags or ). This option adds a directory to the list of directories to search for include files. Specifies filename for sytax-definition to be used, if you don't want to use the defaults. Stores some information about the document currently processing in a seperate file to extend functionality. Read the section about Project management for more details. Note that all documents within a project should use the same project-file. With this you can tell where it should look for files referenced with a server relative URI. The directory has to be specified as a native filename of your OS. Example: SERVERDIR=aws:home might work fine under AmigaOS, SERVERDIR=/user/sepp/public_html could be used on an Unixoid system. In times of always-on internet connections it might seem a little anachronistic to check only local URIs for existence. Using this switch, you can enable external URI checking for HTTP, so will actually ask the remote server for any document you reference. This can and will tremendously slow it down, but for a final run before upload it can be worth the time.
So far, only speaks HTTP. However, proxies are supported via the the same environment variables as in Lynx: http_proxy, ftp_proxy and gopher_proxy. So if you can use a proxy, you can even check URIs of the latter types.
<**************************************************************************>

Options Affecting The Output

<**************************************************************************>
Get width and height of images and set corresponding attributes WIDTH and HEIGHT with these values. Replace all icon entities by images that must be available from the base URI specified. If this URI contains an , it will be substituted by the icon name. For example, with ICONBASE=:icons/*.gif, the entity &back; is replaced by IMG SRC=":icons/back.png" ALT="back". Note that this argument does not denote a directory, but an URI. It's recommended to use a . Specifies which kind of quotes should be used to surround attribute-values. KEEP keeps the kind found in the source, DOUBLE tries to assign double quotes (eg. "value"), SINGLE tries to assign single quotes (eg. 'value') and NONE will remove quotes if possible.
In XHTML mode, only double quotes are permitted. DOUBLE is also the default unless something else is specified.
Sets the rendering of entities either found in the source or generated using RPLCENT. The following styles are possible:
KEEP
Keep entities as they were found in the source. If entities were generated from hi-ASCII characters (see RPLCENT), they will be in the symbolic form, unless their entity definition says otherwise.
REPLACE
Replace entities with the form their definition says is preferred.
NUMERIC
Always render entities numerically.
SYMBOLIC
Always render entities symbolically.
UTF-8
Don't write HTML entities at all, except for &lt;, &gt;, &quot; and &amp;, but write UTF-8 text. This applies to both entities found in the source and replacements for hi-ASCII characters. You must declare the UTF-8 charset in a META tag, otherwise most browsers would assume it to be Latin-1 and render it incorrectly.
For automatic detection of the entity style currently used, defines the Hsc.Opts.Entitystyle variable.
Replace special characters with their entities. For instance, ü turns into &uuml). Replace double-quotes (") found in the text by &quot;. This does not affect quotes used inside attribute-values. There are many different conventions for tag case that people find convenient. As it didn't matter for HTML, that was fine. For XML it does. Even if you are not writing XHTML, you can force your tags and attributes to lowercase with this switch, and keep your tagging idiom and your old macro files as they are. XHTML introduces some new conventions that are incompatible with HSC's usual opinion about correct HTML:
  • Boolean attributes must not be minimized. I.e. it's hugo resi="resi" now, instead of hugo resi.
  • Empty tags may (and, to reduce bogosity and waste of bandwidth, should) be minimized to a form like hugo/, or, to stay compatible with older HTML browsers, hugo / (note the space!). With the trailing-slash-recognition being a bit of a hack, HSC supports only the latter form, i.e. with space.
  • All tags and attributes must be lowercase.
There are probably other criteria that I forgot, but this is what HSC enforces so far if you set this switch.
<* Replace special characters &, < and > with their entities (&amp;, &lt; and &gt;) if they are surrounded by white-spaces.*>
<**************************************************************************>

Stripping Data From The Output

<**************************************************************************>
Strip redundant linefeeds and white-spaces from output. Strip bad white spaces that would have caused or ; this will not strip those which cause . The main advantage of this switch is that it allows you to write well structured macros. Strip all SGML-comments from input. Strip tags which refer to an external URI. Strip some specific tags from document. You can specify a list of tags which is a string, that contains all tags that should be stripped, separated by a .
See also and .
<**************************************************************************>

Miscellaneous Options

<**************************************************************************>
Display a short help message and exit. Display a short version of the GNU General Public License and exit. If you've compiled in debug-mode, it will send lots of information to . Otherwise, this option is equivalent to STATUS=FULL. Display several status messages (output goes to stderr). Legal flags are:
  • QUIET: no status messages
  • LINE: display name and line of file currently processing. Names of files included are also displayed. After processing a file, the filename and the total number of lines remain visible.
  • VERSION: display program title and version
  • VERBOSE: enable verbose status messages; this includes the information displayed during the processing of and some details about images, if has also been enabled.
  • FULL: enable all status messages
The above flags can be combined by separating them with a , eg "STATUS=line|version", except for QUIET and FULL
<* vi: set ts=4 et: *> hsc-0.934.orig/docs-source/others.hsc0100600000175000001440000001171107642675506016415 0ustar loryusers

As HTML has turned out to be incredibly useless very soon, many people have written several extension trying to reduce this uselessness. Most of them only increased it. However, this will shortly comment on some of these extensions, and how you can use them together with .

General Comments

When you process a page with , there is no way to change any data of the HTML object after it has been created; only does a static job. Many of the extensions described below allow documents or parts of them to be created dynamically. But then you will have to care about several security problems.

Most of these concepts integrate themselves into HTML in a fairly clean way (usually by means of sgml-comments). For others you will need to utilise to make accept them. If this still does not help, there is no way to use a specific extension together with . There definitely will not be built-in support for any of these extensions.

This chapter does not pretend to describe all of them, but most suggestions provided here should also work with most others extensions. You also will not find any information about where to obtain these tools from. Ask your favourite w3-search engine for details.

Server Side Includes

Server Side Includes (SSI) are one of the oldest extensions for w3-servers. An example command would be <$source PRE> which more or less does the same as <$source PRE><(GetGMTime())>

in , with the difference that the ssi-version will be executed every time one accesses the page.

As the SSI-call is done inside a sgml-comment, will not care about it and simply skip it. Only make sure you did not set the command line option . The sgml-comment will be substituted by your server later (if it supports SSI).

Usually SSI-operations result in an increased CPU-load of your server, as they have to be performed every time one accesses the page.

Common Gateway Interface

Most w3-servers also support the so called Common Gateway Interface (CGI). This is just the simple capability to return the output a program wrote to as w3-page. CGI-programs are usually unreadable and unmaintainable Perl-scripts more or less entirely consisting of statements like <$source>printf("cool script..").

Ill-minded people could think about invoking inside a CGI-script. I do not recommend this for several reasons that should be obvious.

JavaScript

JavaScript has been developed to show scrolling messages on your pages. It should have been named ScrollerScript, but as it came out more or less at the same time when the hype on a programming language called Java (poor man's SmallTalk raped by C++ which is expected to solve all problems of the world, including traffic, pollution and AIDS) started, its creators decided to use the term Java in it's name, too.

Scripts implemented in a clean way like <$source PRE> should not cause problems, as they are also embedded inside sgml-comments like ssi.

Personal Home Page Tool/Form Interpreter

The Personal Home Page Tool/Form Interpreter (PHP/FI) started as a messy Perl-script acting as some simple CGI-wrapper. As time passed, it grew to a inflated and inconsistent moloch providing a simple programming language inside HTML-documents. It also supports things like embedded SQL, and some people with other presuicidal syndromes even use it as a plug-in with their w3-server.

The syntax does a very good job on combining the drawbacks of C with the disadvantages of Perl, in general resulting in a completely unreadable sequence of seemingly random characters. Therefore, it became quite popular among Unix-fossils. For example, one could have this line in a source code:

<$source PRE>"> If you pass this to , it will not be very happy about it. However, you can use to include PHP/FI-stuff: <$source PRE><|">|> If you want to access data of into your PHP/FI-section, it will become a bit tricky. But with even this is possible: <$source PRE> <$define Name:string="Sepp"> <( '<|' + '' + '|>' )> will temporarily result in <$source PRE><||> and after being processed by a <$source PRE>

will show up in the HTML object. If you are really sure that code like the above will not significantly reduce your life expectancy, do not hesitate to use it. But if you use PHP/FI, you apparently are sure about that.

hsc-0.934.orig/docs-source/ports.hsc0100600000175000001440000001506007771031421016242 0ustar loryusers <*Designed for Nothing Specific*>

As is cryptic to use, has no graphical user interface and does nothing else apart from reading an input file and output to another one, it is quite easy to port it to other systems, as long as they support some sort of command line interface and a decent C-compiler.

This chapter describes existing or planed ports and what are the differences to the version for AmigaOS. Currently ports exist for RiscOS, , AmigaOS with PowerPC, AmigaOS with ixemul.library, BeOS, Windoze and Unixoid systems (including MacOS X).

RiscOS

The port to RiscOS has been done by Sergio Monesi and Nick Craig-Wood. For details, please refer to . Basically, it acts like the version for (see below), although you will have to use a special tool.

Searching For Syntax Definition

When searching for the , will look for the file you've specified using the option . If you did not specify any, it will search the
  • current directory
  • directory you have specified using
  • directory specified in the environment variable , with a lib/ added.
  • directory /usr/local/lib/
  • directory /usr/lib/
for a file named . If one of these directories does not contain a or does not exist at all, will silently proceed with the next one on this list.

Exit Code

On notes/warnings/errors/fatal errors showing up, will return an exit code of 0/0/1/2.

AmigaOS with PowerPC

There is a port available that compiles with SAS/c. However, this was only done to show that it is possible. Although no changes to the code are necessary, currently nobody maintains this version so the executable might be slightly outdated. Concerning the pathetic mess which link format to use: it is the one from p5.

You can find the binary in , so you still need the normal archive for the documentation.

AmigaOS with ixemul.library

Most GNU-tools have been ported to AmigaOS using an additional library called ixemul.library. It is quite successful in turning an Amiga in a moldy and dribbling Un*x-box, emulating all those idiotic things like the .. and /bin pretty shitty well. Of course you can also use with it.

But if you prefer to rape your machine, you have to compile it yourself using the gcc-port from GeekGadgets. If you don't know what I'm currently talking about, you don't want to do this anyway. Actually the binary of included in the archive for AmigaOS is able to deal with native filenames and system directories, so why bother?

BeOS

It has been reported to work. You should be able to compile it with mwcc. It acts similar to the version for .

But currently no one takes care about this port, and I never tried it out myself. So there might be problems with newer versions of this OS or the mwcc compiler. Most likely there are more compiler options that could be specified for better code.

Unixoid Systems

This version acts similar to the one for . There should be no problems compiling HSC out-of-the-box, since it has ben developed mainly on Linux since V0.918. HSC has been successfully used on at least [Mk]Linux, NetBSD, IRIX, HP/UX and Solaris.

MacOS X, as the first of Apple's systems to feature a decent commandline shell (unless you want to call the Apple-II's decent, which I don't), has no problems running and compiling HSC. To compile, you need the Developer Tools (gcc, GNU make etc.) available by FTP from Apple. For obscure reasons, the OSX linker doesn't like HSC to be stripped of symbols with the -s switch, it wants -x. Otherwise the procedure is the same as for other Unixoids.

Windoze NT

Yes, HSC compiles under Windoze, at least under NT. Options for M$ VC++ are included in the Makefile. It is not recommended to use this system for HSC, but if you really have to, by all means stay away from Frontpage(tm), GoLive!(tm), Dreamweaver(tm) and similar abominations and go for HSC.

MS-DOS Based Systems

Anything running off a crippled 8.3-format filesystem is out of the question. These systems should have been trashed 20 years ago and I will certainly not call a .pref-file anything like .prf or .ini just because this junk doesn't run HSC. It might be possible to compile HSC on W32-based systems using FAT32, but I trust people still using them are not the types who'd want HSC anyway. And that's a Good Thing.

Other Systems

Ah, well, there are still systems without .

For MacOS, I don't don't have a compiler and maybe one will have to write a GUI. Internally is not designed to be used from command line only. If you take a look at the main() of source/hsc/hsc.c, you will see that it's only about ten lines of code. However, you will need to find a tool to do the project management - or integrate this part into your GUI. And that's probably where it starts to get tough...

Atari TOS counts as MS-DOS based (see above), especially the filename limitations.

For C64/C128 is too slow and bloated, which of course is my fault. I'm pretty sure one could do a decent -alike program on these machines.

Several other systems should have no trouble compiling the same way as for Unixoid systems or AmigaOS with ixemul.library. It mostly depends on the C-compilers available. Systems like VMS (I was told it's still in use in its incarnation for Alpha CPUs) with weird path separators and other niceties to keep programmers busy will probably need a few #ifdefs in places where there are a few already.

hsc-0.934.orig/docs-source/questions.hsc0100600000175000001440000002040107701661416017126 0ustar loryusers" +"Everything's fine but I just can't see") QAUTHOR='Element of Crime, "Almost dead"'> <$MACRO QUEST NAME:string> <$if COND=(SET NAME)> Q:<$if COND=(SET Name)> <$MACRO ANSWR>A: <* define shortcuts for question-text *> <$macro Q.lha>What about those strange .lha files? <$macro Q.lha.corrupt>I've downloaded the .lha-archives using my WWW-Browser, but they seem to be corrupt?! <$macro Q.lha.why>Why .lha at all?! <$macro Q.unknown> doesn't know about the tag XYZ (the attribute ZYX), but I need this one! <$macro Q.ignore> tells me loads of warnings I don't care about! Is there a way to prevent it from doing this? <$macro Q.pipe>I tried a STATUS=line|verbose in the CLI, and now can't find the verbose command?! <$macro Q.tool>Somewhere in these manual You are talking about a tool called make/weblint/... Where can I obtain it from? <$macro Q.make>I have a problem with make: bla sülz fasel laber... <$macro Q.slow>Why is that slow? <$macro Q.uri>Why do You call it URI? I thought it's URL (Universal Resource Locator or U R lost)? <$macro Q.piss>But URI reminds me of pissing! Add a simple n, and there we are! <$macro Q.jerk>What are jerks?

This chapter provides a list of questions and answers which have come to the mind of several people. Some of them are only necessary because many users don't read this manual, some of them are not very serious,.. but anyway, here's a list of them:

Questions dealing with the archives
  • <*
  • *>
Questions about and it's usage
Miscellaneous questions


LHA is the standard compression utility for AmigaOS. A portable version of lha is available from .


Seems that your browser has no MIME-type configured for .lha. Look up the manual of your browser how to configure MIME-types.

<*


Of course I know that .lha-archives can cause trouble to non-Amigoids. You should understand this as test for your IQ being sufficient to deal with . People who are not even able to compile the portable version of LHA mentioned above (or find a already compiled one for their OS on the net) very probably won't be able to compile and use . You are allowed to feel insulted now.

*>


Read the chapter about Syntax definition and how to extend it.


All non-error messages can be suppressed adding a simple IGNORE=message_id to the call used to invoke . Take a look at the chapter about Options and switches to find out more.


The is commonly used in several CLIs to pipe the output of one program to another as input. Not under AmigaOS (at least not without a patch), which is no real lack as it provides superior concepts like ARexx. So that's the reason why I didn't care about this.

If you want to use this character inside arguments (like for STATUS) in such a CLI, you will have to quote the value, for example like STATUS="line|verbose".


All tools mentioned within these documents should be denoted in the chapter about Related stuff (if not, let me know). Normally I only mention the version for AmigaOS, but the archives or ReadMes usually include some notes where to look for other systems.


Refer to the manual of . Make sure your supports implicit rules and conditionals as described within these documents. Make sure your editor does not replace TABs by blanks (use memacs, which came with your Workbench distribution, if you are not sure).


One reason is, that handles (nearly) all resources dynamically (That means, it often calls malloc() and free(), which are known to be quite slow).

Another, quite embarrassing, reason is, that most of these resources are kept in linked lists. And therefor, if has to look for something, it sequentially searches these list. Shame on me, I should use some sort of balanced binary tree for such things.

But the problem with balanced tree is: though there are lots of sources around, most of them are perverted real C-sources perpetrated by some brain-dead Unix-fossils, ignoring the fact that memory can run out or that there is a -Wall option in most compilers; some of these sources also date back to 1863, when no one even pretended there is a language definition for C.

Meanwhile I'm too lazy to change anything, but if you are interested in the source code for a quite well done tree implementation, check out the Ubiqx library available from <(hsc.anchor)>. If it would have been around in 1995, I would have used it.



Ok, put a finger into your mouth and try to reach as far inside as possible. After some specific point, you will empty your stomach. And what do you say then? Exactly, URL! So the main reason why I do not like the term URL is because it always reminds me of puking.

Additionally, the Internet-Draft for HTML 2.0, June 16, 1995, tells you:
    URI
            A Universal Resource Identifier is a formatted string
            that serves as an identifier for a resource, typically
            on the Internet. URIs are used in HTML to identify the
            destination of hyperlinks. URIs in common practice
            include Uniform Resource Locators (URLs)[URL] and
            Relative URLs [RELURL].
And one of the users of submitted this interpretation to me:
    To me it seems:

    URI = URL and RELURL
    URL = "http://www.intercom.no/~XXXXXX/index.html" - always the same doc
    RELURL = "docs/about.html"  - relative to which dir/machine you are on

Anyway, I really like that term URI a lot more and I've never really understood what's the difference between URL and URI. But who cares anyway?


..which I personally prefer to puking. Certainly a matter of taste.


Jerks are persons suffering by a well-known epidemic called Netscapism1. Their sources contain sections like

    BODY BGCOLOR=#123456
    BLINKClick here!/BLINK

But, not all jerks became jerks because they like to be a jerk. Very often, jerks are forced to use code as seen above by their employee. In this case, they should be refered to as prostitutes.

(1) Or that's what it was called in the Dark Ages of the Web when Agi first wrote this. Now, in the Even Darker Though Truecolor Ages, it's mostly a similar disease called Exploritis. However, owing to HSC's lack of colorful buttons, wizards and the like, HSC users and people suffering from these diseases should be fairly disjunct sets. --mb

hsc-0.934.orig/docs-source/related.hsc0100600000175000001440000000653607701663104016525 0ustar loryusers" +"I've got my saber saw
" +"I've got all I need
" +"Cuz I got my tools") QAUTHOR='Flour, "Tools"'> <* QTEXT=("And if you take a taste
" +"You better leave no waste
" +"You gotta eat up all you get") QAUTHOR='Soup Dragons, "Beauty Freak"'*>

As is only one part of a puzzle, this chapter should give you some hints where you can find other parts. However this does not claim to point out all additional tools that can be useful inc combination with . But at least it should list all utilities mentioned somewhere in this manual.

Some stuff that should be useful for project management:
  • , an Amiga-port of GNUmake. Different to several other Unix-ports, no ixemul.library is required, as it was compiled with SAS/c.
  • , which contains (among other documents) the manual to GNUmake in AmigaGuide format (the exact filename depends on the version of gcc).
  • GNUmake and diff (and all other GNU utilities) can be obtained from <(hsc.anchor)>. There are several mirror sites of this material, scan the ReadMes there for details.
As 's syntax check is quite small and clumsy, maybe you should also have a look at one of the following sources:
  • - based on SGMLS, but easier to use. Available from ; for those who insist on using a .
  • , a Perl-script that is even more cryptic to configure than . And it's Perl.. würg, kotz, reiha.. (<(HSC.ANCHOR)>)
  • HalSoft's validation service maybe provides the most competent syntax-check, but most likely the slowest. (<(HSC.ANCHOR)>)

To show a document in your browser from the once has written it, you can use .

To use Unixoid filenames within AmigaOS, there are numerous tools available. For example, you can use
  • - CLI only, source code included
  • - implemented as a commodity
And some resources that have been quite useful during the development of , but are probably also worth a reading if you are serious about w3-authoring:
  • Composing Good HTML, a general introduction to the whole HTML problem. It's also useful to better understand several messages of . (<(HSC.ANCHOR)>)
  • The Alertbox: Current Issues in Web Usability - might frustrate you, but answers several Why?s. (<(HSC.ANCHOR)>)
  • Richard Scarry: Mein allerschönstes Buch vom Backen, Bauen und Flugzeugfliegen - a general introduction to life and how to cope with it.
hsc-0.934.orig/docs-source/require.hsc0100600000175000001440000000645707765776107016605 0ustar loryusers This section focuses on things the user will need to successfully utilize this program package. This does not only include hardware requirements, but also certain skills of the user.

User Requirements

is not a tool for beginners. It does not make HTML easier. It only makes it a bit less painful and brain-damaged — that's all. Therefore, these documents assume that you are already familiar with HTML. There exist several sources for beginners, and this won't be page #1876545 to list these sources.

The user is expected to have already worked with some macro language before.

If you want to utilize the project management capabilities, you should also know how to work with and write your own s. As it does not make much sense to use without it, this probably is a must.

For several other advanced topics, it is required to have some experiences with any programming language. Rexx is fully sufficient for these task, and most examples and some supporting stuff is written in this language.

As is a commandline tool, any knowledge of how to work with mouse and icons is not required.

Please note that I'm quite serious about all that. As I don't get paid for every new user, there is no need for me to have as many people as possible using this program. Actually I do not care if you try to use it, find out you can not cope with it, scream out Dammit, I'm a loser! and jump out of the window from the 27th floor. But I start caring about it as soon as you do not jump out of the window but send me bloody emails with silly questions instead.

So those who now say Fine, I always wanted to learn how to write Makefiles should consider looking for some other tool or be prepared for jumping out of the window — just in case.

System Requirements

Memory: Well, this mostly depends on your input data. Almost every Unixish system in existence today should run just fine. was developed on AmigaOS and is thus not very resource hungry; the absolute minimum is around 500 KB of free RAM, so an unexpanded A1200 should do. Using the included macro library increases memory requirements to a few megabytes.

Stack: On AmigaOS, the default stack size is 4 KB, this is too little for . The binaries are not linked against any stack-checking or -expansion code, so you should have at least 12 KB of stack, better make it 20 KB. Users of other OS don't have to waste a thought on stack size.

OS and CPU:The AmigaOS binaries require at least OS 2.04 and a 68020 CPU, but a 68040 or higher ist strongly recommended. The binaries in the Linux RPM were compiled for i386 and should run on any x86 system. The kernel version is not critical, but the program was liked against glibc V2.4. Linking against a replacement such as dietlibc is not a problem, but glibc is usually found on development systems anyway. If you run Linux or *BSD on a non-x86 CPU, or HP-UX, Solaris, RiscOS etc., you probably know how to compile your own software anyway.

hsc-0.934.orig/docs-source/source.hsc0100600000175000001440000002452407701663013016401 0ustar loryusers" +"I've been swimming where the fish won't go") QAUTHOR='The Jesus & Mary Chain, "Dirty Water"'> Not for all systems there already compiled versions of this package available. If you can not find binaries anywhere, it seems you will have to go on. Otherwise, you can skip this chapter, as it does not contain anything you would want to know.

Availability

The source archive should be available from the same locations where you are supposed to get updates from. Look out for an archive called hsc-source.lha.

Portability

was written in naked & masochistic ANSI-C. Even worse, it only uses functions of the standard library and does not require any Amiga- or Un*x-specific include files like dir.h, String.h or functions like ReadArgs(), stricmp() etc.

This should ensure a maximum of portability. However, the handling of filenames is a system-dependent thing, which has to be adapted for every OS. See also the section about Existing Ports.

Compiling Under RiscOS

For RiscOS, there is a special and ReadMe you can find in the riscos directory.

Compiling

Basically, compilation works like this: You will need a command line based C-compiler. The compiler must support ANSI-C. There is a which contains settings for all supported systems. You will have to comment in yours. After that you can launch the tool and should hopefully end up with the binaries.

Ok, now all those steps in detail:
  1. If you've compiled older versions of before, remove all files of the old sources before you continue. Do not extract a newer source archive into a directory containing older ones.
  2. Change your current directory to the source directory
  3. Now load the into your editor. Make sure your editor is able to preserve TABs. If it does not, might have some trouble afterwards.
  4. Figure out which system and compiler you have, and remove the from the corresponding lines.
  5. Go back to command line and type make. Lots of strange message should show up indicating that a compiler is started and that there are many options passed to it.
  6. If there is an error - bad luck. If you do not know what to do now (for example starting to fool around with the , fix and report the bug) - worse luck. Go to the cinema or do something else, but forget about this software.

Compiler Warnings

If the compilation was successful, but some compiler warnings showed up, it depends if you should take it serious or not. There are certain parts of the code which declare functions and symbols, but not actually use them (they use them in debug-mode, but I did not want to clutter the source with too many #ifdefs). During linking stage this code should be kicked out anyway. You can safely ignore this.

Other warnings indicate a compiler bug. Contact your compiler vendor.

Ok, maybe not. If you think it could be a nasty one, do a bug report on .

The Binaries

If all went well, you now should have created three files:
hsc/hsc
hsctools/hscdepp
hsctools/hscpitt

These are the executables. Congratulations. Mark the current day in your calendar with a red circle. After that, follow the installation instructions. (In short: put the binaries somewhere in your search-path, and setup hsc.prefs in the appropriate place.)

Cleaning Up

To remove the object files, use
make clean
To also remove binaries, temporary files, core dumps and other trash, use
make sterile
In ideal case, the source directory should then be in exactly the same state as it was before you started with the compilation.

Basic Test Run

Now it is probably a good time to check if basically runs without crashing. Later in this chapter you will read how to do a more exhaustive test run, but for now simply type this into your command line:
hsc/hsc test/simple.hsc to test/simple.html status=full prefsfile=../hsc.prefs
If there now is a file test/simple.html which looks pretty much the same as test/simple.hsc, and the output on the display looks something like
hsc - HTML sucks completely, v0.XXX (dd-mmm-yy)
(C) T.Aglassinger/Tommy-Saftwörx. Freeware, type `hsc LICENSE' for details.
../hsc.prefs: preferences read
test/simple.hsc (9)
passed this test. In this case, you can continue reading at the next heading.

But if you now see something like

*** atexit() failed: Unknown error code

on your display, you are most likely running under . There it seems to be a known bug of the ANSI-C function atexit() to return with in error code even in case of success. However, nobody ever cared about fixing this, and even in OpenStep 4.2 this bug still seems to be there.

As I do not care about faulty implementations of basic ANSI-C functions, you will have to change the source code to make it ignore the result of atexit(). Load source/hsc/hsc.c into your editor and change the line

if (atexit(func))
into something like
if (atexit(func) && 0)

to still call this function and add the additional exit-function, but ignore any errors returned by it. At least this is the work-around suggested to me. And no, there will not be a #ifdef NEXTSTEP for this stupid bug in the runtime library.

About Makefile.agi

If you sneaked around about in the source directory, you maybe also stumbled across a file called Makefile.agi.

Actually I don't use the normal described in the early chapters above for developing. The reason should be obvious, if you watched your compiler before. It only has been invoked a few times, but the there are several small source files.

This is simply because every sub-part of this package has a file which includes all corresponding small files into a single big one. The compiler will have to work quite a while on this, and it will take much more resources - especially memory.

But the optimizer will be more efficient (shorter and faster code), and, most important, there are no problems with any library managers, complex and hardly portable rules in the and so on.

If you just want to compile it once, this is fine for you. However, if one still develops on this package, and has to change and compile sources very often, this is not acceptable: A small change will cause the compiler to recompile large parts, lasting a very long time.

Therefor uses a library manager to avoid this. It is easy for me to make sure that this specific runs on my machine, with the tool installed on my machine. But it might not necessarily work with yours.

But the standard (probably) did. So that's why.

However, there might be one reason why you still want to partially use it:

Performing a Test Run

To test if hsc works as expected, some test data are included in source/test/. Please note that this material might not be up to date for pre-releases you have downloaded from the support-w3-page. Some of the tests might file in such releases.

The test rule is only declared in . This uses some features not supported by all tools. It has been designed to work with GNUmake, which is freely available together with it's source code (see ).

To initiate the test sequence, simple type

make -f Makefile.agi test

from the same directory you have started the compilation before.

Technically speaking, the test run does the following: it will invoke several times: some .hsc files will be used to create some .html files. These are compared with .expected files, which have been created before and contain the expected output.

For this comparison, diff --brief will used. Make sure that such a command is available before starting the test process (again, see if you do not have it).

Additionally, will redirect messages to .msg files. These will be compared with .mex files(messages expected) the same way as described above.

If all works fine, `diff' should not produce any output.

But you should be aware that the test run also includes some faulty input data to test if hsc is able to cope with certain error situations. These will result in an output like

testing test/unknattr.hsc (messages only)..
hsc/hsc failed returncode 10
make: [test/unknattr.msg] Error 10 (ignored)

and should not confuse you. Only an error reported by diff counts as a failed test run.

Debug Mode

These paragraphs are most likely only interesting for freaky people. Normally you do not want to compile in debug mode. Therefor I am not going to explain many details about it, but it should be sufficient for those it is directed to.

In debug mode, performs some additional plausibility checks. Most remarkable, it will check for unreleased resources and trashed memory. It will also output some statistic at the end of every run.

To compile it for this mode, you have to define two symbols called DEBUG and DEBUG_UGLY. After that, you can use the CLI option -DEBUG to enable this additional output.

It does not make sense to run in debug mode all the time, as it is (even more) horrible slow in it. You should only use this if you want to trace internal error messages, some completely unreasonable behavior or crashes.

If you still can not get enough of debugging information, you can take a look at the source files hsclib/ldebug.h and ugly/udebug.h, where you can set some additional flags to 1.

hsc-0.934.orig/docs-source/teutsch.hsc0100600000175000001440000000310707642675506016570 0ustar loryusers" +"Junge Menschen müssen lernen
" +"auf ihren eigenen Beinen zu stehen
" +"unter fernen Sternen") QAUTHOR='Lassie Singers, "Junge Menschen"'>

Zu diesem Thema habe ich eigentlich nur anzumerken, daß Leute, die nicht Englisch können, nicht die Zielgruppe dieses Programms sind. Höchstwahrscheinlich erfüllen sie auch die meisten anderen Voraussetzungen nicht, die zu einer erfolgreichen Verwendung dieses Programms notwendig wären und genauer bei Requirements (natürlich in Englisch) beschrieben sind.

Im Unterschied zu den meisten anderen Programmen für html-Entwicklung ist kompliziert zu bedienen und erfordert einiges Wissen im Umgang mit anderen Werkzeugen, die weit über diese Dokumentation hinausgehen. Für diese zusätzlichen Programme gibt es dann ohnehin wieder nur englischsprachige Dokumentationen. In diesem Fall würde man dann eben erst eine Tür weiter im Regen stehen.

Zur Gestaltung irgendwelcher zweit- oder mehrklassiger sogenannter Homepages ist auch keine wirkliche Hilfe und könnte sich eher negativ auf die Psyche des Anwenders auswirken, sodaß ich an dieser Stelle empfehle, sich lieber dem Verzeichnis zu widmen.

Dem sich nun möglicherweise vor den Kopf gestoßen fühlenden Leser möchte ich noch versichern, daß es diese Seite nicht gäbe, würde ich nicht eine zwingende Notwendigkeit dazu sehen.

hsc-0.934.orig/docs-source/undocumented.hsc0100600000175000001440000000201107642675506017574 0ustar loryusers This chapter covers some undocumented features of . Most of them are hardly tested, some of them are rather inconsistent. Also, I did not make much effort to explain them very well.

Options File

On startup, will look for an options file, which will be parsed for command line options before the actual command line options passed from CLI. Values set in the options file can be overwritten by command line options later.

The format of the options file is easy as can be: it consists of several lines, with every line containing one single options, and, if necessary, also a = and a value. An example options file could look like this:
    FROM=include/stdmacros.hsc
    TO=www:sepp/
    COMPACT
    IGNORE=note|style
The options file always has to be named hsc.options.
hsc-0.934.orig/docs-source/updates.hsc0100600000175000001440000000355707653326020016551 0ustar loryusers

Aminet

New releases of will be uploaded to Aminet, look for

  • - find out which version is the current one
  • - binaries and documentation for AmigaOS
  • - source code

Note: as my Amiga's HD died, there will only be sourcecode releases on the support page for quite a while. If anybody wants to compile them for AmigaOS and upload them to Aminet, feel free do do so!

Support w3-Pages

There is a new support-w3-page for :

[Germany] <(HSC.ANCHOR)>

You can also download the current version from there.
The old pre-V0.918 support page is still available at:

[Austria] <(HSC.Anchor)>

Stupid-Questions-Support

So what if you have a problem not covered in this manual, as it would be out of it scope? This includes things like writing s, fiddling with CLI-arguments, modifying the included example scripts to fit your personal needs and so on?

Well, there are both online and written manuals on all of these topics. Search the usual sources (read: w3, Aminet, book stores etc.).

And by no means send those questions to me. That's the curse of freeware.

Reasonable-Questions-Support

In some rare cases, so might try to contact the author.

hsc-0.934.orig/docs-source/usecases.hsc0100600000175000001440000003142707701663065016723 0ustar loryusers This chapter gives some hints how you can do certain things you might be interested in. It is probably only interesting for experienced users. <********************************************************************>

Multi-lingual Documents

<********************************************************************> This will shortly outline how to create multiple versions of one source file, for example to support more than one language. For example, you want to have a document with a picture being the same in all flavours, but a text depending on the language. Maybe you have a source file hugo.hsc with the interesting part looking like <$source PRE> hugo>
<english>This is Hugo.</english>
<suomi>Tämä on Hugo.</suomi>
</$source>

and as result, you want two documents: an English one

<$source PRE>
<img src=<(file)>

As you can now optionally read this manual in a Postscript version, there might be some interest how it was done.

The rudimentarily bearable application used for conversion is (very originally) called html2ps and can be obtained from <(hsc.Anchor)>. As common with such tools, it started out as a small hack and what really needs to be done is a complete rewriting of the code", but "it is quite unlikely that this [...] will take place. The usual standard disclaimer of every public Perl-script. All quotes taken from the manual to html2ps.

Basically the HTML and the Postscript-version contain the same words. However, there are still some differences, for example the printed version does not need the toolbar for navigation provided at the top of every HTML page.

Therefore, I wrote two macros, html-only and postscript-only. The principle works exactly like the one described for english and suomi earlier in this chapter, and you can find them in and .

However, there is a small difference to the multi-lingual examples, as I do not really want to create two versions all the time. Instead, I prefer to create either a fully hypertext featured version or a crippled Postscript-prepared HTML document in the same location.

You can inspect how this is done: if is invoked without any special options, the hypertext version is created. But if you instead use make PS=1 and therefor define a symbol named PS, the pattern rule responsible for creating the HTML documents acts differently and produces a reduced, Postscript-prepared document without toolbar.

Basically, the rule looks like this: <$source PRE> $(DESTDIR)%.html : %.hsc ifdef PS @$(HSC) inc/ps.hsc $(HSCFLAGS) $< else @$(HSC) inc/html.hsc $(HSCFLAGS) $< endif

Needless to say that the conditional in the does not work with every - I used GNUmake for that, your -tool maybe has a slightly different syntax.

For my convenience, there are two rules called rebuild and rebuild_ps with their meanings being obvious: they rebuild the whole manual in the desired flavour.

So after a successful make rebuild_ps, everything only waits for html2ps. Maybe you want to have a look at the used, although it is strait forward and does not contain anything special. This should not need any further comments, as there is a quite useful manual supplied with it.

However, making html2ps work with an Amiga deserves some remarks. As you might already have guessed, you will need the Perl-archives of GG/ADE - no comments on that, everybody interested should know what and where GG is.

I suppose you can try the full Unix-alike approach with compiled for AmigaOS/ixemul and GG more or less taking over your machine, and therefor directly invoke perl. This will require a rule like
ps :
        html2ps -W l -f html2ps.config -o ../../hsc.ps ../docs/index.html

As I am a dedicated hater of this, I used the AmigaOS-binary, a SAS-compiled GNUmake and the standard CLI. A usually quite successful way to make such things work is with the help of ksh, which, for your confusion, is in a archive at GG called something like pdksh-xxx.tgz (for Public Domain ksh). Invoking ksh with no arguments will start a whole shell-session (würg!), but you can use the switch -c to pass a single command to be executed. After that, ksh will automatically exit, and you are back in your cosy CLI, just as if nothing evil has had happened seconds before.

So finally the rule to convert all those HTML files into one huge Postscript file on my machine is:

ps :
        ksh -c "perl /bin/html2ps -W l -f html2ps.config -o ../../hsc.ps ../docs/index.html"

Note that html2ps is smart enough to follow those (normally invisible) LINK REL="next" .. tags being part of the HTML documents, so only the first file is provided as argument, and it will automatically convert the other ones.

Well, it least you see it can be done.

hsc-0.934.orig/examples/0040700000175000001440000000000007642675506014002 5ustar loryusershsc-0.934.orig/examples/advanced/0040700000175000001440000000000007776512741015546 5ustar loryusershsc-0.934.orig/examples/advanced/README0100600000175000001440000000037107642675506016427 0ustar loryusersAdvanced Example Project ======================== For an advanced example, you should take a look into the drawer `docs-source/'. This contains the hsc sources of the documentation to this package. For a start, take a look at the makefile there. hsc-0.934.orig/examples/fetzenschaedl/0040700000175000001440000000000007776512741016620 5ustar loryusershsc-0.934.orig/examples/fetzenschaedl/hugo/0040700000175000001440000000000007776512741017562 5ustar loryusershsc-0.934.orig/examples/fetzenschaedl/hugo/hugo.gif0100600000175000001440000000053307642675506021214 0ustar loryusersGIF87a@@ðÊÊÊ,@@@þ„©ËíA@ó„‹óµ;ú„}^&6áR1$§v¥ä¶ :gy£/èæ;ì³mbâï§ —Ì&*i|*›«ç¬˜RLGQCÌb‘Æí®b~l‰eu—Z…$ôºý~ÿŠ{¼UÂåÇ“1Ggxö†ÓÕH£Å(çh¢q%ùH© è5¨#µÈIYÄ1ZÓIu*jrª™6)D«¥šZw¹Gè lë;L\l|ŒŒ÷¥–|[ØkQÜ Óü¸; Ü(ü}D¢è†êšÈˆÈU¾Ù²';áèmÙ÷FßÎ[Ùž“-?¦RH ½~­düçåÞ7tï:d›·°œ¶Užœ‰§;‚a(²ºØÍ’“†æ@}8Á†à¯W«¢Œ§P„»ZL&’Š–k¤M71•Á|¶.ã' A}bSÙ,©Ò¥L—;hsc-0.934.orig/examples/fetzenschaedl/hugo/hugo.hsc0100600000175000001440000000033107642675506021220 0ustar loryusers<* ** this is the stupid file of our example project *> <$include file="macro.hsc"> HUGO
This is hugo. Disappointed?
hsc-0.934.orig/examples/fetzenschaedl/Makefile0100600000175000001440000000110707642675506020257 0ustar loryusers# # makefile for hsc example project # # # NOTE: this makefile is prepared for use under AmigaOS (default) and # Unix. To enable the Unix-version, enable the second # definition of the symbol `HSC'. # # # command used to envoke hsc # HSC = //hsc #HSC = ../../hsc # # options for hsc # HSCOPTS = TO= STATUS="line|verbose" all : stupid.html hugo/hugo.html main.html main.html : main.hsc macro.hsc $(HSC) $(HSCOPTS) main.hsc stupid.html : stupid.hsc macro.hsc $(HSC) $(HSCOPTS) stupid.hsc hugo/hugo.html : hugo/hugo.hsc macro.hsc $(HSC) $(HSCOPTS) hugo/hugo.hsc # EOF hsc-0.934.orig/examples/fetzenschaedl/README0100600000175000001440000000470107642675506017502 0ustar loryusersFetzenschädl Example Project ============================ This directory contains a small example project. It will result in exactly the same pages as those you can find in `examples/simple'. However there is a remarkable difference: Both the html documents and the hsc sources are located in the same directory tree. This has mostly disadvantages: - Your hsc sources will waste space on the w3-server disk. - When processing, hsc will have to access the disk of your w3-server, resulting in an increased load. - Unless you set decent access rights of your hsc sources, they can be loaded into a w3-browser just like normal html documents. - Objects and sources are not separated from each other, which will make certain operations (like archiving) more difficult. But there also is an advantage: During the first steps, it might be easier for new users to cope with this approach, as they will not have to mess around with the numerous options of hsc to specify the output. However, you should not design projects this way because of the above mentioned reasons. Refer to `examples/simple' for a more reasonable way to achieve the same results. Description of sources: ----------------------- main.hsc the welcome page of this project stupid.hsc a simple page which can be reached from "main" macro.hsc contains some macro definitions and is included into all files hugo/ a subdirectory, where all information about Hugo is collected hugo/hugo.hsc some information about Hugo hugo/hugo.gif a picture of Hugo Starting the conversion: ------------------------ This text assumes that you are in the CLI and your current directory is "[hsc]/examples/fetzenschaedl/", with "[hsc]" being the directory where you installed this package to. Now you are ready to start `make': make Of course, you need to have a `make' command installed in your search path. See the main documentation where to obtain it. After that, all html-objects should be ready. You can start browsing them by loading `main.html' into your browser. Note that there does not exist a "macro.html", because the there is no rule for this in the makefile. There is no rule necessary, because "macro.hsc" is never converted alone, but only included by the other files. Additionally, "macro.hsc" contains no readable text or tags. Take a look at the "Makefile" to understand the basic concept of hsc. hsc-0.934.orig/examples/fetzenschaedl/macro.hsc0100600000175000001440000000212007642675506020413 0ustar loryusers<* ** here are the macros to our example project *> <* ** macro ITS_ME: ** ** this is just a simple shortcut for the authors email address *> <$macro ITS_ME>
Its Me(me@some.where)
<* ** macro WEBPAGE: ** ** *> <$macro WEBPAGE> <* SGML header *> <* important comment *> <*-------------------------------------*> <$macro /WEBPAGE> <* closing BODY started in HEADING *> <* closing HTML started in WEBPAGE *> <* ** macro HEADING ** ** setup HEAD-part of a page: set -text and Heading *> <$macro HEADING TITLE:string> <HEAD> <TITLE><(Title)> <* insert title and heading *>

<(Title)>

<* BODY starts here, but ends in *> <* ** macro FOOTLINE ** ** insert author's email address and current date & time ** at end of page *> <$macro FOOTLINE>
Updated by at <(GetTime())> hsc-0.934.orig/examples/fetzenschaedl/main.hsc0100600000175000001440000000061607642675506020246 0ustar loryusers<* ** this is the main file of our exmaple project *> <$include FILE="macro.hsc"> This is the main page of this example project. It contains nothing more the two links to the subpages: bla sülz fasel laber.. hsc-0.934.orig/examples/fetzenschaedl/stupid.hsc0100600000175000001440000000026207642675506020627 0ustar loryusers<* ** this is the stupid file of our example project *> <$include file="macro.hsc"> A very stupid example, eh? hsc-0.934.orig/examples/simple/0040700000175000001440000000000007776512741015272 5ustar loryusershsc-0.934.orig/examples/simple/object_html/0040700000175000001440000000000007776512741017564 5ustar loryusershsc-0.934.orig/examples/simple/object_html/README0100600000175000001440000000006707642675506020447 0ustar loryusersIn this directory, hsc will output the example project hsc-0.934.orig/examples/simple/source_hsc/0040700000175000001440000000000007776512741017427 5ustar loryusershsc-0.934.orig/examples/simple/source_hsc/hugo/0040700000175000001440000000000007776512741020371 5ustar loryusershsc-0.934.orig/examples/simple/source_hsc/hugo/hugo.gif0100600000175000001440000000053307642675506022023 0ustar loryusersGIF87a@@ðÊÊÊ,@@@þ„©ËíA@ó„‹óµ;ú„}^&6áR1$§v¥ä¶ :gy£/èæ;ì³mbâï§ —Ì&*i|*›«ç¬˜RLGQCÌb‘Æí®b~l‰eu—Z…$ôºý~ÿŠ{¼UÂåÇ“1Ggxö†ÓÕH£Å(çh¢q%ùH© è5¨#µÈIYÄ1ZÓIu*jrª™6)D«¥šZw¹Gè lë;L\l|ŒŒ÷¥–|[ØkQÜ Óü¸; Ü(ü}D¢è†êšÈˆÈU¾Ù²';áèmÙ÷FßÎ[Ùž“-?¦RH ½~­düçåÞ7tï:d›·°œ¶Užœ‰§;‚a(²ºØÍ’“†æ@}8Á†à¯W«¢Œ§P„»ZL&’Š–k¤M71•Á|¶.ã' A}bSÙ,©Ò¥L—;hsc-0.934.orig/examples/simple/source_hsc/hugo/hugo.hsc0100600000175000001440000000033107642675506022027 0ustar loryusers<* ** this is the stupid file of our example project *> <$include file="macro.hsc"> HUGO
This is hugo. Disappointed?
hsc-0.934.orig/examples/simple/source_hsc/Makefile0100600000175000001440000000136207642675506021071 0ustar loryusers# # makefile for hsc example project # # # NOTE: this makefile is prepared for use under AmigaOS (default) and # Unix. To enable the Unix-version, enable the second # definition of the symbol "HSC" and "DESTDIR". # # # command used to invoke hsc # HSC = ///hsc #HSC = ../../../hsc # # project destination dir # DESTDIR = /object_html/ #DESTDIR = ../object_html/ # # options for hsc # HSCOPTS = TO=$(DESTDIR) STATUS="line|verbose" all : $(DESTDIR)stupid.html $(DESTDIR)hugo/hugo.html $(DESTDIR)main.html $(DESTDIR)main.html : main.hsc macro.hsc $(HSC) $(HSCOPTS) main.hsc $(DESTDIR)stupid.html : stupid.hsc macro.hsc $(HSC) $(HSCOPTS) stupid.hsc $(DESTDIR)hugo/hugo.html : hugo/hugo.hsc macro.hsc $(HSC) $(HSCOPTS) hugo/hugo.hsc # EOF hsc-0.934.orig/examples/simple/source_hsc/macro.hsc0100600000175000001440000000212007642675506021222 0ustar loryusers<* ** here are the macros to our example project *> <* ** macro ITS_ME: ** ** this is just a simple shortcut for the authors email address *> <$macro ITS_ME>
Its Me(me@some.where)
<* ** macro WEBPAGE: ** ** *> <$macro WEBPAGE> <* SGML header *> <* important comment *> <*-------------------------------------*> <$macro /WEBPAGE> <* closing BODY started in HEADING *> <* closing HTML started in WEBPAGE *> <* ** macro HEADING ** ** setup HEAD-part of a page: set -text and Heading *> <$macro HEADING TITLE:string> <HEAD> <TITLE><(Title)> <* insert title and heading *>

<(Title)>

<* BODY starts here, but ends in *> <* ** macro FOOTLINE ** ** insert author's email address and current date & time ** at end of page *> <$macro FOOTLINE>
Updated by at <(GetTime())> hsc-0.934.orig/examples/simple/source_hsc/main.hsc0100600000175000001440000000061607642675506021055 0ustar loryusers<* ** this is the main file of our exmaple project *> <$include FILE="macro.hsc"> This is the main page of this example project. It contains nothing more the two links to the subpages: bla sülz fasel laber.. hsc-0.934.orig/examples/simple/source_hsc/stupid.hsc0100600000175000001440000000026207642675506021436 0ustar loryusers<* ** this is the stupid file of our example project *> <$include file="macro.hsc"> A very stupid example, eh? hsc-0.934.orig/examples/simple/README0100600000175000001440000000503507642675506016155 0ustar loryusersSimple Example Project ====================== This directory contains a small example project. The sources are collected in "source_hsc/" and should be converted to "object_html/". This is the directory where the "browsable" data will be located. This text assumes that you are in the CLI and your current directory is "[hsc]/examples/simple/source_hsc/", with "[hsc]" being the directory where you installed this package to. Description of sources: ----------------------- main.hsc the welcome page of this project stupid.hsc a simple page that can be reached from "main" macro.hsc contains some macro definitions and is included into all files hugo/ a subdirectory, where all information about Hugo is collected hugo/hugo.hsc some information about Hugo hugo/hugo.gif a picture of Hugo Setting up the object directory: -------------------------------- For every directory in the source-dir, a corresponding directory with the same name has to be created. This can be done via makedir /object_html/hugo As the picture is of no real use in the source directory, you should move it to the object directory: rename hugo/hugo.gif /object_html/hugo/ Note that every file, that is not a hsc-source or include-file has to be located somewhere in the object directory. This especially concerns pictures, sounds and everything else that is linked, but not a hsc source file. Starting the conversion: ------------------------ Now you are ready to start `make': make Of course, you need to have a `make' command installed in your search path. See the main documentation where to obtain it. After that, all html-objects in "object_html/" should be ready. Note that there does not exist a "macro.html", because the there is no rule for this in the makefile. There is no rule necessary, because "macro.hsc" is never converted alone, but only included by the other files. Additionally, "macro.hsc" contains no readable text or tags. Take a look at the "Makefile" to understand the basic concept of hsc. Toubleshooting: --------------- If make aborts with a message like *** unable to open `/object_html/hugo/hugo.html' for output: No such file or directory you forgot the call to `makedir' mentioned above. If make aborts with a message like Makefile:31: *** missing separator. Stop. you are using a editor which replaces TABs by normal blanks. This is a good time to start browsing the documantation, section `Project Management/Make'... hsc-0.934.orig/grafflwerk/0040700000175000001440000000000007776512741014315 5ustar loryusershsc-0.934.orig/grafflwerk/CvtEntities0100700000175000001440000000042507642675506016503 0ustar loryusers# This converts entity lists as found on the web to HSC $defent tags perl -e ' while(<>) { chomp; next unless length > 5; ($name,$num,$c)=/(.*)/; printf "<\$defent NAME=\"%s\" RPLC=\"\" NUM=\"%d\" $c\n",$name,hex($num); }' hsc-0.934.orig/grafflwerk/README0100600000175000001440000000266607642675506015207 0ustar loryusersAbout `grafflwerk' ================== This drawer contains some files and material that can be useful in combination with hsc. Do with it whatever you want, use at your own risk. The ARexx-scripts for ScMsg are a bit experimental because I don't like ScMsg and don't use these scripts myself. The Arexx-script `SendBrowser' currently only supports AWeb, but should be easy to modify for other Browsers because it is not very complex. hScMsg.rexx ----------- An ARexx-script that invokes hsc redirecting it's messages and sends messages outputed by hsc to ScMsg, which is part of the SAS/c-package. It is supposed to be used as a substitute for hsc inside Makefiles. See the source-code for usage. hscPalthrow.rexx ---------------- An ARexx-script which invokes hscpitt and parses it's output, so the user can easily access it. Refer to the documentation, section "project management/hscpalthrow for details. SendBrowser.rexx ---------------- An ARexx-script that can be used to display an updated html-object in AWeb. Refer to the documentaion, section "project management/makefiles/postprocessing" for details. SendScMsg.rexx -------------- An ARexx-script that sends messages outputed by hsc to ScMsg, which is part of the SAS/c-package. See the source-code for usage. CvtEntities ----------- This is a primitive Perl script to convert lists of entities in SGML notation to HSC's <$defent> syntax. If you can't figure out how to use it, you shouldn't. hsc-0.934.orig/grafflwerk/SendScMsg.rexx0100600000175000001440000000513707642675506017061 0ustar loryusers/* * SendScMsg.rexx - send hsc-messages to ScMsg * * $VER: SendScMsg.rexx 1.1 (14.9.1998) * * Written 1996-98 Thomas Aglassinger . Public domain. * *-------------------------------------------------------------------------- * * USAGE * rx hScMsg * * When invoking hsc before calling this script, you need to * set the MSGFILE-option to use the same messagefile as * passed to this script. Additionally, you need to set the * option MSGFORMAT="%f:::%y:::%c:::%i:::%m", which is the * expected format for this script. * * EXAMPLE * hsc FROM hugo.hsc TO hugo.html MSGFORMAT="%f:::%y:::%c:::%i:::%m" MSGFILE=t:hscmsg.tmp * rx SendScMsg.rexx hugo.hsc t:hscmsg.tmp * * BUGS * * o There is no way for this script to check if you've set all * options correctly when invoking hsc. * o concurrecy problems will occure when you invoke multiple * instancies of hsc ouputing to the same message-file * o filenames containig blanks won't work * o ScMsg can't handle all message-classes of hsc, therefor only * "Warning" and "Error" are used for display */ ScMsgPath = "sc:c/ScMsg" Options Failat 21 Parse ARG SourceFilename MessageFilename /* display help and exit */ IF ((SourceFilename="") | (SourceFilename='?') | (MessageFilename="")) THEN DO SAY 'Usage: hScMsg ' SAY ' (see source-code for details)' Exit END /* strip leading spaces from MessageFilename */ MessageFilename = Strip(MessageFilename, 'L') /* invoke ScMsg, if it's not already there */ IF ~Show('ports', 'SC_SCMSG') THEN DO Address Command 'Run <>nil:' SCMSGPATH 'HIDDEN' Address Command 'WaitForPort SC_SCMSG' END /* check, if ScMsg showed up */ IF ~Show('ports', 'SC_SCMSG') THEN DO Say "Couldn't start ScMsg, giving up." Exit 10 END /* remove old messages in ScMsg-window */ Address 'SC_SCMSG' DelFile SourceFilename /* process message file, if exists */ IF Open('File', MessageFilename, 'R') THEN DO DO UNTIL Eof('File') Line = ReadLn('File') /* extract information from current message-line */ Parse VAR Line File ':::' Line ':::' MsgClass ':::' MsgNum ':::' Msg IF ((MsgClass='Error') | (MsgClass='Fatal Error')) THEN MsgClass='Error' ELSE MsgClass='Warning' /* Send message to ScMsg */ Address 'SC_SCMSG' NewMsg '"'||SourceFilename||'"' '"'||SourceFilename||'"' Line '0 "" 0' MsgClass MsgNum Msg END Address 'SC_SCMSG' Show Activate /* cleanup */ Call Close('File') END hsc-0.934.orig/grafflwerk/StripNastyChars.hsc0100600000175000001440000000070707642675506020121 0ustar loryusers<* * StripNastyChar.hsc * * This document provides an advanced example usage of <$exec>. * For details refer to the main documentation. *> Strip Nasty Characters <$define nasty-data:string="This#Text|Contains!Ñâ§ïÿ/Characters"> <$define clean-data:string> <$exec COMMAND=("rx StripNastyChars.rexx " + nasty-data) ATTRIBUTE=clean-data> Converted "<(nasty-data)>" to "<(clean-data)>". hsc-0.934.orig/grafflwerk/StripNastyChars.rexx0100600000175000001440000000113407642675506020325 0ustar loryusers/* * StripNastyChars.rexx * * strip all characters except "a".."z", "0".."9" and "A".."Z" from * a text passed as argument and output the result to stdout. * * $VER: StripNastyChars 1.0 (12.10.97) */ /* get input from command line */ PARSE ARG text /* specify nasty chars */ nastyChars = XRANGE(d2c(0), d2c(47)) || XRANGE(d2c(58), d2c(64)) || XRANGE(d2c(91), d2c(96)) || XRANGE(d2c(123), d2c(255)) /* now remove them from input data */ stripped = COMPRESS(text, nastyChars) /* and display them at standard output * (which will be redirected an read by hsc) */ call WriteCH(stdout, stripped) hsc-0.934.orig/grafflwerk/defent-cp1252.prefs0100600000175000001440000000404407703013651017520 0ustar loryusers<* This file contains entity definitions to map Windows CP-1252 characters in * the #128-#159 range to their HTML-valid Unicode equivalents. * You can paste it into your hsc.prefs or just put an <$include> there. *> <$defent NAME="euro" RPLC="€" NUM="8218"> <* Single Low-9 Quotation Mark *> <$defent NAME="sbquo" RPLC="130" NUM="8218"> <* Single Low-9 Quotation Mark *> <$defent NAME="fnof" RPLC="‚131" NUM="402"> <* Latin Small Letter F With Hook *> <$defent NAME="bdquo" RPLC="ƒ132" NUM="8222"> <* Double Low-9 Quotation Mark *> <$defent NAME="hellip" RPLC="„" NUM="8230"> <* Horizontal Ellipsis *> <$defent NAME="dagger" RPLC="…" NUM="8224"> <* Dagger *> <$defent NAME="Dagger" RPLC="†" NUM="8225"> <* Double Dagger *> <$defent NAME="circ" RPLC="‡" NUM="710"> <* Modifier Letter Circumflex Accent *> <$defent NAME="permil" RPLC="ˆ" NUM="8240"> <* Per Mille Sign *> <$defent NAME="Scaron" RPLC="‰" NUM="352"> <* Latin Capital Letter S With Caron *> <$defent NAME="lsaquo" RPLC="Š" NUM="8249"> <* Single Left-Pointing Angle Quotation Mark *> <$defent NAME="OElig" RPLC="‹" NUM="338"> <* Latin Capital Ligature OE *> <$defent NAME="lsquo" RPLC="‘" NUM="8216"> <* Left Single Quotation Mark *> <$defent NAME="rsquo" RPLC="’" NUM="8217"> <* Right Single Quotation Mark *> <$defent NAME="ldquo" RPLC="“" NUM="8220"> <* Left Double Quotation Mark *> <$defent NAME="rdquo" RPLC="”" NUM="8221"> <* Right Double Quotation Mark *> <$defent NAME="bull" RPLC="•" NUM="8226"> <* Bullet *> <$defent NAME="ndash" RPLC="–" NUM="8211"> <* En Dash *> <$defent NAME="mdash" RPLC="—" NUM="8212"> <* Em Dash *> <$defent NAME="tilde" RPLC="˜" NUM="732"> <* Small Tilde *> <$defent NAME="trade" RPLC="™" NUM="8482"> <* Trade Mark Sign *> <$defent NAME="scaron" RPLC="š" NUM="353"> <* Latin Small Letter S With Caron *> <$defent NAME="rsaquo" RPLC="›" NUM="8250"> <* Single Right-Pointing Angle Quotation Mark *> <$defent NAME="oelig" RPLC="œ" NUM="339"> <* Latin Small Ligature OE *> <$defent NAME="Yuml" RPLC="" NUM="376"> <* Latin Capital Letter Y With Diaeresis *> hsc-0.934.orig/grafflwerk/ent2c.pl0100700000175000001440000000042707703022640015650 0ustar loryusers#!/usr/bin/perl # Converts SGML/XML entity lists as found on # http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent # into HSC's C structures while(<>) { chomp; $t .= $_; } $t =~ s///go; $t =~ s//\t{"$1",\t$2, FALSE},\n/gs; print $t; hsc-0.934.orig/grafflwerk/hScMsg.rexx0100600000175000001440000000554307642675506016420 0ustar loryusers/* * hScMsg - invoke hsc and send messages to ScMsg * * $VER: hScMsg 1.1 (14.9.98) * * Written 1996-1998 Thomas Aglassinger . Public domain. * *-------------------------------------------------------------------------- * * USAGE * rx hScMsg * * This script passes all options to hsc, and sets MSGFORMAT and * MSGFILE according to it's needs. Therefore, avoid these two * options when invoking hScMsg. * * Note that you MUST pass the filename as first arg and that it * has to show up again in * * EXAMPLE * rx hScMsg hugo.hsc FROM hugo.hsc TO hugo.html COMPACT RPLCENT * ^^^^^^^^ ^^^^^^^^ * BUGS * o filenames containig blanks won't work * o ScMsg can't handle all message-classes of hsc, therefor only * "Note", "Warning" and "Error" are used for display */ ScMsgPath = "sc:c/ScMsg" hscPath = "hsc" TmpFile = 'T:hScMsg' || PRAGMA('ID') || '.tmp' Options Failat 21 Parse ARG Filename hscOpts /* display help and exit */ IF ((Filename="") | (Filename='?')) THEN DO SAY 'Usage: hScMsg ' SAY ' (see source-code for details)' Exit END /* invoke hsc */ CmdLine = hscPath 'MSGFILE=' || TmpFile 'MSGFORMAT="%f:::%y:::%c:::%i:::%m"' hscOpts Address Command CmdLine /* invoke ScMsg, if it's not already there */ IF ~Show('ports', 'SC_SCMSG') THEN DO Address Command 'Run <>nil:' SCMSGPATH 'HIDDEN' Address Command 'WaitForPort SC_SCMSG' END /* check, if ScMsg showed up */ IF ~Show('ports', 'SC_SCMSG') THEN DO Say "Couldn't start ScMsg, giving up." Exit 10 END /* remove old messages in ScMsg-window */ Address 'SC_SCMSG DelComp "' || FileName || '"' /* store return-code of hsc */ hScMsgRC = RC /* process message file, if exists */ IF Open('File', TmpFile, 'R') THEN DO message_counter = 0 DO WHILE ~ Eof('File') Line = ReadLn('File') IF (Line ~= '') THEN DO message_counter = message_counter + 1 /* extract information from current message-line */ Parse VAR Line File ':::' Line ':::' MsgClass ':::' MsgNum ':::' Msg IF ((MsgClass='Error') | (MsgClass='Fatal Error')) THEN DO MsgClass='Error' END ELSE IF (MsgClass='Note') THEN DO /* Leave message class as 'Note' */ END ELSE DO MsgClass='Warning' END /* Send message to ScMsg */ Address 'SC_SCMSG' NewMsg '"'||FileName||'"' '"'||FileName||'"' Line '0 "" 0' MsgClass MsgNum Msg END END IF (message_counter > 0) THEN DO SAY 'message_counter =' message_counter Address 'SC_SCMSG' Show Activate END /* cleanup */ Call Close('File') Address Command 'Delete quiet' TmpFile END /* exit with returncode of hsc */ Exit hScMsgRC hsc-0.934.orig/grafflwerk/hscpaltrow.rexx0100600000175000001440000001061507642675506017416 0ustar loryusers/* * hscpaltrow.rexx -- Access project data using hscpitt. * * $VER: hscpaltrow 1.1 (14.9.98) * * Written 1997,1998 Thomas Aglassinger . Public domain. * *-------------------------------------------------------------------------- * * USAGE * rx hscpaltrow * * EXAMPLE * rx hscpaltrow hsc.project * * For more details, refer to the documentation of hsc, section * `project management' */ /* * some values you might want to change */ /* command to invoke hscpitt */ pittCmd = 'hscpitt' /* temporary file output is redirected to */ tmpFile = 't:paltrow.' || PRAGMA('ID') /* command to delete a file */ deleteCmd = 'delete QUIET' /* * debugging support: * * `debug=1' will enable some SAY commands which tell you * what hscpaltrow currently is doing. `dbg' contains a * short text which will be used as a prefix by all these * SAYs so it is easier to separate from trace output */ debug=0 dbg =':::' /* * main program: * * when changing anything below, you should know, what are * you doing */ /* reset return code */ paltrowRC = 0 /* parse user args, display help if necessary */ Parse ARG projectFile IF (projectFile="") THEN DO /* show help end exit */ SAY 'Usage: hscpaltrow ' Exit END /* * invoke hscpitt, redirect output to a temporary file */ pittCmd = pittCmd 'COMMAND=EXTRACT QUIET PRJFILE=' || projectFile pittCmd = pittCmd '>' || tmpFile IF (debug) THEN DO SAY dbg 'invoking:' pittCmd END Address Command pittCmd paltrowRC = RC; /* * read the temporary file and parse it line-by-line * * (only of hscpitt returned sucessfull and the temporary * file could be found) */ IF (paltrowRC = 0) THEN DO IF (Open('File', tmpFile, 'R')) THEN DO DO UNTIL Eof('File') /* reset variables which will hold the information * about a document */ docName = "" docSource = "" docIncludes = "" /* process all lines belonging to a specific document */ DO UNTIL (Line="") /* read next line */ Line = ReadLn('File') IF (debug) THEN DO SAY dbg 'line:' Line END IF (Line ~= "") THEN DO /* extract information from current line: * every line corresponds to the template * ="", so everything until * the first "=" is treated as ID, and * the remaining data contain the value, * from which the enclosing quotes are * removed. Usually there should be no need * to modify these two lines */ Parse VAR Line LineID '="' LineValue LineValue = LEFT(LineValue, LENGTH(LineValue) - 1) /* now act differetly on LineID; you can * add further WHENs here */ SELECT WHEN (LineID = 'DOCUMENT') THEN DO docName = LineValue; END WHEN (LineID = 'SOURCE') THEN DO docSource = LineValue; END WHEN (LineID = 'INCLUDE') THEN DO docIncludes = docIncludes LineValue; END OTHERWISE DO IF (debug) THEN SAY dbg 'ignore:' LineID '=' LineValue END END /* select */ END /* if line */ END /* until line */ /* now all information about a specific document * has been extracted, and you can do about it * whatever you want. This example simply displays * it */ SAY 'Document:' docName SAY 'Source :' docSource SAY 'Includes:' || docIncludes SAY '' END /* until eof */ /* close input file */ Call Close('File') END /* if open */ ELSE DO SAY 'error opening temporary file "' || tmpFile || '" for input' paltrowRC = 10 END /* remove temporary file */ Address Command deleteCmd tmpFile END /* if paltrowRC */ ELSE DO /* this part of the code is reached if hscpitt failed */ END Exit paltrowRC hsc-0.934.orig/grafflwerk/htmlhsc.vim0100600000175000001440000001064607653323767016504 0ustar loryusers" Vim syntax file " Language: HTML with HSC " Maintainer: Matthias Bethke " URL: " Last Change: 2003 Apr 10 " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 syntax clear elseif exists("b:current_syntax") finish endif " Same as for HTML if version < 508 command! -nargs=+ HscHiLink hi link else command! -nargs=+ HscHiLink hi def link endif " we define it here so that included files can test for it if !exists("main_syntax") let main_syntax='htmlhsc' endif if version < 600 so :p:h/html.vim else runtime! syntax/html.vim endif unlet b:current_syntax syntax case ignore syntax sync minlines=150 maxlines=500 syn cluster htmlPreproc add=hscTop setlocal iskeyword+=$,- "------------------------------------------------------------------------------- " Additional comments that will be stripped by HSC syn region hscComment start="<\*" end="\*>" contains=hscComment " Verbatim data syn region hscVerbatimR matchgroup=hscVerbatim start="<|" end="|>" " HSC-insert-expression syn region hscInsExprR matchgroup=hscInsExpr start="<(" end=")>" contains=hscString,hscExpr,hscOperator skipwhite skipempty " Single- and double-quoted strings syn match hscString contained /"[^"]*"/ syn match hscString contained /'[^']*'/ " Unary and binary operators syn keyword hscOperator contained basename chr defined exists extension fexists syn keyword hscOperator contained getenv getfilesize getgmtime gettime not ord syn keyword hscOperator contained set urikind syn match hscOperator contained "[-_&+*/<>]" syn match hscOperator contained " mod \|<=\|>=\|==\| lt \| gt \| le \| ge \| and \| or \| xor " " A complete HSC expression syn region hscExpr start="(" end=")" contains=hscString,hscExpr,hscOperator skipwhite skipempty syn region hscExpr start="{" end="}" contains=hscString,hscExpr,hscOperator skipwhite skipempty " Attributes syn match hscAttr contained "\w\([-.]\|\w\)*" nextgroup=hscCondEq,hscEq skipwhite syn match hscEq contained "=" nextgroup=hscString,hscExpr,hscAttr skipwhite syn match hscCondEq contained "?=" nextgroup=hscAttr skipwhite " Normal HSC tags starting with $ syn region hscNormalTagR matchgroup=hscNormalTag start="<\$\(content\|defent\|deficon\|defstyle\|depend\|elseif\|else\|exec\|export\|if\|include\|let\|message\|source\|stripws\)" end=">" contains=hscAttr " Attribute declarations with types and modifiers syn match hscName contained "\w\([-.]\|\w\)*" syn match hscAttrDecl contained #\w\([-.]\|\w\)*:\a\+\s*\(/\a\+\s*\)*\s*=\?# nextgroup=hscString,hscExpr contains=hscAttrD,hscModifier,hscEq syn match hscAttrD contained "\w\([-.]\|\w\)*:\a\+" contains=hscAttr,hscType syn match hscType contained ":\a\+" nextgroup=hscModifier,hscEq syn match hscModifier contained "/\a\+" contains=hscModifierSlash syn match hscModifierSlash contained "/" " The <$define> tag syn region hscDefineR matchgroup=hscDefineTag start="<$define\>" end=">" contains=hscAttrDecl " The <$macro>, <$deftag> and <$varlist> tags syn region hscMacroTagR matchgroup=hscMacroTag start="<$\(macro\|deftag\|varlist\)\>" end=">" contains=hscMacroTag,hscAttrDecl syn match hscMacroTag contained #\w\([-.]\|\w\)*\s*\(/\a\+\s*\)*# contains=hscName,hscModifier,hscAttrDecl " The only closing tags syn match hscEndTag "" syn region hscIfBody start="<$if\>" end="" contains=TOP,hscElse,hscElseif syn region hscIfR matchgroup=hscIf start="<$if\>" end=">" contains=hscAttr syn match hscElse contained "<$else>" syn match hscElseif contained "<$elseif>" " All tags together syn cluster hscTag contains=hscNormalTagR,hscMacroTagR,hscDefineR,hscInsExprR " Top Cluster syn cluster hscTop contains=hscComment,hscVerbatim,@hscTag,hscMacro,hscIfBody " Highlighting hi def hscTag term=bold cterm=bold HscHiLink hscComment Comment HscHiLink hscVerbatim hscTag hi link hscNormalTag hscTag hi link hscMacroTag hscTag hi link hscDefineTag hscTag hi link hscInsExpr hscTag hi link hscEndTag hscTag hi link hscIf hscTag hi link hscElseif hscTag hi link hscElse hscTag hi link hscOperator Operator hi link hscAttr Identifier hi link hscName Identifier hi link hscType Type hi link hscModifier Type hi link hscModifierSlash None hi link hscString htmlString let b:current_syntax = "htmlhsc" if main_syntax == 'htmlhsc' unlet main_syntax endif " " $Id: htmlhsc.vim,v 1.3 2003/04/28 22:14:33 mb Exp mb $ hsc-0.934.orig/hsc/0040700000175000001440000000000010010444573012716 5ustar loryusershsc-0.934.orig/hsc/all_hsc.c0100600000175000001440000000202607732056111014472 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #define NOEXTERN_HSC_STATUS #define NOEXTERN_HSC_GLOBAL_H #define NOEXTERN_HSC_CALLBACK_H #include "hsc/global.c" #include "hsc/status.c" #include "hsc/callback.c" #include "hsc/args.c" #include "hsc/output.c" #include "hsc/hsc.c" hsc-0.934.orig/hsc/args.c0100600000175000001440000010611007776657323014044 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/args.c * * user argument handling for hsc * * updated: 24-Aug-1998 * created: 1-Jul-1995 */ #include "hsc/global.h" #include "hsc/status.h" #include "hsc/callback.h" /* * ugly includes */ #include "ugly/uargs.h" #include "ugly/fname.h" #include "ugly/prginfo.h" #include "ugly/returncd.h" #include "hscprj/license.h" /* default values for some arguments */ #define DEFAULT_EXTENSION "html" #define DEFAULT_MAXERR "20" #define DEFAULT_MAXMSG "40" static STRPTR arg_inpfname = NULL; /* temp vars for set_args() */ static STRPTR arg_outfname = NULL; static STRPTR arg_extension = NULL; static STRPTR arg_server_dir = NULL; static BOOL arg_mode = FALSE; static BOOL arg_compact = FALSE; static BOOL arg_getsize = FALSE; static BOOL arg_rplc_ent = FALSE; static BOOL arg_rplc_quote = FALSE; static BOOL arg_smart_ent = FALSE; static BOOL arg_strip_cmt = FALSE; static BOOL arg_strip_badws = FALSE; static BOOL arg_strip_ext = FALSE; static BOOL arg_license = FALSE; static BOOL arg_help = FALSE; static BOOL arg_debug = FALSE; static BOOL arg_nonesterr = FALSE; static BOOL arg_lctags = FALSE; static BOOL arg_xhtml = FALSE; static BOOL arg_nvcss = FALSE; static BOOL arg_checkext = FALSE; static STRPTR arg_iconbase = NULL; static STRPTR arg_striptags = NULL; static LONG arg_entitymode = EMODE_INVALID; static LONG arg_quotemode = QMODE_DOUBLE; static HSCPRC *arg_hp = NULL; /* contains defines for source-, destination- and global attributes */ static EXPSTR *fileattr_str = NULL; static ARGFILE *argf = NULL; /* * cleanup_hsc_args: free local resources */ VOID cleanup_hsc_args(VOID) { del_argfile(argf); del_estr(fileattr_str); if (msg_browser != NULL) { del_msg_browser(arg_hp); } } /* * arg_ignore_CB * * argument handler for special values that are passed * to "IGNORE=.." several messages are set to be ignored * with the old messages left active */ static STRPTR arg_ignore_CB(STRPTR arg) { STRPTR errmsg = NULL; STRPTR arg_clone = strclone(arg); /* copy of arg; written by strtok() */ HSCPRC *hp = arg_hp; STRPTR nxt_arg = strtok(arg_clone, "|"); /* use "|" to tokenize */ while (nxt_arg) { D(fprintf(stderr, DHSC " ignore `%s'\n", nxt_arg)); if (!upstrcmp(nxt_arg, IGNORE_ALL_STR)) { /* ignore all non-error messages */ HSCMSG_ID i; for (i = 0; i < MAX_MSGID; i++) hsc_set_msg_ignore(hp, i, TRUE); } else if (!upstrcmp(nxt_arg, IGNORE_NOTES_STR)) { /* ignore note messages */ hsc_set_msg_ignore_notes(hp, TRUE); } else if (!upstrcmp(nxt_arg, IGNORE_BADSTYLE_STR)) { /* ignore bad style messages */ hsc_set_msg_ignore_style(hp, TRUE); } else if (!upstrcmp(nxt_arg, IGNORE_PORTABILITY_STR)) { /* ignore potability problems */ hsc_set_msg_ignore_port(hp, TRUE); } else { /* ignore message # */ LONG ignnum; if (!str2long(nxt_arg, &ignnum)) errmsg = "unknown `ignore'"; else hsc_set_msg_ignore(hp, ignnum, ignore); } /* next arg */ nxt_arg = strtok(NULL, "|"); } /* while(nxt_arg) */ /* cleanup */ ufreestr(arg_clone); return (errmsg); } /* * arg_enable_CB * * argument handler for special values that are passed * to "enable=.." several messages are set to be enabled * with the old messages left active */ static STRPTR arg_enable_CB(STRPTR arg) { STRPTR errmsg = NULL; STRPTR arg_clone = strclone(arg); /* copy of arg; written by strtok() */ HSCPRC *hp = arg_hp; STRPTR nxt_arg = strtok(arg_clone, "|"); /* use "|" to tokenize */ while (nxt_arg) { D(fprintf(stderr, DHSC " enable `%s'\n", nxt_arg)); if (!upstrcmp(nxt_arg, IGNORE_ALL_STR)) { /* enable all non-error messages */ HSCMSG_ID i; for (i = 0; i < MAX_MSGID; i++) hsc_set_msg_ignore(hp, i, enable); } else if (!upstrcmp(nxt_arg, IGNORE_NOTES_STR)) { /* enable note messages */ hsc_set_msg_ignore_notes(hp, FALSE); } else if (!upstrcmp(nxt_arg, IGNORE_BADSTYLE_STR)) { /* enable bad style messages */ hsc_set_msg_ignore_style(hp, FALSE); } else if (!upstrcmp(nxt_arg, IGNORE_PORTABILITY_STR)) { /* enable potability problems */ hsc_set_msg_ignore_port(hp, FALSE); } else { /* ignore message # */ LONG ignnum; if (!str2long(nxt_arg, &ignnum)) errmsg = "unknown `enable'"; else hsc_set_msg_ignore(hp, ignnum, enable); } /* next arg */ nxt_arg = strtok(NULL, "|"); } /* while(nxt_arg) */ /* cleanup */ ufreestr(arg_clone); return (errmsg); } /* * arg_include_CB * * argument handler for include directory (IDIR=..) */ static STRPTR arg_incdir_CB(STRPTR arg) { HSCPRC *hp = arg_hp; hsc_add_include_directory(hp, arg); return (NULL); } /* * arg_mode * * argument handler for values that are passed * to "MODE=..". this one resets all ignored * messages. */ static STRPTR arg_mode_CB(STRPTR arg) { STRPTR errmsg = NULL; size_t mode = strenum(arg, MODE_ENUMSTR, '|', STEN_NOCASE); HSCPRC *hp = arg_hp; D(fprintf(stderr, DHSC "args: mode=%s\n", arg)); if (!mode) errmsg = "unknown mode"; else if (mode == MODE_PEDANTIC) { /* pedantic */ /* enable all messages */ HSCMSG_ID i; for (i = 0; i < MAX_MSGID; i++) hsc_set_msg_ignore(hp, i, make_my_day); /* enable all classes */ hsc_set_msg_ignore_notes(hp, FALSE); hsc_set_msg_ignore_style(hp, FALSE); hsc_set_msg_ignore_port(hp, FALSE); } else if (mode == MODE_NORMAL) { /* normal */ /* ignore note messages */ arg_mode_CB(MODE_PEDANTIC_STR); arg_ignore_CB(IGNORE_NOTES_STR); hsc_set_msg_ignore(hp, MSG_WRONG_HEADING, TRUE); hsc_set_msg_ignore(hp, MSG_LF_IN_COMMENT, TRUE); } else if (mode == MODE_RELAXED) { /* relaxed */ arg_mode_CB(MODE_NORMAL_STR); arg_ignore_CB(IGNORE_BADSTYLE_STR); arg_ignore_CB(IGNORE_PORTABILITY_STR); arg_ignore_CB(IGNORE_JERKS_STR); hsc_set_msg_ignore(hp, MSG_MISS_REQTAG, TRUE); hsc_set_msg_ignore(hp, MSG_TAG_OBSOLETE, TRUE); hsc_set_msg_ignore(hp, MSG_TAG_TOO_OFTEN, TRUE); hsc_set_msg_ignore(hp, MSG_CTAG_NESTING, TRUE); } else { /* ignore message # */ LONG ignnum; if (!str2long(arg, &ignnum)) errmsg = "illegal argument"; else hsc_set_msg_ignore(hp, ignnum, TRUE); } return (errmsg); } /* * arg_status * * argument handler for values that are passed * to "STATUS=..". */ static STRPTR arg_status_CB(STRPTR arg) { STRPTR errmsg = NULL; STRPTR argstr = strclone(arg); STRPTR argold = argstr; /* used to call ufree() */ #if DEBUG HSCPRC *hp = arg_hp; #endif D(fprintf(stderr, DHSC "args: status=%s\n", arg)); arg = strtok(argstr, "|"); while (arg) { if (!upstrcmp(arg, STATUS_QUIET_STR)) disp_status = STATUS_QUIET; else if (!upstrcmp(arg, STATUS_LINE_STR)) disp_status |= STATUS_LINE; else if (!upstrcmp(arg, STATUS_VERSION_STR)) disp_status |= STATUS_VERSION; else if (!upstrcmp(arg, STATUS_VERBOSE_STR)) disp_status |= STATUS_VERBOSE; else if (!upstrcmp(arg, STATUS_FULL_STR)) disp_status = -1; else errmsg = "illegal argument"; arg = strtok(NULL, "|"); } ufreestr(argold); return (errmsg); } /* * set/define_dest_attribs, define_source_attribs * * set and define attributes for destination uri */ static VOID set_dest_attribs(HSCPRC * hp, STRPTR destpath, STRPTR reldestpath, 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 (reldestpath) app_estr(fileattr_str, reldestpath); app_estr(fileattr_str, "\">\n<$define HSC.DESTPATH:string/c=\""); if (destpath) app_estr(fileattr_str, destpath); app_estr(fileattr_str, "\">\n<$define HSC.DOCUMENT.URI:string/c=\""); if (destname) app_estr(fileattr_str, reldestpath); if (destname) app_estr(fileattr_str, destname); app_estr(fileattr_str, "\">\n"); } /* 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"); } /* set global attributes to query HSC options from source */ static VOID set_global_attribs(HSCPRC * hp) { STRPTR emode; if (hp->xhtml) app_estr(fileattr_str, "<$define HSC.OPTS.XHTML:bool/c=\"1\">\n"); app_estr(fileattr_str, "<$define HSC.OPTS.ENTITYMODE:string/c=\""); switch(hp->entitymode) { case EMODE_REPLACE : emode = "replace"; break; case EMODE_NUMERIC : emode = "numeric"; break; case EMODE_SYMBOLIC : emode = "symbolic"; break; case EMODE_UTF8 : emode = "utf-8"; break; case EMODE_KEEP : default : emode = "keep"; break; } app_estr(fileattr_str, emode); app_estr(fileattr_str, "\">\n"); } /* set_file_attribs */ static VOID define_file_attribs(HSCPRC * hp) { hsc_include_string(hp, "[define destattr]", estr2str(fileattr_str), IH_PARSE_HSC | IH_NO_STATUS); D(fprintf(stderr, DHSC "destination attributes defines:\n%s", estr2str(fileattr_str)) ); } /* * user_defines_ok * * process all defines passed via user args * * result: always TRUE */ BOOL user_defines_ok(HSCPRC * hp) { /* define destination attributes (HSC.DOCUMENT.URI etc.) */ define_file_attribs(hp); if (define_list && dll_first(define_list)) { DLNODE *nd = dll_first(define_list); EXPSTR *defbuf = init_estr(64); while (nd) { STRPTR defarg = (STRPTR) dln_data(nd); D(fprintf(stderr, DHSC "define using `%s'\n", defarg)); set_estr(defbuf, "<$define "); /* append attribute name */ do { app_estrch(defbuf, defarg[0]); defarg++; } while (defarg[0] && (defarg[0] != '=') && (defarg[0] != '/') && (defarg[0] != ':')); /* if no type set, use "string" as default */ if (defarg[0] != ':') app_estr(defbuf, ":string"); /* append type (if set) and attribute-flags */ while (defarg[0] && (defarg[0] != '=')) { app_estrch(defbuf, defarg[0]); defarg++; } /* append value (if any) and quotes */ if (defarg[0] == '=') { char quote_needed = 0; /* flag: user did not use quotes */ /* append "=" */ app_estrch(defbuf, defarg[0]); defarg++; /* check which kind of quote should be appended */ if ((defarg[0] != '\"') && (defarg[0] != '\'')) { BOOL single_quote = FALSE; BOOL double_quote = FALSE; STRPTR scanarg = defarg; /* scan value for quotes */ while (scanarg[0]) { if (scanarg[0] == '\"') double_quote = TRUE; else if (scanarg[0] == '\'') single_quote = TRUE; scanarg++; } /* choose quote to enclose value */ if (!double_quote) quote_needed = '\"'; else if (!single_quote) quote_needed = '\''; else panic("both quotes in value"); } /* append quote (if not already done by user) */ if (quote_needed) app_estrch(defbuf, quote_needed); /* append value */ while (defarg[0]) { app_estrch(defbuf, defarg[0]); defarg++; } /* append quote (if not already done by user) */ if (quote_needed) app_estrch(defbuf, quote_needed); } /* append end ">" */ app_estrch(defbuf, '>'); D(fprintf(stderr, DHSC "define: `%s'\n", estr2str(defbuf))); hsc_include_string(hp, "DEFINE", estr2str(defbuf), IH_PARSE_HSC | IH_NO_STATUS); nd = dln_next(nd); } del_estr(defbuf); #if 0 hsc_set_msg_ignore(hp, MSG_ARG_NO_QUOTE, old_ignore_quotemsg); #endif } else { D(fprintf(stderr, DHSC "(no defines)\n")); } return ((BOOL) (return_code < RC_ERROR)); } /* * args_ok * * prepare args, check & parse user args, display error and * help message if neccessary * * result: TRUE, if all args ok */ BOOL args_ok(HSCPRC * hp, int argc, char *argv[]) { BOOL ok; /* return value */ DLLIST *ignore_list = NULL; /* dummy */ EXPSTR *destdir = init_estr(32); /* destination dir */ EXPSTR *rel_destdir = init_estr(32); /* relative destination dir */ EXPSTR *kack_name = init_estr(0); /* temp. str for outfilename */ struct arglist *hsc_args; /* argument structure */ LONG maximum_number_of_errors = strtol(DEFAULT_MAXERR, (char **) NULL, 10); LONG maximum_number_of_messages = strtol(DEFAULT_MAXMSG, (char **) NULL, 10); arg_hp = hp; arg_mode_CB(DEFAULT_MODE_STR); /* create arg-table */ hsc_args = prepare_args("HSC_ARGS", /* file args */ "FROM/M", &incfile, "include- and input file(s)", "TO/K", &arg_outfname, "output file (default: stdout)", "PRJFILE/T/K", &prjfilename, "project file (default: none)", "PREFSFILE/T/K", &prefsfilename, "syntax definition file", "MSGFILE=MF/T/K", &msgfilename, "message file (default: stderr)", "MSGFORMAT/T/K", &msg_format, "how to display messages", "MSGBROWSER/T/K", &msg_browser, "message browser to use (default:none)", /* numeric */ "MAXERR/N/K", &maximum_number_of_errors, "max. number of errors (default: " DEFAULT_MAXERR ")", "MAXMSG/N/K", &maximum_number_of_messages, "max. number of messages (default: " DEFAULT_MAXMSG ")", "EXTENSION/T/K", &arg_extension, "output file extension (default: " DEFAULT_EXTENSION ")", "DEFINE=DEF/T/K/M", &define_list, "define global attribute", "IGNORE=IGN/K/M/$", arg_ignore_CB, &ignore_list, "ignore message number or class", "ENABLE=ENA/K/M/$", arg_enable_CB, &ignore_list, "enable message number or class", "MSGMODE/E/K/$", arg_mode_CB, MODE_ENUMSTR, &arg_mode, "mode for syntax check (" MODE_ENUMSTR ")", "QUOTESTYLE=QS/E/K", QMODE_ENUMSTR, &arg_quotemode, "defines how quotes appear (" QMODE_ENUMSTR ")", "ENTITYSTYLE=ES/E/K", EMODE_ENUMSTR, &arg_entitymode, "set character entity rendering (" EMODE_ENUMSTR ")", "INCLUDEDIR=IDIR/K/M/$", arg_incdir_CB, &ignore_list, "add include directory", /* switches */ "COMPACT=CO/S", &arg_compact, "strip useless white spaces", "GETSIZE/S", &arg_getsize, "get width and height of images", "RPLCENT=RE/S", &arg_rplc_ent, "replace special characters", "RPLCQUOTE=RQ/S", &arg_rplc_quote, "replace quotes in text with `"'", "STRIPBADWS/S", &arg_strip_badws, "strip bad whitespace", "STRIPCOMMENT=SC/S", &arg_strip_cmt, "strip SGML comments", "STRIPEXTERNAL=SX/S", &arg_strip_ext, "strip tags with external URIs", "STRIPTAGS=ST/K", &arg_striptags, "tags to be stripped", "ICONBASE/T/K", &arg_iconbase, "base URI for icon entities", "SERVERDIR/T/K", &arg_server_dir, "base directory for server relative URIs", "STATUS/E/K/$", arg_status_CB, STATUS_ENUM_STR, &disp_status, "status message (" STATUS_ENUM_STR ")", "NONESTERR=NNE/S", &arg_nonesterr, "don't show \"previous call\" tracebacks on error", "LOWERCASETAGS=LCT/S", &arg_lctags, "force all tags and attributes to lowercase", "XHTML/S", &arg_xhtml, "use XHTML mode (implies: LCT QS=double)", "NOVALIDATECSS=NVCS/S", &arg_nvcss, "don't validate CSS in STYLE attributes", "CHECKEXTERNAL=CKX/S", &arg_checkext, "check external HTTP links" #ifdef AMIGA "(requires bsdsocket.library)" #endif , "-DEBUG/S", &arg_debug, "enable debugging output if enabled at compile-time", /* help */ "HELP=?=-h=--help/S", &arg_help, "display this text", "LICENSE/S", &arg_license, "display license", NULL); /* remove dummy list TODO: this sucks */ del_dllist(ignore_list); ok = (hsc_args != NULL); /* set & test args */ if (ok) { BOOL use_stdout = FALSE; /* flag: use stdout as output-file */ BOOL any_input_passed = FALSE; /* flag: any input specified in args */ STRPTR argfiles[] = {OPTION_FILE, NULL}; argf = new_argfilev(argfiles); ok = set_args_file(argf, hsc_args) && set_args(argc, argv, hsc_args); /* display help, if requested vie HELP switch, or no * input to pipe or read is passed */ any_input_passed = (incfile && dll_first(incfile)); ok &= (!arg_help && any_input_passed); if (arg_license) { /* display license text */ fprintf_prginfo(stderr); show_license(); set_return_code(RC_WARN); } else if (!ok) { if (arg_help || !any_input_passed) { /* display help, if HELP-switch set */ fprintf_prginfo(stderr); fprintf_arghelp(stderr, hsc_args); } set_return_code(RC_WARN); } else { BOOL fnsux = FALSE; /* flag: TRUE = can't evaluate out-filename */ /* set debugging switch */ hsc_set_debug(hp, arg_debug); /* autoset depending options */ if (hsc_get_debug(hp)) disp_status = STATUS_VERBOSE; /* set default options */ if (!arg_extension) arg_extension = DEFAULT_EXTENSION; /* disable ID-warning if no project-file */ if (!prjfilename) hsc_set_msg_ignore(hp, MSG_NO_DOCENTRY, TRUE); /* compute name of input file */ arg_inpfname = NULL; if (dll_first(incfile)) { /* use last FROM as input file */ arg_inpfname = dln_data(dll_last(incfile)); set_estr(inpfilename, arg_inpfname); /* get path part of inputfilename as relative * destination directory */ get_fpath(rel_destdir, arg_inpfname); /* TODO: set reldir when including first file */ /* TODO: find out why the above TODO is there */ /* remove input filename from incfile */ del_dlnode(incfile, dll_last(incfile)); D(fprintf(stderr, DHSC "input : use `%s'\n" DHSC "reldir: use `%s'\n", estr2str(inpfilename), estr2str(rel_destdir))); } /* display include files */ D( { DLNODE * nd = dll_first(incfile); while (nd) { fprintf(stderr, DHSC "includ: use `%s'\n", ( STRPTR) dln_data(nd)); nd = dln_next(nd); } } ); /* * if no output-filename given, * outfilename stays NULL. this let open_output * open stdout as output-file */ if (arg_outfname) { /* check, if last char of outputfilename is a * directory separator; if so, use the filename * as destination directory */ if (arg_outfname) { UBYTE lastch = 0; #ifdef AMIGA /* treat `TO ""' and `TO=""' the same for AmigaOS */ if (!strcmp(arg_outfname, "\"\"")) { arg_outfname = ""; D(fprintf(stderr, DHSC "AMIGA: use current dir, strange version\n")); } #endif /* get last char of outfname to determine * if it's a directory */ if (strlen(arg_outfname)) lastch = arg_outfname[strlen(arg_outfname) - 1]; #ifdef AMIGA /* for Amiga, accept empty string for current dir */ if (!lastch) { lastch = (PATH_SEPARATOR[0]); D(fprintf(stderr, DHSC "AMIGA: use current dir\n")); } #endif if (strchr(PATH_SEPARATOR, lastch)) { /* use outfilename as destdir */ set_estr(destdir, arg_outfname); arg_outfname = NULL; D(fprintf(stderr, DHSC "output: use `%s' as destdir\n", estr2str(destdir))); } else if (arg_inpfname) { /* output-filename already specified */ /* separate it to destdir + reldir + name */ EXPSTR *kack_destdir = init_estr(0); EXPSTR *kack_reldir = init_estr(0); STRPTR inp_reldir = estr2str(rel_destdir); STRPTR out_reldir = NULL; STRPTR ou2_reldir = NULL; get_fname(kack_name, arg_outfname); get_fpath(kack_destdir, arg_outfname); /* check corresponding dirs for * consistency: check if last strlen(rel_destdir) * chars are equal */ out_reldir = estr2str(kack_destdir); ou2_reldir = out_reldir; out_reldir = out_reldir + (strlen(out_reldir) - strlen(inp_reldir)); if (out_reldir[0]) { /* search for next dir-sparator backwards */ /* (this ones only needed for a smart error message) */ while ((out_reldir != ou2_reldir) && (!strchr(PATH_SEPARATOR, out_reldir[0]))) { out_reldir--; } if (out_reldir != ou2_reldir) out_reldir++; } D(fprintf(stderr, DHSC "corr_inp: `%s'\n" DHSC "corr_out: `%s'\n", inp_reldir, out_reldir)); /* check if correspondig relative in/out-dirs * are equal */ if (!fnamecmp(inp_reldir, out_reldir)) { /* they match.. */ STRPTR tmp_name = NULL; /* copy of kack_nam */ /* cut corresponding chars */ get_left_estr(kack_destdir, kack_destdir, estrlen(kack_destdir) - strlen(out_reldir)); set_estr(kack_reldir, inp_reldir); D(fprintf(stderr, DHSC "kack_dst: `%s'\n" DHSC "kack_rel: `%s'\n" DHSC "kack_nam: `%s'\n", estr2str(kack_destdir), estr2str(kack_reldir), estr2str(kack_name)) ); /* just copy these values where they are * expected to be */ estrcpy(destdir, kack_destdir); estrcpy(rel_destdir, kack_reldir); /* create output filename */ tmp_name = strclone(estr2str(kack_name)); estrcpy(kack_name, kack_destdir); estrcat(kack_name, kack_reldir); app_estr(kack_name, tmp_name); ufreestr(tmp_name); arg_outfname = estr2str(kack_name); } else { /* unmatched corresponding dirs */ fprintf(stderr, "unmatched corresponding relative " "directories:\n input `%s'\n output `%s'\n", inp_reldir, out_reldir); ok = FALSE; } /* free temp. vars */ del_estr(kack_reldir); del_estr(kack_destdir); } } if (arg_outfname) { /* set outputfilename with value passed iwithin args */ outfilename = init_estr(32); set_estr(outfilename, arg_outfname); D(fprintf(stderr, DHSC "output: set to `%s'\n", estr2str(outfilename))); } else { /* no outfilename given */ /* ->outfilename = destdir + inpfilename + ".html" */ /* link destdir & input filename */ outfilename = init_estr(32); link_fname(outfilename, estr2str(destdir), arg_inpfname); if (strcmp(arg_extension, ".")) set_fext(outfilename, arg_extension); D(fprintf(stderr, DHSC "output: concat destdir+inpfile+`.%s'\n" DHSC "output: set to `%s'\n", arg_extension, estr2str(outfilename))); } if (fnsux) { /* no way to find out output filename */ status_error("unable to evaluate output filename\n"); arg_outfname = NULL; ok = FALSE; } } else { D(fprintf(stderr, DHSC "output: use stdout\n")); use_stdout = TRUE; } if (!ok) set_return_code(RC_ERROR); } if (ok) { /* set server dir */ if (arg_server_dir) hsc_set_server_dir(hp, arg_server_dir); /* set icon base */ if (arg_iconbase) hsc_set_iconbase(hp, arg_iconbase); /* check, if stdout should be used as output */ if (!use_stdout) hsc_set_filename_document(hp, estr2str(outfilename)); } /* display argument error message */ if (!ok) { /* NOTE: no strclone() is used on outfilename, if an * error already occured within set_args(). therefore, * you must not call ufreestr( outfilename ) */ pargerr(); arg_outfname = NULL; set_return_code(RC_ERROR); } else { EXPSTR *tmp_fname = init_estr(32); /* filename only part */ fileattr_str = init_estr(64); /* set HSC.DOCUMENT */ if (outfilename) get_fname(tmp_fname, estr2str(outfilename)); set_dest_attribs(hp, estr2str(destdir), estr2str(rel_destdir), estr2str(tmp_fname)); /* set HSC.SOURCE */ if (inpfilename) get_fname(tmp_fname, estr2str(inpfilename)); else clr_estr(tmp_fname); set_source_attribs(hp, estr2str(rel_destdir), estr2str(tmp_fname)); D( { HSCMSG_ID i; fprintf(stderr, "\n" DHSC "input : `%s'\n", estr2str(inpfilename)); fprintf(stderr, DHSC "output: `%s'\n", get_outfilename()); fprintf(stderr, DHSC "destdr: `%s'\n", estr2str(destdir)); fprintf(stderr, DHSC "reldst: `%s'\n", estr2str(rel_destdir)); if (prjfilename) fprintf(stderr, DHSC "projct: `%s'\n", prjfilename); if (!use_stdout) fprintf(stderr, DHSC "procss: `%s'\n", estr2str(outfilename)); /* show classes to be ignored */ fprintf(stderr, DHSC "ignore class:"); if (hsc_get_msg_ignore_notes(hp)) { fprintf(stderr, " notes"); } fprintf(stderr, "\n"); /* show messages to be ignored */ fprintf(stderr, DHSC "ignore:"); for (i = 0; i < MAX_MSGID; i++) { if (hsc_get_msg_ignore(hp, i) == ignore) { fprintf(stderr, " %lu", i); } } fprintf(stderr, "\n"); /* show messages to be enabled */ fprintf(stderr, DHSC "enable:"); for (i = 0; i < MAX_MSGID; i++) { if (hsc_get_msg_ignore(hp, i) == enable) { fprintf(stderr, " %lu", i); } } fprintf(stderr, "\n"); } ); del_estr(tmp_fname); } /* * set flags of hsc-process */ if (ok) { hsc_set_chkid(hp, TRUE); hsc_set_chkuri(hp, TRUE); hsc_set_compact(hp, arg_compact); hsc_set_debug(hp, arg_debug); hsc_set_getsize(hp, arg_getsize); hsc_set_rplc_ent(hp, arg_rplc_ent); hsc_set_rplc_quote(hp, arg_rplc_quote); hsc_set_smart_ent(hp, arg_smart_ent); hsc_set_strip_badws(hp, arg_strip_badws); hsc_set_strip_cmt(hp, arg_strip_cmt); hsc_set_strip_ext(hp, arg_strip_ext); hsc_set_nested_errors(hp, !arg_nonesterr); hsc_set_strip_tags(hp, arg_striptags); hsc_set_lctags(hp, arg_lctags); hsc_set_checkext(hp, arg_checkext); if(arg_xhtml && arg_nvcss) fprintf(stderr, "Warning: cannot disable CSS checking in XHTML mode!\n"); else hsc_set_vcss(hp, !arg_nvcss); if(arg_xhtml && (QMODE_DOUBLE != arg_quotemode)) fprintf(stderr, "Warning: XHTML only allows double quotes, ignoring QUOTESTYLE option!\n"); else hsc_set_quote_mode(hp, arg_quotemode); hsc_set_xhtml(hp, arg_xhtml); hsc_set_entity_mode(hp, arg_entitymode); /* set message limits; 0 means use the value set by * init_hscprc(), which means infinite */ if (maximum_number_of_messages) hsc_set_maximum_messages(hp, maximum_number_of_messages); if (maximum_number_of_errors) hsc_set_maximum_errors(hp, maximum_number_of_errors); /* set directories */ hsc_set_destdir(hp, estr2str(destdir)); hsc_set_reldir(hp, estr2str(rel_destdir)); if (msg_browser != NULL) { STRPTR compilation_unit = estr2str(inpfilename); if (compilation_unit == NULL) compilation_unit = ""; init_msg_browser(hp, compilation_unit); } /* set global attributes according to opts (only XHTML so far) */ set_global_attribs(hp); } /* release mem used by args */ free_args(hsc_args); } else { D( /* only for developer */ fprintf(stderr, "ArgDef error: %lu\n", prep_error_num); ); } del_estr(destdir); del_estr(rel_destdir); del_estr(kack_name); return (ok); } hsc-0.934.orig/hsc/args.h0100600000175000001440000000176207732056111014034 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/args.h * * user argument handling for hsc */ extern BOOL args_ok(HSCPRC * hp, int argc, char *argv[]); extern BOOL user_defines_ok(HSCPRC * hp); extern VOID cleanup_hsc_args(VOID); hsc-0.934.orig/hsc/callback.c0100600000175000001440000002160707732056111014627 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/callback.c * * callbacks of hsc for hsclib * * updated: 14-Sep-1998 * created: 17-Mar-1996 * */ #include "hsc/global.h" #include "hsc/output.h" #include "hsc/status.h" #include "ugly/returncd.h" #define NOEXTERN_HSC_CALLBACK_H #include "hsc/callback.h" /* * defines for ANSI-sequences */ #define ANSI_RESET "\033[0m" #define ANSI_BOLD "\033[1m" #define ANSI_ITALIC "\033[3m" #define ANSI_UNDERLINE "\033[4m" #define ANSI_INVERT "\033[7m" #define ANSI_TEXT_BACKGR "\033[30m" #define ANSI_TEXT_SHADOW "\033[31m" #define ANSI_TEXT_HILITE "\033[32m" #define ANSI_TEXT_STRESS "\033[31m" static FILE *msgfile = NULL; /* * include system specific message browser functions */ #if defined AMIGA #include "amiga/msgbrowser.c" #elif defined RISCOS #include "riscos/msgbrowser.c" #else /* * Generic message browser functions that do nothing but ignore the * MSGBROWSER option. */ BOOL init_msg_browser(HSCPRC * hp, STRPTR filename) { return TRUE; } VOID del_msg_browser(HSCPRC * hp) { /* Do nufin */ } VOID send_msg_browser(HSCPRC * hp, HSCMSG_CLASS msg_class, HSCMSG_ID msg_id, STRPTR fname, ULONG x, ULONG y, STRPTR msg_text) { /* Do nufin */ } #endif /* * hsc_nomem_handler * * called from ugly/umemory/umalloc(), if malloc() did return NULL */ BOOL hsc_nomem_handler(size_t size) { status_error("out of memory"); return_code = RC_FAIL; exit(return_code); return (FALSE); /* immediatly abort */ } /* * message * * hsc-callback to display message coming from parser */ static VOID message(HSCPRC * hp, HSCMSG_CLASS msg_class, HSCMSG_ID msg_id, STRPTR fname, ULONG x, ULONG y, STRPTR msg_text) { STRPTR msg_class_str = "*UNKNOWN*"; STRPTR msg_class_seq = ANSI_BOLD; STRPTR msgfmt = msg_format; BOOL msg_ansi = FALSE; if ((msg_browser != NULL) && (!upstrcmp(msg_browser, "ANSI"))) { msg_ansi = TRUE; } if (!msgfmt) { msgfmt = "%f (%y,%x): %c %i: %m"; } switch (msg_class) { case MSG_NOTE: msg_class_str = "Note"; break; case MSG_STYLE: msg_class_str = "Bad style"; break; case MSG_PORT: msg_class_str = "Portability problem"; break; case MSG_WARN: msg_class_str = "Warning"; break; case MSG_ERROR: msg_class_str = "Error"; msg_class_seq = ANSI_BOLD ANSI_TEXT_HILITE; break; case MSG_FATAL: msg_class_str = "Fatal error"; msg_class_seq = ANSI_BOLD ANSI_TEXT_HILITE; break; } /* update returncode if necessary */ if (msg_class == MSG_WARN) set_return_code(RC_WARN); else if (msg_class == MSG_ERROR) set_return_code(RC_ERROR); else if (msg_class == MSG_FATAL) set_return_code(RC_FAIL); /* couldn't open include file */ if (!fname) { fname = estr2str(inpfilename); x = 1; y = 1; } clr_estr(msgbuf); while (msgfmt[0]) { if (msgfmt[0] == '%') { msgfmt++; switch (msgfmt[0]) { case 'c': if (msg_ansi) app_estr(msgbuf, msg_class_seq); app_estr(msgbuf, msg_class_str); if (msg_ansi) app_estr(msgbuf, ANSI_RESET); break; case 'f': app_estr(msgbuf, fname); break; case 'i': if (msg_ansi) app_estr(msgbuf, msg_class_seq); app_estr(msgbuf, long2str(msg_id)); if (msg_ansi) app_estr(msgbuf, ANSI_RESET); break; case 'm': app_estr(msgbuf, msg_text); break; case 'n': app_estrch(msgbuf, '\n'); break; case 'x': app_estr(msgbuf, long2str(x)); break; case 'y': app_estr(msgbuf, long2str(y)); break; case '%': app_estrch(msgbuf, '%'); break; default: app_estrch(msgbuf, '%'); app_estrch(msgbuf, msgfmt[0]); break; } } else { app_estrch(msgbuf, msgfmt[0]); } msgfmt++; } app_estrch(msgbuf, '\n'); /* append LF */ if ((msg_format == NULL) || (msg_format[0] != '\0')) { fputs(estr2str(msgbuf), msgfile); } /* Send message to browser */ if (msg_browser != NULL) { send_msg_browser(hp, msg_class, msg_id, fname, x, y, msg_text); } D( { if (msgfile != stderr) { fprintf(stderr, DHSC "msg `%s (%ld,%ld): %s %ld: %s'\n", fname, y, x, msg_class_str, msg_id, msg_text); } } ); } /* * message_ref * * hsc-callback to display ref-message coming from parser */ static VOID message_ref(HSCPRC * hp, HSCMSG_CLASS msg_class, HSCMSG_ID msg_id, STRPTR fname, ULONG x, ULONG y, STRPTR msg_text) { if (msg_text && msg_text[0]) message(hp, msg_class, msg_id, fname, x, y, msg_text); else message(hp, msg_class, msg_id, fname, x, y, "(location of previous call)"); } static VOID do_hsc_id(HSCPRC * hp, HSCATTR * attr, STRPTR id) { #if 0 fprintf(stderr, "new id : `%s' for attr `%s'\n", id, attr->name); #endif } /* * do_hsc_start_tag * * hsc-callback for processing start tag */ static VOID do_hsc_start_tag(HSCPRC * hp, HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close) { #if 0 if (tag) fprintf(stderr, "start tag: <%s>\n", tag->name); else fprintf(stderr, "start tag: \n"); #endif append_output(tag_name); append_output(tag_attr); if(hp->xhtml && (tag->option & HT_EMPTY)) { if(hp->xhtml_emptytag) { hsc_message(hp, MSG_XHTML_NOTCLOSED, "EMPTY content model tag %T not closed in XHTML mode", tag); } append_output(" /"); } append_output(tag_close); } static VOID do_hsc_end_tag(HSCPRC * hp, HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close) { #if 0 if (tag) fprintf(stderr, "end tag : \n", tag->name); else fprintf(stderr, "start tag: \n"); #endif append_output(tag_name); append_output(tag_attr); append_output(tag_close); } static VOID do_hsc_text(HSCPRC * hp, STRPTR whtspc, STRPTR text) { #if 0 fprintf(stderr, "text : \"%s\", \"%s\"\n", whtspc, text); #endif append_output(whtspc); append_output(text); } /* * init_callback * * assign hsc's callbacks to a hsc-process */ BOOL init_callback(HSCPRC * hp) { /* status-messages */ hsc_set_status_file_begin(hp, status_file_begin); hsc_set_status_file_end(hp, status_file_end); hsc_set_status_line(hp, status_line); hsc_set_status_misc(hp, status_misc); /* messages */ hsc_set_message(hp, message); hsc_set_message_ref(hp, message_ref); /* processing tags & text */ hsc_set_start_tag(hp, do_hsc_start_tag); hsc_set_end_tag(hp, do_hsc_end_tag); hsc_set_id(hp, do_hsc_id); hsc_set_text(hp, do_hsc_text); return (TRUE); } /* * message file functiuons */ /* * init_msg_file * * open messagefile or assign it to stdderr */ BOOL init_msgfile(HSCPRC * hp, STRPTR fname) { BOOL ok = TRUE; if (fname) { D(fprintf(stderr, DHSC "write msg to `%s'\n", fname)); errno = 0; msgfile = fopen(fname, "w"); if (!msgfile) { #define MSGBUFLEN 79 STRARR msgbuf[MSGBUFLEN + 1]; strncpy(msgbuf, "unable to open message file `", MSGBUFLEN); strncat(msgbuf, fname, MSGBUFLEN - strlen(msgbuf)); strncat(msgbuf, "': ", MSGBUFLEN - strlen(msgbuf)); strncat(msgbuf, strerror(errno), MSGBUFLEN - strlen(msgbuf)); status_error(msgbuf); ok = FALSE; } } else { msgfile = stderr; D(fprintf(stderr, DHSC "write msg to \n")); } return (ok); } /* * cleanup_msg_file * * close message file if neccessary */ VOID cleanup_msgfile(VOID) { if (msgfile && (msgfile != stderr)) fclose(msgfile); } hsc-0.934.orig/hsc/callback.h0100600000175000001440000000275107732056111014633 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/callback.h * * callbacks of hsc for hsclib * */ #ifndef HSC_CALLBACK_H #define HSC_CALLBACK_H /* * global funcs */ #ifndef NOEXTERN_HSC_CALLBACK_H extern BOOL hsc_nomem_handler(size_t size); extern BOOL init_callback(HSCPRC * hp); extern BOOL init_msgfile(HSCPRC * hp, STRPTR fname); extern VOID cleanup_msgfile(VOID); extern BOOL init_msg_browser(HSCPRC * hp, STRPTR filename); extern VOID del_msg_browser(HSCPRC * hp); extern VOID send_msg_browser(HSCPRC * hp, HSCMSG_CLASS msg_class, HSCMSG_ID msg_id, STRPTR fname, ULONG x, ULONG y, STRPTR msg_text); #endif /* NOEXTERN_HSC_CALLBACK_H */ #endif /* HSC_CALLBACK_H */ hsc-0.934.orig/hsc/global.c0100600000175000001440000000520207732056111014324 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/global.c * * global vars & funs for hsc * * updated: 24-Aug-1998 * created: 8-Jul-1995 */ #include #include "hsclib/hsclib.h" #include "ugly/returncd.h" #define NOEXTERN_HSC_GLOBAL_H #include "hsc/global.h" /* * global vars for user args */ EXPSTR *inpfilename = NULL; /* name of input file (def: stdin) */ EXPSTR *outfilename = NULL; /* name of output file (def: stdout) */ STRPTR msgfilename = NULL; /* name of message file (def: stderr) */ STRPTR prjfilename = NULL; /* name for project-file (def: none) */ STRPTR prefsfilename = NULL; /* name for prefs-file (default: search) */ DLLIST *define_list = NULL; /* defines from user-args */ DLLIST *incfile = NULL; /* list of files that should be */ /* included before main file */ int return_code = RC_FAIL; /* exit code of program */ BOOL msg_ansi = FALSE; /* use ANIS-sequences in messages */ STRPTR msg_format = NULL; /* message format */ STRPTR msg_browser = NULL; /* message browser */ EXPSTR *msgbuf = NULL; /* buffer for message */ STRARR misc_buffer[6000]; /* misc. buffer (must be >5000) */ /* * init_global * * init global data */ BOOL init_global(VOID) { BOOL ok = TRUE; return_code = RC_OK; /* init some string */ inpfilename = init_estr(32); msgbuf = init_estr(64); ok = (inpfilename && msgbuf); return (ok); } /* * cleanup_global * * cleanup global data */ VOID cleanup_global(VOID) { del_estr(inpfilename); del_estr(outfilename); del_dllist(define_list); del_dllist(incfile); del_estr(msgbuf); } /* * get_outfilename * * return output filename or `' */ STRPTR get_outfilename(VOID) { if (outfilename) return (estr2str(outfilename)); else return (STDOUT_NAME); } hsc-0.934.orig/hsc/global.h0100600000175000001440000000560707732056111014342 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/global.h * * global variables and functions for hsc * */ #ifndef HSC_GLOBAL_H #define HSC_GLOBAL_H #include #include #include #include "hsclib/hsclib.h" #include "ugly/utypes.h" #include "ugly/dllist.h" #include "ugly/infile.h" #include "ugly/expstr.h" #include "ugly/umemory.h" #include "ugly/ustring.h" #include "hsc/hdebug.h" /* * defines */ #define DHSC "*hscpre* " /* * mode strings for syntax check */ #define MODE_PEDANTIC_STR "pedantic" #define MODE_NORMAL_STR "normal" #define MODE_RELAXED_STR "relaxed" #define MODE_ENUMSTR MODE_PEDANTIC_STR "|" \ MODE_NORMAL_STR "|" \ MODE_RELAXED_STR #define MODE_PEDANTIC 1 #define MODE_NORMAL 2 #define MODE_RELAXED 3 #define DEFAULT_MODE_STR MODE_NORMAL_STR /* * modes for attribute quotes */ #define QMODE_KEEP 1 /* keep quotes from input */ #define QMODE_DOUBLE 2 /* always use double quotes (compatible) */ #define QMODE_SINGLE 3 /* always use single quotes */ #define QMODE_NONE 4 /* never use any quotes (compact) */ #define QMODE_ENUMSTR "keep|double|single|none" /* * modes for special characters/entity extraction */ #define EMODE_ENUMSTR "keep|replace|numeric|symbolic|utf-8" /* * special values for ignore */ #define IGNORE_ALL_STR "all" #define IGNORE_BADSTYLE_STR "style" #define IGNORE_PORTABILITY_STR "portability" #define IGNORE_JERKS_STR "jerk" #define IGNORE_NOTES_STR "note" /* pseudo-name for stdout */ #define STDOUT_NAME "" /* * * extern references * */ #ifndef NOEXTERN_HSC_GLOBAL_H extern EXPSTR *inpfilename; extern EXPSTR *outfilename; extern BOOL msg_ansi; extern STRPTR msgfilename; extern STRPTR prjfilename; extern STRPTR prefsfilename; extern DLLIST *define_list; extern DLLIST *incfile; extern STRPTR msg_format; extern STRPTR msg_browser; extern EXPSTR *msgbuf; extern int return_code; extern BOOL init_global(VOID); extern VOID cleanup_global(VOID); extern STRPTR get_outfilename(VOID); #endif /* NOEXTERN_HSC_GLOBAL_H */ #endif /* HSC_GLOBAL_H */ hsc-0.934.orig/hsc/hdebug.h0100600000175000001440000000202607732056111014330 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef HSC_DEBUG_H #define HSC_DEBUG_H /* * hsc/debug_hsc.h * * hsc debugging defines. * */ #ifdef DEBUG_UGLY #define DEBUG_HSC_OUTPUT 0 #else #define DEBUG_HSC_OUTPUT 0 #endif /* DEBUG_HSC */ #endif /* HSC_DEBUG_H */ hsc-0.934.orig/hsc/hsc.c0100600000175000001440000002066207732056111013650 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc - html sucks completely * * Another stupid html-preprocessor * *------------------------------------------------------------------- * * Author : Thomas Aglassinger (Tommy-Saftwörx) * Email : agi@giga.or.at, agi@sbox.tu-graz.ac.at * *------------------------------------------------------------------- * * hsc/hsc.c * * updated: 9-Aug-1998 * created: 1-Jul-1995 */ #include "hsc/hsc_rev.h" #include "hsc/global.h" #include "ugly/prginfo.h" #include "hscprj/project.h" #ifndef BETA #define BETA 0 #endif /* * ugly includes */ #include "ugly/uargs.h" #include "ugly/returncd.h" /* * local includes */ #include "hsc/args.h" #include "hsc/callback.h" #include "hsc/output.h" #include "hsc/status.h" /* import AmigaOS version string from "hsc/hsc_rev.h" */ #ifdef AMIGA static const char AmigaOS_version[] = VERSTAG; #endif /* hsc-process structure that is used during * the wohle conversion */ static HSCPRC *hp = NULL; /* * attempt_atexit * * try to add another atexit()-function; if it fails, * abort with error message */ static BOOL attempt_atexit(VOID (*func) (VOID)) { #define ERRMSG_LEN 300 BOOL ok = FALSE; errno = 0; if (atexit(func)) { /* atexit() failed; display error message */ char errmsg[ERRMSG_LEN]; strncpy(errmsg, "atexit() failed: ", ERRMSG_LEN); strncat(errmsg, strerror(errno), ERRMSG_LEN); status_error(errmsg); } else { ok = TRUE; } return ok; } /* * includes_ok * * process include-files passed via command line */ static BOOL include_ok(HSCPRC * hp) { BOOL ok = TRUE; if (incfile) { DLNODE *nd = dll_first(incfile); while (nd && ok) { STRPTR filename = (STRPTR) dln_data(nd); ok = hsc_include_file(hp, filename, IH_IS_INCLUDE); nd = dln_next(nd); } } return (ok); } /* * cleanup: free all resources * (called in any case) */ static VOID cleanup(VOID) { #if DEBUG /* just because I'm curious how long cleanup lasts */ /* NOTE: obviously, it last very long */ fputs("(cleanup)\r", stderr); fflush(stderr); #endif del_hscprc(hp); cleanup_global(); cleanup_output(); cleanup_msgfile(); cleanup_hsc_args(); #if DEBUG fputs(" \r", stderr); fflush(stderr); #endif } /* * callback to display "project-file corrupt"-message */ static VOID msg_corrupt_pf(HSCPRJ * project, STRPTR reason) { EXPSTR *msg = init_estr(32); set_estr(msg, infget_fname(project->inpf)); app_estr(msg, ": project file corrupt"); if (reason) { app_estr(msg, " ("); app_estr(msg, reason); app_estr(msg, ")"); } status_error(estr2str(msg)); del_estr(msg); } /* * hsc_init_project * * read project-file */ static BOOL hsc_init_project(HSCPRC * hp, STRPTR project_fname) { BOOL ok = FALSE; /* init project */ hp->project = new_project(); hp->project->user_data = (APTR) hp; hp->project->debug = hp->debug; hp->project->CB_msg_corrupt_pf = msg_corrupt_pf; if (project_fname) { /* * read project-data */ D(fprintf(stderr, DHL "read project file `%s'\n", project_fname)); hsc_status_file_begin(hp, project_fname); /* read project-file */ hp->inpf = infopen(project_fname, 0); if (hp->inpf) { ok = hsc_project_read_data(hp->project, hp->inpf); infclose(hp->inpf); if (ok) { /* message about success */ EXPSTR *msg = init_estr(32); set_estr(msg, project_fname); app_estr(msg, ": project read"); hsc_status_misc(hp, estr2str(msg)); del_estr(msg); } hp->inpf = NULL; } else { fprintf(stderr, "%s: error reading project file: %s\n", project_fname, strerror(errno)); ok = FALSE; } } else { D(fprintf(stderr, DHL "no project file to load\n")); ok = TRUE; } if (ok) { /* dettach current document */ hsc_project_set_document(hp->project, hp->filename_document); } return (ok); } /* * hsc_main() */ int hsc_main(HSCPRC ** hpVar, int argc, char *argv[]) { BOOL init_hp = FALSE; if (!(*hpVar)) { hp = new_hscprc(); /* alloc new hsc-process */ init_hp = TRUE; *hpVar = hp; } else { hp = *hpVar; reset_hscprc(hp); } if (hp && init_global() /* init global vars */ && args_ok(hp, argc, argv) /* process user args */ ) { STRPTR inpfname = NULL; /* input-filename */ BOOL ok = TRUE; /* display programm-info if requested */ if (disp_status_version) { fprintf_prginfo(stderr); } if (init_msgfile(hp, msgfilename) /* open message file */ && init_output(hp)) /* open output file */ { /* init return code; later modified by message() */ return_code = RC_OK; /* evaluate input-filename; use NULL for stdin */ inpfname = estr2str(inpfilename); if (!inpfname[0]) inpfname = NULL; /* * init process, read preferences and project (for new process) */ if (ok && init_hp) { ok = (init_callback(hp) /* assign callbacks */ && hsc_init_tagsNattr(hp) && user_defines_ok(hp) && hsc_init_hscprc(hp, prefsfilename) /* init hsc-process */ && hsc_init_project(hp, prjfilename)); /* read project */ } /* * process user defines and files, write output */ if (ok && include_ok(hp) /* read include files (macros) */ && hsc_include_file(hp, inpfname, IH_PARSE_END | IH_IS_SOURCE | IH_UPDATE_PRJ) /* read main file */ ) { if (write_output(hp)) /* write output file */ { /* write project file */ hsc_project_write_data(hp->project, prjfilename, FALSE); } } } } return (return_code); } /* * * main function * */ int main(int argc, char *argv[]) { int main_return_code = RC_FAIL; BOOL atexit_ok = TRUE; /* set program information */ set_prginfo("hsc", UGLY_AUTHOR, VERSION, REVISION, BETA, "html sucks completely", "Freeware, type `hsc LICENSE' for details."); #if DEBUG /* display a memory tracking report * at end of execution */ atexit_ok = attempt_atexit(atexit_uglymemory); #endif /* install nomem-handler; this one displays an error message * and aborts the program */ ugly_nomem_handler = hsc_nomem_handler; /* use cleanup() as additional exit func * (even called in case of out-of-memory) */ if (atexit_ok) { atexit_ok = attempt_atexit(cleanup); } /* if still all right, let's dance */ if (atexit_ok) { HSCPRC *hpVar = NULL; main_return_code = hsc_main(&hpVar, argc, argv); } #ifdef SINGLE_CLIENT_SERVER /* * The following code is needed for project data * exchage with the hsc-single-client-project-server. * * Concepts and implementation by Andreas Gassner */ strcmp("a", "b"); #endif return (main_return_code); } hsc-0.934.orig/hsc/hsc_rev.h0100600000175000001440000000244310010407556014522 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #define STRINGIFY(x) _STRINGIFY(x) #define _STRINGIFY(x) #x #define VERSION 0 #define REVISION 934 #define DATE "05.02.04" #define TIME "17:39:03" #define __VSTR STRINGIFY(VERSION) #define __RSTR STRINGIFY(REVISION) #define PRGNAME "hsc" #define VERS PRGNAME __VSTR "." __RSTR #define VSTRING PRGNAME __VSTR "." __RSTR DATE "\r\n" #define VERSTAG "\0$VER: " PRGNAME __VSTR "." __RSTR DATE #define BASENAME "HSC" #define VSTR PRGNAME __VSTR "." __RSTR DATE hsc-0.934.orig/hsc/output.c0100600000175000001440000001173707732056112014437 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/output.c * * output functions for hsc * * updated: 20-Mar-1996 * created: 1-Jul-1995 */ #include #include "hsc/global.h" #include "hsc/status.h" #include "ugly/returncd.h" #ifdef RISCOS #include "riscos/unixname.h" #include #endif #define OUTPUT_STEPSIZE 8192 static DLLIST *outlist = NULL; /* * del_outstr */ static VOID del_outstr(APTR data) { del_estr((EXPSTR *) data); } /* * init_output: * * init output string * * result: TRUE if sucessful, else FALSE */ BOOL init_output(HSCPRC * hp) { BOOL ok = TRUE; /* return value */ EXPSTR *outstring = init_estr(OUTPUT_STEPSIZE); /* first output string */ outlist = init_dllist((del_outstr)); /* init outstring-list */ app_dlnode(outlist, (APTR) outstring); /* append first entry */ return (ok); } /* * cleanup_output: * * free output string * */ VOID cleanup_output(VOID) { del_dllist(outlist); } /* * close_output * * close output file, if it not stdout */ BOOL write_output(HSCPRC * hp) { #define MAX_ERRORLEN 500 STRPTR outfilenm = NULL; BOOL written = FALSE; if (outfilename) outfilenm = estr2str(outfilename); if ((return_code == RC_OK) || (return_code == RC_WARN) || hp->debug) { FILE *outfile = NULL; /* output file */ char buf[MAX_ERRORLEN + 2]; /* buffer for error string */ /* * try to open output file */ if (outfilenm) { errno = 0; outfile = fopen(outfilenm, "w"); if (!outfile) { strncpy(buf, "unable to open `", MAX_ERRORLEN); strncat(buf, estr2str(outfilename), MAX_ERRORLEN - strlen(buf)); strncat(buf, "' for output: ", MAX_ERRORLEN - strlen(buf)); strncat(buf, strerror(errno), MAX_ERRORLEN - strlen(buf)); status_error(buf); } } else { outfile = stdout; outfilenm = STDOUT_NAME; } /* * write output */ if (outfile) { DLNODE *nd = dll_first(outlist); status_msg("writing output.."); errno = 0; /* write whole list of output-strings */ while (nd && !errno) { EXPSTR *outstring = (EXPSTR *) dln_data(nd); nd = dln_next(nd); #if 1 fwrite(estr2str(outstring), sizeof(char), estrlen(outstring), outfile); #endif } /* handle write-error, display message */ if (errno) { strncpy(buf, "error writing `", MAX_ERRORLEN); strncat(buf, estr2str(outfilename), MAX_ERRORLEN - strlen(buf)); strncat(buf, "': ", MAX_ERRORLEN - strlen(buf)); strncat(buf, strerror(errno), MAX_ERRORLEN - strlen(buf)); status_error(buf); } else written = TRUE; status_clear(); /* close output file */ if (outfile != stdout) { fclose(outfile); #ifdef RISCOS { /* set the filetype to HTML (&FAF) */ char *riscos_filename=unixname_to_riscos(outfilenm); _swix(OS_File,_IN(0)|_IN(1)|_IN(2),18,riscos_filename,0xFAF); free(riscos_filename); } #endif } } } else { status_msg("no output written"); status_lf(); } return (written); } /* * append_output * * append text to output string */ VOID append_output(STRPTR text) { EXPSTR *outstr = (EXPSTR *) dln_data(dll_last(outlist)); /* check if current output-string will be full */ if ((estrlen(outstr) + strlen(text) + 1) > OUTPUT_STEPSIZE) { /* if so, append a new output-string to the list * and make use this one */ #if DEBUG_HSC_OUTPUT fprintf(stderr, DHSC "new string after %lu/%lu chars\n", estrlen(outstr), OUTPUT_STEPSIZE); #endif outstr = init_estr(OUTPUT_STEPSIZE); app_dlnode(outlist, (APTR) outstr); } app_estr(outstr, text); } hsc-0.934.orig/hsc/output.h0100600000175000001440000000210407732056112014430 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/output.h * * output functions for hsc */ #ifndef HSC_OUTPUT_H #define HSC_OUTPUT_H extern BOOL init_output(HSCPRC * hp); extern VOID cleanup_output(VOID); extern BOOL write_output(HSCPRC * hp); extern VOID append_output(STRPTR text); #endif /* HSC_OUTPUT_H */ hsc-0.934.orig/hsc/status.c0100600000175000001440000001317207732056112014415 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/status.c * * status message functions for hsc * * updated: 30-Sep-1997 * created: 30-Jul-1995 * */ /* * local includes */ #include "hsc/global.h" #define NOEXTERN_HSC_STATUS #include "hsc/status.h" #include "ugly/returncd.h" LONG disp_status = STATUS_LINE; /* mode for status message */ static size_t prev_stmsg_len = 0; /* length of previos status message */ static ULONG prev_status_line = 0; /* previous line num in input file */ #define ST_LINE_QUANTUM 25 /* num of lines that have to be processed */ /* before a status message is printed */ #define MAX_STATUSLEN 160 static STRARR status_buf[MAX_STATUSLEN + 2]; /* buffer for status messages */ /* * set_return_code * * Set new value for return-code of program. If the old retcode * is greater than the new one, nothing is changed. */ VOID set_return_code(int newrc) { if (newrc > return_code) { #if DEBUG_HSCPRE_RETCODE fprintf(stderr, DHSC "returncode: set to %d\n", return_code); #endif return_code = newrc; } #if DEBUG_HSCPRE_RETCODE else { fprintf(stderr, DHSC "returncode: NOT set to %d (is: %d)\n", newrc, return_code); } #endif } /* * status_msg * * display a status message * * params: s.....message to display */ VOID status_msg(STRPTR s) { size_t new_stmsg_len = strlen(s); size_t i; if (disp_status) { /* display message */ if (s[0]) fputs(s, stderr); /* clear tail of old message */ for (i = new_stmsg_len; i < prev_stmsg_len; i++) fputs(" ", stderr); /* perform cr & flush stdder */ fputs("\r", stderr); fflush(stderr); prev_stmsg_len = new_stmsg_len; } } /* * status_clear * * clear status message */ VOID status_clear(VOID) { status_msg(""); } /* * status_file_and_line * * copy status message for current file & line * processing into status_buf[] * * NOTE: messages >79 chars are truncated */ static VOID status_file_and_line(HSCPRC * hp) { STRPTR filename = hsc_get_file_name(hp); if (filename) { /* create status-string */ /* NOTE: this is not done via sprintf(), because * no check for a too long string would be done */ strncpy(status_buf, filename, MAX_STATUSLEN); strncat(status_buf, " (", MAX_STATUSLEN - strlen(status_buf)); strncat(status_buf, long2str(hsc_get_file_line(hp)), MAX_STATUSLEN - strlen(status_buf)); strncat(status_buf, ")", MAX_STATUSLEN - strlen(status_buf)); } else { strcpy(status_buf, ""); } status_msg(status_buf); } /* * status_lf * * perform a linfeed with status messages * (old message will stay visible) */ VOID status_lf(VOID) { if (disp_status) { fputs("\n", stderr); prev_status_line = 0; } } /* * status_file_end * * hsc-callback for file fully processed: display * file and total number of line, perform liefeed */ VOID status_file_begin(HSCPRC * hp, STRPTR filename) { if (filename) { /* create status-string: " (reading)" */ /* NOTE: this is not done via sprintf(), because * no check for a too long string would be done */ strncpy(status_buf, filename, MAX_STATUSLEN); strncat(status_buf, " (reading)", MAX_STATUSLEN - strlen(status_buf)); status_msg(status_buf); } } /* * status_file_end * * hsc-callback for file fully processed: display * file and total number of line, perform liefeed */ VOID status_file_end(HSCPRC * hp) { status_file_and_line(hp); status_msg(status_buf); status_lf(); } /* * status_line */ VOID status_line(HSCPRC * hp) { if (disp_status_line #if 1 /* set this to '0' to see every line displayed in status */ && ((hsc_get_file_line(hp) - prev_status_line) > ST_LINE_QUANTUM) #endif ) { status_file_and_line(hp); status_msg(status_buf); prev_status_line = hsc_get_file_line(hp); } } /* * status_misc * * display misc. status messages */ VOID status_misc(HSCPRC * hp, STRPTR s) { if (disp_status_verbose) { strcpy(status_buf, ""); #if 0 status_file_and_line(hp); #endif strncat(status_buf, s, MAX_STATUSLEN - strlen(status_buf)); status_msg(status_buf); status_lf(); } } /* * status_error * * display error status messages */ VOID status_error(STRPTR s) { /* store current status flags, enable status output */ LONG old_disp_status = disp_status; disp_status = STATUS_LINE; /* display error message */ strncpy(status_buf, "*** ", MAX_STATUSLEN); strncat(status_buf, s, MAX_STATUSLEN); status_msg(status_buf); status_lf(); /* restore status flags */ disp_status = old_disp_status; set_return_code(RC_ERROR); } hsc-0.934.orig/hsc/status.h0100600000175000001440000000456307732056112014426 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsc/status.h * * status messages * */ #ifndef HSC_STATUS_H #define HSC_STATUS_H #include #include "ugly/utypes.h" #include "ugly/infile.h" #define STATUS_QUIET 0 /* no status */ #define STATUS_LINE (1<<0) /* line which parser currently processes */ #define STATUS_VERSION (1<<1) /* display program version */ #define STATUS_VERBOSE (1<<2) /* more verbose output */ #define STATUS_QUIET_STR "quiet" #define STATUS_LINE_STR "line" #define STATUS_VERSION_STR "version" #define STATUS_VERBOSE_STR "verbose" #define STATUS_FULL_STR "full" #define STATUS_ENUM_STR STATUS_QUIET_STR "|" \ STATUS_LINE_STR "|" \ STATUS_VERSION_STR "|" \ STATUS_VERBOSE_STR "|" \ STATUS_FULL_STR #define disp_status_quiet (!disp_status) #define disp_status_line (disp_status & STATUS_LINE) #define disp_status_version (disp_status & (STATUS_VERSION | STATUS_VERBOSE)) #define disp_status_verbose (disp_status & STATUS_VERBOSE) #ifndef NOEXTERN_HSC_STATUS /* * global funcs & vars */ extern LONG disp_status; extern VOID set_return_code(int newrc); extern VOID status_lf(VOID); extern VOID status_file_begin(HSCPRC * hp, STRPTR filename); extern VOID status_file_end(HSCPRC * hp); extern VOID status_line(HSCPRC * hp); extern VOID status_misc(HSCPRC * hp, STRPTR s); extern VOID status_error(STRPTR s); extern VOID status_clear(VOID); extern VOID status_msg(STRPTR s); #endif /* NOEXTERN_HSC_STATUS */ #endif /* HSC_STATUS_H */ hsc-0.934.orig/hsclib/0040700000175000001440000000000010010444412013375 5ustar loryusershsc-0.934.orig/hsclib/all_hscl.c0100600000175000001440000000425007732056102015336 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* compile while hsclib as a single file */ #define NOEXTERN_HSCLIB_ATTRIBUTE_H #define NOEXTERN_HSCLIB_LMESSAGE_H #define NOEXTERN_HSCLIB_URI_H #define NOEXTERN_HSCLIB_DEFATTR #define NOEXTERN_HSCLIB_ENTITY_H #define NOEXTERN_HSCLIB_EVAL_H #define NOEXTERN_HSCLIB_HSCPRC #define NOEXTERN_HSCLIB_ID_H #define NOEXTERN_HSCLIB_INCLUDE_H #define NOEXTERN_HSCLIB_PARSE_H #define NOEXTERN_HSCLIB_SKIP_H #define NOEXTERN_HSCLIB_TAG_H #include "hsclib/ldebug.h" #include "hsclib/msgid.h" #include "ugly/utypes.h" #include "ugly/dllist.h" #include "ugly/expstr.h" #include "ugly/umemory.h" #include "ugly/infile.h" #include "ugly/ustring.h" #include "hsclib/lmessage.c" #include "hsclib/entity.c" #include "hsclib/tag.c" #include "hsclib/attrib.c" #include "hsclib/idref.c" #include "hsclib/hscprc.c" #include "hsclib/lstatus.c" #include "hsclib/input.c" #include "hsclib/skip.c" #include "hsclib/uri.c" #include "hsclib/eval.c" #include "hsclib/posteval.c" #include "hsclib/defattr.c" #include "hsclib/deftag.c" #include "hsclib/css.c" BOOL hsc_include_string( HSCPRC *hp, STRPTR filename, STRPTR s, ULONG optn ); #include "hsclib/parse.c" #include "hsclib/include.c" #include "hsclib/linit.c" #include "hsclib/size.c" #include "hsclib/tag_misc.c" #include "hsclib/tag_a.c" #include "hsclib/tag_hsc.c" #include "hsclib/tag_if.c" #include "hsclib/tag_macro.c" hsc-0.934.orig/hsclib/attrib.c0100600000175000001440000002143607732056102015047 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/attribute.c * * hsc-variable funcs for hsc * */ #define NOEXTERN_HSCLIB_ATTRIBUTE_H #include "hsclib/inc_base.h" #include "hsclib/eval.h" #include "hsclib/uri.h" /* *------------------------------------- * debugging functions *------------------------------------- */ /* * prt_var */ #ifdef DEBUG static VOID prt_var(FILE * stream, APTR data) { HSCATTR *var = (HSCATTR *) data; if (NULL != var) { int varquote = var->quote; if (varquote == VQ_NO_QUOTE) varquote = '.'; /* name & type & macro_id */ fprintf(stream, "%s (type:%u,mci:%lu) ", var->name, var->vartype, var->macro_id); /* text value */ if (var->text) fprintf(stream, "cur:%c%s%c", var->quote, var->text, varquote); else fprintf(stream, ""); fprintf(stream, " "); /* default text */ if (var->deftext) fprintf(stream, "def:%c%s%c", var->quote, var->deftext, varquote); else fprintf(stream, ""); fprintf(stream, "\n"); } else fprintf(stream, "\n"); } VOID prt_varlist(DLLIST * varlist, STRPTR title) { fprintf(stderr, DHL "%s\n", title); fprintf_dllist(stderr, varlist, prt_var); } #endif /* *------------------------------------- * constructor/destructor *------------------------------------- */ /* * del_hscattr * * delete attribute */ VOID del_hscattr(APTR data) { HSCATTR *var = (HSCATTR *) data; #if DEBUG_ATTR fprintf(stderr, DHL " del_attr %s (mci=%d)\n", var->name, var->macro_id); #endif /* release mem */ ufreestr(var->name); ufreestr(var->deftext); ufreestr(var->text); ufreestr(var->enumstr); var->macro_id = 0; var->varflag = 0; var->vartype = VT_NONE; var->quote = EOF; ufree(var); } /* * new_hscattr * * alloc & init a new variable */ HSCATTR *new_hscattr(CONSTRPTR newname) { HSCATTR *newvar = (HSCATTR *) umalloc(sizeof(HSCATTR)); #if DEBUG_ATTR fprintf(stderr, DHL " new_attr %s\n", newname); #endif if (newvar) { /* init new varument item */ newvar->vartype = VT_NONE; newvar->name = strclone(newname); newvar->deftext = NULL; newvar->text = NULL; newvar->enumstr = NULL; newvar->macro_id = 0; if (upstrncmp(newname, PREFIX_HSCATTR, strlen(PREFIX_HSCATTR))) newvar->varflag = 0; else newvar->varflag = VF_KEEP_QUOTES; newvar->quote = VQ_NO_QUOTE; } if (!(newvar->name)) { del_hscattr((APTR) newvar); newvar = NULL; } return (newvar); } /* * cpy_hscattr * * create copy of an already existing attribute */ HSCATTR *cpy_hscattr(HSCATTR * oldvar) { HSCATTR *newvar = new_hscattr(oldvar->name); if (newvar) { newvar->vartype = oldvar->vartype; if (oldvar->deftext) newvar->deftext = strclone(oldvar->deftext); if (oldvar->text) newvar->text = strclone(oldvar->text); if (oldvar->enumstr) newvar->enumstr = strclone(oldvar->enumstr); newvar->macro_id = oldvar->macro_id; newvar->varflag = oldvar->varflag; newvar->quote = oldvar->quote; } if (!(newvar->name)) { del_hscattr((APTR) newvar); newvar = NULL; } return (newvar); } /* * app_var * * append a new var to the var list AT BEGINNING */ HSCATTR *app_var(DLLIST * varlist, STRPTR newname) { HSCATTR *var = new_hscattr(newname); BOOL ok = FALSE; if (var) ok = (add_dlnode(varlist, (APTR) var) != NULL); if (!ok) { del_hscattr((APTR) var); var = NULL; } return (var); } /* *------------------------------------- * search functions *------------------------------------- */ /* * cmp_varname * * compares a var-name with the name of a HSCATTR-entry */ static int cmp_varname(const APTR cmpstr, const APTR vardata) { STRPTR varstr = NULL; if(vardata) varstr = ((HSCATTR*)vardata)->name; if(varstr) return upstrcmp((STRPTR)cmpstr, ((HSCATTR*)vardata)->name) ? 0 : -1; return 0; } /* * find_attrnode */ DLNODE *find_attrnode(DLLIST * varlist, STRPTR name) { return find_dlnode(varlist->first, (APTR) name, cmp_varname); } /* * find_varname */ HSCATTR *find_varname(DLLIST * varlist, STRPTR name) { DLNODE *nd = find_dlnode(varlist->first, (APTR) name, cmp_varname); if(nd) return (HSCATTR*)nd->data; return NULL; } /* *------------------------------------- * misc. functions *------------------------------------- */ /* * set_vartext * * set value of a var * * params: var......var to set * newtext..new text to set * result: value of new text set * errors: return NULL if out of mem, display error message */ STRPTR set_vartext(HSCATTR * var, STRPTR newtext) { if (!var) panic("NULL attribute detected"); if (newtext != var->text) { ufreestr(var->text); if (newtext) var->text = strclone(newtext); else var->text = NULL; } return (var->text); } /* * set_varbool * * set value of a boolean attr * * params: var....var to set * value..new value to set * result: value * errors: if out of mem, display error message */ BOOL set_varbool(HSCATTR * attr, BOOL value) { if (value) set_vartext(attr, attr->name); else set_vartext(attr, ""); return (value); } /* * clr_vartext * * clear or reset var to default text * * params: var..var to clear * result: TRUE, if new value set correctly */ BOOL clr_vartext(HSCATTR * var) { BOOL ok = TRUE; if (var->deftext) { if (!(set_vartext(var, var->deftext))) ok = FALSE; } else { ufreestr(var->text); var->text = NULL; } return (ok); } /* * clr_attrdef * * clear attributes default text * * params: attr..attr to clear */ VOID clr_attrdef(HSCATTR * attr) { ufreestr(attr->deftext); attr->deftext = NULL; } /* * clr_varlist * * clear all vars to default text * * params: varlist..varlist to clear */ BOOL clr_varlist(DLLIST * varlist) { DLNODE *nd = varlist->first; BOOL ok = TRUE; while (nd && ok) { ok &= clr_vartext((HSCATTR *) nd->data); nd = nd->next; } return (ok); } /* * clr_varlist_bool * * set all "empty" (=NULL) boolean attributes of * an attr list to FALSE * * params: varlist..varlist to process */ VOID clr_varlist_bool(DLLIST * varlist) { DLNODE *nd = varlist->first; BOOL ok = TRUE; while (nd && ok) { HSCATTR *attr = (HSCATTR *) nd->data; if ((attr->vartype == VT_BOOL) && !(attr->text)) set_varbool(attr, FALSE); nd = nd->next; } } /* * get_vartext_byname: get text value of a var * * */ STRPTR get_vartext_byname(DLLIST * varlist, STRPTR name) { HSCATTR *var = find_varname(varlist, name); STRPTR vartext = NULL; if (var) vartext = var->text; return (vartext); } /* * get_vartext: get text value of a var * */ STRPTR get_vartext(HSCATTR * var) { return (var == NULL) ? NULL : var->text; } /* * get_varbool: get value of a boolean attr */ BOOL get_varbool(HSCATTR * attr) { BOOL set = FALSE; if (attr && (attr->text[0])) set = TRUE; return (set); } /* * get_varbool_byname: get value of a boolean attr */ BOOL get_varbool_byname(DLLIST * varlist, STRPTR name) { HSCATTR *var = find_varname(varlist, name); return (get_varbool(var)); } /* * get_varnum: get value of a numeric attr */ LONG get_varnum(HSCATTR * attr) { LONG num = 0; if (attr && (attr->text) && (attr->text[0])) str2long(attr->text, &num); return (num); } /* * get_varnum_byname: get value of a numeric attr */ LONG get_varnum_byname(DLLIST * varlist, STRPTR name) { HSCATTR *var = find_varname(varlist, name); return (get_varnum(var)); } /* * get_vardeftext: get default text value of a var * */ STRPTR get_vardeftext(HSCATTR * var) { STRPTR deftext = NULL; if (var) deftext = var->deftext; return (deftext); } /* $Id: attrib.c,v 1.6 2003/07/06 04:37:34 mb Exp mb $ */ hsc-0.934.orig/hsclib/attrib.h0100600000175000001440000001456507772171502015067 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/attribute.h * * attribute structure and funcs for hsc */ #ifndef HSC_ATTRIBUTE_H #define HSC_ATTRIBUTE_H #include "ugly/infile.h" /* variable types */ #define VT_NONE 0 /* no type; only after init */ #define VT_URI 1 /* uri */ #define VT_STRING 2 /* text string */ #define VT_BOOL 3 /* boolean */ #define VT_NUM 4 /* TODO: numeric */ #define VT_ENUM 5 /* enumerator */ #define VT_ID 6 /* TODO: id (name reference) */ #define VT_COLOR 7 /* TODO: jerk's color */ #define VT_STR_URI "URI" /* uri */ #define VT_STR_STRING "STRING" /* text string */ #define VT_STR_BOOL "BOOL" /* boolean */ #define VT_STR_NUM "NUM" /* numeric */ #define VT_STR_ENUM "ENUM" /* enumerator */ #define VT_STR_ID "ID" /* id (name reference) */ #define VT_STR_COLOR "COLOR" /* color */ /* variable flags */ #define VF_ONLYONCE (1<<0) /* attribute may occure only once */ #define VF_REQUIRED (1<<1) /* attribute is required */ #define VF_CONST (1<<2) /* attribute is read-only: <$DEFINE> */ #define VF_JERK (1<<3) /* attribute only used by jerks */ #define VF_STRIPEXT (1<<4) /* URI: strip tag, if external */ #define VF_GETSIZE (1<<5) /* URI: get WIDTH & HEIGHT from here */ #define VF_RECOMMENDED (1<<6) /* attribute is recommended to appear */ #define VF_OBSOLETE (1<<7) /* attribute is obsolete/deprecated */ #define VF_KEEP_QUOTES (1<<28) /* keep quotes untouched */ #define VF_GLOBAL (1<<29) /* attribute is global: <$DEFINE> */ #define VF_MACRO (1<<30) /* macro-attr */ #define VF_TAG (1<<31) /* tag-attr (see note below) */ /* * NOTE on VF_TAG: * * Within uri-attributes, there is one problem: if you pass * an uri-attr to a macro or <$define>, the uri is parsed twice, * when attribute is passed to tag. * This produces shit when the uri is parsed the second time * (eg absolute uri is converted again) * * Therefore, uris are only parsed, if the VF_TAG-flag is * enabled. By default, VF_TAG is disabled and can only be * enabled when copying local macro attribute to the global * attribute list. (see "copy_local_varlist()" in "attrib.c") */ #define VF_CONST_STR "CONST" /* attr is read only <$DEFINE> */ #define VF_CONST_SHT "C" #define VF_GLOBAL_STR "GLOBAL" /* global attribute <$DEFINE> */ #define VF_GLOBAL_SHT "G" #define VF_JERK_STR "JERK" /* attr only used by jerks */ #define VF_JERK_SHT "J" #define VF_ONLYONCE_STR "ONLYONCE" /* attr may appear only once in tag */ #define VF_ONLYONCE_SHT "1" #define VF_REQUIRED_STR "REQUIRED" /* attr is required */ #define VF_REQUIRED_SHT "R" #define VF_STRIPEXT_STR "STRIPEXT" /* strip tag, if URI is external */ #define VF_STRIPEXT_SHT "X" #define VF_GETSIZE_STR "GETSIZE" /* follow URI to get WIDTH & HEIGHT */ #define VF_GETSIZE_SHT "Z" #define VF_RECOMMENDED_STR "RECOMMENDED" /* attribute is recommended */ #define VF_RECOMMENDED_SHT "RCMD" #define VF_OBSOLETE_STR "OBSOLETE" /* attribute is obsolete */ #define VF_OBSOLETE_SHT "O" /* prefix for temporary attributes */ #define PREFIX_HSCATTR "HSC." #define PREFIX_TMPATTR "HSC.TMP." /* chars that act like opening/closing quote */ #define VQ_STR_QUOTE "\"'" /* "no quote" value for quote in HSCATTR */ #define VQ_NO_QUOTE (0) /* error return value for set_macro_args() to set var->macro_id with */ #define MCI_GLOBAL (0) /* indicate global attributes */ #define MCI_ERROR (0xffffffff) #define MCI_APPCTAG (0xfffffffe ) /* used by app_ctag(); see "tag.c" */ /* attribute structure */ typedef struct hscattr { STRPTR name; /* macro id */ STRPTR deftext; /* deftext text */ STRPTR text; /* text to be expanded to */ STRPTR enumstr; /* enumerator string */ ULONG macro_id; /* macro-call-id for local var */ ULONG varflag; /* flags; see VF_xx */ int quote; /* quote char */ BYTE vartype; /* type; see VT_xx */ } HSCATTR; #define HSCVAR HSCATTR /* TODO: remove */ /* a CSS element */ typedef struct hscstyle { STRPTR name; STRPTR value; } HSCSTYLE; /* * global funcs */ #ifndef NOEXTERN_HSCLIB_VARS_H extern VOID prt_varlist(DLLIST * varlist, STRPTR title); extern HSCATTR *new_hscattr(CONSTRPTR newname); extern VOID del_hscattr(APTR data); extern HSCATTR *cpy_hscattr(HSCATTR * oldvar); extern DLNODE *find_attrnode(DLLIST * varlist, STRPTR name); extern HSCATTR *find_varname(DLLIST * varlist, STRPTR name); extern HSCATTR *app_var(DLLIST * varlist, STRPTR newname); extern BOOL check_enumstr(HSCATTR * var, STRPTR value, INFILE * inpf); extern STRPTR set_vartext(HSCATTR * var, STRPTR newtext); extern BOOL set_varbool(HSCATTR * attr, BOOL value); extern BOOL clr_vartext(HSCATTR * var); extern VOID clr_attrdef(HSCATTR * attr); extern BOOL clr_varlist(DLLIST * varlist); extern VOID clr_varlist_bool(DLLIST * varlist); extern STRPTR get_vartext_byname(DLLIST * varlist, STRPTR name); extern STRPTR get_vartext(HSCATTR * var); extern BOOL get_varbool_byname(DLLIST * varlist, STRPTR name); extern BOOL get_varbool(HSCATTR * attr); extern LONG get_varnum(HSCATTR * attr); extern LONG get_varnum_byname(DLLIST * varlist, STRPTR name); extern STRPTR get_vardeftext(HSCATTR * var); #endif /* NOEXTERN_HSCLIB_ATTRIBUTE_H */ #endif /* HSCLIB_ATTRIBUTE_H */ /* $Id: attrib.h,v 1.5 2003/12/24 02:00:15 mb Exp mb $ */ /* vi: set ts=4: */ hsc-0.934.orig/hsclib/hscprc.c0100600000175000001440000004766010010444322015037 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hscprc.c * * hsc process functions * */ #define NOEXTERN_HSCLIB_HSCPRC #include "hsclib/inc_base.h" #include "ugly/fname.h" #include "ugly/ustrlist.h" #include "ugly/returncd.h" #include "hscprj/project.h" #include "hsclib/idref.h" #include "hsclib/tag_if.h" #include "hsclib/css.h" /* * del_inpf_stack_node * * remove node from input file stack */ static VOID del_inpf_stack_node(APTR data) { /* do nufin */ } /* * del_hscprc * * remove hsc process and all it's resources */ VOID del_hscprc(HSCPRC * hp) { if (hp) { /* remove list */ del_dllist(hp->defstyle); del_dllist(hp->defent); del_dllist(hp->deftag); del_dllist(hp->defattr); del_dllist(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 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); } } /* * reset_hscprc * * reset all items of a hsc process */ VOID reset_hscprc(HSCPRC * hp) { int i; /* get current time */ hp->start_time = time(NULL); /* reset strings */ clr_estr(hp->destdir); clr_estr(hp->reldir); clr_estr(hp->if_stack); clr_estr(hp->whtspc); hp->suppress_output = TRUE; hp->fatal = FALSE; hp->prev_heading_num = 0; hp->prev_status_line = (ULONG) - 1; hp->msg_count = 0; hp->inside_pre = FALSE; hp->inside_anchor = FALSE; hp->inside_title = FALSE; hp->tag_next_whtspc = NULL; hp->strip_badws = FALSE; hp->strip_next_whtspc = FALSE; hp->strip_next2_whtspc = FALSE; ufreestr(hp->strip_tags); /* check for prostitute */ hp->prostitute = (getenv(ENV_HSCSALARY) != NULL); hp->nested_errors = TRUE; hp->lctags = FALSE; hp->xhtml = FALSE; /* allow infinite number messages */ hp->max_messages = MAXIMUM_MESSAGE_INFINITE; hp->max_errors = MAXIMUM_MESSAGE_INFINITE; /* enable all messages */ hp->msg_ignore_notes = FALSE; hp->msg_ignore_style = FALSE; hp->msg_ignore_port = FALSE; for (i = 0; i <= MAX_MSGID; i++) { hp->msg_ignore[i] = FALSE; hp->msg_class[i] = MSG_NOTE; } } /* * new_hscprc * * create and init a new hsc process */ HSCPRC *new_hscprc(void) { HSCPRC *hp = NULL; hp = (HSCPRC *) umalloc(sizeof(HSCPRC)); if (hp) { memset(hp, 0, sizeof(HSCPRC)); /* init lists */ hp->defent = init_dllist(del_entity); hp->deftag = init_dllist(del_hsctag); hp->defattr = init_dllist(del_hscattr); hp->deflazy = init_dllist(del_hsctag); hp->defstyle = init_dllist(del_styleattr); hp->container_stack = init_dllist(del_hsctag); hp->content_stack = init_dllist(del_string_node); hp->inpf_stack = init_dllist(del_inpf_stack_node); hp->project = NULL; hp->idrefs = init_dllist(del_idref); hp->select_stack = init_dllist(del_select_stack_node); hp->tag_styles = init_dllist(&del_styleattr); hp->include_dirs = init_strlist(); /* init strings */ hp->destdir = init_estr(0); hp->reldir = init_estr(0); hp->iconbase = init_estr(0); hp->server_dir = init_estr(0); hp->if_stack = init_estr(0); hp->tag_name_str = init_estr(128); hp->tag_attr_str = init_estr(128); hp->tag_close_str = init_estr(0); hp->tmpstr = init_estr(0); hp->curr_msg = init_estr(64); hp->curr_ref = init_estr(64); hp->whtspc = init_estr(0); /* allocate message arrays */ hp->msg_ignore = (HSCIGN *) umalloc((MAX_MSGID + 1) * sizeof(HSCIGN)); hp->msg_class = (HSCMSG_CLASS *) umalloc((MAX_MSGID + 1) * sizeof(HSCMSG_CLASS)); /* allocate image buffer */ hp->image_buffer = (unsigned char *) umalloc(IMAGE_BUFFER_SIZE); reset_hscprc(hp); } return (hp); } /* * * GET-methods for public item of HSCPRC * */ /* * get flags */ BOOL hsc_get_chkid(HSCPRC * hp) { return (hp->chkid); } BOOL hsc_get_chkuri(HSCPRC * hp) { return (hp->chkuri); } BOOL hsc_get_compact(HSCPRC * hp) { return (hp->compact); } BOOL hsc_get_debug(HSCPRC * hp) { return (hp->debug); } BOOL hsc_get_getsize(HSCPRC * hp) { return (hp->getsize); } BOOL hsc_get_htmlonly(HSCPRC * hp) { return (hp->htmlonly); } BOOL hsc_get_jerkvalues(HSCPRC * hp) { return (hp->jerkvalues); } BOOL hsc_get_rplc_ent(HSCPRC * hp) { return (hp->rplc_ent); } BOOL hsc_get_rplc_quote(HSCPRC * hp) { return (hp->rplc_quote); } BOOL hsc_get_smart_ent(HSCPRC * hp) { return (hp->smart_ent); } BOOL hsc_get_strip_badws(HSCPRC * hp) { return (hp->strip_badws); } BOOL hsc_get_strip_cmt(HSCPRC * hp) { return (hp->strip_cmt); } BOOL hsc_get_strip_ext(HSCPRC * hp) { return (hp->strip_ext); } BOOL hsc_get_nested_errors(HSCPRC * hp) { return (hp->nested_errors); } BOOL hsc_get_lctags(HSCPRC * hp) { return (hp->lctags); } BOOL hsc_get_xhtml(HSCPRC * hp) { return (hp->xhtml); } /* * get internal flags */ BOOL hsc_get_suppress_output(HSCPRC * hp) { return (hp->suppress_output); } BOOL hsc_get_inside_pre(HSCPRC * hp) { return (hp->inside_pre); } BOOL hsc_get_inside_anchor(HSCPRC * hp) { return (hp->inside_anchor); } BOOL hsc_get_fatal(HSCPRC * hp) { return (hp->fatal); } /* * get values */ STRPTR hsc_get_destdir(HSCPRC * hp) { return (estr2str(hp->destdir)); } STRPTR hsc_get_reldir(HSCPRC * hp) { return (estr2str(hp->reldir)); } STRPTR hsc_get_iconbase(HSCPRC * hp) { return (estr2str(hp->iconbase)); } STRPTR hsc_get_server_dir(HSCPRC * hp) { return (estr2str(hp->server_dir)); } /* * get internal values */ STRPTR hsc_get_click_here_str(HSCPRC * hp) { return (hp->click_here_str); } STRPTR hsc_get_file_name(HSCPRC * hp) { if (hp->inpf) return (infget_fname(hp->inpf)); else return (NULL); } ULONG hsc_get_file_line(HSCPRC * hp) { if (hp->inpf) return (infget_y(hp->inpf)); else return (0); } ULONG hsc_get_file_column(HSCPRC * hp) { if (hp->inpf) return (infget_x(hp->inpf)); else return (0); } ULONG hsc_get_msg_count(HSCPRC * hp) { return (hp->msg_count); } /* * * SET-methodes for public item of HSCPRC * */ /* * set values */ BOOL hsc_set_destdir(HSCPRC * hp, STRPTR dir) { set_estr(hp->destdir, dir); /* append "/" if neccessary */ link_fname(hp->destdir, estr2str(hp->destdir), ""); D(fprintf(stderr, DHL "destdir=`%s'\n", estr2str(hp->destdir))); return (TRUE); } BOOL hsc_set_reldir(HSCPRC * hp, STRPTR dir) { /* append "/" if neccessary */ link_fname(hp->reldir, dir, ""); D(fprintf(stderr, DHL "reldir =`%s'\n", estr2str(hp->reldir))); return (TRUE); } BOOL hsc_set_iconbase(HSCPRC * hp, STRPTR uri) { set_estr(hp->iconbase, uri); D(fprintf(stderr, DHL "iconbase=`%s'\n", estr2str(hp->iconbase))); return (TRUE); } BOOL hsc_set_server_dir(HSCPRC * hp, STRPTR dir) { set_estr(hp->server_dir, dir); /* if dir does not already end with a directory separator, * append if now */ if (!strchr(PATH_SEPARATOR, last_ch(dir))) { app_estrch(hp->server_dir, PATH_SEPARATOR[0]); } D(fprintf(stderr, DHL "serverdir=`%s'\n", estr2str(hp->server_dir))); return (TRUE); } BOOL hsc_set_strip_tags(HSCPRC * hp, STRPTR taglist) { reallocstr(&(hp->strip_tags), taglist); return (TRUE); } BOOL hsc_set_filename_document(HSCPRC * hp, STRPTR filename) { BOOL ok = FALSE; D(fprintf(stderr, DHL "document=`%s'\n", filename)); hp->filename_document = strclone(filename); return (ok); } /* * set flags */ VOID hsc_set_chkid(HSCPRC * hp, BOOL new_chkid) { hp->chkid = new_chkid; D(fprintf(stderr, DHL "flag: chkid =%d\n", new_chkid)); } VOID hsc_set_chkuri(HSCPRC * hp, BOOL new_chkuri) { hp->chkuri = new_chkuri; D(fprintf(stderr, DHL "flag: chkuri =%d\n", new_chkuri)); } VOID hsc_set_compact(HSCPRC * hp, BOOL new_compact) { hp->compact = new_compact; D(fprintf(stderr, DHL "flag: compact =%d\n", new_compact)); } VOID hsc_set_debug(HSCPRC * hp, BOOL new_debug) { hp->debug = new_debug; D(fprintf(stderr, DHL "flag: debug =%d\n", new_debug)); } VOID hsc_set_getsize(HSCPRC * hp, BOOL new_getsize) { hp->getsize = new_getsize; D(fprintf(stderr, DHL "flag: getsize =%d\n", new_getsize)); } VOID hsc_set_jerkvalues(HSCPRC * hp, BOOL new_jerkvalues) { hp->jerkvalues = new_jerkvalues; D(fprintf(stderr, DHL "flag: jerkval =%d\n", new_jerkvalues)); } VOID hsc_set_rplc_ent(HSCPRC * hp, BOOL new_rplc_ent) { hp->rplc_ent = new_rplc_ent; D(fprintf(stderr, DHL "flag: rplc_ent =%d\n", new_rplc_ent)); } VOID hsc_set_rplc_quote(HSCPRC * hp, BOOL new_rplc_quote) { hp->rplc_quote = new_rplc_quote; D(fprintf(stderr, DHL "flag: rplc_quote =%d\n", new_rplc_quote)); } VOID hsc_set_smart_ent(HSCPRC * hp, BOOL new_smart_ent) { hp->smart_ent = new_smart_ent; D(fprintf(stderr, DHL "flag: smart_ent=%d\n", new_smart_ent)); } VOID hsc_set_strip_badws(HSCPRC * hp, BOOL new_strip_badws) { hp->strip_badws = new_strip_badws; D(fprintf(stderr, DHL "flag: strip_bws=%d\n", new_strip_badws)); } VOID hsc_set_strip_cmt(HSCPRC * hp, BOOL new_strip_cmt) { hp->strip_cmt = new_strip_cmt; D(fprintf(stderr, DHL "flag: strip_cmt=%d\n", new_strip_cmt)); } VOID hsc_set_strip_ext(HSCPRC * hp, BOOL new_strip_ext) { hp->strip_ext = new_strip_ext; D(fprintf(stderr, DHL "flag: strip_ext=%d\n", new_strip_ext)); } VOID hsc_set_nested_errors(HSCPRC * hp, BOOL new_nested_errors) { hp->nested_errors = new_nested_errors; D(fprintf(stderr, DHL "flag: nested_errors=%d\n", new_nested_errors)); } VOID hsc_set_lctags(HSCPRC * hp, BOOL new_lctags) { hp->lctags = new_lctags; D(fprintf(stderr, DHL "flag: lctags=%d\n", new_lctags)); } VOID hsc_set_checkext(HSCPRC * hp, BOOL new_checkext) { hp->checkext = new_checkext; D(fprintf(stderr, DHL "flag: checkext=%d\n", new_checkext)); } VOID hsc_set_xhtml(HSCPRC * hp, BOOL new_xhtml) { if((hp->xhtml = new_xhtml)) { hp->lctags = TRUE; /* XHTML implies LOWERCASETAGS */ hp->quotemode = QMODE_DOUBLE; /* use double quotes */ hp->validate_css = TRUE; /* CSS should be validated */ hp->entitymode = EMODE_UTF8; /* output UTF-8 instead of ASCII entities */ } D(fprintf(stderr, DHL "flag: xhtml=%d\n", new_xhtml)); } VOID hsc_set_vcss(HSCPRC * hp, BOOL new_vcss) { hp->validate_css = new_vcss; D(fprintf(stderr, DHL "flag: validatecss=%d\n", new_vcss)); } /* * set values */ VOID hsc_set_quote_mode(HSCPRC * hp, LONG new_mode) { hp->quotemode = new_mode; D(fprintf(stderr, DHL "quote_mode=%ld\n", new_mode)); } VOID hsc_set_entity_mode(HSCPRC * hp, LONG new_mode) { if(EMODE_INVALID == new_mode) new_mode = EMODE_KEEP; /* default if unspecified */ hp->entitymode = new_mode; D(fprintf(stderr, DHL "entity_mode=%ld\n", new_mode)); } VOID hsc_set_maximum_messages(HSCPRC * hp, LONG messages) { hp->max_messages = messages; } VOID hsc_set_maximum_errors(HSCPRC * hp, LONG errors) { hp->max_errors = errors; } /* * set call-backs */ VOID hsc_set_status_file_begin(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp, STRPTR filename)) { hp->CB_status_file_begin = status_file; } VOID hsc_set_status_file_end(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp)) { hp->CB_status_file_end = status_file; } VOID hsc_set_status_line(HSCPRC * hp, VOID(*status_line) (HSCPRC * hp)) { hp->CB_status_line = status_line; } VOID hsc_set_status_misc(HSCPRC * hp, VOID(*status_misc) (HSCPRC * hp, STRPTR s)) { hp->CB_status_misc = status_misc; } VOID hsc_set_message( HSCPRC * hp, VOID(*message) (struct hsc_process * hp, HSCMSG_CLASS msg_class, HSCMSG_ID msg_id, STRPTR fname, ULONG x, ULONG y, STRPTR msg_text)) { hp->CB_message = message; } VOID hsc_set_message_ref( HSCPRC * hp, VOID(*message_ref) (struct hsc_process * hp, HSCMSG_CLASS msg_class, HSCMSG_ID msg_id, STRPTR fname, ULONG x, ULONG y, STRPTR msg_text)) { hp->CB_message_ref = message_ref; } VOID hsc_set_start_tag(HSCPRC * hp, VOID(*start_tag) (struct hsc_process * hp, HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close)) { hp->CB_start_tag = start_tag; } VOID hsc_set_end_tag(HSCPRC * hp, VOID(*end_tag) (struct hsc_process * hp, HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close)) { hp->CB_end_tag = end_tag; } VOID hsc_set_text(HSCPRC * hp, VOID(*text) (struct hsc_process * hp, STRPTR white_spaces, STRPTR text)) { hp->CB_text = text; } VOID hsc_set_id(HSCPRC * hp, VOID(*id) (struct hsc_process * hp, HSCATTR * attr, STRPTR id)) { hp->CB_id = id; } /* * message methodes */ BOOL hsc_set_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id, HSCIGN value) { BOOL set = FALSE; if ((msg_id & MASK_MESSAGE) <= MAX_MSGID) hp->msg_ignore[msg_id & MASK_MESSAGE] = value; return (set); } HSCIGN hsc_get_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id) { /* HSCMSG_ID max_msgid = MAX_MSGID; */ return ((msg_id & MASK_MESSAGE) <= MAX_MSGID) ? hp->msg_ignore[msg_id & MASK_MESSAGE] : FALSE; } BOOL hsc_set_msg_class(HSCPRC * hp, HSCMSG_ID msg_id, HSCMSG_CLASS msg_class) { BOOL set = FALSE; if ((msg_id & MASK_MESSAGE) <= MAX_MSGID) hp->msg_class[msg_id & MASK_MESSAGE] = msg_class; return (set); } HSCMSG_CLASS hsc_get_msg_class(HSCPRC * hp, HSCMSG_ID msg_id) { HSCMSG_ID msg_id_unmasked = msg_id & MASK_MESSAGE; if (msg_id_unmasked <= MAX_MSGID) { HSCMSG_CLASS mchp = hp->msg_class[msg_id_unmasked]; HSCMSG_CLASS mcid = msg_id & MASK_MSG_CLASS; return (mcid > mchp) ? mcid : mchp; } return (MSG_NONE); } /* * set message classes to be ignored */ BOOL hsc_get_msg_ignore_notes(HSCPRC * hp) { return hp->msg_ignore_notes; } BOOL hsc_get_msg_ignore_style(HSCPRC * hp) { return hp->msg_ignore_style; } BOOL hsc_get_msg_ignore_port(HSCPRC * hp) { return hp->msg_ignore_port; } BOOL hsc_set_msg_ignore_notes(HSCPRC * hp, BOOL value) { hp->msg_ignore_notes = value; return (value); } BOOL hsc_set_msg_ignore_style(HSCPRC * hp, BOOL value) { hp->msg_ignore_style = value; return (value); } BOOL hsc_set_msg_ignore_port(HSCPRC * hp, BOOL value) { hp->msg_ignore_port = value; return (value); } /* * reset whole arrays for message-class/ignores */ VOID hsc_clear_msg_ignore(HSCPRC * hp) { size_t i; for (i = 0; i <= MAX_MSGID; i++) hp->msg_ignore[i] = FALSE; } VOID hsc_reset_msg_class(HSCPRC * hp) { size_t i; for (i = 0; i <= MAX_MSGID; i++) hp->msg_class[i] = MSG_NONE; } /* * methods for include-directories */ BOOL hsc_add_include_directory(HSCPRC * hp, STRPTR dir) { return ((BOOL) (app_strnode(hp->include_dirs, dir) != NULL)); } VOID hsc_clr_include_directory(HSCPRC * hp) { clr_strlist(hp->include_dirs); } /* *------------------------------------- * misc. funtions for white spaces *------------------------------------- */ /* * compactWs - reduce white space string to blank * or linefeed */ STRPTR compactWs(HSCPRC * hp, STRPTR ws) { STRPTR newWs = ""; if (ws[0]) { /* any white spaces at all */ STRPTR containsLF = strchr(ws, '\n'); STRPTR containsCR = strchr(ws, '\r'); if (containsLF) { if (containsCR) newWs = "\r\n"; else newWs = "\n"; } else { if (containsCR) newWs = "\r"; else newWs = " "; } } return (newWs); } /* * 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); } /* * nomem-handler */ BOOL hsc_standard_nomem_handler(size_t size) { fputs("\n*** out of memory\n\n", stderr); exit(RC_FAIL); return (FALSE); /* abort immediately */ } /* $Id: hscprc.c,v 1.8 2004/02/05 13:44:35 mb Exp mb $ */ /* vi: set ts=4: */ hsc-0.934.orig/hsclib/css.c0100600000175000001440000001010107732056102014335 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/css.c * * Support functions for Cascading Stylesheet values * */ #include "hsclib/inc_base.h" #include "hsclib/css.h" /* * cmp_stylename * * compares a string with a style element's name (for find_dlnode) */ static int cmp_stylename(const APTR cmpstr, const APTR vardata) { return upstrcmp((STRPTR)cmpstr, ((HSCSTYLE*)vardata)->name) ? 0 : -1; } /* * find_stylename */ static HSCSTYLE *find_stylename(DLLIST *stylelist, CONSTRPTR name) { DLNODE *nd = find_dlnode(stylelist->first, (APTR) name, cmp_stylename); if(nd) return (HSCSTYLE*)nd->data; return NULL; } /* * new_styleattr * * alloc & init a new style element */ HSCSTYLE *new_styleattr(CONSTRPTR name, CONSTRPTR value) { HSCSTYLE *newvar = (HSCSTYLE*)umalloc(sizeof(HSCSTYLE)); #if DEBUG_ATTR fprintf(stderr, DHL " new_styleattr\n"); #endif if(newvar) { newvar->name = strclone(name); newvar->value = strclone(value); } return newvar; } /* * del_styleattr * * delete style element */ VOID del_styleattr(APTR data) { #if DEBUG_ATTR fprintf(stderr, DHL " del_styleattr %s (mci=%d)\n", var->name, var->macro_id); #endif ufreestr(((HSCSTYLE*)data)->name); ufreestr(((HSCSTYLE*)data)->value); ufree(data); } /* * add_styleattr * * Adds a CSS style definition (property/value) to its list in hp. If a * property is present already, its value will be overwritten and a warning * issued. A TRUE return value means the property did not exist yet. */ BOOL add_styleattr(HSCPRC *hp, CONSTRPTR property, CONSTRPTR value) { HSCSTYLE *styledef; /* check if CSS property is already defined for this tag */ if(NULL != (styledef = find_stylename(hp->tag_styles,property))) { hsc_message(hp, MSG_STYLE_REDEFINED, "CSS property %q redefined, previous value was %q", property,styledef->value); ufreestr(styledef->value); styledef->value = strclone(value); return FALSE; } else { /* check if this is a valid property unless check was disabled */ if(hp->validate_css) { if(NULL == (styledef = find_stylename(hp->defstyle,property))) { /* this property is unknown */ hsc_message(hp, MSG_INVALID_STYLE, "unknown CSS property %q", property); }else { /* property is OK, so check value */ if((NULL != styledef->value) && !strenum(value,styledef->value,'|',STEN_CASE)) { /* defined property has non-empty value, but actual value was not * found therein */ hsc_message(hp, MSG_INVALID_STYLE, "value %q invalid for CSS property %q", value, property); } } } styledef = new_styleattr(property,value); app_dlnode(hp->tag_styles,styledef); return FALSE; } } /* * add_width_height_attrs * * Adds "width" and "height" properties to the current tag */ BOOL add_width_height_attrs(HSCPRC *hp, ULONG width, ULONG height) { char buf[10+2+1]; BOOL rw,rh; /* make string from integers */ sprintf(buf,"%ldpx",width); rw = add_styleattr(hp,"width",buf); sprintf(buf,"%ldpx",height); rh = add_styleattr(hp,"height",buf); return (BOOL)(rw && rh); } /* $Id: css.c,v 1.5 2003/07/06 04:37:34 mb Exp mb $ */ hsc-0.934.orig/hsclib/css.h0100600000175000001440000000247107732056102014355 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/css.h * * Support functions for Cascading Stylesheet values * */ #ifndef HSC_CSS_H #define HSC_CSS_H #ifndef NOEXTERN_HSCLIB_CSS_H HSCSTYLE *new_styleattr(CONSTRPTR name, CONSTRPTR value); extern BOOL add_styleattr(HSCPRC *hp, CONSTRPTR property, CONSTRPTR value); extern VOID del_styleattr(APTR data); extern BOOL add_width_height_attrs(HSCPRC *hp, ULONG width, ULONG height); #endif /* NOEXTERN_CSS_H */ #endif /* HSC_CSS_H */ /* $Id: css.h,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */ /* vi: set ts=4: */ hsc-0.934.orig/hsclib/tcpip.c0100600000175000001440000002641210010444220014661 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/tcpip.c * * Functions for TCP/IP-based protocols support * * created: 23-Dec-2003 */ #include "hsclib/tcpip.h" #include "hsclib/ldebug.h" #include "hsclib/lmessage.h" #include "hsclib/msgid.h" #include "ugly/umemory.h" #include #include #include #include #include #ifdef AMIGA #include #include #include #include #include #include #include struct Library *SocketBase; #elif defined UNIX #include #include #include #include #include #else /* this system is not yet supported, just create a dummy function */ BOOL check_ext_uri(HSCPRC *hp, char *uri) { hsc_message(hp, MSG_NO_EXTCHECK, "cannot check external URIs -- system not supported"); return FALSE; } #endif #if defined(UNIX) || defined(AMIGA) #define HTTP_METHOD ("HEAD ") #define HTTP_VERSION (" HTTP/1.0") #define RCVBUF_SIZE (256) #define REPLYLEN (12) /* the following protocols are only supported via proxy */ #define check_ftp_uri(h,u,p) (check_proxyonly_uri(h,u,p)) #define check_gopher_uri(h,u,p) (check_proxyonly_uri(h,u,p)) /* get_http_hdr * Tries an HTTP/1.0 HEAD request for the given URI and returns a success code * Arguments: * fulluri: complete URI, only used for error reporting * host : name of server to contact. May be NULL if proxy!=NULL * proxy : name of proxy, if any. NULL otherwise * res : resource to fetch from server. Set res==fulluri unless proxy==NULL! * port : port of server/proxy to contact. Usually 80 for HTTP, 3128 for Squid * proxies */ static BOOL get_http_hdr( HSCPRC *hp, CONSTRPTR fulluri, CONSTRPTR host, CONSTRPTR proxy, CONSTRPTR res, unsigned short port) { EXPSTR *message, *request; BOOL reading, ret = FALSE; int sock, nread, n; struct sockaddr_in saddr; struct hostent *he; char *rcvbuf, *cr=NULL; D(fprintf(stderr,DHL "get_http_hdr(%s,%s,%s,%s,%hd)\n",fulluri,host,proxy,res,port);) #ifdef AMIGA if(NULL == (SocketBase = OpenLibrary("bsdsocket.library",0))) { hsc_message(hp, MSG_NO_EXTCHECK, "cannot check external URIs -- no bsdsocket.library"); return FALSE; } #endif /* top directories must be requested as "/", even though they are sometimes * not explicitly given in the URI */ if('\0' == *res) res = "/"; /* allocate buffer for reply */ rcvbuf = ucalloc(RCVBUF_SIZE,1); /* create socket */ if(-1 != (sock = socket(PF_INET, SOCK_STREAM, 0))) { /* construct HTTP request */ request = init_estr(64); set_estr(request,HTTP_METHOD); app_estr(request,res); app_estr(request,HTTP_VERSION); app_estr(request,"\r\n"); /* if no proxy in use, send "Host:" line too (virtual server support) */ if(NULL == proxy) { app_estr(request,"Host: "); app_estr(request,host); app_estr(request,"\r\n"); } app_estr(request,"\r\n"); /* resolve server/proxy name */ if(NULL != (he = gethostbyname((proxy != NULL) ? proxy : host))) { saddr.sin_family = AF_INET; saddr.sin_port = htons(port); saddr.sin_addr.s_addr = *((unsigned long*)(he->h_addr_list[0])); /* connect to server */ if(-1 != connect(sock,(struct sockaddr*)&saddr,sizeof(saddr))) { /* send request */ D(fprintf(stderr,DHL "Requesting '%s' %s %s\n", estr2str(request),(NULL==proxy)?"from":"via",(NULL==proxy)?host:proxy);) write(sock,estr2str(request),strlen(estr2str(request))); shutdown(sock,SHUT_WR); /* read first part of response: "HTTP/x.x xxx " */ for(nread=0,reading=TRUE; reading && (REPLYLEN-nread);) { switch(n = read(sock,rcvbuf,REPLYLEN-nread)) { case -1 : hsc_message(hp, MSG_DUBIOUS_EXTURI, "dubious external URI \"%s\": error reading from server: %s", fulluri,strerror(errno)); reading = FALSE; break; case 0 : hsc_message(hp, MSG_DUBIOUS_EXTURI, "dubious external URI \"%s\": short read from server", fulluri); reading = FALSE; break; default : nread += n; break; } } if(REPLYLEN == nread) { D(fprintf(stderr,DHL "Response: %s\n",rcvbuf);) if(0 == strncmp(rcvbuf,"HTTP/",5)) { switch(rcvbuf[9]) { case '2' : ret = TRUE; /* success! */ break; case '4' : case '5' : hsc_message(hp, MSG_NO_EXTURI, "external URI \"%s\" does not exist (error code %s)",fulluri,rcvbuf+9); break; case '3' : /* count 302 as success */ if(('0' == rcvbuf[10]) && ('2' == rcvbuf[11])) { ret = TRUE; break; } /* fall through */ default : message = init_estr(32); set_estr(message,rcvbuf+9); /* read rest of response */ while((nread = read(sock,rcvbuf,RCVBUF_SIZE-1)) > 0) { if(-1 == nread) break; if(NULL == cr) { cr = strchr(rcvbuf,'\r'); if(NULL != cr) *cr = '\0'; app_estr(message,rcvbuf); } /* else do nothing, just read message until end */ } hsc_message(hp, MSG_DUBIOUS_EXTURI, "dubious external URI \"%s\": server said \"%s\"",fulluri,estr2str(message)); del_estr(message); ret = TRUE; /* we'll count this as OK... */ break; } } else { /* this should hardly ever happen and counts as OK */ D(fprintf(stderr,DHL "Apparently HTTP/0.9; server response: '%s'\n",rcvbuf);) ret = TRUE; } } /* error handled before */ } else { if(NULL==proxy) hsc_message(hp, MSG_NO_EXTURI, "external URI \"%s\" does not exist (no connection to server)",fulluri); else hsc_message(hp, MSG_DUBIOUS_EXTURI, "dubious external URI \"%s\": proxy \"%s\" is down", fulluri,proxy); } } else { if(NULL==proxy) hsc_message(hp, MSG_NO_EXTURI, "external URI \"%s\" does not exist: host address not found", fulluri,proxy); else hsc_message(hp, MSG_DUBIOUS_EXTURI, "dubious external URI \"%s\": no address for proxy \"%s\"", fulluri,proxy); } del_estr(request); close(sock); } else hsc_message(hp, MSG_NO_EXTCHECK, "socket() failed: %s)",strerror(errno)); ufree(rcvbuf); #ifdef AMIGA CloseLibrary(SocketBase); #endif return ret; } /* parse_proxy_addr * * Splits a Lynx-style proxy URI into host part, stored in the EXPSTR , * and a port, stored numerically in the short int pointed to by * Returns TRUE on success, FALSE for NULL proxy or missing "http://" prefix. */ static BOOL parse_proxy_addr(CONSTRPTR proxy, EXPSTR *host, unsigned short *port) { BOOL done; CONSTRPTR p; if((NULL == proxy) || (0 != strncmp(proxy,"http://",7))) return FALSE; *port = 3128; /* Squid default */ for(p = proxy+7, done=FALSE; !done; ++p) { switch(*p) { case '\0' : case '/' : done = TRUE; break; case ':' : *port = atoi(++p); while(isdigit(*p)) ++p; break; default : app_estrch(host,*p); break; } } return TRUE; } static BOOL check_http_uri(HSCPRC *hp, CONSTRPTR uri, CONSTRPTR proxyvar) { EXPSTR *host = init_estr(32); EXPSTR *proxy = init_estr(32); EXPSTR *res = init_estr(32); unsigned short port=80; BOOL ret,done,use_proxy=TRUE; CONSTRPTR p,fulluri=uri; if(!parse_proxy_addr(proxyvar,proxy,&port)) { use_proxy = FALSE; /* no valid proxy specified, so has to be parsed */ for(p = uri+7, done=FALSE; !done; ++p) { switch(*p) { case '\0' : done = TRUE; break; case '/' : set_estr(res,p); done = TRUE; break; case ':' : port = atoi(++p); while(isdigit(*p)) ++p; break; default : app_estrch(host,*p); break; } } /* without a proxy, only the server-relative part must be * sent in the request! */ uri = estr2str(res); } ret = get_http_hdr(hp,fulluri,estr2str(host), use_proxy?estr2str(proxy):NULL,uri,port); del_estr(host); del_estr(proxy); del_estr(res); return ret; } static BOOL check_proxyonly_uri(HSCPRC *hp, CONSTRPTR uri, CONSTRPTR proxy) { EXPSTR *host = init_estr(32); unsigned short port=80; BOOL ret; if(!parse_proxy_addr(proxy,host,&port)) { /* FTP is only supported via proxy */ ret = TRUE; } else { ret = get_http_hdr(hp,uri,uri,estr2str(host),uri,port); } del_estr(host); return ret; } BOOL check_ext_uri(HSCPRC *hp, char *uri) { while(isspace(*uri)) ++uri; if(0 == strncmp(uri,"http://",7)) { return check_http_uri(hp,uri,getenv("http_proxy")); } else if(0 == strncmp(uri,"ftp://",6)) { return check_ftp_uri(hp,uri,getenv("ftp_proxy")); } else if(0 == strncmp(uri,"gopher://",9)) { return check_gopher_uri(hp,uri,getenv("gopher_proxy")); } /* URI scheme is not supported, so we'll just assume it's OK */ return TRUE; } #endif /* defined(UNIX) || defined(AMIGA) */ /* $Id: tcpip.c,v 1.3 2004/02/05 13:43:20 mb Exp mb $*/ /* vi: set ts=4: */ hsc-0.934.orig/hsclib/defattr.c0100600000175000001440000003757007732056103015222 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/defattr.c * * functions to define new attribute * and manipulate attribute lists * */ #define NOEXTERN_HSCLIB_DEFATTR #include "hsclib/inc_base.h" #include "hsclib/defattr.h" #include "hsclib/eval.h" #include "hsclib/input.h" /* *------------------------------------- * misc. functions *------------------------------------- */ static BYTE str2vartype(STRPTR s) { BYTE vartype = VT_NONE; if (!upstrcmp(VT_STR_URI, s)) vartype = VT_URI; else if (!upstrcmp(VT_STR_STRING, s)) vartype = VT_STRING; else if (!upstrcmp(VT_STR_BOOL, s)) vartype = VT_BOOL; else if (!upstrcmp(VT_STR_NUM, s)) vartype = VT_NUM; else if (!upstrcmp(VT_STR_ENUM, s)) vartype = VT_ENUM; else if (!upstrcmp(VT_STR_ID, s)) vartype = VT_ID; else if (!upstrcmp(VT_STR_COLOR, s)) vartype = VT_COLOR; return (vartype); } /* * check_varlist: check for required attributes missing * * result: TRUE, if all attributes ok */ static BOOL check_reqvar(HSCPRC * hp, HSCATTR * var) { BOOL ok = TRUE; if ((var->varflag & VF_RECOMMENDED) && (!var->text)) hsc_message(hp, MSG_MISS_RCMD_ATTR, "recommended %A missing", var); if ((var->varflag & VF_REQUIRED) && (!var->text)) { hsc_message(hp, MSG_MISS_REQ_ATTR, "required %A missing", var); ok = FALSE; } return (ok); } BOOL check_varlist(HSCPRC * hp, DLLIST * varlist) { DLNODE *nd = varlist->first; BOOL ok = TRUE; while (nd) { ok &= check_reqvar(hp, (HSCATTR *) (nd->data)); nd = nd->next; } return (ok); } /* *------------------------------------- * scope functions *------------------------------------- */ /* * get_mci * */ LONG get_mci(HSCPRC * hp) { hp->tag_call_id++; return (hp->tag_call_id); } /* * unget_mci * */ VOID unget_mci(HSCPRC * hp) { hp->tag_call_id--; if (hp->tag_call_id < 0) { panic("MCI underflow"); } } /* * get_current_mci * */ LONG get_current_mci(HSCPRC * hp) { return (hp->tag_call_id); } /* *------------------------------------- * define a new var from input file *------------------------------------- */ /* * read_enum_str * * sidefx: modifies tmpstr */ static BOOL read_enum_str(HSCPRC * hp, HSCATTR * var) { HSCATTR *attr = new_hscattr(PREFIX_TMPATTR "enumerator"); attr->vartype = VT_STRING; /* store enumstr in var-struct */ if (eval_expression(hp, attr, NULL)) { /*DDA(fprintf(stderr, DHL " enum: %s\n", estr2str(hp->tmpstr)));*/ var->enumstr = strclone(get_vartext(attr)); DDA(fprintf(stderr, DHL " enum: %s\n",var->enumstr)); } del_hscattr(attr); return ((BOOL) (!hp->fatal)); } /* * check_attr_option * * check if a attribute-option-string is equal to an id/short id. * if so, set the corresponding option value within the attribute. * * params: option..option string to check for (read from input) * attr....attribute to update option value for * id......id string of option (eg "REQUIRED") * sid.....short id string (eg "R") * value...option value to OR with old tag's option value * result: TRUE, if tag's option value updated */ static BOOL check_attr_option(HSCPRC * hp, STRPTR option, HSCATTR * attr, STRPTR id, STRPTR sid, ULONG value, ULONG unmasked_flags) { BOOL found = FALSE; if (!((upstrcmp(option, id)) && (upstrcmp(option, sid)))) { DDA(fprintf(stderr, DHL " option %s\n", id)); if (value & unmasked_flags) { hsc_message(hp, MSG_ILLG_ATTR_FLAG, "attribute option %q not allowed in this context", id); } else attr->varflag |= value; found = TRUE; } return (found); } /* * define_var * * define a new var with reading its def from input file * (starts parsing after ":", so ":" has to be read before) * * params: varname..name of new var * varlist..list new var should be inserted at the beginning * inpf.....input file where to read def from * flag.....flags: VF_ONLYONCE to avoid re-definition of a var * result: ptr to new var * * definition syntax in input file: * [/flag]["="] * legal vartypes: see VT_STR_xx in "vars.h" * legal flags : see VF_STR_xx in "vars.h" */ HSCATTR *define_var(HSCPRC * hp, DLLIST * varlist, ULONG unmasked_flags) { HSCATTR *var = NULL; /* result */ BOOL ok = FALSE; BYTE val_vartype = VT_NONE; /* var-type (numeric) */ BOOL newattr = FALSE; /* next word read from input */ STRPTR nw = NULL; STRPTR varname = NULL; BOOL eof_called = FALSE; /* used at end-of-func, if nw==NULL */ INFILE *inpf = hp->inpf; /* read attribute name */ nw = infget_attrid(hp); if (nw) varname = strclone(nw); /* remember attribute name */ else eof_called = TRUE; /* err_eof() called already */ /* read attribute type */ if (nw) { if (parse_wd(hp, ":")) { nw = infgetw(inpf); if (nw) val_vartype = str2vartype(nw); } else inungetcw(inpf); } if (nw) { /* * look if attr already exist; * if yes, clear old attribute * to redefine the new one */ var = find_varname(varlist, varname); if (var) { DLNODE *nd = find_attrnode(varlist, varname); /* remove old attribute */ if (nd) del_dlnode(varlist, nd); else panic("no node for redefined attribute"); hsc_message(hp, MSG_ATTR_REDEFINED, "redefined %a", varname); } /* * create new attribute */ DDA(fprintf(stderr, DHL "new attr: %s\n", varname)); var = app_var(varlist, varname); /* set type */ var->vartype = val_vartype; if (var->vartype == VT_ENUM) { /* init enum-attribute */ read_enum_str(hp, var); } else if (var->vartype == VT_BOOL) { /* init boolean attr with FALSE */ set_varbool(var, FALSE); } newattr = TRUE; } /* disable "/STRIPEXT" and "/GETSIZE" for non-URI-attributes */ if (nw) { if (var->vartype != VT_URI) unmasked_flags |= VF_GETSIZE | VF_STRIPEXT; nw = infgetw(inpf); /* get net word */ } /* * handle attribute flags */ while (nw && !strcmp(nw, "/")) { nw = infgetw(inpf); /* read flag identifier */ if (nw) { BOOL ok = FALSE; ok |= check_attr_option(hp, nw, var, VF_CONST_STR, VF_CONST_SHT, VF_CONST, unmasked_flags); ok |= check_attr_option(hp, nw, var, VF_GLOBAL_STR, VF_GLOBAL_SHT, VF_GLOBAL, unmasked_flags); ok |= check_attr_option(hp, nw, var, VF_JERK_STR, VF_JERK_SHT, VF_JERK, unmasked_flags); ok |= check_attr_option(hp, nw, var, VF_ONLYONCE_STR, VF_ONLYONCE_SHT, VF_ONLYONCE, unmasked_flags); ok |= check_attr_option(hp, nw, var, VF_REQUIRED_STR, VF_REQUIRED_SHT, VF_REQUIRED, unmasked_flags); ok |= check_attr_option(hp, nw, var, VF_GETSIZE_STR, VF_GETSIZE_SHT, VF_GETSIZE, unmasked_flags); ok |= check_attr_option(hp, nw, var, VF_STRIPEXT_STR, VF_STRIPEXT_SHT, VF_STRIPEXT, unmasked_flags); ok |= check_attr_option(hp, nw, var, VF_OBSOLETE_STR, VF_OBSOLETE_SHT, VF_OBSOLETE, unmasked_flags); ok |= check_attr_option(hp, nw, var, VF_RECOMMENDED_STR, VF_RECOMMENDED_SHT, VF_RECOMMENDED, unmasked_flags); if (!ok) { hsc_message(hp, MSG_UNKN_ATTR_OPTION, "unknown attribute flag %q", nw); } /* read next word (should be "/", "=" or next attr / ">") */ nw = infgetw(inpf); } else hsc_msg_eof(hp, "defining attribute"); } /* * handle default value */ if (nw && !strcmp(nw, "=")) { /* get new deftext value */ STRPTR new_deftext = NULL; LONG old_attrflag = var->varflag; /* disable quotemode-checking */ var->varflag |= VF_KEEP_QUOTES; if (!(var->deftext)) new_deftext = eval_expression(hp, var, NULL); else { STRPTR dummy; hsc_message(hp, MSG_SYMB_2ND_DEFAULT, "default value for %A already set", var); /* skip illegal default value */ dummy = eval_expression(hp, var, NULL); } /* restore quotemode-checking */ var->varflag = old_attrflag; /* store default text value */ if (new_deftext) var->deftext = strclone(new_deftext); /* read next word, only to be ungotten below */ nw = infgetw(inpf); } /* check for unexpected end of file */ if (!nw) { if (!eof_called) hsc_msg_eof(hp, "defining attribute"); } else { /* end of var definition reached */ inungetcw(inpf); ok = TRUE; } /* cleanup */ if (!ok && var) { DLNODE *nd = find_attrnode(varlist, varname); if (nd) del_dlnode(varlist, (APTR) nd); else del_hscattr(var); var = NULL; } ufreestr(varname); return (var); } /* * define_attr_by_hp * * define a new attribute with obtaining data from hsc-process * * SEE ALSO: * define_attr_by_text */ HSCATTR *define_attr_by_hp(HSCPRC * hp, STRPTR default_value, ULONG unmasked_flags) { HSCATTR *attr = define_var(hp, hp->defattr, 0); if (attr) { /* set scope for local attribute */ attr->macro_id = ((attr->varflag & VF_GLOBAL) ? MCI_GLOBAL : get_current_mci(hp)); /* see "attrib.h" why this */ attr->varflag |= VF_MACRO; /* set new value (copy from default) if passed */ if (get_vardeftext(attr)) { if (default_value) panic("default value already set"); else clr_vartext(attr); } /* set default value passed in function args */ if (default_value) set_vartext(attr, default_value); /* remove default value */ clr_attrdef(attr); } return (attr); } /* * 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: * ":"[/flag]["="] * * 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); } /* *------------------------------------- * copy & remove local vars to/from * global varlist *------------------------------------- */ /* * copy_local_var * * copies a local attribute to the global attribute list * * NOTE: the VF_MACRO-flag of the copy is disabled! */ static HSCATTR *copy_local_var(DLLIST * destlist, HSCATTR * locvar, ULONG mci) { HSCATTR *var = app_var(destlist, locvar->name); var->macro_id = mci; var->vartype = locvar->vartype; var->varflag = locvar->varflag & (~VF_MACRO); /* disable VF_MACRO */ set_vartext(var, locvar->text); var->quote = locvar->quote; return (var); } /* * copy_local_vars * * add all local attributes of a macro to the global * attribute list. * If this_mci_only is TRUE, only variables matching the macro ID given as * will be copied. Otherwise, the whole list is copied and all variables' * macro_id set to * */ BOOL copy_local_varlist(DLLIST * destlist, DLLIST * varlist, ULONG mci) { BOOL ok = TRUE; if (MCI_ERROR != mci) { DLNODE *nd = varlist->first; HSCATTR *var; while (nd && ok) { var = copy_local_var(destlist, (HSCATTR *) (nd->data), mci); ok &= (BOOL) (var != NULL); nd = nd->next; } } else panic("mci=MCI_ERROR"); return (ok); } /* * set_local_var * * copies a local attribute to the global attribute list * * NOTE: the VF_MACRO-flag of the set is enabled! */ static HSCATTR *set_local_var(DLLIST * destlist, HSCATTR * locvar, ULONG mci) { HSCATTR *var = find_varname(destlist, locvar->name); if (var) { var->macro_id = mci; var->vartype = locvar->vartype; set_vartext(var, locvar->text); } else panic("set_local_var to UNKNOWN ATTR"); return (var); } /* * set_local_vars * * add all local attributes of a macro to the global * attribute list. * */ BOOL set_local_varlist(DLLIST * destlist, DLLIST * varlist, ULONG mci) { BOOL ok = TRUE; if (MCI_ERROR != mci) { DLNODE *nd = varlist->first; HSCATTR *var; while (nd && ok) { var = set_local_var(destlist, (HSCATTR *) (nd->data), mci); ok &= (BOOL) (var != NULL); nd = nd->next; } } else panic("mci=MCI_ERROR"); return (ok); } /* * remove_local_varlist */ VOID remove_local_varlist(DLLIST * varlist, ULONG mci) { DLNODE *nd = varlist->first; while (nd) { HSCATTR *var = (HSCATTR *) nd->data; /* var data of node */ DLNODE *nd_nxt = nd->next; /* next node */ if (var->macro_id == mci) del_dlnode(varlist, nd); nd = nd_nxt; } } /* * move_local_varlist * Moves variables with matching mci to another varlist */ void move_local_varlist(DLLIST * destlist, DLLIST * varlist, ULONG mci) { if (MCI_ERROR != mci) { DLNODE *nd = varlist->first; while (NULL != nd) { if((((HSCATTR*)(nd->data))->macro_id) == mci) { move_dlnode(destlist,varlist,nd); } nd = dln_next(nd); } } else panic("mci=MCI_ERROR"); } /* $Id: defattr.c,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */ hsc-0.934.orig/hsclib/defattr.h0100600000175000001440000000401007732056103015206 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * defattr.h * * functions to define new attribute * and manipulate attribute lists * */ #ifndef HSCLIB_DEFATTR_H #define HSCLIB_DEFATTR_H /* * global funcs */ #ifndef NOEXTERN_HSCLIB_DEFATTR /* scope rules support */ extern LONG get_mci( HSCPRC *hp ); extern VOID unget_mci( HSCPRC *hp ); extern LONG get_current_mci( HSCPRC *hp ); /* attribute list manipulation */ extern BOOL copy_local_varlist(DLLIST * destlist, DLLIST * varlist, ULONG mci); extern void move_local_varlist(DLLIST * destlist, DLLIST * varlist, ULONG mci); extern BOOL set_local_varlist(DLLIST * destlist, DLLIST * varlist, ULONG mci); extern VOID remove_local_varlist(DLLIST * varlist, ULONG mci); extern BOOL check_varlist(HSCPRC * hp, DLLIST * varlist); /* define attribute */ extern HSCVAR *define_var(HSCPRC * hp, DLLIST * varlist, ULONG unmasked_flags); extern HSCATTR *define_attr_by_hp(HSCPRC * hp, STRPTR default_value, ULONG unmasked_flags); extern HSCATTR *define_attr_by_text(HSCPRC * hp, STRPTR attr_text, STRPTR default_value, ULONG unmasked_flags); #endif /* NOEXTERN_HSCLIB_DEFATTR */ #endif /* HSCLIB_DEFATTR_H */ /* $Id: defattr.h,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */ /* vi: set ts=4: */ hsc-0.934.orig/hsclib/size.c0100600000175000001440000003274510010443430014524 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/size.c * * evaluate values for WIDTH and HEIGHT from file */ #include "hsclib/inc_base.h" #include "hsclib/uri.h" #include "hsclib/css.h" /* markers for JFIF/JPEG that contain * information about image dimensions */ static const UBYTE msof[] = { /* M_SOF0 */ 0xc0, /* M_SOF1 */ 0xc1, /* M_SOF2 */ 0xc2, /* M_SOF3 */ 0xc3, /* M_SOF5 */ 0xc5, /* M_SOF6 */ 0xc6, /* M_SOF7 */ 0xc7, /* M_SOF9 */ 0xc9, /* M_SOF10 */ 0xca, /* M_SOF11 */ 0xcb, /* M_SOF13 */ 0xcd, /* M_SOF14 */ 0xce, /* M_SOF15 */ 0xcf, /* end */ 0x00 }; /* PNG image header */ static const unsigned char id_PNG[] = { 137, 80, 78, 71, 13, 10, 26, 10 }; /* file indeces for PNG */ #define WIDTH_PNG 16 #define HEIGHT_PNG 20 /* * fucking macro to compare fucking unsigned strings without * fucking warnings that are only a result of the fucking * difference in the declaration of fucking `char' between * fucking C (by fucking K&R) and fucking C++ (by fucking * Stroustrupp-or-whatever-the-unspellable-name-of-this-guy-is) * * WHY DID I NEVER HAVE SUCH PROBLEMS IN BASIC,REXX,PASCAL * OR OBERON? * * Because the people who specified these languages had a brain. * * Where was I? Uh, back to the source code: */ #define fuck_strncmp(a,b,n) strncmp((char*)(a),(char*)(b),(n)) /* * hsc_msg_img_corrupt * * display message that image is corrupt */ static VOID hsc_msg_img_corrupt(HSCPRC * hp, STRPTR name, STRPTR cause) { hsc_message(hp, MSG_IMG_CORRUPT, "image %q is corrupt (%s)",name,cause); } /* * try_set_attr * * if attribute exists and its value is empty, set * new value and update tag-attribute-string; otherwise * just compare the old and new value and warn if they * differ */ 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, " "); if(hp->lctags) { STRPTR tmp = ugly_strclone(attr->name,hp->inpf->filename, hp->inpf->pos_y); lowstr(tmp); app_estr(hp->tag_attr_str, tmp); ugly_freestr(tmp,hp->inpf->filename,hp->inpf->pos_y); } else { 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); } } } } /* * get_attr_size * * tries to get values for WIDTH and HEIGHT attributes or CSS specification * from file; if possible, the corresponding attributes * for the tag passed will be set (or validated). * * result: TRUE, if filetype has been recognised */ BOOL get_attr_size(HSCPRC * hp, HSCTAG * tag) { STRPTR srcuri = NULL; if (tag->uri_size) srcuri = get_vartext(tag->uri_size); else panic("no uri_size"); if (hp->getsize && srcuri && (uri_kind(srcuri) != URI_ext)) { unsigned char *buf = hp->image_buffer; EXPSTR *srcpath = init_estr(64); EXPSTR *imgpath = init_estr(64); ULONG width = 0; ULONG height = 0; BOOL transparent = FALSE; BOOL progressive = FALSE; STRPTR filetype = NULL; STRPTR filename = NULL; /* native filename for image-URI */ FILE *fref = NULL; /* file link references to */ /* convert URI to native filename */ conv_hscuri2file(hp, srcpath, srcuri); filename = estr2str(srcpath); DSZ(fprintf(stderr, DHL " uri : \"%s\"\n" DHL " path: \"%s\"\n", srcuri, filename)); fref = fopen(filename, "rb"); if (fref) { size_t bytes_read = 0; /* number of bytes in image buffer */ /* fill buffer with zero */ memset(buf, 0, IMAGE_BUFFER_SIZE); /* read buffer from file */ errno = 0; bytes_read = fread(buf, 1, IMAGE_BUFFER_SIZE, fref); if (errno) { /* read error */ hsc_msg_read_error(hp, filename); } else if((0xff == buf[0]) && (0xd8 == buf[1])){ /* * JFIF/JPEG */ BOOL found = FALSE; long offset = 2; do { fseek(fref,offset,SEEK_SET); fread(buf,1,16,fref); if(0xff != buf[0]) break; /* obviously corrupted file */ if(NULL == strchr((char*)msof,(int)buf[1])) { /* current chunk has no size information, so skip it */ offset += (buf[2]<<8) + buf[3] + 2; DSZ(fprintf(stderr,"Skipped JFIF chunk 0x%02x, continuing at offset %ld\n",buf[1],offset);) } else { /* found size information */ filetype = "JFIF/JPEG"; width = buf[8] + (buf[7] << 8); height = buf[6] + (buf[5] << 8); found = TRUE; DSZ(fprintf(stderr,"Found size info in chunk 0x%02x: %ldx%ld\n",buf[1],width,height);) } } while(!(found || feof(fref))); if (!found) hsc_msg_img_corrupt(hp, filename, "no size info or illegal marker"); } else if (!fuck_strncmp("GIF87a", (STRPTR) buf, 6) || !fuck_strncmp("GIF89a", (STRPTR) buf, 6)) { /* * GIF */ ULONG use_global_colormap = (buf[10] & 0x80) >> 7; ULONG pixeldepth = (buf[10] & 0x07) + 1; ULONG startimg = 13 + use_global_colormap * 3 * (1 << pixeldepth); BOOL fucked_up = FALSE; DSZ(fprintf(stderr, DHL " buf=%d: gcolmap=%ld, pxldep=%ld\n", buf[10], use_global_colormap, pixeldepth)); while (!fucked_up && (buf[startimg] != ',')) { DSZ(fprintf(stderr, DHL " %04lx: id=%02x\n", startimg, buf[startimg])); if (buf[startimg] == '!') { UBYTE blksize = 0; if (buf[startimg + 1] == 0xF9) { /* graphic control extensions */ /* check if transparent */ transparent = (buf[startimg + 3] & 0x01); if (transparent) { DDA(fprintf(stderr, DHL " (transparent)\n")); } } /* skip all blocks */ startimg += 2; do { blksize = buf[startimg]; DDA(printf(" skip block sized %d\n", blksize)); startimg += 1L + blksize; } while (!fucked_up && (blksize)); /* check if buffer exeeds */ if (startimg > (bytes_read - 9)) { hsc_msg_img_corrupt(hp, filename, "image buffer exeeds"); fucked_up = TRUE; } } else { hsc_msg_img_corrupt(hp, filename, "unknown GIF-block"); DSZ(fprintf(stderr, " id='%x', index=%ld/\n", buf[startimg], startimg)); fucked_up = TRUE; } } if ((buf[startimg] != ',') && !fucked_up) { DSZ(fprintf(stderr, DHL " %04lx: id=%02x\n", startimg, buf[startimg])); hsc_msg_img_corrupt(hp, filename, "image separator expected"); } else { /* been sucessful */ DSZ(fprintf(stderr, DHL " %04lx: id=%02x\n", startimg, buf[startimg])); filetype = "GIF"; width = buf[startimg + 5] + 256 * buf[startimg + 6]; height = buf[startimg + 7] + 256 * buf[startimg + 8]; progressive = (0 != (buf[startimg + 9] & (1 << 6))); DDA(fprintf(stderr, DHL " width : %lu\n" DHL " height: %lu\n", width, height)); } } else if (!fuck_strncmp(id_PNG, buf, 8)) { /* * PNG */ filetype = "PNG"; width = 0x00800000 * buf[WIDTH_PNG] + 0x00010000 * buf[WIDTH_PNG + 1] + 0x00000100 * buf[WIDTH_PNG + 2] + 0x00000001 * buf[WIDTH_PNG + 3]; height = 0x00800000 * buf[HEIGHT_PNG] + 0x00010000 * buf[HEIGHT_PNG + 1] + 0x00000100 * buf[HEIGHT_PNG + 2] + 0x00000001 * buf[HEIGHT_PNG + 3]; progressive = buf[HEIGHT_PNG + 9]; /*TODO: figure out transparent */ #if DEBUG_SIZE /* display whole image buffer */ if (hp->debug) { int i; for (i = 0; i < (int)bytes_read; i++) { fprintf(stderr, "%-2d: $%02x %-3d", i, buf[i], buf[i]); if (buf[i] >= 32) fprintf(stderr, " '%c'\n", buf[i]); else fprintf(stderr, "\n"); } } #endif DDA(fprintf(stderr, DHL " width : %lu\nheight: %lu\n", width, height)); } else { /* unknown file type */ hsc_message(hp, MSG_UNKN_FILETYPE, "filetype of %q not recognised", estr2str(srcpath)); } if (filetype) { DSZ(fprintf(stderr, DHL " size: \"%s\" (%ldx%ld)\n", filetype, width, height)); }; fclose(fref); } else { DSZ(fprintf(stderr, DHL " can't open image `%s'\n", estr2str(srcpath))); hsc_msg_nouri(hp, estr2str(srcpath), srcuri, "image dimension"); } /* set attribute values */ if (height && width) { HSCVAR *awidth=NULL, *aheight=NULL; awidth = find_varname(tag->attr, "WIDTH"); aheight = find_varname(tag->attr, "HEIGHT"); /* status message telling about the dimension */ app_estr(srcpath, ": "); app_estr(srcpath, filetype); app_estr(srcpath, ", "); app_estr(srcpath, long2str(width)); app_estr(srcpath, "x"); app_estr(srcpath, long2str(height)); if (progressive) app_estr(srcpath, ", progressive"); if (transparent) app_estr(srcpath, ", transparent"); hsc_status_misc(hp, estr2str(srcpath)); if(hp->xhtml) { /* in XHTML mode, add to the STYLE attribute */ add_width_height_attrs(hp,width,height); } else { /* in regular HTML mode, set WIDTH/HEIGHT */ try_setattr(hp, awidth, width); try_setattr(hp, aheight, height); } } /* free local resources */ del_estr(srcpath); del_estr(imgpath); } return (TRUE); } /* $Id: size.c,v 1.8 2004/02/05 13:36:27 mb Exp mb $ */ /* vi: set ts=4: */ hsc-0.934.orig/hsclib/deftag.c0100600000175000001440000005670207732056103015021 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/deftag.c * * define new tag from input file * */ #include "hsclib/inc_base.h" #include "hsclib/defattr.h" #include "hsclib/eval.h" #include "hsclib/input.h" #include "hsclib/skip.h" #include "hsclib/css.h" /* *------------------------------------- * define a new tag from input file *------------------------------------- */ /* * def_tag_name * */ HSCTAG *def_tag_name(HSCPRC * hp, BOOL * start_tag) { STRPTR nw = NULL; HSCTAG *tag = NULL; DLLIST *taglist = hp->deftag; /* get tag name */ nw = infget_tagid(hp); /* create new tag */ if (nw) { *start_tag = (BOOL) (strcmp(nw, "/")); if (!(*start_tag)) { /* add closing tag */ nw = infget_tagid(hp); if (nw) { tag = find_strtag(taglist, nw); if (tag) { if ((tag->option & HT_CLOSE) || (tag->option & HT_CONTENT)) { /* tried to redefine end tag */ tag = NULL; hsc_message(hp, MSG_REDEFINE_ENDTAG, "redefined %c", nw); } else { /* mark macro as a container */ tag->option |= HT_CLOSE; } } else { /* tried to define end tag without previous start tag */ tag = NULL; hsc_message(hp, MSG_DEFTAG_NO_OPEN, "no start tag for %c", nw); } } /* err_eof already called in infget_tagid() */ } else { tag = find_strtag(taglist, nw); if (tag) { /* find tag-node in list to delete it * NOTE: this is rather stupid, 'cause the list * has to be searched twice this way; but who cares? */ DLNODE *nd = find_dlnode(hp->deftag->first, (APTR) nw, cmp_strtag); /* new tag/macro replaces old tag/macro */ tag->occured = FALSE; hsc_message(hp, MSG_REDEFINE_TAG, "redefined %T", tag); del_dlnode(hp->deftag, nd); } /* create a new opening tag */ tag = app_tag(taglist, nw); } } /* err_eof already called in infget_tagid() */ return (tag); } /* * check_tag_option * * check if a tag-option-string is equal to an id/short id. * if so, set the corresponding option value within the tag. * * params: option..option string to check for (read from input) * tag.....tag to update option value for * id......id string of option (eg "REQUIRED") * sid.....short id string (eg "REQ") * value...option value to OR with old tag's option value * result: TRUE, if tag's option value updated */ static BOOL check_tag_option(HSCPRC * hp, STRPTR option, HSCTAG * tag, STRPTR id, STRPTR sid, ULONG value) { BOOL found = FALSE; if (!((upstrcmp(option, id)) && (upstrcmp(option, sid)))) { DDT(fprintf(stderr, DHL " option %s\n", id)); tag->option |= value; found = TRUE; } return (found); } /* * parse_lazy_option * * allowed abbrevations: * * c CLASS:string * d DIR:enum("ltr|rtl") * h HREF:uri * i ID:id * k CLEAR:enum("left|right|all|none") * l LANG:enum(...) * m MD:string * s SRC:URI * t TITLE:string * y STYLE:string */ static HSCATTR *def_lazy_attr(HSCPRC * hp, HSCTAG * tag, STRPTR attrname, BYTE attrtype, ULONG flags) { HSCATTR *newattr = app_var(tag->attr, attrname); DDA(fprintf(stderr, DHL "new attr: `%s'\n", attrname)); newattr->vartype = attrtype; newattr->varflag = flags; return (newattr); } static BOOL parse_lazy_option(HSCPRC * hp, HSCTAG * tag, STRPTR lazy) { BOOL ok = TRUE; HSCATTR *attr; while (lazy[0]) { switch (lazy[0]) { case 'c': def_lazy_attr(hp, tag, "CLASS", VT_STRING, 0); break; case 'd': attr = def_lazy_attr(hp, tag, "DIR", VT_ENUM, 0); attr->enumstr = strclone("ltr|rtl"); break; case 'h': def_lazy_attr(hp, tag, "HREF", VT_URI, 0); break; case 'i': def_lazy_attr(hp, tag, "ID", VT_ID, 0); break; case 'k': attr = def_lazy_attr(hp, tag, "CLEAR", VT_ENUM, 0); attr->enumstr = strclone("left|right|all|none"); break; case 'l': def_lazy_attr(hp, tag, "LANG", VT_STRING, 0); break; case 'm': /* what's this supposed to be? -mb */ def_lazy_attr(hp, tag, "MD", VT_STRING, 0); break; case 's': def_lazy_attr(hp, tag, "SRC", VT_URI, 0); break; case 't': def_lazy_attr(hp, tag, "TITLE", VT_STRING, 0); break; case 'v': /* bulk declaration for all %events in HTML4 */ def_lazy_attr(hp, tag, "ONCLICK", VT_STRING, 0); def_lazy_attr(hp, tag, "ONDBLCLICK", VT_STRING, 0); def_lazy_attr(hp, tag, "ONMOUSEDOWN", VT_STRING, 0); def_lazy_attr(hp, tag, "ONMOUSEUP", VT_STRING, 0); def_lazy_attr(hp, tag, "ONMOUSEOVER", VT_STRING, 0); def_lazy_attr(hp, tag, "ONMOUSEMOVE", VT_STRING, 0); def_lazy_attr(hp, tag, "ONMOUSEOUT", VT_STRING, 0); def_lazy_attr(hp, tag, "ONKEYDOWN", VT_STRING, 0); def_lazy_attr(hp, tag, "ONKEYUP", VT_STRING, 0); break; case 'y': def_lazy_attr(hp, tag, "STYLE", VT_STRING, 0); break; default: hsc_message(hp, MSG_UNKN_TAG_OPTION, "unknown tag modifier %q (arg %q)", "LAZY", ch2str(lazy[0])); break; } lazy++; } return (ok); } /* * parse_tag_option * * check a tag-modifier, read additional values (if necessary), update * tag structure * * params: hp......hsc process * option..string that contains modifier (eg. "REQUIRED") * tag.....tag to modify * result: TRUE, if modifier could be handled * errors: return FALSE, output message */ static BOOL parse_tag_option(HSCPRC * hp, STRPTR option, HSCTAG * tag) { BOOL ok = FALSE; HSCATTR *attr = new_hscattr(PREFIX_TMPATTR "mbi.naw"); attr->vartype = VT_STRING; if (!(upstrcmp(option, TO_MBI_STR) && upstrcmp(option, TO_MBI_SHT))) { /* must be inside */ if (parse_eq(hp)) { STRPTR strmbi = eval_expression(hp, attr, NULL); if (strmbi) { tag->mbi = strclone(strmbi); DDT(fprintf(stderr, DHL " mbi = `%s'\n", tag->mbi)); ok = TRUE; } } } else if (!(upstrcmp(option, TO_NAW_STR) && upstrcmp(option, TO_NAW_SHT))) { /* not allowed within */ if (parse_eq(hp)) { STRPTR strnaw = eval_expression(hp, attr, NULL); if (strnaw) { tag->naw = strclone(strnaw); DDT(fprintf(stderr, DHL " mbi = `%s'\n", tag->naw)); ok = TRUE; } } } else if (!(upstrcmp(option, TO_LAZY_STR) && upstrcmp(option, TO_LAZY_SHT))) { /* lazy standard attribs */ if (parse_eq(hp)) { STRPTR strlazy = eval_expression(hp, attr, NULL); if (strlazy) { DDT(fprintf(stderr, DHL " lazy= `%s'\n", strlazy)); ok = parse_lazy_option(hp, tag, strlazy); } } } else { ok |= check_tag_option(hp, option, tag, TO_CLOSE_STR, TO_CLOSE_SHT, HT_CLOSE); /* now check for all the other stuff */ ok |= check_tag_option(hp, option, tag, TO_SPECIAL_STR, TO_SPECIAL_SHT, HT_SPECIAL); ok |= check_tag_option(hp, option, tag, TO_JERK_STR, TO_JERK_SHT, HT_JERK); ok |= check_tag_option(hp, option, tag, TO_AUTOCLOSE_STR, TO_AUTOCLOSE_SHT, (ULONG)(hp->xhtml ? HT_CLOSE : HT_AUTOCLOSE)); ok |= check_tag_option(hp, option, tag, TO_EMPTY_STR, TO_EMPTY_SHT, HT_EMPTY); ok |= check_tag_option(hp, option, tag, TO_OBSOLETE_STR, TO_OBSOLETE_SHT, HT_OBSOLETE); ok |= check_tag_option(hp, option, tag, TO_ONLYONCE_STR, TO_ONLYONCE_SHT, HT_ONLYONCE); ok |= check_tag_option(hp, option, tag, TO_REQUIRED_STR, TO_REQUIRED_SHT, HT_REQUIRED); ok |= check_tag_option(hp, option, tag, TO_RECOMMENDED_STR, TO_RECOMMENDED_SHT, HT_RECOMMENDED); ok |= check_tag_option(hp, option, tag, TO_SKIPLF_STR, TO_SKIPLF_SHT, HT_SKIPLF); ok |= check_tag_option(hp, option, tag, TO_WHTSPC_STR, TO_WHTSPC_SHT, HT_WHTSPC); /* in XHTML mode, HT_EMPTY excludes HT_CLOSE */ if((tag->option & HT_EMPTY) && hp->xhtml) { DDT(if(tag->option & HT_CLOSE) fprintf(stderr, DHL " EMPTY set, disabling CLOSE\n");) tag->option &= ~HT_CLOSE; } if (!ok) hsc_message(hp, MSG_UNKN_TAG_OPTION, "unknown tag modifer %q", option); } /* remove temp. attribute */ del_hscattr(attr); return (ok); } /* * parse_tag_var */ static BOOL parse_tag_var(HSCPRC * hp, HSCTAG * tag) { BOOL ok = FALSE; HSCATTR *var = NULL; /* define new attribute */ var = define_var(hp, tag->attr, VF_CONST | VF_GLOBAL); /* set several values of tag structure, if attribute has * some special flags set */ if (var) { /* attribute is uri that tells the size */ if (var->varflag & VF_GETSIZE) tag->uri_size = var; /* attribute is uri that tells if the tag should be stripped */ if (var->varflag & VF_STRIPEXT) tag->uri_stripext = var; /* set attribute flag to keep quotes */ if (tag->option & HT_KEEP_QUOTES) var->varflag |= VF_KEEP_QUOTES; /* set macro attribute flag for macro tags */ if (tag->option & HT_MACRO) var->varflag |= VF_MACRO; ok = TRUE; } return (ok); } /* * def_tag_args * */ BOOL def_tag_args(HSCPRC * hp, HSCTAG * tag) { BOOL ok = FALSE; STRPTR nw; INFILE *inpf = hp->inpf; if (tag) { ok = TRUE; /* read args */ nw = infgetw(inpf); /* * set tag options */ while (nw && (!strcmp(nw, "/"))) { nw = infgetw(inpf); if (nw) { ok &= parse_tag_option(hp, nw, tag); nw = infgetw(inpf); } } /* auto-set HT_KEEP_QUOTES */ if (!strncmp(tag->name, HSC_TAGID, strlen(HSC_TAGID))) tag->option |= HT_KEEP_QUOTES; /* * set tag attributes */ while (nw && (strcmp(nw, ">"))) { if (strcmp(nw, "[")) { /* define classic attribute */ inungetcw(inpf); ok &= parse_tag_var(hp, tag); } else { /* insert attribute list */ STRPTR name = infget_tagid(hp); if (nw) { HSCTAG *lazy = find_strtag(hp->deflazy, name); if (lazy) copy_local_varlist(tag->attr, lazy->attr, MCI_GLOBAL); else hsc_message(hp, MSG_UNKN_LAZY, "unknown %l", name); } parse_wd(hp, "]"); } nw = infgetw(inpf); } /* check for ">" at end */ if (nw) { inungetcw(inpf); ok = parse_gt(hp); } } return (ok); } /* * set_tag_arg * * parse & set one single tag argument * */ static BOOL set_tag_arg(HSCPRC * hp, DLLIST * varlist, STRPTR varname, STRPTR tagname, BOOL tag_unknown, BOOL is_macro_tag) { HSCATTR *attr = find_varname(varlist, varname); INFILE *inpf = hp->inpf; STRPTR arg = NULL; BOOL ok = FALSE; BOOL inheritage_failed = FALSE; /* flag: set, if "?=" failed */ STRPTR nw; HSCATTR skipvar; /* dummy-attribute to skip unknown */ EXPSTR *attr_str = init_estr(40); /* string for attribute name */ EXPSTR *val_str = init_estr(40); /* string for "=" and value */ const BOOL is_styleattr = (0 == upstrcmp(varname,"STYLE")); DAV(fprintf(stderr, DHL " set attr %s\n", varname)); /* don't process pseudo-attribute "/" in XHTML mode */ if(!strcmp(varname,"/")) return TRUE; /* append attribute name to attr_str */ if (hp->compact) app_estr(attr_str, " "); else app_estr(attr_str, infgetcws(inpf)); app_estr(attr_str, infgetcw(inpf)); /* lowercase attribute name if requested */ if(hp->lctags) lowstr(estr2str(attr_str)); if (!attr) { /* attribute not found: assign to dummy-attribute */ attr = &skipvar; attr->name = varname; attr->deftext = NULL; attr->text = NULL; attr->enumstr = NULL; attr->vartype = VT_STRING; attr->varflag = 0; /* launch message about unknown attribute * * if the whole tag is unknown, no message is launched; * if it is a normal tag, this causes a warning * if it is a macro tag, it causes an error */ if (!tag_unknown) { if (is_macro_tag) hsc_msg_unkn_attr_macro(hp, varname, tagname); else hsc_msg_unkn_attr_tag(hp, varname, tagname); } } /* get argument */ nw = infgetw(inpf); if (nw) { if (!strcmp(nw, "=")) { /* append "=" to log - always strips WS b/w attribute and value */ if(!is_styleattr) app_estr(val_str, infgetcw(inpf)); /* parse expression */ arg = eval_expression(hp, attr, NULL); /* append value to log */ if(!is_styleattr && (attr->quote != VQ_NO_QUOTE)) app_estrch(val_str, attr->quote); if(get_vartext(attr)) app_estr(val_str, get_vartext(attr)); if (!is_styleattr && (attr->quote != VQ_NO_QUOTE)) app_estrch(val_str, attr->quote); if (arg) { DAV(fprintf(stderr, DHL " `%s'\n", arg)); ok = TRUE; } } else if (!strcmp(nw, "?")) { /* process "?="-assignment */ if (!hp->compact) app_estr(val_str, infgetcws(inpf)); if (parse_eq(hp)) { if(!is_styleattr) app_estr(val_str, "="); arg = eval_conditional_assignment(hp, attr); /* append value to log */ if(!is_styleattr && (attr->quote != VQ_NO_QUOTE)) app_estrch(val_str, attr->quote); if (get_vartext(attr)) app_estr(val_str, get_vartext(attr)); if (!is_styleattr && (attr->quote != VQ_NO_QUOTE)) app_estrch(val_str, attr->quote); if (arg) { DAV(fprintf(stderr, DHL " inherited `%s'\n", arg)); } else { DAV(fprintf(stderr, DHL " inheritage failed\n")); inheritage_failed = TRUE; } ok = TRUE; } } else { /* handle boolean attribute */ arg = NULL; inungetcwws(inpf); if (attr == &skipvar) attr->vartype = VT_BOOL; ok = TRUE; } } else hsc_msg_eof(hp, "read attribute value"); if (ok) { if (arg) { if (attr->vartype == VT_BOOL) { /* set boolean attribute depending on expression */ set_varbool(attr, get_varbool(attr)); /* if the expression returned FALSE, remove * the boolean switch from tag-call */ if (!get_varbool(attr)) clr_estr(attr_str); } else if (!inheritage_failed) { /* append value to attribute string */ estrcat(attr_str, val_str); } } else if (inheritage_failed) { /* if attribute to inherit from was empty, * remove the attribute from tag-call */ clr_estr(attr_str); } else { /* no value has been passed to the attribute */ if (attr->vartype == VT_BOOL) { /* for boolean attributes, this is legal, * and enables the attribute * but: see below for XHTML normalization! */ set_varbool(attr, TRUE); } else if (!tag_unknown) { /* for non-boolean attributes, display * error message */ hsc_message(hp, MSG_NOARG_ATTR, "missing value for %A", attr); } } } /* for XHTML, normalize boolean attributes */ if(hp->xhtml && (VT_BOOL == attr->vartype)) { char *s,*t,*q; /* choose quotes */ q = (QMODE_SINGLE == hp->quotemode) ? "'" : "\""; /* clone attribute string */ s = t = strclone(estr2str(attr_str)); /* skip leading blanks */ while(isspace(*t)) ++t; /* turn attr into attr="attr" or attr='attr' */ app_estr(attr_str,"="); app_estr(attr_str,q); app_estr(attr_str,t); app_estr(attr_str,q); ufreestr(s); } else if(hp->lctags && (VT_ENUM == attr->vartype)) { /* lowercase entire attribute + value for ENUM attributes if req. */ lowstr(estr2str(attr_str)); } /* warn on obsolete attribute */ if((attr->varflag & VF_OBSOLETE) && (strlen(estr2str(val_str))) && (strlen(estr2str(attr_str)))) { hsc_message(hp,MSG_ATTR_OBSOLETE,"%A is obsolete",attr); } /* cleanup pseudo-attr */ if (attr == &skipvar) clr_vartext(attr); if(is_styleattr && strlen(estr2str(val_str)) && strlen(estr2str(attr_str))) { /* attr_str contains gibberish here, don't use it */ BOOL done = FALSE; STRPTR cstyle, nstyle, value; cstyle = estr2str(val_str); /* TODO: move this to css.c */ do { /* check if there is more than one property-value-pair in * this string */ if(NULL != (nstyle = strchr(cstyle,';'))) { /* terminate string there */ *nstyle++ = '\0'; /* skip leading blanks of next style pair */ while(isspace(*nstyle)) ++nstyle; /* if rest is empty, we're done anyway */ if('\0' == *nstyle) done = TRUE; } else { done = TRUE; } value = strchr(cstyle,':'); if(NULL != value) { /* separate property/value */ *value++ = '\0'; /* skip leading blanks on value */ while(isspace(*value)) ++value; /* check whether both property and value are there */ if(strlen(cstyle) && strlen(value)) { add_styleattr(hp,cstyle,value); } else { hsc_message(hp, MSG_INVALID_STYLE, "invalid CSS style definition `%s:%s'", cstyle,value); } } else { hsc_message(hp, MSG_INVALID_STYLE, "invalid CSS style definition %q", cstyle); } /* continue with next style pair */ cstyle = nstyle; } while(!done); } else { /* append attribute */ app_estr(hp->tag_attr_str, estr2str(attr_str)); } del_estr(attr_str); del_estr(val_str); return (ok); } /* * set_tag_defaults * * append attributes which have not been set by user but contain * a default value to the hp->tag_attr_str */ static VOID set_tag_defaults(HSCPRC * hp, HSCTAG * tag) { DLNODE *nd = dll_first(tag->attr); while (nd) { HSCATTR *attr = (HSCATTR *) dln_data(nd); STRPTR value = get_vartext(attr); STRPTR defval = get_vardeftext(attr); if (!value && defval) { /* there is no current value, but a default value: * set value with default, */ set_vartext(attr, defval); /* append attribute name to tag_attr_str */ app_estr(hp->tag_attr_str, " "); app_estr(hp->tag_attr_str, attr->name); DAV(fprintf(stderr, DHL " `%s:%s' defaults to `%s'\n", tag->name, attr->name, defval)); /* if it is a non-bool attrib, also append value */ if (attr->vartype != VT_BOOL) { app_estr(hp->tag_attr_str, "="); /* decide which quote to use for default value */ attr->quote = DOUBLE_QUOTE; choose_quote(hp, attr); /* append quote */ if (attr->quote != VQ_NO_QUOTE) { app_estrch(hp->tag_attr_str, attr->quote); } /* append value */ app_estr(hp->tag_attr_str, attr->name); /* append quote */ if (attr->quote != VQ_NO_QUOTE) { app_estrch(hp->tag_attr_str, attr->quote); } } } nd = dln_next(nd); } } /* * set_tag_args * * parse & set all arguments of a tag */ ULONG set_tag_args(HSCPRC * hp, HSCTAG * tag) { INFILE *inpf = hp->inpf; BOOL ok = FALSE; DLLIST *varlist; ULONG result_tci = get_mci(hp); /* resulting tag_call_id */ STRPTR nw = infgetw(inpf); /* evaluate which varlist to use */ varlist = tag->attr; /* clear string that logs all attributes passed to tag */ clr_estr(hp->tag_attr_str); /* read args */ do { if (!nw) { hsc_msg_eof(hp, "read attributes"); } else { /* * process next attribute */ if (!strcmp(nw, ">")) { nw = NULL; ok = TRUE; } else { /* if in XHTML mode, ensure there is no attribute after * the closing slash */ if(hp->xhtml && (tag->option & HT_EMPTY) && !hp->xhtml_emptytag) hsc_message(hp, MSG_ATTR_AFTER_SLASH, "%a after closing slash in empty tag", nw); /* process attribute */ if (NULL != (nw = check_attrname(hp, NULL, nw, FALSE))) { set_tag_arg(hp, varlist, nw, tag->name, (BOOL)(tag->option & HT_UNKNOWN), (BOOL)(tag->option & HT_MACRO)); } else { /* append empty value */ #if 0 app_estr(hp->tag_attr_str, "\"\""); skip_until_eot(hp, NULL); nw = NULL; #endif } /* read next attribute */ if (nw) nw = infgetw(inpf); } } } while (nw); /* for all attributes with defaults, but no value, * append it to the tag call */ set_tag_defaults(hp, tag); /* unset scope */ unget_mci(hp); /* set all undefined bool. attr to FALSE */ clr_varlist_bool(varlist); /* check for required attributes */ if (ok) if(!(ok = check_varlist(hp, varlist))) inungetcw(inpf); if (!ok) result_tci = MCI_ERROR; return (result_tci); } /* $Id: deftag.c,v 1.9 2003/07/06 04:37:34 mb Exp mb $ */ /* vi: set ts=4: */ hsc-0.934.orig/hsclib/deftag.h0100600000175000001440000000232707732056103015020 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/deftag.h */ #ifndef HSCLIB_DEFTAG_H #define HSCLIB_DEFTAG_H #ifndef NOEXTERN_HSCLIB_DEFTAG_H extern ULONG set_tag_args(HSCPRC * hp, HSCTAG * tag); extern BOOL def_tag_args(HSCPRC * hp, HSCTAG * tag); extern HSCTAG *def_tag_name(HSCPRC * hp, BOOL * open_tag); #endif /* NOEXTERN_HSCLIB_DEFTAG_H */ #endif /* HSCLIB_DEFTAG_H */ /* $Id: deftag.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */ /* vi: set ts=4: */ hsc-0.934.orig/hsclib/hscprc.h0100600000175000001440000004436210010443750015044 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1995-1998 Thomas Aglassinger * Copyright (C) 2001 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * hsclib/hscprc.h * * hsc process structure * */ #ifndef HSC_HSCPRC_H #define HSC_HSCPRC_H #include #include "hsclib/ldebug.h" #include "hsclib/tag.h" #include "hscprj/project.h" /* * system-dependant defines */ #if defined(AMIGA) || defined(AROS) #define CONFIG_FILE "hsc.prefs" #define OPTION_FILE "hsc.options", "env:hsc.options" #define CONFIG_PATH "PROGDIR:" /* TODO: find out what the hell this did here in the first place #define UNIX 1 */ /* utilize POSIX-layer of BeOS */ #elif defined RISCOS #define CONFIG_FILE "hsc:hsc.prefs" #define CONFIG_PATH "hsc:" #define OPTION_FILE "hsc.options" #elif (defined NEXTSTEP) || (defined UNIX) || (defined BEOS) || (defined WINNT) #define CONFIG_FILE "hsc.prefs" #define CONFIG_PATH "/usr/local/lib/", "/usr/lib/" #define OPTION_FILE "hsc.options" /* [3] */ #else #error "Operating system not supported: config-file/path" #endif /* utilize POSIX-layer of BEOS */ #if defined BeOS #define UNIX 1 #endif /* step sizes for expstr's */ #define ES_STEP_MACRO 1024 /* tag_macro.c */ #define ES_STEP_INFILE 4096 /* input file buffer */ /* * modes for syntax check */ #define MODE_PEDANTIC 1 #define MODE_NORMAL 2 #define MODE_RELAXED 3 /* * modes for attribute quotes */ #define QMODE_KEEP 1 /* keep quotes from input */ #define QMODE_DOUBLE 2 /* always use double quotes (compatible) */ #define QMODE_SINGLE 3 /* always use single quotes */ #define QMODE_NONE 4 /* never use any quotes (compact) */ /* * modes for special characters/entity extraction */ #define EMODE_KEEP (1) /* do not replace */ #define EMODE_REPLACE (2) /* replace by preferred value (numeric/symbolic) */ #define EMODE_NUMERIC (3) /* always replace with numeric entity ({) */ #define EMODE_SYMBOLIC (4) /* always replace with symbolic entity (ü) */ #define EMODE_UTF8 (5) /* always replace with UTF-8 representation */ #define EMODE_INVALID (-1) /* option has not been set */ /* * misc. defines for files & envvars */ #define ENV_HSCPATH "HSCPATH" /* envvar that contains path for prefs */ #define ENV_HSCSALARY "HSCSALARY" /* contains salary of user */ #define ENV_HSCUSER "HSCUSER_PATH" /* to substitute "~/" */ #define ENV_HSCUSERS "HSCUSERS_PATH" /* to substitute "~" */ #define ENV_HSCROOT "HSCROOT_PATH" /* to substitute "/" */ /* used as prefix in filename for * internal (pseudo-)files (macros,init) */ #define SPECIAL_FILE_ID "::s::" /* prefix to be used by filenames if parent file on input-stack * should be used for message-pos. * * NOTE: this is set if IH_POS_PARENT is passed on hsc_include() */ #define PARENT_FILE_ID "::p::" /* pseudo-filenames for stdin */ #define FILENAME_STDIN1 "STDIN" #define FILENAME_STDIN2 "-" /* size of input buffer for getting dimension of image files */ #define IMAGE_BUFFER_SIZE 2048 #define MAXIMUM_MESSAGE_INFINITE ((ULONG) -1) /* names for special attributes */ #define CLICK_HERE_ATTR "HSC.CLICK-HERE" /* attribute that holds "click here" words */ #define COLOR_NAMES_ATTR "HSC.COLOR-NAMES" #define CONTENT_ATTR "HSC.CONTENT" /* keep macro content for content macros */ #define ANCHOR_ATTR "HSC.ANCHOR" #define RESULT_ATTR "HSC.EXEC.RESULT" #define FILESIZEFORMAT_ATTR "HSC.FORMAT.FILESIZE" #define TIMEFORMAT_ATTR "HSC.FORMAT.TIME" #define LINEFEED_ATTR "HSC.LF" #define HSCVERSION_ATTR "HSC.VERSION" #define HSCREVISION_ATTR "HSC.REVISION" /* attribute that holds condition on <$if/$elseif> */ #define CONDITION_ATTR "COND" /* attribute that tells operating system */ #define SYSTEM_ATTR "hsc.System" #ifdef AMIGA #define SYSTEM_ATTR_ID "Amiga" #elif defined AROS #define SYSTEM_ATTR_ID "AROS" #elif defined BEOS #define SYSTEM_ATTR_ID "BeOS" #elif defined RISCOS #define SYSTEM_ATTR_ID "RiscOS" #elif defined NEXTSTEP #define SYSTEM_ATTR_ID "NeXTStep" #elif defined UNIX #define SYSTEM_ATTR_ID "Unix" #elif defined WINNT #define SYSTEM_ATTR_ID "Win32" /* dos4 */ #else #error "system not supported: SYSTEM_ATTR_ID" #endif /* * some typedefs used inside the hsc_process */ typedef LONG HSCMSG_ID; /* hsc message id */ typedef LONG HSCMSG_CLASS; /* hsc message class */ /* enumerator values for hsc_process->msg_ignore */ enum hsc_ignore_status { make_my_day, /* ignore only, if whole class is ignored */ ignore, /* always ignore */ enable /* always show up (even if class ignored) */ }; typedef enum hsc_ignore_status HSCIGN; /* * hsc process structure */ struct hsc_process { INFILE *inpf; /* current input file */ DLLIST *inpf_stack; /* stack of nested input files */ DLLIST *deftag; /* defined tags and macros */ DLLIST *defattr; /* defined attributes */ DLLIST *defent; /* defined special charcters & entities */ DLLIST *deflazy; /* defined lazy attribute lists */ DLLIST *defstyle; /* defined CSS styles */ DLLIST *container_stack; /* stack of container-tags currently open */ DLLIST *content_stack; /* stack of contents of container macros */ DLLIST *include_dirs; /* include directories */ DLLIST *tag_styles; /* CSS styles used by current tag */ HSCPRJ *project; /* project data */ DLLIST *idrefs; /* list of references to local IDs */ EXPSTR *destdir; /* destination root directory */ EXPSTR *reldir; /* relative destination directory */ EXPSTR *tmpstr; /* temp. string used by several functions */ EXPSTR *curr_msg; /* current message */ EXPSTR *curr_ref; /* current reference message */ EXPSTR *iconbase; /* base URI for icons */ EXPSTR *server_dir; /* root dir for server-relative URIs */ time_t start_time; /* time process has been started */ DLLIST *select_stack; /* stack for results of <$select> */ EXPSTR *if_stack; /* stack for results of <$if> */ EXPSTR *tag_name_str; /* strings for communication with tag-handlers */ EXPSTR *tag_attr_str; EXPSTR *tag_close_str; STRPTR filename_document; /* document-name to be stored in project */ HSCIGN *msg_ignore; /* messages to be ignored */ BOOL msg_ignore_notes; /* message-classes to be ignored */ BOOL msg_ignore_style; BOOL msg_ignore_port; HSCMSG_CLASS *msg_class; /* messages with remaped classes */ ULONG msg_count; /* number of messages/errors occured until now */ ULONG max_messages; /* maximum number of messages/errors allowed */ ULONG max_errors; unsigned char *image_buffer; /* buffer to get image dimension from file */ BOOL chkid; /* flag: check existence of URIs/IDs */ BOOL chkuri; BOOL compact; /* flag: create compact output */ BOOL debug; /* flag: display debuging info */ BOOL getsize; /* flag: get size of images/embedded docs */ BOOL htmlonly; /* flag: disable hsc-extensions */ BOOL jerkvalues; /* flag: interpret jerk values */ BOOL rplc_ent; /* flag: replace special chars */ BOOL rplc_quote; /* flag: replace quotes in text by """ */ BOOL smart_ent; /* flag: replace special entities "<>&" */ BOOL strip_cmt; /* flag: strip SGML-comments */ BOOL strip_ext; /* flag: strip external references */ BOOL strip_badws; /* flag: strip bad white spaces */ BOOL weenix; /* flag: unix compatibilty mode */ BOOL xhtml_emptytag; /* flag: processing empty XHTML tag */ BOOL suppress_output; /* flag: TRUE, until outputable data occure */ BOOL docbase_set; /* occured */ BOOL inside_pre; /* inside preformatted tag
 & Co. */
    BOOL inside_anchor;         /* inside anchor-tag  */
    BOOL inside_title;          /* inside title-tag  */
    BOOL prostitute;            /* use "prostitute" or "jerk"? */
    BOOL nested_errors;         /* show "location of previous call" msgs */
    BOOL lctags;                /* force all tags to lowercase */
    BOOL checkext;              /* check external links */
    BOOL xhtml;                 /* try to be XHTML compatible */
    BOOL validate_css;          /* validate contents of STYLE attributes */

    BOOL fatal;                 /* fatal error occured; abort process */

    LONG tag_call_id;
    ULONG prev_status_line;
    LONG prev_heading_num;      /* number of previous heading */
    LONG entitymode;            /* entity replace mode */
    LONG quotemode;             /* quotes to use as output quotes */

    STRPTR click_here_str;      /* keywords for click-here syndrome */
    STRPTR color_names;         /* predifined names for colors */
    STRPTR strip_tags;          /* tags that should be stripped */
    EXPSTR *whtspc;             /* white spaces buffered */
    HSCTAG *tag_next_whtspc;    /* set, if a tag did not allow succ.whtspc */
    BOOL strip_next_whtspc;     /* flag: strip next whtite space
                                 * set by parse_tag(), if strip_badws = TRUE */
    BOOL strip_next2_whtspc;    /* flag: strip next but one white space */
    /* status callbacks */
    VOID(*CB_status_misc) (struct hsc_process * hp, STRPTR s);
    /* called for verbose messages */
    VOID(*CB_status_line) (struct hsc_process * hp);
    /* called after new line */
    VOID(*CB_status_file_begin) (struct hsc_process * hp, STRPTR filename);
    /* called when new file is going to be loaded */
    VOID(*CB_status_file_end) (struct hsc_process * hp);
    /* called after file has fully been processed */

    /* message callbacks */
    VOID(*CB_message) (struct hsc_process * hp,
                       HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
                       STRPTR fname, ULONG x, ULONG y,
                       STRPTR msg_text);
    VOID(*CB_message_ref) (struct hsc_process * hp,
                           HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
                           STRPTR fname, ULONG x, ULONG y,
                           STRPTR msg_text);

    /* syntax elements callbacks */
    VOID(*CB_start_tag) (struct hsc_process * hp,
          HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close);
    VOID(*CB_end_tag) (struct hsc_process * hp,
          HSCTAG * tag, STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close);
    VOID(*CB_text) (struct hsc_process * hp,
                    STRPTR white_spaces, STRPTR text);
    VOID(*CB_id) (struct hsc_process * hp,
                  HSCATTR * attr, STRPTR id);

};

typedef struct hsc_process HSCPRC;

/*
 * global funcs
 */
#ifndef NOEXTERN_HSC_HSCPRC

#define anyWhtspc(hp) (estrlen(hp->whtspc))

extern VOID del_hscprc(HSCPRC * hp);
extern HSCPRC *new_hscprc(void);
extern VOID reset_hscprc(HSCPRC * hp);

/* set-methodes for callbacks */
extern VOID hsc_set_status_file_begin(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp, STRPTR filename));
extern VOID hsc_set_status_file_end(HSCPRC * hp, VOID(*status_file) (HSCPRC * hp));
extern VOID hsc_set_status_line(HSCPRC * hp, VOID(*status_line) (HSCPRC * hp));
extern VOID hsc_set_status_misc(HSCPRC * hp, VOID(*status_misc) (HSCPRC * hp, STRPTR s));
extern VOID hsc_set_message(HSCPRC * hp,
                            VOID(*message) (struct hsc_process * hp,
                                            HSCMSG_CLASS msg_class,
                                            HSCMSG_ID msg_id,
                                            STRPTR fname, ULONG x, ULONG y,
                                            STRPTR msg_text));
extern VOID hsc_set_message_ref(HSCPRC * hp,
                                VOID(*message_ref) (struct hsc_process * hp,
                                                    HSCMSG_CLASS msg_class,
                                                    HSCMSG_ID msg_id,
                                                    STRPTR fname,
                                                    ULONG x, ULONG y,
                                                    STRPTR msg_text));
extern VOID hsc_set_start_tag(HSCPRC * hp,
                              VOID(*CB_start_tag) (struct hsc_process * hp,
                                                   HSCTAG * tag,
                                                   STRPTR tag_name,
                                                   STRPTR tag_attr,
                                                   STRPTR tag_close));
extern VOID hsc_set_end_tag(HSCPRC * hp,
                            VOID(*CB_end_tag) (struct hsc_process * hp,
                                               HSCTAG * tag,
                                               STRPTR tag_name,
                                               STRPTR tag_attr,
                                               STRPTR tag_close));
extern VOID hsc_set_text(HSCPRC * hp,
                         VOID(*CB_text) (struct hsc_process * hp,
                                         STRPTR white_spaces, STRPTR text));
extern VOID hsc_set_id(HSCPRC * hp,
                       VOID(*id) (struct hsc_process * hp,
                                  HSCATTR * attr, STRPTR id));

/* set-methodes for flags */
extern VOID hsc_set_chkid(HSCPRC * hp, BOOL new_chkid);
extern VOID hsc_set_chkuri(HSCPRC * hp, BOOL new_chkuri);
extern VOID hsc_set_compact(HSCPRC * hp, BOOL new_compact);
extern VOID hsc_set_debug(HSCPRC * hp, BOOL new_debug);
extern VOID hsc_set_getsize(HSCPRC * hp, BOOL new_getsize);
extern VOID hsc_set_jerkvalues(HSCPRC * hp, BOOL new_jerkvalues);
extern VOID hsc_set_rplc_ent(HSCPRC * hp, BOOL new_rplc_ent);
extern VOID hsc_set_rplc_quote(HSCPRC * hp, BOOL new_rplc_quote);
extern BOOL hsc_set_server_dir(HSCPRC * hp, STRPTR dir);
extern VOID hsc_set_smart_ent(HSCPRC * hp, BOOL new_smart_ent);
extern VOID hsc_set_strip_badws(HSCPRC * hp, BOOL new_strip_badws);
extern VOID hsc_set_strip_cmt(HSCPRC * hp, BOOL new_strip_cmt);
extern VOID hsc_set_strip_ext(HSCPRC * hp, BOOL new_strip_ext);
extern VOID hsc_set_nested_errors(HSCPRC * hp, BOOL new_nested_errors);
extern VOID hsc_set_lctags(HSCPRC * hp, BOOL new_lctags);
extern VOID hsc_set_checkext(HSCPRC * hp, BOOL new_checkext);
extern VOID hsc_set_xhtml(HSCPRC * hp, BOOL new_xhtml);
extern VOID hsc_set_vcss(HSCPRC * hp, BOOL new_vcss);

/* set-methodes for values */
extern BOOL hsc_set_destdir(HSCPRC * hp, STRPTR dir);
extern BOOL hsc_set_reldir(HSCPRC * hp, STRPTR fname);
extern BOOL hsc_set_iconbase(HSCPRC * hp, STRPTR uri);
extern BOOL hsc_set_strip_tags(HSCPRC * hp, STRPTR taglist);
extern BOOL hsc_set_filename_document(HSCPRC * hp, STRPTR filename);
extern VOID hsc_set_quote_mode(HSCPRC * hp, LONG new_mode);
extern VOID hsc_set_entity_mode(HSCPRC * hp, LONG new_mode);
extern VOID hsc_set_maximum_messages(HSCPRC * hp, LONG messages);
extern VOID hsc_set_maximum_errors(HSCPRC * hp, LONG errors);

/* methodes for include-directories */
extern BOOL hsc_add_include_directory(HSCPRC * hp, STRPTR dir);
extern VOID hsc_clr_include_directory(HSCPRC * hp);

/* get-methodes for flags */
extern BOOL hsc_get_chkid(HSCPRC * hp);
extern BOOL hsc_get_chkuri(HSCPRC * hp);
extern BOOL hsc_get_compact(HSCPRC * hp);
extern BOOL hsc_get_debug(HSCPRC * hp);
extern BOOL hsc_get_getsize(HSCPRC * hp);
extern BOOL hsc_get_htmlonly(HSCPRC * hp);
extern BOOL hsc_get_jerkvalues(HSCPRC * hp);
extern BOOL hsc_get_rplc_ent(HSCPRC * hp);
extern BOOL hsc_get_rplc_quote(HSCPRC * hp);
extern BOOL hsc_get_smart_ent(HSCPRC * hp);
extern BOOL hsc_get_strip_badws(HSCPRC * hp);
extern BOOL hsc_get_strip_cmt(HSCPRC * hp);
extern BOOL hsc_get_strip_ext(HSCPRC * hp);

/* get-methodes for internal flags */
extern BOOL hsc_get_fatal(HSCPRC * hp);
extern BOOL hsc_get_inside_anchor(HSCPRC * hp);
extern BOOL hsc_get_inside_pre(HSCPRC * hp);
extern BOOL hsc_get_suppress_output(HSCPRC * hp);

/* get-methodes for values */
extern STRPTR hsc_get_destdir(HSCPRC * hp);
extern STRPTR hsc_get_reldir(HSCPRC * hp);
extern STRPTR hsc_get_iconbase(HSCPRC * hp);
extern STRPTR hsc_get_server_dir(HSCPRC * hp);

/* get-methodes for internal values */
extern STRPTR hsc_get_click_here_str(HSCPRC * hp);
extern STRPTR hsc_get_file_name(HSCPRC * hp);
extern ULONG hsc_get_file_line(HSCPRC * hp);
extern ULONG hsc_get_file_column(HSCPRC * hp);
extern ULONG hsc_get_msg_count(HSCPRC * hp);

/* methodes for messages */
extern BOOL hsc_get_msg_ignore_notes(HSCPRC * hp);
extern BOOL hsc_get_msg_ignore_style(HSCPRC * hp);
extern BOOL hsc_get_msg_ignore_port(HSCPRC * hp);
extern BOOL hsc_set_msg_ignore_notes(HSCPRC * hp, BOOL value);
extern BOOL hsc_set_msg_ignore_style(HSCPRC * hp, BOOL value);
extern BOOL hsc_set_msg_ignore_port(HSCPRC * hp, BOOL value);
extern BOOL hsc_set_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id, HSCIGN value);
extern HSCIGN hsc_get_msg_ignore(HSCPRC * hp, HSCMSG_ID msg_id);
extern BOOL hsc_set_msg_class(HSCPRC * hp, HSCMSG_ID msg_id, HSCMSG_CLASS msg_class);
extern HSCMSG_CLASS hsc_get_msg_class(HSCPRC * hp, HSCMSG_ID msg_id);
extern VOID hsc_clear_msg_ignore(HSCPRC * hp);
extern VOID hsc_reset_msg_class(HSCPRC * hp);

/* output function */
extern STRPTR compactWs(HSCPRC * hp, STRPTR ws);
extern BOOL hsc_output_text(HSCPRC * hp, STRPTR wspc, STRPTR text);

/* misc. functions */
extern BOOL hsc_standard_nomem_handler(size_t size);

#endif /* NOEXTERN_HSC_HSCPRC */
#endif /* HSC_HSCPRC_H */

/* $Id: hscprc.h,v 1.8 2004/02/05 13:40:39 mb Exp mb $ */
/* vi: set ts=4: */

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/entities.c��������������������������������������������������������������������0100600�0001750�0000144�00000010445�07732056103�015405� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Entities to be defined during startup -- replaces $defent tags in hsc.prefs */

static struct HSCENTITY {
   STRPTR name;
   unsigned short numeric;
   BOOL prefnum;
} HSCInternalEntities[] = {
   /* basic entities w/o replacement chars */
   {"amp",     0, FALSE},  /* & */
   {"lt",      0, FALSE},  /* < */
   {"gt",      0, FALSE},  /* > */
   {"quot",    0, FALSE},  /* " */
   {"apos",    0, FALSE},  /* ' */

   /* ISO-8859-1 entities stay in the prefs file to allow users to utilize
    * different 8-bit charsets! */

	{"OElig",	338, FALSE},
 	{"oelig",	339, FALSE},
 	{"Scaron",	352, FALSE},
 	{"scaron",	353, FALSE},
 	{"Yuml",	376, FALSE},
 	{"circ",	710, FALSE},
 	{"tilde",	732, FALSE},
 	{"ensp",	8194, FALSE},
 	{"emsp",	8195, FALSE},
 	{"thinsp",	8201, FALSE},
 	{"zwnj",	8204, FALSE},
 	{"zwj",	8205, FALSE},
 	{"lrm",	8206, FALSE},
 	{"rlm",	8207, FALSE},
 	{"ndash",	8211, FALSE},
 	{"mdash",	8212, FALSE},
 	{"lsquo",	8216, FALSE},
 	{"rsquo",	8217, FALSE},
 	{"sbquo",	8218, FALSE},
 	{"ldquo",	8220, FALSE},
 	{"rdquo",	8221, FALSE},
 	{"bdquo",	8222, FALSE},
 	{"dagger",	8224, FALSE},
 	{"Dagger",	8225, FALSE},
 	{"permil",	8240, FALSE},
 	{"lsaquo",	8249, FALSE},
 	{"rsaquo",	8250, FALSE},
 	{"euro",	8364, FALSE},
 	{"fnof",	402, FALSE},
 	{"Alpha",	913, FALSE},
 	{"Beta",	914, FALSE},
 	{"Gamma",	915, FALSE},
 	{"Delta",	916, FALSE},
 	{"Epsilon",	917, FALSE},
 	{"Zeta",	918, FALSE},
 	{"Eta",	919, FALSE},
 	{"Theta",	920, FALSE},
 	{"Iota",	921, FALSE},
 	{"Kappa",	922, FALSE},
 	{"Lambda",	923, FALSE},
 	{"Mu",	924, FALSE},
 	{"Nu",	925, FALSE},
 	{"Xi",	926, FALSE},
 	{"Omicron",	927, FALSE},
 	{"Pi",	928, FALSE},
 	{"Rho",	929, FALSE},
 	{"Sigma",	931, FALSE},
 	{"Tau",	932, FALSE},
 	{"Upsilon",	933, FALSE},
 	{"Phi",	934, FALSE},
 	{"Chi",	935, FALSE},
 	{"Psi",	936, FALSE},
 	{"Omega",	937, FALSE},
 	{"alpha",	945, FALSE},
 	{"beta",	946, FALSE},
 	{"gamma",	947, FALSE},
 	{"delta",	948, FALSE},
 	{"epsilon",	949, FALSE},
 	{"zeta",	950, FALSE},
 	{"eta",	951, FALSE},
 	{"theta",	952, FALSE},
 	{"iota",	953, FALSE},
 	{"kappa",	954, FALSE},
 	{"lambda",	955, FALSE},
 	{"mu",	956, FALSE},
 	{"nu",	957, FALSE},
 	{"xi",	958, FALSE},
 	{"omicron",	959, FALSE},
 	{"pi",	960, FALSE},
 	{"rho",	961, FALSE},
 	{"sigmaf",	962, FALSE},
 	{"sigma",	963, FALSE},
 	{"tau",	964, FALSE},
 	{"upsilon",	965, FALSE},
 	{"phi",	966, FALSE},
 	{"chi",	967, FALSE},
 	{"psi",	968, FALSE},
 	{"omega",	969, FALSE},
 	{"thetasym",	977, FALSE},
 	{"upsih",	978, FALSE},
 	{"piv",	982, FALSE},
 	{"bull",	8226, FALSE},
 	{"hellip",	8230, FALSE},
 	{"prime",	8242, FALSE},
 	{"Prime",	8243, FALSE},
 	{"oline",	8254, FALSE},
 	{"frasl",	8260, FALSE},
 	{"weierp",	8472, FALSE},
 	{"image",	8465, FALSE},
 	{"real",	8476, FALSE},
 	{"trade",	8482, FALSE},
 	{"alefsym",	8501, FALSE},
 	{"larr",	8592, FALSE},
 	{"uarr",	8593, FALSE},
 	{"darr",	8595, FALSE},
 	{"harr",	8596, FALSE},
 	{"crarr",	8629, FALSE},
 	{"lArr",	8656, FALSE},
 	{"uArr",	8657, FALSE},
 	{"rArr",	8658, FALSE},
 	{"dArr",	8659, FALSE},
 	{"hArr",	8660, FALSE},
 	{"forall",	8704, FALSE},
 	{"part",	8706, FALSE},
 	{"exist",	8707, FALSE},
 	{"empty",	8709, FALSE},
 	{"nabla",	8711, FALSE},
 	{"isin",	8712, FALSE},
 	{"notin",	8713, FALSE},
 	{"ni",	8715, FALSE},
 	{"prod",	8719, FALSE},
 	{"sum",	8721, FALSE},
 	{"minus",	8722, FALSE},
 	{"lowast",	8727, FALSE},
 	{"radic",	8730, FALSE},
 	{"prop",	8733, FALSE},
 	{"infin",	8734, FALSE},
 	{"ang",	8736, FALSE},
 	{"and",	8743, FALSE},
 	{"or",	8744, FALSE},
 	{"cap",	8745, FALSE},
 	{"cup",	8746, FALSE},
 	{"int",	8747, FALSE},
 	{"there4",	8756, FALSE},
 	{"sim",	8764, FALSE},
 	{"cong",	8773, FALSE},
 	{"asymp",	8776, FALSE},
 	{"ne",	8800, FALSE},
 	{"equiv",	8801, FALSE},
 	{"le",	8804, FALSE},
 	{"ge",	8805, FALSE},
 	{"sub",	8834, FALSE},
 	{"sup",	8835, FALSE},
 	{"nsub",	8836, FALSE},
 	{"sube",	8838, FALSE},
 	{"supe",	8839, FALSE},
 	{"oplus",	8853, FALSE},
 	{"otimes",	8855, FALSE},
 	{"perp",	8869, FALSE},
 	{"sdot",	8901, FALSE},
 	{"lceil",	8968, FALSE},
 	{"rceil",	8969, FALSE},
 	{"lfloor",	8970, FALSE},
 	{"rfloor",	8971, FALSE},
 	{"lang",	9001, FALSE},
 	{"rang",	9002, FALSE},
 	{"loz",	9674, FALSE},
 	{"spades",	9824, FALSE},
 	{"clubs",	9827, FALSE},
 	{"hearts",	9829, FALSE},
 	{"diams",	9830, FALSE}
};

/* $Id: entities.c,v 1.4 2003/07/09 14:36:35 mb Exp mb $ */
/* vi: set ts=4: */
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/entity.c����������������������������������������������������������������������0100600�0001750�0000144�00000010224�07732056103�015070� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, an html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001-2003  Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * entity.c
 *
 * entity structure, variables and functions ( "&xx;")
 *
 */

#define NOEXTERN_HSCLIB_ENTITY_H
#include "hsclib/inc_base.h"
#include "hsclib/entity.h"

/*
 *-------------------------------------
 * constructor/destructor
 *-------------------------------------
 */

/*
 * new_hscent
 *
 * alloc & init a new hscentity
 */
HSCENT *new_hscent(STRPTR newid) {
    HSCENT *newent = (HSCENT*) umalloc(sizeof(HSCENT));

#if DEBUG_ENTITY
    fprintf(stderr, DHL "   new_enty %s\n", newid);
#endif

    if (newent) {
       /* init new entity item */
       newent->name = strclone(newid);
       newent->replace[0] = newent->replace[1] = '\0';
       newent->numeric = 0;
       newent->flags = 0;
    }
    return (newent);
}

/*
 * del_entity
 */
VOID del_entity(APTR data) {
    HSCENT *ent = (HSCENT*)data;

#if DEBUG_ENTITY
    fprintf(stderr, DHL "   del_enty %s\n", ent->name);
#endif

    if(NULL != ent->name)
       ufreestr(ent->name);
    ent->replace[0] = '\0';
    ent->numeric = 0;
    ufree(ent);
}

/*
 * cpy_hscent
 *
 * create a copy of an already existing entity
 */
HSCENT *cpy_hscent(HSCENT * oldent) {
    HSCENT *newent = new_hscent(oldent->name);

    if (newent) {
        newent->replace[0] = oldent->replace[0];
        newent->numeric = oldent->numeric;
    }
    return (newent);
}

/*
 *---------------------------
 * find entity string
 *---------------------------
 */

/*
 * cmp_strent
 *
 * compares a entity-string with the name
 * of a HSCENT-entry
 */
int cmp_strent(APTR cmpstr, APTR entdata) {
   STRPTR entstr = NULL;

   if (entdata)
      entstr = ((HSCENT*)entdata)->name;

   if(NULL != entstr) {
      if (!strcmp(cmpstr, entstr))
         return -1;
      else
         return 0;
   }
   return 0;
}

/*
 * cmp_nument
 *
 * compares an entity-string with the numeric
 * data of an HSCENT-entry
 */
int cmp_nument(APTR cmpstr, APTR entdata) {
    LONG num = -1;
    LONG cmpnum = (LONG) cmpstr;

    if (entdata)
        num = ((HSCENT *) entdata)->numeric;

    return ((num != -1) && (num == cmpnum));
}

/*
 * cmp_rplcent
 *
 * compares an entity-string with the replace-item
 * of an HSCENT-entry
 */
int cmp_rplcent(APTR cmpstr, APTR entdata) {
    STRPTR entstr = NULL;

    if (entdata)
        entstr = ((HSCENT*)entdata)->replace;

    if (entstr) {
        if (!strcmp(cmpstr, entstr))
            return -1;
        else
            return 0;
    }
    return 0;
}

/*
 *-------------------------------------
 * append entity functions
 *-------------------------------------
 */

/*
 * app_entnode
 *
 * create a new entity and append it to entity-list
 *
 * params: entid..name of the new entity (eg "uuml")
 * result: ptr to the new entity or NULL if no mem
 */
HSCENT *app_entnode(DLLIST * entlist, STRPTR entid) {
    HSCENT *newent;

    newent = new_hscent(entid);
    if(NULL != newent) {
       if (app_dlnode(entlist, newent) == NULL) {
          del_entity((APTR) newent);
          newent = NULL;
       }
    }
    return (newent);
}

/*
 * add_ent
 */
void add_ent(DLLIST * entlist, STRPTR entid, char entreplace, short num, char flags) {
    HSCENT *newent = app_entnode(entlist, entid);

    if(NULL != newent) {
       newent->replace[0] = entreplace;
       newent->numeric = num;
       newent->flags = flags;
    }
}

/* $Id: entity.c,v 1.5 2003/09/17 13:04:41 mb Exp mb $ */
/* vi: set ts=4: */
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/entity.h����������������������������������������������������������������������0100600�0001750�0000144�00000005063�07772171315�015111� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * entity.h
 *
 * entity structure, variables and functions
 *
 */

#ifndef HSCLIB_ENTITY_H
#define HSCLIB_ENTITY_H

/*
 * defines
 */

/* convert numeric representation to text. pass an array as "buffer", not a pointer! */
#ifdef __SASC
/* SAS/C doesn't have snprintf. Thus, we will just assume (yuck!) the buffer to
 * be large enough and not bother to provide an own snprintf implementation */
#define ENTITY_NUM2TEXT(buffer,num) \
   (sprintf((buffer), "&%d;",(int)(unsigned short)(num)))
#else
/* yes, this is a proper compiler */
#define ENTITY_NUM2TEXT(buffer,num) \
   (snprintf((buffer), sizeof(buffer), "&%d;",(int)(unsigned short)(num)))
#endif

/* value for hscent.numeric to mark icon entities */
#define ICON_ENTITY (-1)
/* flag values for entities */
#define HSCENTF_PREFNUM (0x01)
#define HSCENTF_NONSTD  (0x02)

/*
 * structures & typdefs for entities
 */
typedef struct hscent {
    STRPTR name;        /* name/id (e.g. &"uuml"; ) */
    int numeric;        /* numeric code of entity (e.g. 252) */
    char replace[2];    /* replaces this 8-bit character (e.g. "ü" ) */
    char flags;         /* see definitions above */
} HSCENT;


/*
 *
 * extern references
 *
 */
#ifndef NOEXTERN_HSCLIB_ENTITY_H

extern HSCENT *new_hscent(STRPTR newid);
extern VOID del_entity(APTR data);
extern HSCENT *cpy_hscent(HSCENT * oldent);

extern int cmp_strent(APTR cmpstr, APTR entdata);
extern int cmp_nument(APTR cmpstr, APTR entdata);
extern int cmp_rplcent(APTR cmpstr, APTR entdata);

extern HSCENT *app_entnode(DLLIST * entlist, STRPTR entid);
extern void add_ent(DLLIST * entlist, STRPTR entid, char entreplace, short num, char flags);

#endif /* NOEXTERN_HSCLIB_ENTITY_H */
#endif /* HSCLIB_ENTITY_H */

/* $Id: entity.h,v 1.6 2003/12/24 01:58:16 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tcpip.h�����������������������������������������������������������������������0100600�0001750�0000144�00000002051�10007677173�014704� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 2003 Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/tcpip.h
 *
 * Functions for TCP/IP-based protocols support
 *
 * created:  23-Dec-2003
 */

#include "ugly/utypes.h"
#include "ugly/umemory.h"
#include "ugly/expstr.h"
#include "hsclib/hscprc.h"

extern BOOL check_ext_uri(HSCPRC *hp, char *uri);

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/eval.c������������������������������������������������������������������������0100600�0001750�0000144�00000133703�10010444412�014476� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001 Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/eval.c
 *
 * attribute value evaluation functions
 *
 */

#define NOEXTERN_HSCLIB_EVAL_H

#include <ctype.h>
#include <time.h>

#include "hsclib/inc_base.h"

#include "hsclib/eval.h"
#include "hsclib/input.h"
#include "hsclib/skip.h"
#include "hsclib/uri.h"

/* maximul length of an operator identifer */
#define MAX_OP_LEN 8

/* step-size for temp. string */
#define TMP_STEPSIZE 128

/*
 * equation operators
 */
#define OP_EQ_STR  "="
#define OP_CEQ_STR "=="
#define OP_NEQ_STR "<>"
#define OP_NUMGT_STR ">"
#define OP_NUMLT_STR "<"
#define OP_NUMGE_STR ">="
#define OP_NUMLE_STR "<="
#define OP_GT_STR "GT"
#define OP_LT_STR "LT"
#define OP_GE_STR "GE"
#define OP_LE_STR "LE"
#define OP_INSIDE_STR "IN"
#define OP_CL_BRACKET_STR ")"   /* closing bracket */
#define OP_CL_BRACE_STR "}"     /* closing brace */

/*
 * boolean operators
 */
#define OP_AND_STR "AND"
#define OP_NOT_STR "NOT"
#define OP_OR_STR  "OR"
#define OP_XOR_STR "XOR"

/*
 * string/arithmetic operators
 */
#define OP_CAT_STR "+"
#define OP_ADD_STR "&"          /* this sucks */
#define OP_SUB_STR "-"
#define OP_MUL_STR "*"
#define OP_DIV_STR "/"
#define OP_MOD_STR "MOD"        /* modulo */

typedef enum {OP_NONE=0, OP_EQ, OP_NEQ, OP_CEQ,
   OP_GT, OP_LT, OP_GE, OP_LE,
   OP_NUMGT, OP_NUMLT, OP_NUMGE, OP_NUMLE,
   OP_INSIDE, 
   OP_AND, OP_NOT, OP_OR, OP_XOR,
   OP_CAT, OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD,
   OP_CL_BRACKET, OP_CL_BRACE} op_t;

/*
 * forward references
 */
STRPTR eval_expression(HSCPRC * hp, HSCATTR * dest, STRPTR endstr);
static VOID check_integer(HSCPRC * hp, HSCATTR * dest, STRPTR value);

/*
 * 
 * global funcs
 *
 */

/*
 * err_op: unknown binary operator
 */
static VOID err_op(HSCPRC * hp, STRPTR opstr) {
   hsc_message(hp, MSG_UNKN_BINOP, "unknown binary operator %q", opstr);
}

/*
 * eval_boolstr
 */
static BOOL eval_boolstr(STRPTR s) {
   if (s[0])
      return (TRUE);
   else
      return (FALSE);
}

/* check for empty brackets (after GetTime/GetGmTime) */
static VOID check_brackets(HSCPRC * hp) {
   if (parse_wd(hp, "("))
      parse_wd(hp, ")");
}

/*
 * gettimestr
 */
static EXPSTR *gettimestr(HSCPRC * hp, const struct tm *time) {
#define TIMEBUF_INC 20
   STRPTR timefmt = get_vartext_byname(hp->defattr, TIMEFORMAT_ATTR);
   EXPSTR *timebuf = init_estr(TIMEBUF_INC);
   BOOL strftrc = 0;            /* result of strftime() */
   size_t i;                    /* loop var */

   /* set default time format */
   if (!timefmt)
      timefmt = "%d-%b-%Y, %H:%M";

   while (!(hp->fatal) && !strftrc) {
      /* expand timebuffer */
      for (i = 0; i < TIMEBUF_INC; i++)
         app_estrch(timebuf, '.');

      D(fprintf(stderr, DHL "    timebuf: inc+%d\n", TIMEBUF_INC));

      /* output time */
      strftrc = strftime(estr2str(timebuf), estrlen(timebuf),
            timefmt, time);
   }

   if (!strftrc) {
      del_estr(timebuf);
      timebuf = NULL;
   }

   return (timebuf);
}

/*
 * getfilesize
 *
 * get size of a specific file
 *
 * templates for HSC.FORMAT.FILESIZE:
 * %b   size in byte
 * %k   size in Kbyte
 * %m   size in MByte
 * %g   size in Gbyte
 * %a   size, unit computed automatically
 * %u   unit for %A (none, "K", "M" or "G")
 */
static STRPTR getfilesize(HSCPRC * hp, EXPSTR * dest, STRPTR uri) {
   STRPTR filesizestr = NULL;
   FILE *file = NULL;
   LONG filesize = 0;           /* filesize in byte */
   LONG filesize_k = 0;         /* filesize in Kbyte */
   LONG filesize_m = 0;         /* filesize in Mbyte */
   LONG filesize_g = 0;         /* filesize in Gbyte */
   LONG filesize_auto = 0;      /* filesize in auto-units (%A) */
   EXPSTR *efilename = init_estr(32);
   STRPTR filename = NULL;
   STRPTR sizeunit = "";
   STRPTR s = get_vartext_byname(hp->defattr,
         FILESIZEFORMAT_ATTR);

   conv_hscuri2file(hp, efilename, uri);
   filename = estr2str(efilename);

   D(fprintf(stderr, DHL "  GETFILESIZE(`%s')\n", filename));
   errno = 0;
   file = fopen(filename, "rb");
   if (file) {
      /* retrieve size */
      fseek(file, 0L, SEEK_END);
      filesize = ftell(file);
      fclose(file);

      /* compute size in units, */
      filesize_k = (filesize + 512) >> 10;
      filesize_m = (filesize_k + 512) >> 10;
      filesize_g = (filesize_m + 512) >> 10;

      /* compute auto-size */
      if (filesize_g > 10) {
         filesize_auto = filesize_g;
         sizeunit = "G";
      } else if (filesize_m > 10) {
         filesize_auto = filesize_m;
         sizeunit = "M";
      } else if (filesize_k > 10) {
         filesize_auto = filesize_k;
         sizeunit = "K";
      } else {
         filesize_auto = filesize;
         sizeunit = "";
      }
   } else {
      /* file not found */
      filesize = 0;
      filesize_k = 0;
      filesize_m = 0;
      filesize_g = 0;
      filesize_auto = 0;
      sizeunit = "";
      hsc_msg_nouri(hp, filename, uri, "get filesize");
   }

   /* parse template */
   clr_estr(dest);
   if (s) {
      while (s[0]) {
         if (s[0] == '%') {
            if (s[1])
               s++;
            switch (s[0]) {
               case 'b':
                  app_estr(dest, long2str(filesize));
                  break;

               case 'k':
                  app_estr(dest, long2str(filesize_k));
                  break;

               case 'm':
                  app_estr(dest, long2str(filesize_m));
                  break;

               case 'g':
                  app_estr(dest, long2str(filesize_g));
                  break;

               case 'a':
                  app_estr(dest, long2str(filesize_auto));
                  break;

               case 'u':
                  app_estr(dest, sizeunit);
                  break;

               default:
                  app_estrch(dest, '%');
                  app_estrch(dest, s[0]);
                  break;
            }
         } else
            app_estrch(dest, s[0]);
         s++;
      }
   } else {
      D(panic("no template for filesize-format"));
   }

   /* set filesize-str */
   filesizestr = estr2str(dest);
   D(fprintf(stderr, DHL "  =`%s'\n", filesizestr));

   del_estr(efilename);

   return (filesizestr);
}

/*
 * set_var_basename_ext
 *
 * Set HSC variable <dest> to basename or extension of filename stored
 * in string <src>, depending on the "ext" flag.
 * Returns contents of <dest> as a read-only C string or NULL on error.
 */
static const STRPTR set_var_basename_ext(STRPTR src, HSCATTR *dest, BOOL ext) {
   STRPTR end;
   EXPSTR *tmp = init_estr(0);
   BOOL ok=FALSE;

   if(tmp) {
      end   = src + strlen(src) - 1;
      while((*end != '.') && (end > src)) end--;
      if((end == src) && (*end != '.')) {
         /* no period */ 
         if(ext) set_vartext(dest,"");
         else set_vartext(dest,src);
      } else {
         if(ext) ok = set_estr(tmp,end+1);
         else ok = set_estrn(tmp,src,(size_t)(end-src));
         if(ok) set_vartext(dest,estr2str(tmp));
         del_estr(tmp);
      }
   }
   return ok ? get_vartext(dest) : NULL;
}

/*
 * check_attrname
 *
 * check string for legal attribute name
 * "dest" must be set to an HSC attribute initialized by new_hscattr() if and
 * only if allow_expr==TRUE.
 */
STRPTR check_attrname(HSCPRC * hp, HSCATTR *dest, STRPTR name, BOOL allow_expr) {
   STRPTR res = NULL;

   if (hsc_normch(name[0])) {
      res = name;
   } else if(('/' == name[0]) && ('\0' == name[1]) && hp->xhtml_emptytag) {
      hp->xhtml_emptytag = FALSE; /* only allow once */
      res = name;
   } else if(('{' == name[0]) && allow_expr) {
      dest->vartype = VT_STRING;
      res = eval_expression(hp,dest,"}");
   } else {
      hsc_message(hp, MSG_ILLG_ATTRNAME,
            "illegal attribute identifier %q%s",
            name,strcmp(name,"/") ? "" : " (XHTML mode?)");
   }
   return res;
}

/*
 * eval_attrname
 *
 * read next word and check it for a legal
 * attribute identifier
 */
static STRPTR eval_attrname(HSCPRC *hp, HSCATTR *tmpdest) {
   STRPTR result = NULL;
   STRPTR nw = infgetw(hp->inpf);
   if (nw) {
      if (NULL != (nw = check_attrname(hp, tmpdest, nw, TRUE))) {
         result = nw;
      }
   } else {
      hsc_msg_eof(hp, "attribute identifier expected");
   }
   return (result);
}

/*
 * quotestr
 *
 * return readable string for quote-kind
 */
STRPTR quotestr(int quote) {
   STRPTR s = "UNKNOWN";

   if (quote == DOUBLE_QUOTE)
   {
      s = "[double]";
   }
   else if (quote == SINGLE_QUOTE)
   {
      s = "[single]";
   }
   else if (quote == BACK_QUOTE)
   {
      s = "[back]";
   }
   else if (quote == VQ_NO_QUOTE)
   {
      s = "[none]";
   }
   else
   {
      STRARR tmp[60];
      sprintf(tmp, "unknown quote-kind: $%02x #%03d", quote, quote);
      panic(tmp);
   }

   return (s);
}

/*
 * choose_quote
 *
 * choose quote to be used for attr, depending on
 * hp->quotemode and quotes used inside the value
 */
VOID choose_quote(HSCPRC * hp, HSCATTR * attr) {
   int quote = attr->quote;
   LONG qm = hp->quotemode;     /* lazy.. */
   BOOL single_quote = FALSE;
   BOOL double_quote = FALSE;
   BOOL nasty_char = FALSE;

   STRPTR value = get_vartext(attr);

   D(fprintf(stderr, DHL "  choosing quote\n"));

   if (attr->vartype == VT_BOOL) {
      D(fprintf(stderr, DHL "    forget it, it's just a boolean attrib\n"));
   } else if (value[0]) {
      /* scan attribute value for quotes */
      while (value[0]) {
         if (value[0] == SINGLE_QUOTE) {
            D(fprintf(stderr, DHL "    single quote detected\n"));
            single_quote = TRUE;
            nasty_char = TRUE;
         } else if (value[0] == DOUBLE_QUOTE) {
            D(fprintf(stderr, DHL "    double quote detected\n"));
            double_quote = TRUE;
            nasty_char = TRUE;
         } else if ((!hsc_normch(value[0]) || (value[0] == '_')) && !nasty_char) {
            D(fprintf(stderr, DHL "    nasty-char #%d detected\n", value[0]));
            nasty_char = TRUE;
         }
         value++;
      }
   } else {
      /* empty value */
      nasty_char = TRUE;
   }

   if (qm == QMODE_KEEP) {
      /* check, if quote is missing */
      if ((attr->quote == VQ_NO_QUOTE) && nasty_char) {
         hsc_message(hp, MSG_REQU_QUOTE,
               "value for %A requires quotes", attr);
      }
   } else {
      /* choose quote */
      if (single_quote && double_quote) {
         /* both kind of quotes appeared in value:
          * replace double-quotes by """ */
         EXPSTR *newval = init_estr(32);  /* new attribute value */

         /* scan old value for `\"', replace them by `"'
          * and store new value in newval */
         value = get_vartext(attr);
         while (value[0]) {
            if (value[0] == DOUBLE_QUOTE) {
               D(fprintf(stderr, DHL "    replace by `"' in value\n"));
               /* TODO: message */
               app_estr(newval, """);
            } else
               app_estrch(newval, value[0]);
            value++;
         }

         /* update attribute value */
         set_vartext(attr, estr2str(newval));
         quote = DOUBLE_QUOTE;
         del_estr(newval);
      } else {
         if (single_quote) {
            D(fprintf(stderr, DHL "    double quote forced\n"));
            quote = DOUBLE_QUOTE;
         } else if (double_quote) {
            D(fprintf(stderr, DHL "    single quote forced\n"));
            quote = SINGLE_QUOTE;
         } else {
            /* no quote in value: choose quote user prefers */
            if (qm == QMODE_SINGLE) {
               D(fprintf(stderr, DHL "    single quote preferred\n"));
               quote = SINGLE_QUOTE;
            } else if (qm == QMODE_DOUBLE) {
               D(fprintf(stderr, DHL "    double quote preferred\n"));
               quote = DOUBLE_QUOTE;
            } else if (qm == QMODE_NONE) {
               if (nasty_char) {
                  D(fprintf(stderr, DHL "    quote needed (nasty char)\n"));
                  quote = DOUBLE_QUOTE;
               } else {
                  D(fprintf(stderr, DHL "    no quote needed\n"));
                  quote = VQ_NO_QUOTE;
               }
            } else {
               panic("illegal quote-mode");
            }
         }
      }
      /* check, if quote has changed */
      if (attr->quote != quote) {
         hsc_message(hp, MSG_CHANGED_QUOTE,
               "changed quotes for %A from %s to %s",
               attr, quotestr(attr->quote), quotestr(quote));
      }
   }
   attr->quote = quote;
}

/*
 * try_eval_unary_op
 *
 * reads next word and tries to interpret it as an unary
 * operator; if no fitting operator exists, return NULL,
 * else immediatly process the operator and return its
 * result
 */
static STRPTR try_eval_unary_op(HSCPRC * hp, HSCATTR * dest, BOOL * err) {
   STRPTR eval_result = NULL;
   INFILE *inpf = hp->inpf;
   HSCATTR *eadest = new_hscattr(PREFIX_TMPATTR "eval_attrname");
   STRPTR nw = eval_attrname(hp,eadest);
   HSCATTR *tmpdest = new_hscattr(PREFIX_TMPATTR "unary.operator");

   tmpdest->vartype = VT_STRING;

   *err = FALSE;
   if (nw) {
      if (!upstrcmp(nw, "NOT")) {
         /* TODO: this part looks a bit stupid... */
         STRPTR nw = infgetw(inpf);

         if (nw) {
            BOOL err_rec = FALSE;   /* error var for recursive call */
            STRPTR endstr = NULL;

            if (strcmp(nw, "(")) {
               /* try to process another unary operator */
               inungetcw(inpf);
               eval_result = try_eval_unary_op(hp, dest, &err_rec);
            } else
               endstr = ")";

            /* if not, process another expression */
            if (!eval_result && !err_rec)
               eval_result = eval_expression(hp, dest, endstr);
         } else
            hsc_msg_eof(hp, "after NOT");

         /* set result or return error */
         if (eval_result) {
            set_varbool(dest, (BOOL)!get_varbool(dest));
            eval_result = get_vartext(dest);
         } else
            *err = TRUE;
      } else if (!upstrcmp(nw, "DEFINED")) {
         nw = eval_attrname(hp,eadest);
         if (nw) {
            HSCATTR *attr = find_varname(hp->defattr, nw);
            
            if (attr)
               set_varbool(dest, TRUE);
            else
               set_varbool(dest, FALSE);
            eval_result = get_vartext(dest);
         }
      } else if (!upstrcmp(nw, "ORD")) {
         eval_result = eval_expression(hp, tmpdest, NULL);
         if (eval_result) {
            char ts[4];
            D(fprintf(stderr, DHL "  ORD(`%s')\n", eval_result));
            sprintf(ts,"%d",(int)eval_result[0]);
            set_vartext(dest,ts);
            eval_result = get_vartext(dest); 
            D(fprintf(stderr, DHL "  =`%s'\n", eval_result));
         }
      } else if (!upstrcmp(nw, "CHR")) {
         eval_result = eval_expression(hp, tmpdest, NULL);
         if (eval_result) {
            char ts[2];
            D(fprintf(stderr, DHL "  CHR(`%s')\n", eval_result));
            check_integer(hp,tmpdest,eval_result);
            ts[0] = (char)atoi(eval_result);
            ts[1] = '\0';
            set_vartext(dest,ts);
            eval_result = get_vartext(dest); 
            D(fprintf(stderr, DHL "  =`%s'\n", eval_result));
         }
      } else if (!upstrcmp(nw, "EXISTS")) {
         /* check existence of file (relative to destination dir) */
         eval_result = eval_expression(hp, tmpdest, NULL);
         if (eval_result) {
            FILE *file = NULL;
            EXPSTR *dest_fname = init_estr(64);

            D(fprintf(stderr, DHL "  EXISTS(`%s')\n", eval_result));

            conv_hscuri2file(hp, dest_fname, eval_result);
            file = fopen(estr2str(dest_fname), "r");
            if (file) {
               fclose(file);
               set_varbool(dest, TRUE);
            } else
               set_varbool(dest, FALSE);

            del_estr(dest_fname);
            eval_result = get_vartext(dest);
         }
      } else if (!upstrcmp(nw, "FEXISTS")) {
         /* check existence of file */
         eval_result = eval_expression(hp, tmpdest, NULL);
         if (eval_result) {
            FILE *file = NULL;
            EXPSTR *dest_fname = init_estr(64);

            D(fprintf(stderr, DHL "  EXISTS(`%s')\n", eval_result));

            file = fopen(eval_result, "r");
            if (file) {
               fclose(file);
               set_varbool(dest, TRUE);
            } else
               set_varbool(dest, FALSE);

            del_estr(dest_fname);
            eval_result = get_vartext(dest);
         }
      } else if (!upstrcmp(nw, "GETENV")) {
         /* get environment variable */
         eval_result = eval_expression(hp, dest, NULL);
         if (eval_result) {
            STRPTR env_value = getenv(get_vartext(dest));

            D(fprintf(stderr, DHL "  GETENV(`%s')\n", eval_result));
            if (!env_value) {
               hsc_message(hp, MSG_UNKN_ENVVAR,
                     "unknown environment variable %q",
                     get_vartext(dest));

               env_value = "";
            }
            set_vartext(dest, env_value);
            eval_result = get_vartext(dest);
            D(fprintf(stderr, DHL "  =`%s'\n", eval_result));
         }
      } else if (!upstrcmp(nw, "GETFILESIZE")) {
         /* retrieve size of a file */
         EXPSTR *filesizestr = init_estr(0);
         HSCATTR *filedestattr = new_hscattr(PREFIX_TMPATTR "get.filesize");
         STRPTR filename = NULL;

         eval_result = NULL;
         filedestattr->vartype = VT_STRING;
         filename = eval_expression(hp, filedestattr, NULL);
         if (filename)
            eval_result = getfilesize(hp, filesizestr, filename);
         if (eval_result) {
            set_vartext(dest, eval_result);
            eval_result = get_vartext(dest);
         }
         del_hscattr(filedestattr);
         del_estr(filesizestr);
      } else if (!upstrcmp(nw, "GETFILEDATE")) {
         EXPSTR *filedatestr = NULL;
         HSCATTR *filedestattr = new_hscattr(PREFIX_TMPATTR "get.filedate");
         STRPTR filename = NULL;
         const struct tm *time;

         eval_result = NULL;
         filedestattr->vartype = VT_STRING;
         if((NULL != (filename = eval_expression(hp, filedestattr, NULL))) &&
               (NULL != (time = fgetmtime(filename))) &&
               (NULL != (filedatestr = gettimestr(hp, time)))) {
            set_vartext(dest, estr2str(filedatestr));
            eval_result = get_vartext(dest);
         }
         del_hscattr(filedestattr);
         del_estr(filedatestr);
      } else if (!upstrcmp(nw, "GETTIME")) {
         /* get local time */
         EXPSTR *timestr = gettimestr(hp, localtime(&(hp->start_time)));

         D(fprintf(stderr, DHL "  GETTIME\n"));
         if (timestr) {
            set_vartext(dest, estr2str(timestr));
            del_estr(timestr);
            eval_result = get_vartext(dest);
         }
         check_brackets(hp);
      } else if (!upstrcmp(nw, "GETGMTIME")) {
         /* get greenwich mean time */
         EXPSTR *timestr = gettimestr(hp, gmtime(&(hp->start_time)));

         D(fprintf(stderr, DHL "  GETGMTIME\n"));
         if (timestr) {
            set_vartext(dest, estr2str(timestr));
            del_estr(timestr);
            eval_result = get_vartext(dest);
         }
         check_brackets(hp);
      } else if (!upstrcmp(nw, "SET")) {
         nw = eval_attrname(hp,eadest);
         if (nw) {
            HSCATTR *attr = find_varname(hp->defattr, nw);

            if (attr) {
               if (attr->vartype == VT_BOOL)
                  set_varbool(dest, get_varbool(attr));
               else if (get_vartext(attr))
                  set_varbool(dest, TRUE);
               else
                  set_varbool(dest, FALSE);
               eval_result = get_vartext(dest);
            } else {
               hsc_msg_unkn_attr_ref(hp, nw);
               *err = TRUE;
            }
         }
      } else if (!upstrcmp(nw, "BASENAME")) {
         eval_result = eval_expression(hp, tmpdest, NULL);
         if (eval_result) {
            D(fprintf(stderr, DHL "  BASENAME(`%s')\n", eval_result));
            set_var_basename_ext(eval_result,dest,FALSE);
            eval_result = get_vartext(dest); 
            D(fprintf(stderr, DHL "  =`%s'\n", eval_result));
         }
      } else if (!upstrcmp(nw, "EXTENSION")) {
         eval_result = eval_expression(hp, tmpdest, NULL);
         if (eval_result) {
            D(fprintf(stderr, DHL "  EXTENSION(`%s')\n", eval_result));
            set_var_basename_ext(eval_result,dest,TRUE);
            eval_result = get_vartext(dest); 
            D(fprintf(stderr, DHL "  =`%s'\n", eval_result));
         }
      } else if (!upstrcmp(nw, "URIKIND")) {
         eval_result = eval_expression(hp, tmpdest, NULL);
         if (eval_result) {
            static const STRPTR kinds[] = {"abs","ext","rel","rsv"};

            D(fprintf(stderr, DHL "  URIKIND(`%s')\n", eval_result));
            set_vartext(dest,kinds[uri_kind(eval_result)]);
            eval_result = get_vartext(dest); 
            D(fprintf(stderr, DHL "  =`%s'\n", eval_result));
         }
      } else
         inungetcw(inpf);
   }

   del_hscattr(tmpdest);
   del_hscattr(eadest);

   if (!nw)
      *err = TRUE;

   return (eval_result);
}

/*
 * eval_op
 *
 * evaluate binary operator string
 */
static BYTE eval_op(HSCPRC * hp) {
   op_t op = OP_NONE;
   BOOL op_eof = FALSE;         /* flag: end of file reached */
   INFILE *inpf = hp->inpf;
   STRPTR nw = infgetw(inpf);

   D(fprintf(stderr, DHL "  operator \"%s", nw));

   if (nw) {
      /* boolean operators */
      if (!upstrcmp(nw, OP_AND_STR))         op = OP_AND;
      else if (!upstrcmp(nw, OP_OR_STR))     op = OP_OR;
      else if (!upstrcmp(nw, OP_XOR_STR))    op = OP_XOR;
      else if (!strcmp(nw, OP_CAT_STR))      op = OP_CAT; /* concatenation operator */
      else if (!strcmp(nw, OP_ADD_STR))      op = OP_ADD; /* concatenation operator */
      else if (!strcmp(nw, OP_SUB_STR))      op = OP_SUB; /* subtraction operator */
      else if (!strcmp(nw, OP_MUL_STR))      op = OP_MUL; /* multiplication operator */
      else if (!strcmp(nw, OP_DIV_STR))      op = OP_DIV; /* division operator */
      else if (!upstrcmp(nw, OP_MOD_STR))    op = OP_MOD; /* modulo operator */
      else if (!upstrcmp(nw, OP_GT_STR))     op = OP_GT;  /* string greater-than */
      else if (!upstrcmp(nw, OP_LT_STR))     op = OP_LT;  /* string less-than */
      else if (!upstrcmp(nw, OP_LE_STR))    op = OP_LE; /* string less-or-equal */
      else if (!upstrcmp(nw, OP_GE_STR))    op = OP_GE;  /* string greater-or-equal */
      else if (!upstrcmp(nw, OP_INSIDE_STR)) op = OP_INSIDE; /* substring search */
      else if (!strcmp(nw, OP_CL_BRACKET_STR)) op = OP_CL_BRACKET; /* closing bracket */
      else if (!strcmp(nw, OP_CL_BRACE_STR)) op = OP_CL_BRACE; /* closing brace */
      else if (strenum(nw, "<|=|>", '|', STEN_CASE)) {
         /* comparison operators */
         STRARR opstr[3];
         int ch;

         /* determine whole comparison operator:
          * take first word, and check for next
          * single character, if it is one of
          * "<", "=" or ">", too. if so, append
          * it to the string that tells the
          * operator.
          */
         strcpy(opstr, nw);
         ch = infgetc(inpf);
         if (ch != EOF) {
            D(fprintf(stderr, "%c", (char) ch));

            if (strchr("<=>", ch)) {
               opstr[1] = ch;
               opstr[2] = 0;
            } else {
               inungetc(ch, inpf);
            }
         } else
            op_eof = TRUE;

         /* find out comparison operator */
         if (!strcmp(opstr, OP_EQ_STR))
            op = OP_EQ;
         else if (!strcmp(opstr, OP_NEQ_STR))
            op = OP_NEQ;
         else if (!strcmp(opstr, OP_NUMGT_STR))
            op = OP_NUMGT;
         else if (!strcmp(opstr, OP_NUMLT_STR))
            op = OP_NUMLT;
         else if (!strcmp(opstr, OP_NUMLE_STR))
            op = OP_NUMLE;
         else if (!strcmp(opstr, OP_NUMGE_STR))
            op = OP_NUMGE;
         else if (!strcmp(opstr, OP_CEQ_STR))
            op = OP_CEQ;
         else
            err_op(hp, opstr);
      } else {
         err_op(hp, nw);
      }
   } else {
      op_eof = TRUE;
   }

   D(fprintf(stderr, "\"\n"));

   if (op_eof)
      hsc_msg_eof(hp, "operator expected");

   return (BYTE)op;
}

/*
 * stroptol
 *
 * convert string operand to long int; treat "" as 0,
 * any non-numeric values as 1
 *
 * this enables to use boolean vars in numeric expressions
 *
 * result: TRUE
 */
static BOOL stroptol(HSCPRC * hp, LONG * dest, STRPTR str) {
   BOOL ok = TRUE;

   *dest = 0;

   if (str[0]) {
      STRPTR last_char = NULL;
      *dest = strtol(str, &last_char, 0);
      if (!last_char || (last_char[0]))
         *dest = 1;
   } else {
      /* empty string "" counts as 0, too */
   }
   return ok;
}

/*
 * process_arithmetic_op
 */
static BOOL process_arithmetic_op(HSCPRC * hp, EXPSTR * result, BYTE op, STRPTR str1, STRPTR str2) {
   BOOL result_set = TRUE;
   LONG int1 = 0;               /* integer value of string operands */
   LONG int2 = 0;
   LONG intr = 0;               /* integer result */

   /* convert both string operands to integers */
   result_set = stroptol(hp, &int1, str1);
   result_set &= stroptol(hp, &int2, str2);

   if ((int2 == 0) && ((op == OP_DIV) || (op == OP_MOD))) {
      /* division by zero */
      hsc_message(hp, MSG_ARITHMETIC_ERROR,
            "arithmetic error: division by zero");
      result_set = FALSE;
   } else {
      /* compute it */
      switch (op) {
         case OP_ADD:
            intr = int1 + int2;
            break;
         case OP_SUB:
            intr = int1 - int2;
            break;
         case OP_MUL:
            intr = int1 * int2;
            break;
         case OP_DIV:
            intr = int1 / int2;
            break;
         case OP_MOD:
            intr = int1 % int2;
            break;
         default:
            panic("unknown arithmetic operator");
            break;
      }
   }

   /* set result */
   if (result_set) {
      STRARR buf[20];
      sprintf(buf, "%ld", intr);
      set_estr(result, buf);
   }
   return result_set;
}

/*
 * process_boolean_op
 */
static BOOL process_boolean_op(HSCPRC * hp, HSCATTR * dest, BYTE op, STRPTR str1, STRPTR str2)
{
   BOOL bool_val1 = eval_boolstr(str1);
   BOOL bool_val2 = eval_boolstr(str2);
   BOOL bool_valr;

   switch (op) {
   case OP_AND: bool_valr = bool_val1 && bool_val2;
      break;

   case OP_OR:
      bool_valr = bool_val1 || bool_val2;
      break;

   case OP_XOR:
      bool_valr = bool_val1 ^ bool_val2;
      break;

   default:
      bool_valr = 0; /* just to make gcc happy */
      panic("unknown boolean operator");
      break;
   }
   set_varbool(dest, bool_valr);

   return FALSE;
}


/*
 * process_comparison_op
 */
static BOOL process_comparison_op(HSCPRC * hp, HSCATTR * dest, BYTE op, STRPTR str1, STRPTR str2)
{
   BOOL comparison_matches = FALSE;
   EXPSTR *uri1 = NULL;
   EXPSTR *uri2 = NULL;
   EXPSTR *fname = NULL;
   LONG int1,int2;

   /* If dest is an URI, apply the URI conversion on the two operands */
   if (dest->vartype == VT_URI) {
      uri1 = init_estr(0);
      uri2 = init_estr(0);
      fname = init_estr(64);

      D(fprintf(stderr, DHL "    URI comparison; conversion required\n"));

      /* copy operands to URI strings */
      set_estr(uri1, str1);
      set_estr(uri2, str2);

      /* convert URIs */
      conv_hscuri2fileNuri(hp, uri1, fname, str1);
      conv_hscuri2fileNuri(hp, uri2, fname, str2);

      /* set operands with URI values */
      str1 = estr2str(uri1);
      str2 = estr2str(uri2);

      D(fprintf(stderr, DHL "    str1=`%s'\n", str1));
      D(fprintf(stderr, DHL "    str2=`%s'\n", str2));
   }

   /* if using a numeric operator, convert operands */
   if((op == OP_NUMGT) ||
         (op == OP_NUMLT) ||
         (op == OP_NUMGE) ||
         (op == OP_NUMLE)) {
      stroptol(hp, &int1, str1);
      stroptol(hp, &int2, str2);
   }

   switch (op) {

      case OP_EQ:
         /* string comparison, ignore case */
         comparison_matches = !upstrcmp(str1, str2);
         break;

      case OP_NEQ:
         /* string comparison "<>" */
         comparison_matches = upstrcmp(str1, str2);
         break;

      case OP_NUMGT:
         /* integer comparison ">" */
         comparison_matches = (int1 > int2);
         break;

      case OP_NUMLT:
         /* integer comparison "<" */
         comparison_matches =  (int1 < int2);
         break;

      case OP_NUMGE:
         /* integer comparison ">=" */
         comparison_matches =  (int1 >= int2);
         break;

      case OP_NUMLE:
         /* integer comparison "<=" */
         comparison_matches =  (int1 <= int2);
         break;

      case OP_GT:
         /* string comparison "GT" */
         comparison_matches = (upstrcmp(str2, str1) > 0);
         break;

      case OP_LT:
         /* string comparison "LT" */
         comparison_matches = (upstrcmp(str2, str1) < 0);
         break;

      case OP_GE:
         /* string comparison "GE" */
         comparison_matches = (upstrcmp(str2, str1) >= 0);
         break;

      case OP_LE:
         /* string comparison "LE" */
         comparison_matches = (upstrcmp(str2, str1) <= 0);
         break;

      case OP_CEQ:
         /* string comparison, case sensitive */
         comparison_matches = !strcmp(str1, str2);
         break;

      default:
         panic("unknown comparison operator");
         break;
   }

   /* return comparison result */
   set_varbool(dest, comparison_matches);

   /* cleanup */
   del_estr(uri1);
   del_estr(uri2);
   del_estr(fname);

   return FALSE;
}

/*
 * process_op
 */
static VOID process_op(HSCPRC * hp, HSCATTR * dest, BYTE op, STRPTR str1, STRPTR str2) {
   EXPSTR *result = init_estr(40);
   BOOL result_set = FALSE;

   D(fprintf(stderr, DHL "  \"%s\", \"%s\"\n", str1, str2));
   if (str2 && (op != OP_NONE)) {
      switch (op) {
         case OP_CAT:
            /* concat two expressions */
            set_estr(result, str1);
            app_estr(result, str2);
            result_set = TRUE;
            break;

         case OP_AND:
         case OP_OR:
         case OP_XOR:
            result_set = process_boolean_op(hp, dest, op, str1, str2);
            break;

         case OP_INSIDE:
            /* sub-string search, ignore case */
            set_varbool(dest,(upstrstr(str2, str1)==NULL) ? FALSE : TRUE);
            break;

         case OP_ADD:
         case OP_SUB:
         case OP_MUL:
         case OP_DIV:
         case OP_MOD:
            result_set = process_arithmetic_op(hp, result, op, str1, str2);
            break;

         case OP_EQ:
         case OP_NEQ:
         case OP_NUMGT:
         case OP_NUMLT:
         case OP_NUMGE:
         case OP_NUMLE:
         case OP_GT:
         case OP_LT:
         case OP_GE:
         case OP_LE:
         case OP_CEQ:
            result_set = process_comparison_op(hp, dest, op, str1, str2);
            break;

         default:
            panic("empty operator");
            break;
      }
   }
   /* store result in destination attribute,
    * if this has not happened yet
    */
   if (result_set)
      set_vartext(dest, estr2str(result));

   /* remove temp. string for result */
   del_estr(result);
}

/*
 *-------------------------------------
 * eval_expression: evaluate expression
 *-------------------------------------
 */

/*
 * eval_string_expr
 *
 * evaluate string expression WITH enclosing quotes
 */
static STRPTR eval_string_expr(HSCPRC * hp, HSCATTR * dest) {
   INFILE *inpf = hp->inpf;
   STRPTR eval_result = NULL;
   EXPSTR *tmpstr = init_estr(TMP_STEPSIZE);
   int quote;

   /* get quote char */
   quote = infgetc(inpf);
   if (quote != EOF) {
      BOOL end = FALSE;

      while (!end) {
         int ch = infgetc(inpf);
         if (ch == EOF) {
            hsc_msg_eof(hp, "reading string constant");
            eval_result = NULL;
            end = TRUE;
         } else if (ch != quote) {
            /* check for LF inside string */
            if (ch == '\n')
               hsc_message(hp, MSG_STR_LF,
                     "linefeed found inside string");

            /* append next char to string */
            app_estrch(tmpstr, ch);
         } else {
            /* closing quote reached */
            eval_result = estr2str(tmpstr);
            end = TRUE;
         }
      }
   } else
      hsc_msg_eof(hp, "reading string constant");

   /* set new attribute value */
   if (eval_result) {
      /* set new quotes */
      dest->quote = quote;
      /* set new value */
      set_vartext(dest, eval_result);
      eval_result = get_vartext(dest);
   }
   /* remove temp. string */
   del_estr(tmpstr);

   return (eval_result);
}

/*
 * eval_string_expr_noquote
 *
 * evaluate string expression WITHOUT enclosing quotes
 */
static STRPTR eval_string_expr_noquote(HSCPRC * hp, HSCATTR * dest) {
   INFILE *inpf = hp->inpf;
   STRPTR eval_result = NULL;
   EXPSTR *tmpstr = init_estr(TMP_STEPSIZE);
   BOOL end = FALSE;

   /*
    * read next char from input file until a
    * closing quote if found.
    * if the arg had no quote, a white space
    * or a '>' is used to detect end of arg.
    * if a LF is found, view error message
    */
   while (!end) {
      int ch = infgetc(inpf);
      if (ch == EOF) {
         hsc_msg_eof(hp, "reading attribute");

         end = TRUE;
      } else if ((ch == '\n') || (inf_isws((char)ch, inpf) || (ch == '>'))) {
         /* end of arg reached */
         inungetc(ch, inpf);
         eval_result = estr2str(tmpstr);
         end = TRUE;
      } else {
         /* append next char to tmpstr */
         app_estrch(tmpstr, ch);
      }
   }

   /* set new attribute value */
   if (eval_result) {
      set_vartext(dest, eval_result);
      eval_result = get_vartext(dest);
   }
   /* remove temp. string */
   del_estr(tmpstr);

   return (eval_result);
}

/*
 * eval_attrref
 *
 * evaluate reference to attribute
 *
 */
STRPTR eval_attrref(HSCPRC * hp, HSCATTR * destattr) {
   STRPTR eval_result = NULL;
   HSCATTR *eadest = new_hscattr(PREFIX_TMPATTR "eval_attrname");
   STRPTR nw = eval_attrname(hp,eadest);

   if (nw) {
      HSCATTR *refvar = find_varname(hp->defattr, nw);

      if (refvar) {
         destattr->quote = refvar->quote;
         destattr->vartype = refvar->vartype;

         eval_result = refvar->text;

         /* check empty/circular reference */
         if (!eval_result)
            hsc_message(hp, MSG_EMPTY_SYMB_REF,
                  "empty reference to %A", destattr);

         /* debugging message */
         DDA(fprintf(stderr, DHL "   %s refers to (%s)\n",
                  destattr->name, refvar->name));
      } else {
         /* reference to unknown destattr */
         hsc_msg_unkn_attr_ref(hp, nw);
      }

      /* set empty value for reference to NULL */
      if ((!refvar) || (!eval_result)) {
         /* return empty destattr */
         destattr->quote = '"';
         eval_result = "";
      }
   }

   /* set value of destination attribute */
   if (eval_result)
      set_vartext(destattr, eval_result);

   del_hscattr(eadest);
   return (eval_result);
}

/*
 * check_color - check if a color constant is legal
 */
static VOID check_color(HSCPRC * hp, HSCATTR * dest, STRPTR value) {
   BOOL ok = FALSE;
   size_t color_len = strlen("#rrggbb");

   if (value[0] == '#') {
      /* check RGB-value */
      if (strlen(value) == color_len) {
         size_t i = 1;

         ok = TRUE;
         for (; i < color_len; i++) {
            if (!isxdigit(value[i]))
               ok = FALSE;
         }
      }
   } else {
      /* check color name */
      if (hp->color_names) {
         if (strenum(value, hp->color_names, '|', STEN_NOCASE))
            ok = TRUE;
      } else
         ok = TRUE;
   }

   if (!ok) {
      /* illegal color value */
      hsc_message(hp, MSG_ILLG_COLOR,
            "illegal color value %q for %A",
            value, dest);
   }
}

/*
 * check_integer - check if a integer constant is legal
 */
static VOID check_integer(HSCPRC * hp, HSCATTR * dest, STRPTR value) {
   BOOL ok = FALSE;
   int i = 0;

   if ((value[0] == '+') || (value[0] == '-'))
      i = 1;

   if (strlen(value) - i) {
      ok = TRUE;
      while (value[i] && ok) {
         if (!isdigit(value[i]))
            ok = FALSE;
         else
            i++;
      }
   }

   if (!ok) {
      /* illegal integer value */
      hsc_message(hp, MSG_ILLG_NUM,
            "illegal numeric value %q for %A",
            value, dest);
   }
}

/*
 * new_cloned_attr
 *
 * create a new attribute and clone the type and flags
 * of another attribute.
 *
 * Normally the cloned attribute has the same name as the
 * initial target attribute, but in debug mode a more
 * informative name is used
 */
static HSCATTR *new_cloned_attr(STRPTR debug_name, HSCATTR * attr)
{
#if DEBUG
   STRPTR cloned_name = debug_name;
#else
   STRPTR cloned_name = attr->name;
#endif
   HSCATTR *cloned_attr = new_hscattr(cloned_name);

   /* init cloned attribute */
   cloned_attr->vartype = attr->vartype;
   cloned_attr->varflag = attr->varflag;
   cloned_attr->quote = attr->quote;

   return cloned_attr;
}

void do_tag_checks(HSCPRC *hp, HSCATTR *dest, STRPTR str)  {
   /*
    * checks performed only for tags,
    * but are skipped for macros
    */
   if (!(dest->varflag & VF_MACRO)) {
      /*
       * parse uri (convert abs.uris, check existence)
       */
      if (dest->vartype == VT_URI) {
         EXPSTR *dest_uri = init_estr(32);

         parse_uri(hp, dest_uri, str);
         set_vartext(dest, estr2str(dest_uri));

         del_estr(dest_uri);
      }
   }
}

/*
 * eval_expression
 *
 * params: dest....attribute where to store result in
 *         inpf....input file
 *         err.....flag that is set to TRUE if an error occured
 *         endstr..word that is expected at end of expression;
 *                 NULL for no special ending word
 * result: result of evaluation (IF_TRUE or FALSE)
 *
 * NOTE: if endstr==NULL, that means that eval_expression() is called
 *   immediatly after the "=" of an attribute. In this case, if no
 *   quotes are found as next char, all chars are read until the next
 *   white-space or LF occures.
 *
 */
STRPTR eval_expression(HSCPRC * hp, HSCATTR * dest, STRPTR endstr) {
   INFILE *inpf = hp->inpf;

   /* used as destination by eval_string_exprXX() */
   EXPSTR *vararg = init_estr(TMP_STEPSIZE);

   /* create cloned attribute to hold result */
   HSCATTR *dest1 = new_cloned_attr(PREFIX_TMPATTR "1st.operand", dest);

   STRPTR exprstr = NULL;       /* return value */
   int ch;                      /* char read from input */

   /* skip white spaces */
   infskip_ws(inpf);

   /* read dest->quote char */
   ch = infgetc(inpf);
   if (!strchr(VQ_STR_QUOTE, ch)) {
      if (ch != EOF) {
         dest1->quote = VQ_NO_QUOTE;
      } else {
         hsc_msg_eof(hp, "reading attribute");
      }
   } else {
      dest1->quote = ch;
   }

   if (ch == '(') {
      /* process bracket */
      exprstr = eval_expression(hp, dest1, ")");

      /* set generic double quote */
      if (!endstr) {
         dest1->quote = '\"';
      }
   } else if (ch == '{') {
      DDA(prt_varlist(hp->defattr, "attributes before symref"));
      /* process brace */
      exprstr = eval_expression(hp, dest1, "}");
      inungets(exprstr,inpf);
      exprstr = eval_attrref(hp,dest1);
      DDA(prt_varlist(hp->defattr, "attributes after symref"));
   } else if (ch != EOF) {
      /* write current char read back to input buffer */
      inungetc(ch, inpf);

      if (dest1->quote != VQ_NO_QUOTE) {
         /* process string expression with quotes */
         exprstr = eval_string_expr(hp, dest1);
      } else if (endstr) {
         BOOL err = FALSE;

         /* try to process unary operator */
         exprstr = try_eval_unary_op(hp, dest1, &err);

         /* process attribute reference */
         if (!exprstr && !err)
            exprstr = eval_attrref(hp, dest1);
      } else {
         /* process string expression without quotes */
         exprstr = eval_string_expr_noquote(hp, dest1);
      }
   }

   if (exprstr && endstr) {
      BYTE op;

      /* evaluate operator */
      op = eval_op(hp);

      switch(op) {
         case OP_CL_BRACKET :
         case OP_CL_BRACE :
            DMSG("  END mark operator reached");
            break;
         case OP_NONE :
            DMSG("  NO operator");
            break;
         default :
            /* read second operator */
            if (op != OP_NONE) {
               HSCATTR *dest2 = new_cloned_attr(PREFIX_TMPATTR "2nd.operand", dest1);
               STRPTR str1 = get_vartext(dest1);
               STRPTR str2 = NULL;

               if(NULL != (str2 = eval_expression(hp, dest2, endstr)))
                  process_op(hp, dest1, op, str1, str2);
               else
                  exprstr = NULL;

               /* remove temporary resources */
               del_hscattr((APTR) dest2);
            } else
               exprstr = NULL;

            if (exprstr) {
               /* store result */
               exprstr = get_vartext(dest1);
            }
      }
   }

   if (!endstr) {
      /* if (exprstr && !endstr) */
      if (exprstr) {
         /* choose quote (only for tag attributes) */
         if ((dest1->vartype != VT_BOOL) && !(dest1->varflag & (VF_MACRO | VF_KEEP_QUOTES)))
            choose_quote(hp, dest1);

         /* check enum type */
         if (dest1->vartype == VT_ENUM) {
            DDA(fprintf(stderr,DHL "Checking value '%s' against enum '%s'\n",
                     exprstr, dest->enumstr);)
               if (!strenum(exprstr, dest->enumstr, '|', STEN_NOCASE)) {
                  /* unknown enum value */
                  hsc_message(hp, MSG_ENUM_UNKN,
                        "unknown value %q for enumerator %A",
                        exprstr, dest);
               }
         } else if (dest1->vartype == VT_COLOR) {
            /* check color value */
            check_color(hp, dest1, exprstr);
         } else if (dest1->vartype == VT_NUM) {
            /* check numeric value */
            check_integer(hp, dest1, exprstr);
         } else if (dest1->vartype == VT_BOOL) {
            /*
             * for boolean attributes, set the name
             * of the attribute if TRUE, or set an
             * empty string, if FALSE
             */
            if (eval_boolstr(exprstr))
               set_vartext(dest1, dest1->name);
            else
               set_vartext(dest1, "");
         }
         do_tag_checks(hp,dest1,exprstr);
         exprstr = get_vartext(dest1);
      } else {
         /* if error occured,
          * skip until ">", unread ">"
          */
         skip_until_eot(hp, NULL);
         if (!hp->fatal)
            inungetcw(inpf);
      }
   }

   /* assign result to destination attribute */
   if (exprstr) {
      set_vartext(dest, exprstr);
      dest->quote = dest1->quote;
      exprstr = get_vartext(dest);
   }

   /* remove temporary resources */
   del_hscattr((APTR) dest1);
   del_estr(vararg);

   return (exprstr);
}

/*
 * assign_conditional_attr
 *
 * validate and find name of source attrib, if set, copy value
 * to destination attribute
 *
 * params: hp...........hsc-process
 *         dest.........detination attribute where to store value
 *         source_attr..name of source attribute
 * result: value of attribute, if it has been set, or NULL
 *         if attribute is empty or unknown or other error
 *         has occured.
 */
static STRPTR assign_conditional_attr(HSCPRC * hp, HSCATTR * dest, STRPTR source_name) {
   STRPTR attrval = NULL;

   if (source_name) {
      HSCATTR *tmpdest = new_hscattr(PREFIX_TMPATTR "check.attrname");

      if (NULL != (source_name = check_attrname(hp,tmpdest,source_name,TRUE))) {
         HSCATTR *attr = find_varname(hp->defattr, source_name);

         if (attr) {
            attrval = get_vartext(attr);
            dest->quote = attr->quote;
         } else {
            hsc_msg_unkn_attr_ref(hp, source_name);
         }
      }
      del_hscattr(tmpdest);
   } else {
      panic("no source attribute");
   }

   /* update attribute value and quotes */
   if (attrval) {
      set_vartext(dest, attrval);
      attrval = get_vartext(dest);
      do_tag_checks(hp,dest,attrval);
      if(!(dest->varflag & VF_MACRO)) choose_quote(hp, dest);
   }

   return (attrval);
}

/*
 * eval_conditional_assignment
 *
 * evaluate a conditional expression like
 *   SEPP?=HUGO or SEPP?=("hu"+"go")
 * and modify destination attribute only if the source
 * attribute really exists
 *
 * params: hp...hsc-process
 *         dest..target attribute to update
 * result: new value or NULL in case of no update or error
 */
STRPTR eval_conditional_assignment(HSCPRC * hp, HSCATTR * dest) {
   STRPTR nw = infgetw(hp->inpf);
   STRPTR attr_val = NULL;

   D(fprintf(stderr, DHL "  conditional assignment\n"));

   if (nw) {
      /* temp. attribute to store name of source attribute if it
       * is specified with an expression */
      HSCATTR *tmp_attr = NULL;
      STRPTR source_name = NULL;    /* name of source attribute */

      if (!strcmp(nw, "(")) {
         /* get attribute name from expression */
         tmp_attr = new_hscattr(PREFIX_TMPATTR "conditional.assignment");
         source_name = eval_expression(hp, tmp_attr, ")");
      } else {
         /* attribute name was simply specified */
         source_name = nw;
      }

      if (source_name) {
         D(fprintf(stderr, DHL "    assign from %s\n", source_name));
         attr_val = assign_conditional_attr(hp, dest, source_name);
      }

      /* free resources */
      if (tmp_attr) {
         del_hscattr(tmp_attr);
      }

   } else {
      hsc_msg_eof(hp, "conditional attribute identifier expected");
   }

   return (attr_val);
}

/* $Id: eval.c,v 1.9 2004/02/05 13:45:40 mb Exp mb $ */
/* vi: set ts=4: */
�������������������������������������������������������������hsc-0.934.orig/hsclib/eval.h������������������������������������������������������������������������0100600�0001750�0000144�00000003034�07732056103�014511� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/eval.h
 *
 * attribute value evaluation functions
 */

#ifndef HSCLIB_EVAL_H
#define HSCLIB_EVAL_H

#define DOUBLE_QUOTE '\"'
#define SINGLE_QUOTE '\''
#define BACK_QUOTE   '`'

/*
 *
 * extern references
 *
 */
#ifndef NOEXTERN_HSCLIB_EVAL_H

extern STRPTR check_attrname(HSCPRC* hp, HSCATTR *dest, STRPTR name, BOOL allow_expr);
extern VOID choose_quote(HSCPRC * hp, HSCATTR * attr);

extern STRPTR eval_expression(HSCPRC * hp, HSCATTR * dest, STRPTR endstr);
extern STRPTR eval_conditional_assignment(HSCPRC *hp, HSCATTR *dest);
extern STRPTR eval_attrref(HSCPRC * hp, HSCATTR * destattr);

#endif /*  NOEXTERN_HSCLIB_EVAL_H */

#endif /* HSCLIB_EVAL_H */

/* $Id: eval.h,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/msgid.h�����������������������������������������������������������������������0100600�0001750�0000144�00000023231�10010443654�014660� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001-2003  Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/msgid.h
 *
 * defines for message-ids (warnings, errors,..)
 *
 */

#ifndef HSC_MSGID_H
#define HSC_MSGID_H

#include "ugly/utypes.h"

/* masks for message classes */
#define MASK_MESSAGE   0x0fff
#define MASK_MSG_CLASS 0xf000

/* message  classes */
#define MSG_NOTE  0x00000       /* message */
#define MSG_STYLE 0x01000       /* bad style */
#define MSG_PORT  0x02000       /* portability prolem */
#define MSG_WARN  0x03000       /* warning */
#define MSG_ERROR 0x04000       /* error */
#define MSG_FATAL 0x0f000       /* fatal error */
#define MSG_NONE  0xff000       /* out of msg-array */

/*
 *=========================
 * next message number
 *=========================
 */
#define MAX_MSGID (96-1)

/*
 * obsolete numbers:
 * - see below
 * CURRENTLY NONE
 */

/*
 * fatal errors
 */
#define MSG_NEW_PRJFILE        (MSG_WARN +  1)  /* creating new project file */
#define MSG_CORRUPT_PRJFILE    (MSG_FATAL+  2)  /* corrupt project file */
#define MSG_UNEX_EOF           (MSG_FATAL+  3)  /* unexpected eof */
#define MSG_READ_ERROR         (MSG_FATAL+  4)  /* read error */
#define MSG_TOO_MANY           (MSG_FATAL+  5)  /* too many messages/errors */
#define MSG_NO_INPUT           (MSG_FATAL+  6)  /* can't open input file */
#define MSG_ARITHMETIC_ERROR   (MSG_FATAL+  8)  /* arithmetic error */

/*
 * information messages
 */
#define MSG_TAG_STRIPPED       (MSG_NOTE +  7)  /* stripped tag with ext. href */
#define MSG_TAG_CANT_STRIP     (MSG_WARN + 70)  /* can't strp special tag */

/*
 * bad style messages
 */
#define MSG_WRONG_HEADING      (MSG_STYLE+  9)  /* wrong heading */
#define MSG_CLICK_HERE         (MSG_STYLE+ 10)  /* click-here-syndrome */

/*
 * messages within tags
 */
#define MSG_UNKN_TAG           (MSG_WARN + 11)  /* unknown tag */
#define MSG_TAG_TOO_OFTEN      (MSG_ERROR+ 12)  /* tag occured too often */
#define MSG_UNMA_CTAG          (MSG_ERROR+ 13)  /* unmatched end-tag */
#define MSG_CTAG_NESTING       (MSG_WARN + 14)  /* illegal end-tag nesting */
#define MSG_MISS_REQTAG        (MSG_ERROR+ 15)  /* required tag missing */
#define MSG_MISS_RCMDTAG       (MSG_STYLE+ 67)  /* recommended tag missing */
#define MSG_MISS_CTAG          (MSG_WARN + 16)  /* end-tag missing */
#define MSG_UNKN_TAG_OPTION    (MSG_ERROR+ 17)  /* unknown tag option */
#define MSG_TAG_OBSOLETE       (MSG_WARN + 37)  /* obsolete tag */
#define MSG_TAG_JERK           (MSG_WARN + 38)  /* jerk tag */
#define MSG_ILLG_WHTSPC        (MSG_ERROR+ 47)  /* illegal whitespace */
#define MSG_MBI                (MSG_ERROR+ 60)  /* must be inside */
#define MSG_NAW                (MSG_ERROR+ 61)  /* not allowed with */
#define MSG_ILLG_CTAG          (MSG_ERROR+ 66)  /* illegal end-tag */
#define MSG_SUCC_WHTSPC        (MSG_PORT + 78)  /* succeeding white-space */
#define MSG_PREC_WHTSPC        (MSG_PORT + 79)  /* preceeding white-space */
#define MSG_XHTML_NOTCLOSED    (MSG_WARN + 88)  /* EMPTY tag not closed in
                                                   XHTML mode */

/*
 * messages within entities
 */
#define MSG_UNKN_ENTITY        (MSG_WARN + 18)  /* unknown entity */
#define MSG_EXPT_SEMIC         (MSG_WARN + 19)  /* ";" expected */
#define MSG_RPLC_ENT           (MSG_NOTE + 46)  /* replaced entity */
#define MSG_ILLG_DEFENT        (MSG_ERROR+ 69)  /* illegal entity definition */
#define MSG_ICON_ENTITY        (MSG_PORT + 58)  /* icon-entity found */
#define MSG_RPLC_ICON          (MSG_NOTE + 77)  /* icon-entity found */
#define MSG_DEFENT_WARN        (MSG_WARN + 92)  /* suspicious entity definition */

/* 
 * messages pertaining to Cascading Style Sheets
 */
#define MSG_INVALID_STYLE      (MSG_WARN + 90)  /* sytax error in CSS definition */
#define MSG_STYLE_REDEFINED    (MSG_WARN + 91)  /* CSS property redefined */

/*
 * messages within attributes
 */
#define MSG_UNKN_ATTR_REF      (MSG_ERROR+ 20)  /* unknown attribute reference */
#define MSG_UNKN_ATTR_TAG      (MSG_WARN + 84)  /* unknown tag attribute */
#define MSG_UNKN_ATTR_MACRO    (MSG_ERROR+ 85)  /* unknown macro attribute */
#define MSG_NO_URIPATH         (MSG_WARN + 21)  /* path to URI not found */
#define MSG_SERVER_URI         (MSG_WARN + 36)  /* suspicios enum value */
#define MSG_ARG_NO_QUOTE       (MSG_PORT + 22)  /* argument without quote */
#define MSG_EMPTY_SYMB_REF     (MSG_ERROR+ 23)  /* empty symbol reference */
#define MSG_ILLG_ATTR_FLAG     (MSG_WARN + 24)  /* attribute flag not allowed
                                                   here */
#define MSG_UNEX_ATTR_TYPE     (MSG_ERROR+ 25)  /* illegal symbol type */
#define MSG_UNEX_ATTR_VALUE    (MSG_WARN + 45)  /* unexpected attribute value */
#define MSG_SYMB_2ND_DEFAULT   (MSG_ERROR+ 26)  /* default value already set */
#define MSG_ENUM_UNKN          (MSG_WARN + 35)  /* unknown enum value */
#define MSG_NOARG_ATTR         (MSG_ERROR+ 42)  /* attr requires arg */
#define MSG_UNKN_ATTR_OPTION   (MSG_ERROR+ 43)  /* unknown attr option */
#define MSG_MISS_REQ_ATTR      (MSG_ERROR+ 44)  /* required attr missing */
#define MSG_MISS_RCMD_ATTR     (MSG_STYLE+ 90)  /* recommended attr missing */
#define MSG_ATTR_REDEFINED     (MSG_WARN + 63)  /* attr already defined */
#define MSG_ILLG_ATTRNAME      (MSG_ERROR+ 64)  /* illegal attribute
                                                   identifier */
#define MSG_UNKN_BINOP         (MSG_ERROR+ 65)  /* unknown binary operator */
#define MSG_ATTR_CONST         (MSG_ERROR+ 27)  /* can't change constant attr */
#define MSG_IMG_CORRUPT        (MSG_ERROR+  8)  /* image corrupt */
#define MSG_ATTR_OBSOLETE      (MSG_WARN + 87)  /* attribute is obsolete */
#define MSG_ATTR_AFTER_SLASH   (MSG_ERROR+ 89)  /* attribute after closing slash
                                                   in XHTML mode */
#define MSG_NO_EXTURI          (MSG_WARN + 93)  /* external URI does not exist (server returned 4xx/5xx) */
#define MSG_DUBIOUS_EXTURI     (MSG_WARN + 94)  /* external URI may not exist (server returned something
                                                   other than [245]xx */
#define MSG_NO_EXTCHECK        (MSG_ERROR+ 95)  /* cannot check external URI due to network problems */

/*
 * messages from tag handles
 */
#define MSG_ANCHOR_HEADING     (MSG_STYLE+ 28)  /* heading inside anchor */
#define MSG_ANCH_NO_NMHR       (MSG_ERROR+ 29)  /* A : no NAME or HREF */
#define MSG_CL_TAG_ARG         (MSG_ERROR+ 62)  /* args for end-tag */
#define MSG_LF_IN_COMMENT      (MSG_PORT + 48)  /* LF within comment */
#define MSG_GT_IN_COMMENT      (MSG_PORT + 49)  /* GT within comment */
#define MSG_ZERO_COMMENT       (MSG_PORT + 50)  /* SGML zero comment */
#define MSG_TEXT_IN_COMMENT    (MSG_WARN + 55)  /* text outside comment context */

/*
 * messages from hsc-tag handles
 */
#define MSG_SYSTEM_RETURN      (MSG_WARN + 54)  /* external process result <> 0 */
#define MSG_UNMA_ELSE          (MSG_ERROR+ 53)  /* unmatched $ELSE */
#define MSG_DEFTAG_NO_OPEN     (MSG_FATAL+ 57)  /* no opening tag for deftag cl. */
#define MSG_REDEFINE_ENDTAG    (MSG_ERROR+ 52)  /* redefined end tag */
#define MSG_REDEFINE_TAG       (MSG_WARN + 59)  /* redefined & replaced tag */
#define MSG_USER_MESSAGE       (           39)  /* user message */
#define MSG_BLINK_SUX          (MSG_STYLE+ 25)  /* blink sucks  */
#define MSG_FRAME_SUX          (MSG_STYLE+ 76)  /* frames are disgusting */
#define MSG_NO_CONTENT         (MSG_FATAL+ 28)  /* no content */
#define MSG_REDEFINE_LAZY      (MSG_ERROR+ 56)  /* redefined lazy */
#define MSG_UNKN_LAZY          (MSG_ERROR+ 32)  /* unknown lazy */

/*
 * messages within expressions
 */
#define MSG_UNKN_ENVVAR        (MSG_WARN + 41)  /* unknown environ. var */
#define MSG_ILLG_NUM           (MSG_WARN + 71)  /* illegal numeric value */
#define MSG_ILLG_COLOR         (MSG_WARN + 72)  /* illegal color value */
#define MSG_REQU_QUOTE         (MSG_WARN + 81)  /* value required quotes */
#define MSG_CHANGED_QUOTE      (MSG_NOTE + 82)  /* not assign quote requested */

/*
 * misc. messages
 */
#define MSG_UNMA_GT            (MSG_ERROR+ 30)  /* unmatched ">" */
#define MSG_UNEXPT_CH          (MSG_ERROR+ 31)  /* unexpected char */
#define MSG_STR_LF             (MSG_WARN + 33)  /* linefeed in string */
#define MSG_UNEX_EOL           (MSG_ERROR+ 34)  /* unexpected eol */
#define MSG_NO_CONFIG          (MSG_FATAL+ 40)  /* can't open config */
#define MSG_NO_DOCENTRY        (MSG_WARN + 51)  /* no document-entry for id */
#define MSG_UNKN_FILETYPE      (MSG_WARN + 68)  /* unknown file type (for size) */
#define MSG_UNKN_LOCAL_ID      (MSG_WARN + 73)  /* unknown local ID */
#define MSG_UNKN_ID            (MSG_WARN + 74)  /* unknown ID */
#define MSG_REDEFINE_ID        (MSG_WARN + 75)  /* duplicate ID */
#define MSG_NOEXEC_OUTPUT      (MSG_WARN + 80)  /* no output-file for <$exec>*/
#define MSG_IOERROR            (MSG_ERROR+ 83)  /* i/o-error */
#define MSG_REMOVE_FAILED      (MSG_WARN + 86)  /* remove file failed */


#endif

/* $Id: msgid.h,v 1.7 2004/02/05 13:39:46 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/hsclib.h����������������������������������������������������������������������0100600�0001750�0000144�00000002322�07732056103�015025� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/hsclib.h
 *
 * this file should be included by every program that uses
 * functions of hsclib
 *
 */

#ifndef HSCLIB_HSCLIB_H         /* avoid include twice */
#define HSCLIB_HSCLIB_H

#include "hsclib/inc_base.h"

#include "hsclib/include.h"
#include "hsclib/linit.h"
#include "hscprj/project.h"

#endif /* HSCLIB_HSCLIB_H */

/* $Id: hsclib.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/idref.c�����������������������������������������������������������������������0100600�0001750�0000144�00000012501�07732056103�014645� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/idref.c
 *
 * functions for id-references
 *
 */

#include "hsclib/inc_base.h"

#include <stdarg.h>
#include "ugly/ustrlist.h"

#include "hscprj/document.h"
#define NOEXTERN_HSCLIB_ID_H
#include "hsclib/idref.h"

#if DEBUG_ID
#define DIHP(x) if ( hp->debug ) x
#define DI(x)   x
#else
#define DIHP(x)                 /* nufin */
#define DI(x)                   /* nufin */
#endif

/* hsc_msg_unknown_id: warning about unknown id-refrence */
VOID hsc_msg_unknown_id(HSCPRC * hp, STRPTR filename, STRPTR id)
{
    if (filename)
        hsc_message(hp, MSG_UNKN_ID, "unknown id `%s#%s'",
                    filename, id);
    else
        hsc_message(hp, MSG_UNKN_ID, "unknown id %q", id);
}

/* macros for local compare-callbacks */
#define cmp_idname cmp_string_node
#define cmp_idref cmp_string_node
#define cmp_id_local cmp_string_node

/*
 *
 * new- and del-methodes
 *
 */

/*
 * del/new_idref
 */

/* del_idref: remove referenced id */
VOID del_idref(APTR data)
{
    IDREF *idref = (IDREF *) data;

    ufreestr(idref->name);
    del_infilepos(idref->fpos);
    ufree(idref);
}

/* new_id_local: create new reference to local id  */
static IDREF *new_idref(STRPTR id, INFILEPOS * fpos)
{
    IDREF *newid = (IDREF *) umalloc(sizeof(IDREF));

    newid->name = strclone(id);
    newid->fpos = fpos;

    return (newid);
}

VOID prt_idref(FILE * stream, APTR data)
{
    IDREF *idref = (IDREF *) data;
    INFILEPOS *fpos = idref->fpos;

    fprintf(stream, "`%s' at (%lu,%lu)\n",
            idref->name, ifp_get_y(fpos), ifp_get_x(fpos));
}

/*
 * add_local_iddef
 *
 * define a new local ID that can be refered to
 */
BOOL add_local_iddef(HSCPRC * hp, STRPTR id)
{
    INFILEPOS *fpos = new_infilepos(hp->inpf);
    HSCIDD *iddef = find_iddef(hp->project->document, id);

    DIHP(fprintf(stderr, DHL "add ref to id `%s' at `%s' (%lu,%lu)\n",
                 id, ifp_get_fname(fpos),
                 ifp_get_y(fpos), ifp_get_x(fpos)));

    /* check for duplicate definition */

    if (iddef)
    {
        /* duplicate definition */
        DIHP(fprintf(stderr, DHL "    duplicate definition\n"));

        hsc_message(hp, MSG_REDEFINE_ID,
                    "local id %q already declared", id);

        set_infilepos(hp->inpf, iddef->fpos);
        hsc_message(hp, MSG_REDEFINE_ID,
                    "(location of previous declaration)");

        set_infilepos(hp->inpf, fpos);
        del_infilepos(fpos);
    }
    else
    {
        /* remember new local id */
        iddef = app_iddef(hp->project->document, id);
        iddef->caller = fpos2caller(fpos);
        iddef->fpos = fpos;

        DIHP(fprintf(stderr, DHL "    append to local iddefs\n"));
    }

    return (TRUE);
}

/*
 * check_id_local
 *
 * append id to idref-list so it as checked when
 * check_all_local_idref() is called
 */
VOID add_local_idref(HSCPRC * hp, STRPTR id)
{
    INFILEPOS *fpos = new_infilepos(hp->inpf);

    DIHP(fprintf(stderr, DHL "  check id: `#%s' (local)\n", id));
    DIHP(fprintf(stderr, DHL "    append to idref\n"));
    app_dlnode(hp->idrefs, new_idref(id, fpos));
}

/*
 * check_local_idref
 */
static BOOL check_local_idref(HSCPRC * hp, IDREF * idref)
{
    HSCIDD *iddef = find_iddef(hp->project->document, idref->name);
    BOOL found = FALSE;

    if (iddef)
    {
        found = TRUE;
        DIHP(fprintf(stderr, DHL " local id ok: `%s'\n", idref->name));
    }
    else
    {
        DIHP(
                {
                INFILEPOS * fpos = idref->fpos;
                fprintf(stderr, DHL " local id unknown: `%s' (%lu,%lu)\n",
                        idref->name, ifp_get_y(fpos), ifp_get_x(fpos));
                }
        );

        set_infilepos(hp->inpf, idref->fpos);
        hsc_msg_unknown_id(hp, NULL, idref->name);
    }

    return (found);
}

/*
 * check_all_local_idref
 */
BOOL check_all_local_idref(HSCPRC * hp)
{
    BOOL ok = TRUE;
    DLNODE *nd = NULL;
    INFILEPOS *infpos = new_infilepos(hp->inpf);

    DIHP(fprintf(stderr, DHL "check local IDs\n"));

    DIHP(
            {

            fprintf(stderr, DHL " local IDs defined:\n");
            fprintf_dllist(stderr, hp->project->document->iddefs, prt_iddef);
            fprintf(stderr, DHL " local IDs referenced:\n");
            fprintf_dllist(stderr, hp->idrefs, prt_idref);

            }
    );

    nd = dll_first(hp->idrefs);
    while (nd)
    {
        check_local_idref(hp, ((IDREF *) nd->data));
        nd = dln_next(nd);
    }

    set_infilepos(hp->inpf, infpos);
    del_infilepos(infpos);

    return (ok);
}

/* $Id: idref.c,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/idref.h�����������������������������������������������������������������������0100600�0001750�0000144�00000003214�07732056103�014653� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/idref.h
 *
 * functions for id-references
 *
 */

#ifndef HSCLIB_IDREF_H
#define HSCLIB_IDREF_H

typedef struct idref_node {
    STRPTR name;                /* name of id */
    INFILEPOS *fpos;            /* position where ID has been called from */
} IDREF;

#ifndef NOEXTERN_HSCLIB_IDREF_H

extern VOID del_string_entry(APTR data);
extern STRPTR new_string_entry(STRPTR data);
extern int cmp_string_entry(APTR cmp_data, APTR list_data);


extern VOID hsc_msg_unknown_id(HSCPRC * hp, STRPTR filename, STRPTR id);

extern BOOL add_local_iddef(HSCPRC * hp, STRPTR id);

extern VOID del_idref(APTR data);
extern VOID add_local_idref(HSCPRC * hp, STRPTR id);

extern BOOL check_all_local_idref(HSCPRC * hp);

#endif /* NOEXTERN_HSCLIB_IDREF_H */

#endif /* HSC_IDREF_H */

/* $Id: idref.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/inc_base.h��������������������������������������������������������������������0100600�0001750�0000144�00000003206�07732056103�015326� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/inc_base.h
 *
 * include basic structures and prototypes that are
 * required by most other modules
 *
 */

#ifndef HSCLIB_INC_BASE_H
#define HSCLIB_INC_BASE_H

#define NMEMBERS(s) (sizeof(s)/sizeof(s[0]))

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>

#include "hsclib/ldebug.h"

#include "ugly/utypes.h"
#include "ugly/dllist.h"
#include "ugly/expstr.h"
#include "ugly/umemory.h"
#include "ugly/infile.h"
#include "ugly/ustring.h"
#include "ugly/ufile.h"

#include "hsclib/msgid.h"

#include "hscprj/document.h"

#include "hsclib/attrib.h"
#include "hsclib/entity.h"
#include "hsclib/tag.h"
#include "hsclib/hscprc.h"
#include "hsclib/lmessage.h"
#include "hsclib/lstatus.h"

#endif /* HSCLIB_INC_BASE_H */

/* $Id: inc_base.h,v 1.4 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/inc_tagcb.h�������������������������������������������������������������������0100600�0001750�0000144�00000002153�07732056103�015474� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/inc_tagcb.h
 *
 * include callbacks for tags
 *
 */

#ifndef HSCLIB_INC_TAGCB_H
#define HSCLIB_INC_TAGCB_H

#include "hsclib/inc_base.h"
#include "hsclib/input.h"
#include "hsclib/skip.h"

#endif /* HSCLIB_INC_TAGCB_H */

/* $Id: inc_tagcb.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/include.c���������������������������������������������������������������������0100600�0001750�0000144�00000021731�07732056103�015204� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/include.c
 *
 * hsc include functions
 */

#include <time.h>

#include "hsclib/inc_base.h"

#include "ugly/ufile.h"
#include "ugly/fname.h"

#include "hsclib/input.h"
#include "hsclib/parse.h"

#define NOEXTERN_HSCLIB_INCLUDE_H
#include "hsclib/include.h"

/*
 * 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? */
    {
        /* push current input file on input-file-stack */
        if (hp->inpf)
            add_dlnode(hp->inpf_stack, (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_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 */
            ok = (optn & IH_PARSE_SOURCE) ? hsc_parse_source(hp) : 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);
}

/*
 * hsc_include_file
 *
 * open input file and include it
 */
BOOL hsc_base_include_file(HSCPRC * hp, STRPTR filename, ULONG optn, INFILEPOS * base_pos)
{
    BOOL ok = FALSE;
    INFILE *inpf = NULL;
    EXPSTR *fpath = init_estr(32);

    /* status message: reading input */
    if (!(optn & (IH_PARSE_MACRO | IH_PARSE_HSC)))
        hsc_status_file_begin(hp, filename);

    /* check for stdin to use as input-file */
    if (!(strcmp(filename, FILENAME_STDIN1) &&
          strcmp(filename, FILENAME_STDIN2))) {
        filename = NULL;
    } else {
       /* this is a real file -- try to get path */
       
       get_fpath(fpath,filename);
       /* if there is a path, add it to the list of include directories */
       if(0 != estrlen(fpath)) {
          STRPTR newpath = umalloc(estrlen(fpath) + 1);
          strcpy(newpath,estr2str(fpath));
          add_dlnode(hp->include_dirs,newpath);
       }
    }

    /* open & read input file */
    errno = 0;
    inpf = infopen(filename, ES_STEP_INFILE);

    if (inpf) {
        /* include opened file */
        ok = hsc_include(hp, inpf, optn, base_pos);

        /* check if this file is the main-source-file
         * or an include-file and update project-data
         * if neccessary
         */
        if (ok && hp->project) {
            if (optn & IH_IS_SOURCE) {
                if (!filename)
                    filename = FILENAME_STDIN1;
                D(fprintf(stderr, DHL "INCLUDE source: `%s'\n", filename));
                hsc_project_set_source(hp->project, filename);
                /*reallocstr(&(hp->document->sourcename), filename); */
            }

            /* check if this file is an include-file
             * and update project-data if neccessary */
            if (filename && (optn & IH_IS_INCLUDE)) {
                D(fprintf(stderr, DHL "INCLUDE subfile: `%s'\n", filename));
                hsc_project_add_include(hp->project, filename);
            }
        }
    } else
        hsc_msg_noinput(hp, filename);  /* couldn't open file */

    /* if we got a path part earlier, remove the corresponding incdir node */
    if(0 != estrlen(fpath)) {
       del_dlnode(hp->include_dirs,dll_first(hp->include_dirs));
    }
    del_estr(fpath);
    return (ok);
}

/*
 * hsc_include_string
 *
 * open string as input file and include it
 */
BOOL hsc_base_include_string(HSCPRC * hp, STRPTR filename, STRPTR s, ULONG optn, INFILEPOS * base_pos)
{
    BOOL ok;
    INFILE *inpf = NULL;

    if (optn & IH_POS_PARENT) {
        filename = PARENT_FILE_ID;
        optn &= ~IH_POS_PARENT;
    }
    inpf = infopen_str(filename, s, 0);         /* try to open input file */

    ok = hsc_include(hp, inpf, optn, base_pos);

    return (ok);
}

/*
 * find_includefile
 *
 * scan all include-directories for file to be opened;
 * if the file can't be found, the filename in the current
 * directory will be returned (which should therefor result
 * in an error while processing hsc_include())
 *
 * NOTE: this function considers the file to be found if it could have
 *       been opened for input. afterwards, the file is immediatly
 *       closed. This isn't really a multitasking-conform behavior
 *       because the file will have to be reopend again by the
 *       hsc_include() function later and meanwhile could have been
 *       removed by another task.
 */
static BOOL find_includefile(HSCPRC *hp, EXPSTR * dest, STRPTR filename)
{
    BOOL found = FALSE;

    /* reset filename */
    set_estr(dest, filename);

    if (!fexists(filename)) {
        DLNODE *nd = dll_first(hp->include_dirs);

        /* process all include-directories.. */
        while (nd && !found) {
            /* concat incdir+filename, check if it exists,
             * process next or abort loop */
            link_fname(dest, (STRPTR) dln_data(nd), filename);
            D(fprintf(stderr, DHL "  try `%s'\n", estr2str(dest)));
            if (fexists(estr2str(dest)))
                found = TRUE;
            else
                nd = dln_next(nd);
        }
    } else {
        /* found in current directory */
        found = TRUE;
    }

    if (found)
    {
        D(fprintf(stderr, DHL "  found at `%s'\n", estr2str(dest)));
    }

    return (found);
}

/* hsc_include_file: include file without base-position */
BOOL hsc_include_file(HSCPRC * hp, STRPTR filename, ULONG optn)
{
    BOOL ok = FALSE;
    EXPSTR *real_filename = init_estr(64);

    if(NULL == filename) {
       fprintf(stderr,"hsc_include_file(): NULL/empty filename!\n");
       return ok;
    }
    
    /* scan include directories */
    find_includefile(hp, real_filename, filename);

    /* now include file */
    ok = hsc_base_include_file(hp, estr2str(real_filename), optn, NULL);

    /* cleanup */
    del_estr(real_filename);

    return ok;
}

/* hsc_include_string: include string without base-position */
BOOL hsc_include_string(HSCPRC * hp, STRPTR filename, STRPTR s, ULONG optn)
{
    return (hsc_base_include_string(hp, filename, s, optn, NULL));
}

/* $Id: include.c,v 1.5 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */
���������������������������������������hsc-0.934.orig/hsclib/include.h���������������������������������������������������������������������0100600�0001750�0000144�00000004535�07732056103�015214� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/include.h
 */

#ifndef HSCLIB_INCLUDE_H
#define HSCLIB_INCLUDE_H

/*
 * flags for include_hsc_xxx()
 */
#define IH_PARSE_END    (1<<0)  /* check for unclosed tags & co at end */
#define IH_PARSE_PRE    (1<<1)  /* parse with replacing "><&" */
#define IH_PARSE_MACRO  (1<<2)  /* include macro */
#define IH_PARSE_HSC    (1<<3)  /* include text of a special
                                 *   hsc-command (eg $insert time) */
#define IH_PARSE_SOURCE (1<<4)  /* include source (replace special chars) */
#define IH_NO_STATUS    (1<<5)  /* oppress status message */
#define IH_UPDATE_PRJ   (1<<6)  /* update project file */
#define IH_POS_PARENT   (1<<7)  /* use position of next file on stack
                                 *   for messages */
#define IH_IS_INCLUDE   (1<<8)  /* included via <$include>
                                 *   (should be stored in project-file */
#define IH_IS_SOURCE    (1<<9)  /* this is the main source-file
                                 *   (should be stored in project-file */

#ifndef NOEXTERN_HSCLIB_INCLUDE_H

extern BOOL hsc_include_file(HSCPRC * hp, STRPTR filename, ULONG optn);
extern BOOL hsc_include_string(HSCPRC * hp, STRPTR filename, STRPTR s, ULONG optn);
extern BOOL hsc_base_include_file(HSCPRC * hp, STRPTR filename, ULONG optn, INFILEPOS * base_pos);
extern BOOL hsc_base_include_string(HSCPRC * hp, STRPTR filename, STRPTR s, ULONG optn, INFILEPOS * base_pos);

#endif /* NOEXTERN_HSCLIB_INCLUDE_H */

#endif /* HSCLIB_INCLUDE_H */

/* $Id: include.h,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/input.c�����������������������������������������������������������������������0100600�0001750�0000144�00000012025�07732056103�014714� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/input.c
 *
 * basic functions for parsing input
 */

#include <ctype.h>

#include "hsclib/inc_base.h"

/*
 *---------------------------
 * overloaded methods for
 * INFILE class
 *---------------------------
 */

/*
 * hsc_whtspc
 *
 * decides if an char is a white-space
 *
 * params: ch...char to test
 * result: TRUE, if ch is a 'normal' ch
 *
 * NOTE: this function is used as is_ws-methode
 *       for the INFILE class
 */
BOOL hsc_whtspc(int ch)
{
    if ((ch == ' ')
        || (ch == '\n')
        || (ch == '\r')
        || (ch == '\t')
        )
    {
        return TRUE;
    }
    else
        return FALSE;
}

/*
 * hsc_normch
 *
 * decides if an char is an 'normal' char
 *
 * params: ch...char to test
 * result: TRUE, if ch is a 'normal' ch
 *
 * NOTE: this function is used as is_nc-method
 *       for the INFILE class
 */
BOOL hsc_normch(int ch)
{
    if (((ch >= '0') && (ch <= '9'))
        || ((ch >= 'a') && (ch <= 'z'))
        || ((ch >= 'A') && (ch <= 'Z'))
        || (ch == '_') || (ch == '-') || (ch == '.')
        )
    {
        return TRUE;
    }
    else
        return FALSE;
}

/*
 * hsc_normch_tagid
 *
 * decides if an char is an 'normal' char for tagnames
 *
 * params: ch...char to test
 * result: TRUE, if ch is a 'normal' ch
 *
 * NOTE: this function is used as is_nc-methode
 *       for the infile class
 */
BOOL hsc_normch_tagid(int ch)
{
    BOOL found = hsc_normch(ch);

    if (!found)
        if (strchr(HSC_TAGID, ch))
            found = TRUE;

    return (found);
}

/*
 *-------------------------------------
 * read a tag/attribute name from input file
 *-------------------------------------
 */

/*
 * infget_tagid
 *
 * read next word from input, but with a
 * different is_nc-method that also handles
 * the id for hsc-tags (usually "$")
 */
STRPTR infget_tagid(HSCPRC * hp)
{
    INFILE *inpf = hp->inpf;
    STRPTR tagid = NULL;

    BOOL(*old_is_nc) (int ch);

    old_is_nc = inpf->is_nc;    /* remember old is_nc-method */
    inpf->is_nc = hsc_normch_tagid;
    tagid = infgetw(inpf);      /* read tagid */
    if (!tagid)
        hsc_msg_eof(hp, "reading tag name");
    inpf->is_nc = old_is_nc;    /* remember old is_nc-method */

    /* if LOWERCASETAGS option is set, force tag to lowercase */
    if(hp->lctags && (NULL != tagid)) {
       lowstr(tagid);
    }
    return (tagid);
}

/*
 * infget_attrid
 *
 * read next word from input, but with a
 * different is_nc-methode that also handles
 * the id for hsc-attribs (usually "$")
 */
STRPTR infget_attrid(HSCPRC * hp)
{
    INFILE *inpf = hp->inpf;
    STRPTR attrid = NULL;

    BOOL(*old_is_nc) (int ch);

    old_is_nc = inpf->is_nc;    /* remember old is_nc-method */
    inpf->is_nc = hsc_normch_tagid;
    attrid = infgetw(inpf);     /* read attrid */
    if (!attrid)
        hsc_msg_eof(hp, "reading attribute name");
    inpf->is_nc = old_is_nc;    /* restore old is_nc-method */

    return (attrid);
}

/*
 *-------------------------------------
 * parse simple chars/words
 *-------------------------------------
 */

/*
 * parse_wd
 *
 * check if a expected word really occured and
 * display error message if neccessary
 *
 * params: inpf.....input file to read char from
 *         expstr...expected word
 * result: TRUE if successful, FALSE if wrong char found
 */
BOOL parse_wd(HSCPRC * hp, STRPTR expstr)
{
    INFILE *inpf = hp->inpf;
    BOOL value = TRUE;

    if (expstr)
    {
        STRPTR nw = infgetw(inpf);

        /* check for expeted word */
        if (!nw || upstrcmp(nw, expstr))
        {
            if (!nw)
                nw = "<EOF>";

            hsc_message(hp, MSG_UNEXPT_CH,
                        "expected %q, found %q", expstr, nw);
            value = FALSE;
        }
    }
    else
    {
        panic("no data to expect");
    }

    return (value);
}

/*
 * parse_eq
 *
 * check for '='
 *
 * params: inpf...input file to read char from
 * result: -1 if successful, 0 if wrong char found
 */
BOOL parse_eq(HSCPRC * hp)
{
    return (parse_wd(hp, "="));
}

/*
 * parse_gt
 *
 * check for '>'
 *
 * params: inpf...input file to read char from
 * result: -1 if successful, 0 if wrong char found
 */
BOOL parse_gt(HSCPRC * hp)
{
    return (parse_wd(hp, ">"));
}

/* $Id: input.c,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/input.h�����������������������������������������������������������������������0100600�0001750�0000144�00000002611�07732056103�014721� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/input.h
 *
 * basic functions for parsing input
 */

#ifndef HSCLIB_INPUT_H
#define HSCLIB_INPUT_H

#include "ugly/utypes.h"
#include "ugly/infile.h"

/*
 * global funcs
 */

extern BOOL hsc_whtspc(int ch);
extern BOOL hsc_normch(int ch);
extern BOOL hsc_normch_tagid(int ch);

extern STRPTR infget_tagid(HSCPRC * hp);
extern STRPTR infget_attrid(HSCPRC * hp);

extern BOOL parse_wd(HSCPRC * hp, STRPTR expstr);
extern BOOL parse_eq(HSCPRC * hp);
extern BOOL parse_gt(HSCPRC * hp);

#endif /* HSCLIB_INPUT_H */

/* $Id: input.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/ldebug.h����������������������������������������������������������������������0100600�0001750�0000144�00000010513�10006441536�015020� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/ldebug.h
 *
 * debugging defines for hsc
 */

#ifndef HSCLIB_LDEBUG_H
#define HSCLIB_LDEBUG_H

/*
 * debugging switches
 *
 * if switch is set to "1", requested debugging information is
 * displayed if also the "-debug" switch is enabled when
 * starting hsc
 */
#ifdef DEBUG

/* this debugging info is displayed only
 * if the  switch "-debug" has been enabled
 */
#undef  DEBUG
#define DEBUG         1         /* misc. debugging */
#define DEBUG_ATTRVAL 1         /* display attribute values */
#define DEBUG_CONFIG  1         /* display config messages */
#define DEBUG_DEFATTR 1         /* display defined attributes */
#define DEBUG_DEFENT  1         /* display defined entities */
#define DEBUG_DEFTAG  1         /* display defined tags */
#define DEBUG_IF      1         /* display if/else */
#define DEBUG_MACRO   1         /* display macro */
#define DEBUG_SIZE    1         /* display getsize-info */
#define DEBUG_URI     1         /* display uri conversion */
#define DEBUG_ID      1         /* display IDs added/checked/.. */
#define DEBUG_HSCLIB_OUTPUT 0

/* this debugging info is displayed always,
 * independant of the hscprc's debug-flag */
#define DEBUG_ATTR    0         /* display new/del attribute */
#define DEBUG_ENTITY  0         /* display new/del entity */

/* ugly debugging info */
#ifndef DEBUG_UGLY
#define DEBUG_UGLY
#endif

#else

#define DEBUG         0         /* misc. debugging */
#define DEBUG_ATTRVAL 0         /* display attribute values */
#define DEBUG_CONFIG  0         /* display config messages */
#define DEBUG_DEFATTR 0         /* display defined attributes */
#define DEBUG_DEFENT  0         /* display defined entities */
#define DEBUG_DEFTAG  0         /* display defined tags */
#define DEBUG_IF      0         /* display if/else */
#define DEBUG_MACRO   0         /* display macro */
#define DEBUG_SIZE    0         /* display getsize-info */
#define DEBUG_URI     0         /* display uri conversion */
#define DEBUG_ID      0         /* display uri conversion */
#define DEBUG_HSCLIB_OUTPUT 0

#define DEBUG_ATTR    0         /* display new/del attribute */
#define DEBUG_ENTITY  0         /* display new/del entity */

#endif

/* debug message prefix for hsclib-modules */
#define DHL "*hsclib* "

/*
 * debugging defines
 */
#if DEBUG
#define D(x) if (hp->debug) x
#else
#define D(x)                    /* nufin */
#endif

#if DEBUG
#define DMSG(msg) ((hp->debug) ? (fprintf( stderr, DHL msg "\n" )) : 0 )
#else
#define DMSG(msg)               /* nufin */
#endif

#if DEBUG_ATTRVAL
#define DAV(x) if ( hp->debug ) x
#else
#define DAV(x)                  /* nufin */
#endif

#if DEBUG_CONFIG
#define DC(x) if ( hp->debug ) x
#else
#define DC(x)                   /* nufin */
#endif

#if DEBUG_DEFATTR
#define DDA(x) if ( hp->debug ) x
#else
#define DDA(x)                  /* nufin */
#endif

#if DEBUG_DEFENT
#define DDE(x) if ( hp->debug ) x
#else
#define DDE(x)                  /* nufin */
#endif

#if DEBUG_DEFTAG
#define DDT(x) if ( hp->debug ) x
#else
#define DDT(x)                  /* nufin */
#endif

#if DEBUG_IF
#define DIF(x) if ( hp->debug ) x
#else
#define DIF(x)                  /* nufin */
#endif

#if DEBUG_MACRO
#define DMC(x) if ( hp->debug ) x
#else
#define DMC(x)                  /* nufin */
#endif

#if DEBUG_SIZE
#define DSZ(x) if ( hp->debug ) x
#else
#define DSZ(x)                  /* nufin */
#endif

#if DEBUG_URI
#define DU(x) if ( hp->debug ) x
#else
#define DU(x)                   /* nufin */
#endif

#endif /* HSCLIB_LDEBUG_H */

/* $Id: ldebug.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/linit.c�����������������������������������������������������������������������0100600�0001750�0000144�00000034264�07732056103�014705� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001  Matthias Bethke 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/linit.c
 *
 * functions to init & read preferences for a hsc-process
 *
 */

#include "hsclib/inc_base.h"

#include "hsclib/defattr.h"
#include "hsclib/deftag.h"
#include "hsclib/include.h"
#include "hsclib/parse.h"

#include "hsclib/tag_a.h"
#include "hsclib/tag_hsc.h"
#include "hsclib/tag_if.h"
#include "hsclib/tag_macro.h"
#include "hsclib/tag_misc.h"

#include "hsc/hsc_rev.h"

#include "ugly/fname.h"

#include "hsclib/entities.c"

#if DEBUG
/*
 * debugging print functions
 */
#if 0
static VOID prt_ent(FILE * stream, APTR data)
{
    HSCENT *ent = (HSCENT *) data;

    if (ent)
    {
        fprintf(stream, " %s", ent->name);
        if (ent->replace)
            fprintf(stream, "=%s", ent->replace);
        if (ent->numeric)
            fprintf(stream, "=%ld", ent->numeric);
    }
    else
        fprintf(stream, " <NULL>");
}
#endif

static VOID prt_tag(FILE * stream, APTR data)
{
    if (data)
    {
        HSCTAG *tag = (HSCTAG *) data;
        fprintf(stream, " <");
        if (tag->option & HT_CLOSE)
            fprintf(stream, "/");
        if (tag->o_handle)
            fprintf(stderr, "*");
        fprintf(stream, "%s", tag->name);
        if (tag->c_handle)
            fprintf(stderr, "*");
        if (tag->option & HT_REQUIRED)
            fprintf(stream, "/r");
        if (tag->option & HT_RECOMMENDED)
            fprintf(stream, "/rcmd");
        if (tag->option & HT_ONLYONCE)
            fprintf(stream, "/1");
        if (tag->option & HT_AUTOCLOSE)
            fprintf(stream, "/ac");
        if (tag->option & HT_EMPTY)
            fprintf(stream, "/e");
        if (tag->option & HT_SPECIAL)
            fprintf(stream, "/a");
        fprintf(stream, ">");
    }
    else
        fprintf(stream, " <NULL>");
}

/* function to temporarily disable debuggin output */
static BOOL dbg_old = FALSE;

#define dbg_disable(hp) {dbg_old = hp->debug; hp->debug=FALSE;}
#define dbg_restore(hp) {hp->debug=dbg_old;}

#else
#define dbg_disable(hp)
#define dbg_restore(hp)
#endif

/*
 * 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);
}

/*
 * hsc_read_prefs
 *
 * try to open (any) config file and read preferences
 * from it
 */
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);
}


/*
 * hsc_set_tagCB
 */
VOID hsc_set_tagCB(HSCPRC * hp, STRPTR name,
                   BOOL(*op_hnd) (HSCPRC * inpf, HSCTAG * tag),
                   BOOL(*cl_hnd) (HSCPRC * inpf, HSCTAG * tag))
{
    HSCTAG *tag = find_strtag(hp->deftag, name);

    if (tag && !(tag->option & HT_NOHANDLE)) {
        /* set handles */
        DC(fprintf(stderr, DHL "add handles for <%s> (%p,%p)\n",
                   name, (void*)op_hnd, (void*)cl_hnd));
        tag->o_handle = op_hnd;
        tag->c_handle = cl_hnd;
    }
}

/*
 * 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_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_STRIPWS_STR, handle_hsc_stripws, NULL);
    }

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

    return (ok);
}

/*
 * hsc_init_basicEntities
 *
 * create internal entities
 * (should be called BEFORE hsc_read_prefs())
 */
BOOL hsc_init_basicEntities(HSCPRC * hp) {
   unsigned i;
   
   for(i=0; i < NMEMBERS(HSCInternalEntities); ++i) {
      add_ent(hp->defent,
            HSCInternalEntities[i].name,
            '\0',
            HSCInternalEntities[i].numeric,
            HSCInternalEntities[i].prefnum);
   }
   return (TRUE);
}

/*
 * hsc_assign_tagCBs
 *
 * assign tag-callbacks to standard html-tags
 * (MUST ONLY be called AFTER hsc_read_prefs())
 */
BOOL hsc_assign_tagCBs(HSCPRC * hp)
{
    hsc_set_tagCB(hp, "!", handle_sgml_comment, NULL);
    hsc_set_tagCB(hp, "A", handle_anchor, handle_canchor);
    hsc_set_tagCB(hp, "BASE", handle_base, NULL);
    hsc_set_tagCB(hp, "BLINK", handle_blink, NULL);
    hsc_set_tagCB(hp, "H1", handle_heading, NULL);
    hsc_set_tagCB(hp, "H2", handle_heading, NULL);
    hsc_set_tagCB(hp, "H3", handle_heading, NULL);
    hsc_set_tagCB(hp, "H4", handle_heading, NULL);
    hsc_set_tagCB(hp, "H5", handle_heading, NULL);
    hsc_set_tagCB(hp, "H6", handle_heading, NULL);
    hsc_set_tagCB(hp, "IMG", handle_img, NULL);
    hsc_set_tagCB(hp, "PRE", handle_pre, handle_end_pre);

    return (TRUE);
}

/*
 * hsc_init_hscprc
 *
 * - init all items of hsc-process
 * - create hsc-tags & special atttributes
 * - read preferences file
 * - assign tag-callbacks
 */
BOOL hsc_init_hscprc(HSCPRC * hp, STRPTR prefs_fname)
{
    BOOL ok = FALSE;            /* return value */

    if ( hsc_init_basicEntities(hp)
        && hsc_read_prefs(hp, prefs_fname)
        && hsc_assign_tagCBs(hp)
        )
    {
        /* return sucess */
        ok = TRUE;

        /* printf list of defined tags & entities */
        DC(
              {
              DLNODE * nd;
              HSCENT * ent;

              nd = hp->defent->first;
              if (nd)
              {
              fprintf(stderr, DHL "Known entities:");

              while (nd)
              {
              ent = (HSCENT *) nd->data;
              fprintf(stderr, " &%s;", ent->name);
              nd = nd->next;
              }
              fprintf(stderr, "\n");
              }

              nd = hp->deftag->first;
              if (nd)
              {
              fprintf(stderr, DHL "Known tags:");
              while (nd)
              {
              prt_tag(stderr, nd->data);
              nd = nd->next;
              }
              fprintf(stderr, "\n");
              }

              }
        );                      /* DC */
    }

    hp->click_here_str =
        get_vartext_byname(hp->defattr, CLICK_HERE_ATTR);
    hp->color_names =
        get_vartext_byname(hp->defattr, COLOR_NAMES_ATTR);

    return (ok);
}

/* $Id: linit.c,v 1.7 2003/09/17 13:04:41 mb Exp mb $ */
/* vi: set ts=4: */
��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/linit.h�����������������������������������������������������������������������0100600�0001750�0000144�00000002662�07732056103�014707� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/linit.h
 *
 * configuration & initialisation functions
 */
#ifndef HSCLIB_LINIT_H          /* avoid include twice */
#define HSCLIB_LINIT_H

#ifndef NOEXTERN_HSCLIB_LINIT_H

extern HSCPRC *hsc_read_base_info(VOID);
extern BOOL hsc_copy_base_info(HSCPRC * dest_hp, HSCPRC * dummy_hp);

extern BOOL hsc_init_hscprc(HSCPRC * hp, STRPTR prefs_fname);

extern BOOL hsc_init_tagsNattr(HSCPRC * hp);
extern BOOL hsc_init_basicEntities(HSCPRC * hp);
extern BOOL hsc_assign_tagCBs(HSCPRC * hp);

#endif /* NOEXTERN_HSCLIB_LINIT_H */
#endif /* HSCLIB_LINIT_H */

/* $Id: linit.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

������������������������������������������������������������������������������hsc-0.934.orig/hsclib/lmessage.c��������������������������������������������������������������������0100600�0001750�0000144�00000035011�10010444321�015337� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001-2003  Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/message.c
 *
 * message functions for hsc
 *
 */

#define NOEXTERN_HSCLIB_MESSAGE_H

#include "hsclib/inc_base.h"

#include "ugly/returncd.h"

/* forward reference */
static VOID handle_too_many_messages(HSCPRC * hp);

/*
 * NOTE: see "hsclib/msgid.h" for message-ids and
 *       how a message-id is build.
 */

static VOID msg_tag(EXPSTR * msgstr, CONSTRPTR tagname)
{
    app_estr(msgstr, "tag <");
    app_estr(msgstr, tagname);
    app_estr(msgstr, ">");
}

static VOID msg_endtag(EXPSTR * msgstr, CONSTRPTR tagname)
{
    app_estr(msgstr, "end tag </");
    app_estr(msgstr, tagname);
    app_estr(msgstr, ">");
}

static VOID msg_attr(EXPSTR * msgstr, CONSTRPTR attrname)
{
    app_estr(msgstr, "attribute ");
    app_estr(msgstr, attrname);
}

static VOID msg_lazy(EXPSTR * msgstr, CONSTRPTR lazy_name)
{
    app_estr(msgstr, "var-list ");
    app_estr(msgstr, lazy_name);
}

static VOID msg_entity(EXPSTR * msgstr, CONSTRPTR entname)
{
    app_estr(msgstr, "entity `");
    app_estr(msgstr, entname);
    app_estr(msgstr, "'");
}

static VOID msg_idname(EXPSTR * msgstr, CONSTRPTR idname)
{
    app_estr(msgstr, "id ");
    app_estr(msgstr, "\"#");
    app_estr(msgstr, idname);
    app_estrch(msgstr, '"');
}

/*
 * hsc_message
 *
 * create message string and send it to call-back
 *
 * legal placeholders inside format:
 *  %A ptr to HSCATTR
 *  %a string for attribute-name
 *  %C ptr to HSCTAG, displayed as end-tag
 *  %c string to end-tag
 *  %d dezimal number (LONG)
 *  %E ptr to HSCENT
 *  %e string to entity-name
 *  %i string to id-name
 *  %j string to jerk/prostitute
 *  %L ptr to var-list
 *  %l string to var-list
 *  %q quoted string
 *  %s string
 *  %T ptr to HSCTAG
 *  %t string for tag-name
 *
 * example:
 * ---
 *  HSCTAG *mytag;
 *  STRPTR expected_tag = "dummy";
 *
 *  hsc_message( hp, MSG_my_tag_expected,
 *               "Expected tag %T insted of %t",
 *               mytag, expected_tag );
 * ---
 */

/* checks if filename starts with PARENT_FILE_ID */
static BOOL is_child_file(STRPTR filename)
{
    return ((BOOL) ! strncmp(filename, PARENT_FILE_ID,
                             strlen(PARENT_FILE_ID)));
}

/* decides if a message should be ignored or display */
static BOOL really_display_message(HSCPRC * hp, HSCMSG_ID msg_id)
{
    HSCMSG_CLASS msg_class = hsc_get_msg_class(hp, msg_id);
    BOOL disp_msg = TRUE;       /* function result */
#if DEBUG
    HSCMSG_ID msg_id_unmasked = msg_id & MASK_MESSAGE;
#endif

    if (hp->fatal) {

        /* suppress all messages after fatal errors */
        disp_msg = FALSE;
    } else if ((hsc_get_msg_ignore(hp, msg_id) == ignore) && (msg_class <= MSG_WARN)) {
        /* suppress message if it is marked as ignored
         * and it is no ERROR/FATAL message */
        D(fprintf(stderr, DHL "ignore msg#%ld: ignore enabled\n",
                  msg_id_unmasked));
        disp_msg = FALSE;
    } else if (((msg_class == MSG_NOTE) && (hp->msg_ignore_notes))
             || ((msg_class == MSG_STYLE) && (hp->msg_ignore_style))
             || ((msg_class == MSG_PORT) && (hp->msg_ignore_port))) {
        /* class should be ignored; however, if this message is set
         * to enable, still display it */
        if (hsc_get_msg_ignore(hp, msg_id) != enable) {
            /* suppress message if its class is
             * marked as to be ignored */
            D(fprintf(stderr, DHL "ignore msg#%ld: ignore whole class (%06lx)\n",
                      msg_id_unmasked, msg_class));
            disp_msg = FALSE;
        } else {
            D(fprintf(stderr, DHL "enable msg#%ld: only ignore whole class (%06lx)\n",
                      msg_id_unmasked, msg_class));
        }
    }

    return disp_msg;
}

VOID hsc_message(HSCPRC * hp, HSCMSG_ID msg_id, const char *format,...) {
    HSCMSG_CLASS msg_class = hsc_get_msg_class(hp, msg_id);
    HSCMSG_ID msg_id_unmasked = msg_id & MASK_MESSAGE;
    INFILE *msg_inpf = NULL;
    STRPTR msg_fname = "unknown";
    ULONG msg_x = 0;
    ULONG msg_y = 0;
    BOOL disp_msg = really_display_message(hp, msg_id);     /* display message? */

    if (disp_msg) {
        va_list ap;

        /* increase message-counter */
        hp->msg_count++;

        /* set fatal-flag, if this is a fatal message */
        if (msg_id > MSG_FATAL)
            hp->fatal = TRUE;

        /* clear message buffer */
        clr_estr(hp->curr_msg);

        /* create message string */
        va_start(ap, format);
        while (format[0]) {
            if (format[0] == '%') {
                STRPTR s = NULL;
                HSCTAG *tag = NULL;
                HSCTAG *lazy = NULL;
                HSCATTR *attr = NULL;
                HSCENT *ent = NULL;

                format++;
                switch (format[0]) {

                case 'd':
                    /*
                     * append decimal number
                     */
                    app_estr(hp->curr_msg,
                             long2str(va_arg(ap, LONG)));
                    break;

                case 'q':
                    /*
                     * append quoted string
                     */
                    s = va_arg(ap, STRPTR);

                    app_estrch(hp->curr_msg, '`');
                    while (s[0]) {
                        switch (s[0]) {

                        case '\n':
                            app_estr(hp->curr_msg, "\\n");
                            break;
                        case '\"':
                            app_estr(hp->curr_msg, "\\\"");
                            break;
                        default:
                            if (((unsigned char) s[0]) < ' ') {
                                app_estrch(hp->curr_msg, '\\');
                                app_estr(hp->curr_msg,
                                         long2str((LONG) s[0]));
                                app_estrch(hp->curr_msg, ';');
                            } else
                                app_estrch(hp->curr_msg, s[0]);
                        }
                        s++;    /* process next char */
                    }
                    app_estrch(hp->curr_msg, '\'');

                    break;

                case 's':
                    /*
                     * append simple string
                     */
                    app_estr(hp->curr_msg, va_arg(ap, STRPTR));
                    break;

                case 'T':
                    /* append tag-pointer */
                    tag = va_arg(ap, HSCTAG *);
                    msg_tag(hp->curr_msg, tag->name);
                    break;

                case 't':
                    /* append tag */
                    msg_tag(hp->curr_msg, va_arg(ap, STRPTR));
                    break;

                case 'C':
                    /* append end tag-pointer */
                    tag = va_arg(ap, HSCTAG *);
                    msg_endtag(hp->curr_msg, tag->name);
                    break;

                case 'c':
                    /* append end tag */
                    msg_endtag(hp->curr_msg, va_arg(ap, STRPTR));
                    break;

                case 'A':
                    /* append attribute-pointer */
                    attr = va_arg(ap, HSCATTR *);
                    msg_attr(hp->curr_msg, attr->name);
                    break;

                case 'a':
                    /* append attribute */
                    msg_attr(hp->curr_msg, va_arg(ap, STRPTR));
                    break;

                case 'E':
                    /* append entity-pointer */
                    ent = va_arg(ap, HSCENT *);
                    msg_entity(hp->curr_msg, ent->name);
                    break;

                case 'e':
                    /* append entity */
                    msg_entity(hp->curr_msg, va_arg(ap, STRPTR));
                    break;

                case 'i':
                    /* append ID */
                    msg_idname(hp->curr_msg, va_arg(ap, STRPTR));
                    break;

                case 'j':
                    /* append jerk/prostitute */
                    if (hp->prostitute)
                        app_estr(hp->curr_msg, "prostitutes");
                    else
                        app_estr(hp->curr_msg, "jerks");
                    break;

                case 'L':
                    /* append var-list-pointer */
                    lazy = va_arg(ap, HSCTAG *);
                    msg_lazy(hp->curr_msg, lazy->name);
                    break;

                case 'l':
                    /* append var-list */
                    msg_lazy(hp->curr_msg, va_arg(ap, STRPTR));
                    break;

                default:
                    /*
                     * append unknown
                     */
                    app_estrch(hp->curr_msg, '%');
                    if (format[0] && (format[0] != '%')) {
                        app_estrch(hp->curr_msg, '%');
                        format--;
                    }
                    break;
                }
            }
            else
                app_estrch(hp->curr_msg, format[0]);

            if (format[0])
                format++;
        }
        va_end(ap);

        /* evaluate message position */
        if (hp->inpf) {
            msg_inpf = hp->inpf;

            msg_fname = infget_fname(msg_inpf);

            /* use parent file for position? */
            if (is_child_file(msg_fname)) {
                DLNODE *nd = dll_first(hp->inpf_stack);

                msg_inpf = NULL;
                msg_fname = NULL;

                if (nd)
                    do {
                        D(fprintf(stderr, DHL "skip parent file `%s'\n", msg_fname));

                        /* use position of file on stack */
                        msg_inpf = (INFILE *) dln_data(nd);
                        msg_fname = infget_fname(msg_inpf);
                        nd = dln_next(nd);
                    } while (nd && is_child_file(msg_fname));
            }

            if (msg_inpf) {
                msg_x = infget_wx(msg_inpf) + 1;
                msg_y = infget_wy(msg_inpf) + 1;
            } else {
                msg_fname = "hsc-internal.hsc";
                msg_x = 0;
                msg_y = 0;
            }
        } else {
            msg_fname = NULL;
            msg_x = 0;
            msg_y = 0;
        }

        /* send message via callback */
        if (hp->CB_message)
            (*(hp->CB_message))
                (hp,
                 msg_class, msg_id_unmasked,
                 msg_fname, msg_x, msg_y,
                 estr2str(hp->curr_msg)
                );

        /* process nested files */
        if (hp->CB_message_ref && hp->nested_errors) {
            DLNODE *nd = dll_first(hp->inpf_stack);

            while (nd) {
                msg_inpf = dln_data(nd);
                msg_fname = infget_fname(msg_inpf);
                msg_x = infget_wx(msg_inpf) + 1;
                msg_y = infget_wy(msg_inpf) + 1;

                (*(hp->CB_message_ref))
                    (hp,
                     msg_class, msg_id_unmasked,
                     msg_fname, msg_x, msg_y,
                     ""
                    );

                nd = dln_next(nd);
            }
        }

        /* check, if already too many messages or errors have
         * occured and abort process in case */
        handle_too_many_messages(hp);
    } else
        D(fprintf(stderr, DHL "suppressed msg#%ld\n", msg_id_unmasked));
}

/* check if there are already too many errors and view an
 * fatal error "too many messages" */
static VOID handle_too_many_messages(HSCPRC * hp)
{
    if (hp->max_errors != MAXIMUM_MESSAGE_INFINITE)
        hp->max_errors -= 1;
    if (hp->max_messages != MAXIMUM_MESSAGE_INFINITE)
        hp->max_messages -= 1;

    if ((hp->max_messages == 0) || (hp->max_errors == 0))
        hsc_message(hp, MSG_TOO_MANY, "too many errors or messages");
}

/*
 *-------------------------------------
 * often occurable errors & messages
 *-------------------------------------
 */

VOID hsc_msg_eof(HSCPRC * hp, STRPTR descr)
{
    STRPTR eoftxt = "unexpected end of context";

    if (descr)
        hsc_message(hp, MSG_UNEX_EOF, "%s (%s)", eoftxt, descr);
    else
        hsc_message(hp, MSG_UNEX_EOF, "%s", eoftxt);
}

VOID hsc_msg_illg_whtspc(HSCPRC * hp)
{
    hsc_message(hp, MSG_ILLG_WHTSPC, "illegal white space");
}

VOID hsc_msg_stripped_tag(HSCPRC * hp, HSCTAG * tag, STRPTR why)
{
    if (why)
        hsc_message(hp, MSG_TAG_STRIPPED,
                    "stripped %T (%s)", tag, why);
    else
        hsc_message(hp, MSG_TAG_STRIPPED,
                    "stripped %T", tag);
}

VOID hsc_msg_unkn_attr_ref(HSCPRC * hp, STRPTR attr)
{
    hsc_message(hp, MSG_UNKN_ATTR_REF,
                "unknown %a", attr);
}

VOID hsc_msg_unkn_attr_tag(HSCPRC * hp, STRPTR attr, STRPTR tag)
{
    hsc_message(hp, MSG_UNKN_ATTR_TAG,
                "unknown %a for %t", attr, tag);
}

VOID hsc_msg_unkn_attr_macro(HSCPRC * hp, STRPTR attr, STRPTR macro)
{
    hsc_message(hp, MSG_UNKN_ATTR_MACRO,
                "unknown %a for %t", attr, macro);
}

VOID hsc_msg_noinput(HSCPRC * hp, STRPTR filename)
{
    hsc_message(hp, MSG_NO_INPUT,
                "can not open %q for input: %s",
                filename, strerror(errno));
}

VOID hsc_msg_read_error(HSCPRC * hp, STRPTR filename)
{
    hsc_message(hp, MSG_READ_ERROR,
                "error reading %s: %s",
                filename, strerror(errno));
}

VOID hsc_msg_nouri(HSCPRC * hp, STRPTR filename, STRPTR uriname, STRPTR note)
{
    if (note) {
        hsc_message(hp, MSG_NO_URIPATH,
                    "file %q for URI %q not found (%s)",
                    filename, uriname, note);
    } else {
        hsc_message(hp, MSG_NO_URIPATH,
                    "file %q for URI %q not found",
                    filename, uriname);
    }
}

/* $Id: lmessage.c,v 1.6 2004/02/05 13:44:35 mb Exp mb $ */
/* vi: set ts=4: */
�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/lmessage.h��������������������������������������������������������������������0100600�0001750�0000144�00000003567�10010443704�015363� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/message.h
 *
 * message funcs for hsc
 *
 */

#ifndef HSCLIB_MESSAGE_H
#define HSCLIB_MESSAGE_H
#include "hsclib/hscprc.h"

#ifndef NOEXTERN_HSCLIB_MESSAGE_H

extern VOID hsc_message(HSCPRC * hp, HSCMSG_ID msg_id,
                        const char *format,...);

extern VOID hsc_msg_eof(HSCPRC * hp, STRPTR descr);
extern VOID hsc_msg_illg_whtspc(HSCPRC * hp);
extern VOID hsc_msg_stripped_tag(HSCPRC * hp, HSCTAG * tag, STRPTR why);
extern VOID hsc_msg_unkn_attr_ref(HSCPRC * hp, STRPTR attr);
extern VOID hsc_msg_unkn_attr_tag(HSCPRC * hp, STRPTR attr, STRPTR tag);
extern VOID hsc_msg_unkn_attr_macro(HSCPRC * hp, STRPTR attr, STRPTR macro);
extern VOID hsc_msg_read_error(HSCPRC * hp, STRPTR filename);

#if 1 /* TODO: get rid of this */
extern VOID hsc_msg_eol(HSCPRC * hp);
#endif

extern VOID hsc_msg_noinput(HSCPRC * hp, STRPTR filename);
extern VOID hsc_msg_nouri(HSCPRC * hp, STRPTR filename, STRPTR uriname, STRPTR note);

#endif /* NOEXTERN_HSCLIB_MESSAGE */
#endif /* HSCLIB_MESSAGE_H */

/* $Id: lmessage.h,v 1.4 2004/02/05 13:40:07 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/lstatus.c���������������������������������������������������������������������0100600�0001750�0000144�00000002703�07732056103�015256� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/status.c
 *
 * status message functions for hsc
 *
 */

#include "hsclib/inc_base.h"

VOID hsc_status_misc(HSCPRC * hp, STRPTR s)
{
    if (hp->CB_status_misc)
        (*hp->CB_status_misc) (hp, s);
}

VOID hsc_status_file_begin(HSCPRC * hp, STRPTR filename)
{
    if (hp->CB_status_file_begin)
        (*hp->CB_status_file_begin) (hp, filename);
}

VOID hsc_status_file_end(HSCPRC * hp)
{
    if (hp->CB_status_file_end)
        (*hp->CB_status_file_end) (hp);
}

VOID hsc_status_line(HSCPRC * hp)
{
    if (hp->CB_status_line)
        (*hp->CB_status_line) (hp);
}

/* $Id: lstatus.c,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�������������������������������������������������������������hsc-0.934.orig/hsclib/lstatus.h���������������������������������������������������������������������0100600�0001750�0000144�00000002323�07732056103�015261� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/lstatus.h
 *
 * status messages
 *
 */

#ifndef HSCLIB_LSTATUS_H
#define HSCLIB_LSTATUS_H

extern VOID hsc_status_misc(HSCPRC * hp, STRPTR s);
extern VOID hsc_status_file_begin(HSCPRC * hp, STRPTR filename);
extern VOID hsc_status_file_end(HSCPRC * hp);
extern VOID hsc_status_line(HSCPRC * hp);

#endif /* HSCLIB_LSTATUS_H */

/* $Id: lstatus.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/parse.c�����������������������������������������������������������������������0100600�0001750�0000144�00000110037�07732056103�014671� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001 Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/parse.c
 *
 * parse file: handle for entities & tags
 *
 */

#include <ctype.h>

#define NOEXTERN_HSCLIB_PARSE_H

#include "hsclib/inc_base.h"
#include "ugly/unikot.h"

#include "hsclib/defattr.h"
#include "hsclib/deftag.h"
#include "hsclib/idref.h"
#include "hsclib/include.h"
#include "hsclib/input.h"
#include "hsclib/parse.h"
#include "hsclib/posteval.h"
#include "hscprj/project.h"
#include "hsclib/skip.h"
#include "hsclib/size.h"
#include "hsclib/uri.h"

/*
 *---------------------------
 * misc. functions
 *---------------------------
 */

/*
 * message_rplc
 *
 * message that tells user that a special char
 * was replaced by its entity
 */
static VOID message_rplc(HSCPRC * hp, STRPTR what, STRPTR by) {
   hsc_message(hp, MSG_RPLC_ENT,
         "replaced %q by %q", what, by);
}

/*
 * check_mbinaw
 *
 * check if tag occurs in allowed context with other tags
 */
static BOOL check_mbinaw(HSCPRC * hp, HSCTAG * tag) {
   BOOL ok = TRUE;
   const BOOL xhtml_strictmbi = (hp->xhtml && (!((tag->option & HT_MACRO) || is_hsc_tag(tag))));

   /* check for tags that must be called before */
   if (tag->mbi) {
      DLNODE *nd = hp->container_stack->last;
      LONG found = 0;

      D(fprintf(stderr,DHL "Checking /MBI for %s (%s): ", tag->name, tag->mbi);)
      while (nd && !found) {
         HSCTAG *ctag = (HSCTAG *) nd->data;

         nd = nd->prev;
         found = strenum(ctag->name, tag->mbi, '|', STEN_NOCASE);
         /* skip enclosing macros in XHTML mode to avoid false errors below */
         if(xhtml_strictmbi && (ctag->option & (HT_SPECIAL | HT_MACRO))) {
            D(fprintf(stderr,"[%s] ",ctag->name);)
            continue;
         }
         D(fprintf(stderr, "%s ",ctag->name);)
         if(xhtml_strictmbi && !is_hsc_tag(ctag)) break;
      }
      D(fprintf(stderr,"\n");)

      if (!found) {
         hsc_message(hp, MSG_MBI,
               "%T must be inside %t", tag, tag->mbi);
         ok = FALSE;
      }
   }

   /* check for tags that are not to be called before */
   if (tag->naw) {
      DLNODE *nd = hp->container_stack->last;
      LONG found = 0;

      while (nd) {
         HSCTAG *ctag = (HSCTAG *) nd->data;

         found = strenum(ctag->name, tag->naw, '|', STEN_NOCASE);
         if (found) {
            hsc_message(hp, MSG_NAW,
                  "%T not allowed within %T", tag, ctag);

            ok = FALSE;
         }
         nd = dln_prev(nd);
      }
   }
   return ok;
}

/* check if an AUTOCLOSE should be done despite the current opening tag not
 * being the same as the last on the container stack. If so, remove all
 * intervening tags and return TRUE.
 */
static BOOL check_autoclose_anyway(HSCPRC *hp, DLNODE *nd) {
   DLNODE *cnd; /* current node */
   DLNODE *tnd; /* temp node */
   BOOL anyway = TRUE;

   for(cnd = dll_last(hp->container_stack);
         (cnd != nd) && anyway;
         cnd = dln_prev(cnd)) {
      anyway = (BOOL)(((HSCTAG*)dln_data(cnd))->option & HT_AUTOCLOSE);
      D(fprintf(stderr, DHL "  /AC-stackcheck: <%s> [%s]\n",
               ((HSCTAG*)dln_data(cnd))->name, anyway ? "YES" : "NO"));
   }

   if(anyway) {
      /* there are only /AUTOCLOSE tags between the end of stack
       * and the current tag, so remove all of them.
       * Example: <dl><dt>foo<dd>bar</dl>
       * -> <dd> autocloses <dt> (which is /AC) but not <dl>
       */
      for(cnd = dll_last(hp->container_stack);
            cnd != nd;
            cnd = tnd) {
         D(fprintf(stderr,
                  DHL "  autoclosing extra <%s> \n",
                  ((HSCTAG*)dln_data(cnd))->name));
         tnd = cnd->prev;
         del_dlnode(hp->container_stack,cnd);
      }
      return TRUE;
   }
   return FALSE;
} 

/* enable output for a process */
void hp_enable_output(HSCPRC * hp, STRPTR cause)
{
   if (hp->suppress_output)
   {
      clr_estr(hp->whtspc);
      D(fprintf(stderr, DHL "output enabled (%s)\n", cause));
   }
   hp->suppress_output = FALSE;
}

/*
 *---------------------------
 * remove/append end tag
 * from/to container_stack
 *---------------------------
 */

/*
 * find_end_tag_node
 *
 * return first node of an end tag on the container stack;
 * if not found, return NULL
 */
DLNODE *find_end_tag_node(HSCPRC * hp, STRPTR tagname) {
   return find_dlnode_bw(dll_last(hp->container_stack),
         (APTR) tagname, cmp_strtag);
}

/*
 * find_end_tag
 *
 * return first end tag on the container stack;
 * if not found, return NULL
 */
HSCTAG *find_end_tag(HSCPRC * hp, STRPTR tagname) {
   DLNODE *nd = find_dlnode_bw(dll_last(hp->container_stack),
         (APTR) tagname, cmp_strtag);

   return (HSCTAG*) ((NULL != nd) ? dln_data(nd) : NULL);
}

/*
 * find_end_container
 *
 * search container stack for the first macro which is a
 * container macro and return the cerresponding tag structure
 */
HSCTAG *find_end_container_macro(HSCPRC * hp) {
   HSCTAG *tag = NULL;
   DLNODE *nd = dll_last(hp->container_stack);

   while (nd) {
      HSCTAG *nd_tag = (HSCTAG *) dln_data(nd);

      if (nd_tag->option & HT_CONTENT) {
         tag = nd_tag;
         nd = NULL;
      } else {
         nd = dln_prev(nd);
      }
   }
   return tag;
}

/*
 * append_end_tag
 *
 * create end tag and append it to tag-list;
 * also clone options & attribute list of parent
 * tag, if tag is a macro and has a closing tag.
 *
 * params: hp.....hscprc with container_stack to be modified
 *         tagid..name of the new tag (eg "IMG")
 * result: ptr to the new tag or NULL if no mem
 */
HSCTAG *append_end_tag(HSCPRC * hp, HSCTAG * tag) {
   HSCTAG *end_tag;
   DLLIST *taglist = hp->container_stack;

   end_tag = new_hsctag(tag->name);
   if (end_tag) {
      BOOL ok = TRUE;
      DLNODE *nd = NULL;

      /* copy important data of tag */
      end_tag->option = tag->option;

      /* clone attributes, if tag is a
       * macro tag and has a closing tag
       */
      if ((tag->option & HT_MACRO) && (tag->option & HT_CLOSE))
         ok = copy_local_varlist(end_tag->attr, tag->attr, MCI_APPCTAG);

      /* remeber position where start tag has been called */
      /* (for message "end tag missing) */
      end_tag->start_fpos = new_infilepos(hp->inpf);

      /* insert tag in list */
      if (ok) {
         nd = app_dlnode(taglist, end_tag);
         if (!nd) {
            del_hsctag((APTR) end_tag);
            end_tag = NULL;
         }
      }
   }
   return (end_tag);
}

/*
 * remove_end_tag
 *
 * remove tag from container stack, check for legal nesting,
 * show up message if necessary.
 *
 * params: hp....hsc process
*         tag...tag to be removed
*/
VOID remove_end_tag(HSCPRC * hp, HSCTAG * tag) {
   /* search for tag on stack of occured tags */
   DLNODE *nd = find_dlnode_bw(dll_last(hp->container_stack),
         (APTR) tag->name, cmp_strtag);

   if (nd == NULL) {
      /* closing tag not found on stack */
      /* ->unmatched closing tag without previous opening tag */
      hsc_message(hp, MSG_UNMA_CTAG, "unmatched %C", tag);
   } else {
      /* closing tag found on stack */
      HSCTAG *end_tag, *last_tag;
      STRPTR foundnm, lastnm;

      /* check for any /AC tags and remove them */
      if(!is_hsc_tag(tag))
         check_autoclose_anyway(hp, nd);

      end_tag = (HSCTAG*) dln_data(nd);
      foundnm = (STRPTR) end_tag->name;
      lastnm = ((HSCTAG*)dln_data(dll_last(hp->container_stack)))->name;

      /* check if name of closing tag is -not- equal
       * to the name of the last tag last on stack
       * ->illegal tag nesting
       */
      if(upstrcmp(lastnm, foundnm) &&
            !(tag->option & HT_MACRO) && !is_hsc_tag(tag)) {
         if(NULL != (last_tag = find_strtag(hp->deftag,lastnm))) {
            if(!is_hsc_tag(last_tag))
               hsc_message(hp, MSG_CTAG_NESTING,
                     "illegal end tag nesting (expected %c, found %C)",
                     lastnm, tag);
         }
      }

      /* if closing tag has any attributes defined, it must be a closing macro
       * tag. so copy the attributes of the closing tag to the attributes of the
       * macro tag. therefore, the closing macro tag inherits the attributes of
       * its opening macro
       */
      if (end_tag->attr) set_local_varlist(tag->attr, end_tag->attr,
            MCI_APPCTAG);

      /* remove node for closing tag from container_stack */
      del_dlnode(hp->container_stack, nd);
   }
}

/*
 *---------------------------
 * parse tag functions
 *---------------------------
 */

/*
 * hsc_parse_tag
 *
 * parse tag (after "<")
 */
BOOL hsc_parse_tag(HSCPRC * hp) {
   INFILE *inpf = hp->inpf;
   STRPTR nxtwd = NULL;
   DLNODE *nd = NULL;
   HSCTAG *tag = NULL;
   HSCTAG *now_tag_strip_whtspc = NULL;
   ULONG tci = 0;              /* tag_call_id returned by set_tag_args() */
   BOOL(*hnd) (HSCPRC * hp, HSCTAG * tag) = NULL;
   BOOL open_tag;
   DLLIST *taglist = hp->deftag;
   BOOL rplc_lt = FALSE;       /* TRUE, if replace spc. char "<" */
   BOOL hnd_result = TRUE;     /* result returned by handle */
   BOOL unknown_tag = FALSE;   /* TRUE, if tag has not been defined before */
   BOOL preceeding_whtspc = estrlen(hp->whtspc);

   /* init strings used inside tag-handles */
   set_estr(hp->tag_name_str, infgetcw(inpf));
   clr_estr(hp->tag_attr_str);
   clr_estr(hp->tag_close_str);

   /* default is no trailing slash */
   hp->xhtml_emptytag = FALSE;

   if (hp->smart_ent && preceeding_whtspc) {
      /*
       * check for special char "<"
       */
      int ch = infgetc(inpf);

      /* check if next char is a white space */
      if (hsc_whtspc(ch)) {
         rplc_lt = TRUE;

         /* write "<" and white spaces */
         message_rplc(hp, "<", "<");
         hsc_output_text(hp, "", "<");
      }
      inungetc(ch, inpf);
   }

   if (!rplc_lt) {
      /* get tag id */
      nxtwd = infget_tagid(hp);
      if (!hp->fatal) {
         /* append tag-name to tag_name_str */
         if (!hp->compact)
            app_estr(hp->tag_name_str, infgetcws(inpf));
         app_estr(hp->tag_name_str, infgetcw(inpf));

         if (!hp->suppress_output) {
            /* output tag currently processing
             * NOTE: the first tag of the source is skipped because
            *   hp->supress_ouptut is disabled later */
            D(fprintf(stderr, DHL "tag <"));
         }
      }
   }

   if (!hp->fatal && !rplc_lt) {
      BOOL write_tag = FALSE; /* flag: write tag text & attrs to output? */

      if (strcmp("/", nxtwd)) { /* is it a closing tag? */
         /*
          *
          * process start-tag
          *
          */
         open_tag = TRUE;
         if (!hp->suppress_output)
            D(fprintf(stderr, "%s>\n", nxtwd));

         /* search for tag in list */
         nd = find_dlnode(taglist->first, (APTR) nxtwd, cmp_strtag);
         if(NULL == nd) {
            /* tag not found */
            hsc_message(hp, MSG_UNKN_TAG, "unknown %t", nxtwd);
            tag = new_hsctag(nxtwd);
            tag->option |= HT_UNKNOWN;
            unknown_tag = TRUE;
         } else {
            tag = (HSCTAG *) nd->data;
         }

         /* set handle-function */
         hnd = tag->o_handle;

         /*
          * handle options
          */

         /* check for obsolete tag */
         if (tag->option & HT_OBSOLETE) {
            hsc_message(hp, MSG_TAG_OBSOLETE,
                  "%T is obsolete", tag);
         }

         /* check for /EMPTY tag and XHTML */
         hp->xhtml_emptytag = 
            (BOOL)((tag->option & HT_EMPTY) && hp->xhtml);

         /* check for jerk-tag */
         if (tag->option & HT_JERK) {
            hsc_message(hp, MSG_TAG_JERK,
                  "%T is only used by %j", tag);
         }

         /* only-once-tag occured twice? */
         if ((tag->option & HT_ONLYONCE) && (tag->occured)) {
            hsc_message(hp, MSG_TAG_TOO_OFTEN,
                  "%T occured too often", tag);
         }

         /* set occured-flag */
         if (tag->option & (HT_ONLYONCE | HT_REQUIRED))
            tag->occured = TRUE;

         /* check for "must be inside"/"not allowed within"-tags */
         if (!check_mbinaw(hp, tag))
            hnd = NULL;

         /* clear (reset to default) attribute values of tag */
         clr_varlist(tag->attr);

         /* set attributes or check for ">" */
         if (!(tag->option & HT_SPECIAL)) {
            tci = set_tag_args(hp, tag);
            if (tci == MCI_ERROR) {
               skip_until_eot(hp, NULL);
               hnd = NULL;
            }

            if (!hp->fatal) {
               /* set ">" in string that contains closing text */
               if(!hp->compact)
                  set_estr(hp->tag_close_str, infgetcws(inpf));
               else
                  clr_estr(hp->tag_close_str);
               app_estr(hp->tag_close_str, infgetcw(inpf));

               /* check for succeeding white-space */
               if ((tag->option & HT_WHTSPC) && !infeof(inpf)) {
                  int ch = infgetc(inpf);

                  if (hsc_whtspc(ch)) {
                     if (hp->strip_badws)
                        hp->strip_next2_whtspc = TRUE;
                     else if (!hp->strip_next2_whtspc)
                        now_tag_strip_whtspc = tag;
                  }
                  inungetc(ch, inpf);
               }
            }
         }

         /* for AUTOCLOSE-tags, remove potential end tags on stack */
         if (tag->option & HT_AUTOCLOSE) {
            DLNODE *nd = find_end_tag_node(hp, tag->name);

            if (nd) {
               if ((nd == dll_last(hp->container_stack)) ||
                     check_autoclose_anyway(hp,nd))
               {
                  D(fprintf(stderr, DHL "  autoclose </%s> before\n",
                           tag->name));
                  remove_end_tag(hp, tag);
               } else {
                  D(fprintf(stderr,
                           DHL "  no autoclose because of <%s> \n",
                           ((HSCTAG*)
                            dln_data(dll_last(hp->container_stack)))->name));
               }
            } else {
                  D(fprintf(stderr, DHL "  no autoclose neccessary\n"));
            }
         }

         /* end-tag required? */
         if ((tag->option & HT_CLOSE) || (tag->option & HT_AUTOCLOSE)) {
            /* yes: push current tag to container stack;
             * (current values of attributes will be
             * remembered */
            append_end_tag(hp, tag);
         }
      } else {
         /*
          *
          * process end-tag
          *
          */

         /* get tag id */
         nxtwd = infget_tagid(hp);   /* get tag id */
         open_tag = FALSE;

         /* append tag-name to tag_name_str */
         if (!hp->compact)
            app_estr(hp->tag_name_str, infgetcws(inpf));
         app_estr(hp->tag_name_str, infgetcw(inpf));

         if (!hp->suppress_output)
            D(fprintf(stderr, "/%s>\n", nxtwd));

         /* search for tag in taglist */
         /* (see if it exists at all) */
         nd = find_dlnode(taglist->first, (APTR) nxtwd, cmp_strtag);
         if (nd == NULL) {
            /* closing tag is absolutely unknown */
            hsc_message(hp, MSG_UNKN_TAG,   /* tag not found */
                  "unknown %c", nxtwd);
            skip_until_eot(hp, hp->tag_attr_str);
         } else {
            tag = (HSCTAG *) nd->data;      /* fitting tag in taglist */

            /* check for preceding white-spaces */
            if ((tag->option & HT_WHTSPC) && anyWhtspc(hp)) {
               if (hp->strip_badws)
                  hp->strip_next_whtspc = TRUE;
               else if (!hp->strip_next_whtspc)
                  hsc_message(hp, MSG_PREC_WHTSPC,
                        "preceding white space for %C", tag);
            }

            if (tag->option & (HT_CLOSE | HT_AUTOCLOSE)) {
               /* set closing handle */
               hnd = tag->c_handle;

               /* check for no args */
               if (!parse_wd(hp, ">")) {
                  hsc_message(hp, MSG_CL_TAG_ARG,
                        "no attributes allowed for end-tags");
               } else {
                  /* set ">" in string that contains closing text */
                  if (!hp->compact)
                     set_estr(hp->tag_close_str, infgetcws(inpf));
                  app_estr(hp->tag_close_str, infgetcw(inpf));
               }

               /* set values of attributes stored
                * in end-tag,
                * remove end-tag from stack
                */
               remove_end_tag(hp, tag);
            } else {
               /* illegal closing tag */
               hsc_message(hp, MSG_ILLG_CTAG,      /* tag not found */
                     "illegal %c", nxtwd);
               parse_gt(hp);
               tag = NULL;
            }
         }
      }

      /*
       * processed for opening AND closing tag
       */
      write_tag = (!(tag) || !(tag->option & HT_NOCOPY));

      if (tag) {
         /*
          * check if tag should be stripped
          */
         if (!postprocess_tagattr(hp, tag, open_tag)) {
            /* stripped tag with external reference */
            if (open_tag)
               hsc_msg_stripped_tag(hp, tag, "external reference");
            hnd = NULL;     /* don't call handle */
            write_tag = FALSE;      /* don't output tag */
         } else if (hp->strip_tags &&
                    strenum(tag->name, hp->strip_tags, '|', STEN_NOCASE)) {
            /* strip tag requested by user */
            if (!(tag->option & HT_SPECIAL)) {
               if (open_tag)
                  hsc_msg_stripped_tag(hp, tag, "as requested");
               hnd = NULL; /* don't call handle */
               write_tag = FALSE;  /* don't output tag */
            }
            else hsc_message(hp, MSG_TAG_CANT_STRIP,
                  "can not strip special tag %T", tag);

            /*
             * get values for size from reference
             */
         } else if (tag->uri_size && get_vartext(tag->uri_size))
            get_attr_size(hp, tag);

         /* flush all CSS properties to a STYLE attribute */
         if(NULL != hp->tag_styles->first) {
            BOOL semicolon = FALSE;
            STRPTR quote = (QMODE_SINGLE == hp->quotemode) ? "'" : "\"";
            HSCSTYLE *stylend;
            DLNODE *nd;

            /* append attribute and quote */
            app_estr(hp->tag_attr_str, hp->lctags ? " style=" : " STYLE=");
            app_estr(hp->tag_attr_str, quote);
            /* loop over all nodes in styles list */
            while(NULL != (nd = hp->tag_styles->first)) {
               stylend = (HSCSTYLE*)(nd->data);
               /* if there is more than one pair, they have
                * to be separated */
               if(semicolon) app_estr(hp->tag_attr_str, "; ");
               /* append <name>:<value> */
               app_estr(hp->tag_attr_str, stylend->name);
               app_estr(hp->tag_attr_str, ":");
               app_estr(hp->tag_attr_str, stylend->value);
               /* remove node from list */
               del_dlnode(hp->tag_styles, nd);
               semicolon = TRUE;
            }
            /* closing quote */
            app_estr(hp->tag_attr_str, quote);
         }
      }

      /* call handle if available */
      if (hnd && !hp->fatal)
         hnd_result = (*hnd) (hp, tag);

      /* write whole tag out */
      if (write_tag && hnd_result) {
         VOID(*tag_callback) (HSCPRC * hp, HSCTAG * tag,
               STRPTR tag_name, STRPTR tag_attr, STRPTR tag_close) = NULL;

         if (open_tag)
            tag_callback = hp->CB_start_tag;
         else
            tag_callback = hp->CB_end_tag;

         /* enable output if necessary */
         if (hp->suppress_output)
            hp_enable_output(hp, "non-internal tag occured");

         /* write (flush) white spaces */
         hsc_output_text(hp, "", "");

         if (tag_callback) {
            (*tag_callback) (hp, tag,
                             estr2str(hp->tag_name_str),
                             estr2str(hp->tag_attr_str),
                             estr2str(hp->tag_close_str));
         }
      }

      /* skip LF if requested */
      if (tag && (tag->option & HT_SKIPLF))
         skip_next_lf(hp);

      /* if tag should check for succeeding white spaces,
       * tell this hscprc now */
      if (now_tag_strip_whtspc) {
         D(fprintf(stderr, "  requested to check for succ.whtspc\n"));
         hp->tag_next_whtspc = now_tag_strip_whtspc;
      }

      /* remove temporary created tag */
      if (unknown_tag)
         del_hsctag(tag);

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

/*
 *---------------------------
 * other parse functions
 *---------------------------
 */

/* 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);
}


/*
 * hsc_parse_amp
 *
 * parse ampersand ("&")
 */
BOOL hsc_parse_amp(HSCPRC * hp) {
   if (!hp->fatal) {
      unsigned long numeric_ent = -1UL;
      BOOL invalid_ent = TRUE;
      INFILE *inpf = hp->inpf;
      EXPSTR *amp_str = init_estr(0);
      DLNODE *nd = NULL;
      HSCENT *entity = NULL;

      /*
       * get entity-id, test for unknown entity
       */
      char *nxtwd;
      BOOL app_entity = TRUE;

      /* remember "&" */
      set_estr(amp_str, infgetcw(inpf));

      /* get entity id */
      nxtwd = infgetw(inpf);

      /* check for illegal white-space */
      if (strlen(infgetcws(inpf)))
         hsc_msg_illg_whtspc(hp);

      if (nxtwd == NULL) {
         hsc_msg_eof(hp, "missing entity");
      } else if (!strcmp(nxtwd, "\\")) {
         /* flush white spaces */
         clr_estr(hp->whtspc);
         clr_estr(amp_str);
         infskip_ws(inpf);
      } else if (!strcmp(nxtwd, "/")) {
         /* replace white spaces by a single blank */
         set_estr(hp->whtspc, " ");
         clr_estr(amp_str);
         infskip_ws(inpf);
      } else {
         hp_enable_output(hp, "entity");

         /* append (illegal anyway) whitespace */
         app_estr(amp_str, infgetcws(inpf));

         if (!strcmp(nxtwd, "#")) {
            /*
             * process numeric entity
             */
            int base = 10;              /* numeric encoding base */
            STRPTR digit_start = NULL;  /* start of numeric digits */

            /* append "#" */
            app_estr(amp_str, infgetcw(inpf));

            /* get the digit sequence */
            nxtwd = infgetw(inpf);

            /* check for illegal white-space */
            if (strlen(infgetcws(inpf)))
               hsc_msg_illg_whtspc(hp);

            /* find out wheter it is an decimal or a hexadecimal
             * entity and set base according to it */
            if (toupper(nxtwd[0]) == 'X') {
               base = 16;      /* hexadecimal */
               digit_start = nxtwd + 1;
            } else {
               base = 10;      /* decimal */
               digit_start = nxtwd;
            }

            /* try to convert entity to number */
            errno = 0;
            numeric_ent = strtoul(digit_start, NULL, base);
            if(errno || (0x0000ffff < numeric_ent)) {
               hsc_message(hp, MSG_ILLG_NUM,   /* illegal numeric entity */
                     "illegal numeric value %q for entity", nxtwd);
            } else {
               invalid_ent = FALSE;
            }
            /* try to find the corresponding entity node if it might be needed later */
            if((EMODE_KEEP != hp->entitymode) && (EMODE_NUMERIC != hp->entitymode))
               if(NULL != (nd = find_dlnode(hp->defent->first, (APTR)numeric_ent, cmp_nument)))
                  entity = dln_data(nd);

            /* append entity specifier */
            app_estr(amp_str, nxtwd);
         } else {
            /*
             * process text entity
             */

            /* search for entity in list */
            if(NULL != (nd = find_dlnode(hp->defent->first, (APTR) nxtwd, cmp_strent))) {
               /* check for icon-entity and warn about */
               /* portability problem */

               invalid_ent = FALSE;
               entity = dln_data(nd);
               if (entity->numeric == ICON_ENTITY) {
                  if (estrlen(hp->iconbase)) {
                     replace_icon(hp, nxtwd);
                     set_estr(amp_str, "");
                     app_entity = FALSE;
                  } else {
                     hsc_message(hp, MSG_ICON_ENTITY,
                           "icon %e found", nxtwd);
                  }
               } else
                  numeric_ent = entity->numeric;
            } else
               hsc_message(hp, MSG_UNKN_ENTITY, "unknown %e", nxtwd);

            if (app_entity) {
               /* append entity specifier */
               app_estr(amp_str, nxtwd);
            }
         }

         /* check for closing ';' */
         nxtwd = infgetw(inpf);
         if (nxtwd) {
            if (!strcmp(nxtwd, ";")) {
               if (strlen(infgetcws(inpf)))
                  hsc_msg_illg_whtspc(hp);

               if (app_entity) {
                  app_estr(amp_str, infgetcws(inpf));
                  app_estr(amp_str, infgetcw(inpf));
               }
            } else {
               hsc_message(hp, MSG_EXPT_SEMIC, "%q expected after entity", ";");
               inungetcwws(inpf);
            }
         } else {
            hsc_msg_eof(hp, "expected \";\") for entity");
         }
      }

      /* output whole entity */
      if (estrlen(amp_str)) {
         if(invalid_ent) {
            /* output invalid entity as found in source */
            hsc_output_text(hp, "", estr2str(amp_str));
         } else {
            char tbuf[8];
            char *ent_out = tbuf;

            switch(hp->entitymode) {
               case EMODE_KEEP :
                  if((NULL != entity) &&
                        (entity->flags & HSCENTF_NONSTD)) {
                     /* nonstandard entities must be converted to numeric */
                     ENTITY_NUM2TEXT(tbuf,numeric_ent);
                  } else
                     ent_out = estr2str(amp_str);
                  break;

               case EMODE_REPLACE :
                  if(NULL != entity) {
                     if(entity->flags & (HSCENTF_PREFNUM | HSCENTF_NONSTD))
                        /* entity should be output numerically */
                        ENTITY_NUM2TEXT(tbuf,numeric_ent);
                     else {
                        /* reconstruct symbolic name (entity may have been
                         * specified numerically! */
                        set_estr(amp_str,"&");
                        app_estr(amp_str,entity->name);
                        app_estr(amp_str,";");
                        ent_out = estr2str(amp_str);
                     }
                  } else
                     ent_out = estr2str(amp_str);
                  break;

               case EMODE_NUMERIC :
                  /* if !invalid_ent, numeric_ent has been set */
                  ENTITY_NUM2TEXT(tbuf,numeric_ent);
                  break;

               case EMODE_SYMBOLIC :
                  /* if entity was found, reconstruct symbolic name, otherwise
                   * use what was in the source */
                  if(NULL != entity) {
                     set_estr(amp_str,"&");
                     app_estr(amp_str,entity->name);
                     app_estr(amp_str,";");
                  }
                  ent_out = estr2str(amp_str);
                  break;

               case EMODE_UTF8 :
                  /* simply convert numeric_ent to UTF-8, unless numeric_ent==0,
                   * which means entity is one of lt/gt/quot/amp and should be
                   * kept as is */
                  if(numeric_ent)
                     UCS4_TO_UTF8_STR((utf8_t*)tbuf,numeric_ent);
                  else
                     ent_out = estr2str(amp_str);
                  break;

               default :
                  ent_out = estr2str(amp_str);
                  break;
            }
            hsc_output_text(hp, "", ent_out);
         }
      }
      del_estr(amp_str);
   }
   return (BOOL) (!hp->fatal);
}

/*
 * hsc_parse_text
 */
BOOL hsc_parse_text(HSCPRC * hp) {
   INFILE *inpf = hp->inpf;
   STRPTR nw = infgetcw(inpf);

   if (nw && hp->suppress_output)
      hp_enable_output(hp, "some text");

   if (nw) {                           /* do test below only if not end-of-file */
      /*
       * check unmatched ">"
       */
      if (!strcmp(nw, ">")) {
         BOOL rplc = hp->smart_ent;  /* TRUE, if ">" should be replaced */

         if (rplc) {
            /*
             * test if char before and
             * after ">" is white-space
             */
            int ch = infgetc(inpf);

            inungetc(ch, inpf);

            if (!(hsc_whtspc(ch) && estrlen(hp->whtspc)))
               rplc = FALSE;
         }
         if (rplc) {
            /* replace gt */
            message_rplc(hp, nw, ">");
            nw = ">";
         } else
            hsc_message(hp, MSG_UNMA_GT, "unmatched %q", ">");
      } else if (!strcmp(nw, "\"")) { /* check for quote */
         if (hp->rplc_quote) {
            /* replace quote */
            message_rplc(hp, nw, """);
            nw = """;
         }
      } else { /* check for entities to replace */
         DLNODE *nd = NULL;  /* entity search result */

         if (hp->rplc_ent && (strlen(nw) == 1) && (((UBYTE) nw[0]) >= 127)) {
            nd = find_dlnode(hp->defent->first, (APTR) nw, cmp_rplcent);

            if (nd) {
               char tbuf[8];
               BOOL ok = TRUE;

               /* copy replaced entity to buffer */
               switch(hp->entitymode) {
                  case EMODE_KEEP :       /* EMODE_KEEP refers only to entities used in source */
                  case EMODE_REPLACE :
                  case EMODE_SYMBOLIC :   /* we want symbolic entities */
                     ok &= set_estr(hp->tmpstr, "&");
                     ok &= app_estr(hp->tmpstr, ((HSCENT*)nd->data)->name);
                     ok &= app_estr(hp->tmpstr, ";");
                     break;
                  case EMODE_NUMERIC :    /* we want numeric entities */
                     ok &= (sizeof(tbuf) >=
                           (unsigned)ENTITY_NUM2TEXT(tbuf,((HSCENT*)nd->data)->numeric));
                     ok &= set_estr(hp->tmpstr, tbuf);
                     break;
                  case EMODE_UTF8 :       /* convert to UTF-8 representation */
                     UCS4_TO_UTF8_STR((utf8_t*)tbuf,((HSCENT*)nd->data)->numeric);
                     ok &= set_estr(hp->tmpstr, tbuf);
                     break;
                  default :
                     ok = FALSE;
                     break;
               }
               if (ok) {
                  /* replace-message */
                  message_rplc(hp, nw, estr2str(hp->tmpstr));
                  nw = estr2str(hp->tmpstr);
               }
            }
         }
         /*
          * check for "click here" syndrome
          */
         if (hp->inside_anchor && hp->click_here_str) {
            ULONG found = strenum(nw, hp->click_here_str, '|', STEN_NOCASE);
            if (found)
               hsc_message(hp, MSG_CLICK_HERE,
                     "%q-syndrome detected", "click here");
         }
      }
   }

   if (nw)
      hsc_output_text(hp, "", nw);    /* output word */

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

/*
 * 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);
      }
   }

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

/*
 * hsc_parse_source
 *
 * parse input chars with full hsc support
 *
 * params: inpf...input file
 *
 * result: TRUE, if no error
 */
BOOL hsc_parse_source(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);

      if (nxtwd)
      {
         /* process next word */
         if (!strcmp(nxtwd, "<"))
            hsc_output_text(hp, "", "<");
         else if (!strcmp(nxtwd, ">"))
            hsc_output_text(hp, "", ">");
         else if (!strcmp(nxtwd, "&"))
            hsc_output_text(hp, "", "&");
         else
            hsc_parse_text(hp);
      }
   }
   return (BOOL) (!hp->fatal);
}

/*
 *---------------------------
 * parse end functions
 *---------------------------
 */

/*
 * hsc_parse_end
 *
 * check for all tags closed and required
 * tags occured
 */
BOOL hsc_parse_end(HSCPRC * hp)
{
   if (!hp->fatal)
   {
      /* remember current file position */
      INFILEPOS *infpos = new_infilepos(hp->inpf);
      DLNODE *nd = NULL;

      /* check for unclosed containers:
       * for every container tag still on stack launch a message,
       * exept for autoclose tags */
      nd = hp->container_stack->last;
      while (nd)
      {
         HSCTAG *endtag = (HSCTAG *) dln_data(nd);

         if (!(endtag->option & HT_AUTOCLOSE))
         {
            set_infilepos(hp->inpf, endtag->start_fpos);
            hsc_message(hp, MSG_MISS_CTAG,
                  "%c missing", endtag->name);
         }

         nd = dln_prev(nd);
      }

      /* restore file position */
      set_infilepos(hp->inpf, infpos);
      del_infilepos(infpos);

      /* check for required and recommended tags missing */
      nd = dll_first(hp->deftag);
      while (nd)
      {
         HSCTAG *tag = (HSCTAG *) dln_data(nd);

         if ((tag->option & HT_REQUIRED
                  && (tag->occured == FALSE)))
         {
            hsc_message(hp, MSG_MISS_REQTAG,
                  "required %T missing", tag);
         }
         else if ((tag->option & HT_RECOMMENDED
                  && (tag->occured == FALSE)))
         {
            hsc_message(hp, MSG_MISS_RCMDTAG,
                  "recommended %T missing", tag);
         }
         nd = dln_next(nd);
      }

      /* output last white spaces at eof */
      hsc_output_text(hp, "", "");
   }
   return (BOOL) (!hp->fatal);
}

/*
 *---------------------------
 * parse IDs functions
 *---------------------------
 */

/*
 * hsc_parse_end_id
 *
 * append all locally defined IDs to global IDs,
 * check all before referenced local IDs
 *
 */
BOOL hsc_parse_end_id(HSCPRC * hp)
{
   if (!hp->fatal)
      check_all_local_idref(hp);      /* check local IDs */

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

/* $Id: parse.c,v 1.10 2003/09/17 13:04:41 mb Exp mb $ */
/* vi: set ts=4: */
�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/parse.h�����������������������������������������������������������������������0100600�0001750�0000144�00000003317�07732056103�014700� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/parse.h
 *
 * functions for parsing of hsc files
 *
 */

#ifndef HSC_PARSE_H
#define HSC_PARSE_H

/*
 * global funcs
 */
#ifndef NOEXTERN_HSCLIB_PARSE_H

extern BOOL hsc_parse(HSCPRC * hp);
extern BOOL hsc_parse_tag(HSCPRC * hp);
extern BOOL hsc_parse_amp(HSCPRC * hp);
extern BOOL hsc_parse_text(HSCPRC * hp);
extern BOOL hsc_parse_source(HSCPRC * hp);
extern BOOL hsc_parse_end(HSCPRC * hp);
extern BOOL hsc_parse_end_id(HSCPRC * hp);

extern void hp_enable_output(HSCPRC * hp, STRPTR cause);
extern DLNODE *find_end_tag_node(HSCPRC *hp, STRPTR tagname);
extern HSCTAG *find_end_tag(HSCPRC *hp, STRPTR tagname);
extern HSCTAG *find_end_container_macro(HSCPRC *hp);

extern HSCTAG *append_end_tag(HSCPRC * hp, HSCTAG * tag);
extern VOID remove_end_tag(HSCPRC * hp, HSCTAG * tag);

#endif /* NOEXTERN_PARSE_H */
#endif /* HSC_PARSE_H */

/* $Id: parse.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/posteval.c��������������������������������������������������������������������0100600�0001750�0000144�00000006615�07732056103�015422� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, an html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/posteval.c
 *
 * functions to postprocess attributes
 * (remember IDs, references, etc)
 *
 */

#define NOEXTERN_HSCLIB_EVAL_H

#include <ctype.h>

#include "hsclib/inc_base.h"

#include "hscprj/document.h"
#include "hsclib/idref.h"
#include "hsclib/uri.h"

/*
 * postprocess_attributes
 *
 * This function scans a tag's list of attributes for URI-attributes
 * referring to an external URI. If it succeeds, and the hsc-process
 * has it's hp->strip_ext flag enabled, the function exits.
 *
 * Otherwise, it scans the attributes for new IDs and references
 * and updates the document data if neccessary (but only for start tags)
 *
 * params:
 *   hp ........ hsc-process
 *   tag ....... tag whose attribute list should be examined
 *   open_tag .. for end tags, the document-data should not be
 *               updated again
 * result:
 *   TRUE, if tag should NOT be stripped
 */
BOOL postprocess_tagattr(HSCPRC * hp, HSCTAG * tag, BOOL open_tag) {
    BOOL dontstrip = TRUE;

    if (tag->attr) {

        /*
         * find out, if list should be refused
         */
        if (hp->strip_ext
            && tag->uri_stripext
            && get_vartext(tag->uri_stripext)
            && (uri_kind(get_vartext(tag->uri_stripext)) == URI_ext)
            )
        {
            D(fprintf(stderr, DHL "strip external\n"));
            dontstrip = FALSE;
        } else if (open_tag) {
            /*
             * search for new IDs and references
             */
            DLNODE *nd = dll_first(tag->attr);
            while (nd) {
                HSCATTR *attrib = (HSCATTR *) dln_data(nd);
                STRPTR value = get_vartext(attrib);

                if (value) {
                    if (attrib->vartype == VT_URI) {
                        /* new reference */
                        INFILEPOS *fpos = new_infilepos(hp->inpf);
                        CALLER *newcaller = fpos2caller(fpos);
                        HSCREF *newref =
                        app_reference(hp->project->document, value);

                        newref->caller = newcaller;

                        del_infilepos(fpos);
                        D(fprintf(stderr, DHL "new REFERENCE: `%s'\n", value));

                    } else if (attrib->vartype == VT_ID) {
                        /* new id defined */
                        D(fprintf(stderr, DHL "new ID: `%s'\n", value));
                        add_local_iddef(hp, value);
                    }
                }
                nd = dln_next(nd);
            }
        }
    }
    return (dontstrip);
}


/* $Id: posteval.c,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */
�������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/posteval.h��������������������������������������������������������������������0100600�0001750�0000144�00000002371�07732056103�015422� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/posteval.h
 *
 * functions to postprocess attributes
 * (remember IDs, references, etc)
 */

#ifndef HSCLIB_POSTEVAL_H
#define HSCLIB_POSTEVAL_H

/*
 *
 * extern references
 *
 */
#ifndef NOEXTERN_HSCLIB_POSTEVAL_H

extern BOOL postprocess_tagattr(HSCPRC * hp, HSCTAG *tag, BOOL open_tag);

#endif /*  NOEXTERN_HSCLIB_POSTEVAL_H */

#endif /* HSCLIB_POSTEVAL_H */

/* $Id: posteval.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/size.h������������������������������������������������������������������������0100600�0001750�0000144�00000002072�07732056103�014535� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * size.h
 *
 * get size of link destination (WIDTH, HEIGHT)
 *
 */

#ifndef HSC_SIZE_H
#define HSC_SIZE_H

extern BOOL get_attr_size(HSCPRC * hp, HSCTAG * tag);

#endif /* HSC_SIZE_H */

/* $Id: size.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/skip.c������������������������������������������������������������������������0100600�0001750�0000144�00000074613�07732056103�014536� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/skip.c
 *
 * functions for skipping several things
 */

#define NOEXTERN_HSCLIB_SKIP_H

#include "hsclib/inc_base.h"

#include "hsclib/input.h"
#include "hsclib/skip.h"

/* debug skip */
#if DEBUG
#define DS(x) if(hp->debug) x
#else
#define DS(x)
#endif
#define DHLS "*hsclib* skip: "

/*
 * forward references
 */
BOOL skip_expression(HSCPRC * hp, EXPSTR * content, int endmark);

/* append text to content, if it does not point to NULL;
 * used by several functions in this file */
#define APP_CONTENT(w) if (content) app_estr(content,(w))
#define APP_CONTENT_ESTR(s) if (content) estrcat(content, (s))
#define APP_CONTENT_CH(c) if (content) app_estrch(content,(c))
#define APP_CONTENT_CWWS(inpf)                                       \
{                                                                    \
    /* apppend current white spaces & word to content_buffer */      \
    APP_CONTENT(infgetcws((inpf)));                                  \
    APP_CONTENT(infgetcw((inpf)));                                   \
}
/* append expstring and clear it afterwards */
#define APP_CONTENT_ESTR_CLR(s)                                      \
{                                                                    \
    APP_CONTENT_ESTR((s));                                           \
    clr_estr((s));                                                   \
}

/* a small debugging-function to print a single char
 * in hex, dez and, if useful,  ascii-representation */
#if DEBUG
static VOID dbg_printc(int ch)
{
    fprintf(stderr, "%02x #%03d", ch, ch);
    if (ch > 31)
    {
        fprintf(stderr, " `%c'", (char) ch);
    }
    fprintf(stderr, "\n");
}
#endif

/*
 * skip_next_lf
 *
 * ignore '\n'
 *
 * params: inpf...input file to read char from
 * result: TRUE if skipped
 */
BOOL skip_next_lf(HSCPRC * hp)
{
    INFILE *inpf = hp->inpf;
    int nc = infgetc(inpf);

    /* handle "\r\n", single "\r" and single "\n" */
    if (nc == '\r')
    {
        nc = infgetc(inpf);
    }
    if (nc != '\n')
    {
        inungetc(nc, inpf);
    }

    return ((BOOL) (nc == EOF));
}

/*
 * 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));
}

/*
 *-----------------
 * skip comment
 *-----------------
 */

/*
 * eoc_reched
 *
 * check if end of an hsc-comment is reached
 *
 * params:
 *   inpf...where to read next word from
 *   state..state var; has to be initiales by
 *          calling func with CMST_TEXT
 *   nest...comment netsing counter; has to be
 *          initiales by calling func with 0
 * result: TRUE, if end of comment reached
 */
BOOL eoc_reached(HSCPRC * hp, BYTE * state, LONG * nest)
{
    INFILE *inpf = hp->inpf;
    STRPTR nw = infgetw(inpf);

    if (nw)
    {
        switch (*state)
        {
        case CMST_TEXT:
            if (!strcmp(nw, "*"))
                *state = CMST_STAR;
            else if (!strcmp(nw, "<"))
                *state = CMST_TAG;
            break;

        case CMST_STAR:
            if (!strcmp(nw, "*"))
                *state = CMST_STAR;
            else if (!strcmp(nw, "<"))
                *state = CMST_TAG;
            else if (!strcmp(nw, ">")) {
               if (*nest)
               {
                  (*nest)--;
                  *state = CMST_TEXT;
               } else
                  *state = CMST_END;
            }
            break;

        case CMST_TAG:
            if (!strcmp(nw, "<"))
                *state = CMST_TAG;
            else
            {
                if (!strcmp(nw, "*"))
                    (*nest)++;
                *state = CMST_TEXT;
            }
            break;
        }
    }
    else
    {
        hsc_msg_eof(hp, "missing end of comment (\"*>\")");
        *state = CMST_ERR;
    }

    return ((BOOL) ((*state == CMST_END) || (*state == CMST_ERR)));
}

/*
 * skip_hsc_comment
 *
 * skip text until '*>' occures;
 * nested commets are supported
 *
 * params:
 *  hp           hsc-process to work with
 *  content      string where to store skipped text; NULL, if text should
 *               not be stored (which is faster)
 * result:
 *  TRUE, if no fatal error occured
 */
BOOL skip_hsc_comment(HSCPRC * hp, EXPSTR * content)
{
    INFILE *inpf = hp->inpf;
    int ch = infgetc(inpf);     /* read next char */
    BYTE state = CMST_TEXT;     /* parser state */
    LONG nesting = 0;           /* nesting counter */
    BOOL end = FALSE;           /* flag: end of comment reached? */

    DS(fprintf(stderr, DHLS "skip_hsc_comment\n"));
    while ((ch != EOF) && (!end))
    {
#if 0                           /* optional debugging */
        STRPTR state_str = "UNKN";

        switch (state)
        {
        case CMST_TEXT:
            state_str = "text";
            break;
        case CMST_TAG:
            state_str = "tag ";
            break;
        case CMST_STAR:
            state_str = "star";
            break;
        }

        fprintf(stderr, DHL "  st=%s  nc=%02x #%03d", state_str, ch, ch);
        if (ch > 31)
        {
            fprintf(stderr, " '%c'", (char) ch);
        }
        fprintf(stderr, "\n");
#endif

        /* append current char to content */
        APP_CONTENT_CH(ch);

        /* handle current char */
        switch (state)
        {
        case CMST_TEXT:
            if (ch == '*')
            {
                state = CMST_STAR;
            }
            else if (ch == '<')
            {
                state = CMST_TAG;
            }
            break;

        case CMST_STAR:
            if (ch == '*')
            {
                state = CMST_STAR;
            }
            else if (ch == '<')
            {
                state = CMST_TAG;
            }
            else if (ch == '>')
            {
                if (nesting)
                {
                    DS(fprintf(stderr,
                             DHLS "  nested comment-end (%ld)\n", nesting));
                    nesting--;
                    state = CMST_TEXT;
                }
                else
                {
                    end = TRUE;
                }
            }
            else
            {
              state = CMST_TEXT;
            }

            break;

        case CMST_TAG:
            if (ch == '<')
                state = CMST_TAG;
            else
            {
                if (ch == '*')
                {
                    nesting++;
                    DS(fprintf(stderr,
                             DHLS "  nested comment-tag (%ld)\n", nesting));
                }
                state = CMST_TEXT;
            }
            break;
        }

        /* read next char */
        if (!end)
        {
            ch = infgetc(inpf);
        }
    }

    /* handle unexpected end-of-file */
    if (ch == EOF)
    {
        hsc_msg_eof(hp, "missing end of comment (\"*>\")");
    }

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

/*
 * skip_hsc_verbatim
 *
 * skip text until '|>' occures; nesting is not supported
 *
 * params:
 *  hp           hsc-process to work with
 *  content      string where to store skipped text; NULL, if text should
 *               not be stored (which is faster)
 * result:
 *  TRUE, if no fatal error occured
 */
BOOL skip_hsc_verbatim(HSCPRC * hp, EXPSTR * content)
{
#define VBST_TEXT 1
#define VBST_VBAR 2
#define VBST_END  3

    INFILE *inpf = hp->inpf;
    int ch = infgetc(inpf);     /* read next char */
    BYTE state = VBST_TEXT;     /* parser state */

    while ((ch != EOF) && (state != VBST_END))
    {
        /* append current char to content */
        APP_CONTENT_CH(ch);

        /* handle current char */
        switch (state)
        {
        case VBST_TEXT:
            if (ch == (HSC_VERBATIM_STR[0]))
            {
                state = VBST_VBAR;
            }
            break;
        case VBST_VBAR:
            if (ch == '>')
            {
                state = VBST_END;
            }
            else if (ch == (HSC_VERBATIM_STR[0]))
            {
                state = VBST_VBAR;
            }
            else
            {
                state = VBST_TEXT;
            }
            break;
        default:
            panic("unhandled state");
            state = VBST_END;
            break;
        }

        /* read next char */
        if (state != VBST_END)
        {
            ch = infgetc(inpf);
        }
    }

    /* handle unexpected end-of-file */
    if (ch == EOF)
    {
        hsc_msg_eof(hp, "missing end verbatim section \"<|..|>\"");
    }

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

/*
 * skip_sgml_special
 *
 * skip SGML special commands (beginning with "<!":
 * - checks, if first two chars are "--"; if so,
 *   it will treat input as SGML comment
 *
 * params:
 *  hp           hsc-process to work with
 *  content      string where to store skipped text; NULL, if text should
 *               not be stored (which is faster)
 *  stripped     will be set to TRUE if comment was not stored
 * result:
 *  TRUE, if no fatal error occured
 */

/* display message "linefeed inside sgml-comment" */
static VOID msg_lf_in_comment(HSCPRC * hp)
{
    hsc_message(hp, MSG_LF_IN_COMMENT,
                "line feed inside sgml-comment");
}

BOOL skip_sgml_special(HSCPRC * hp, EXPSTR * content, BOOL *stripped)
{
    INFILE *inpf = hp->inpf;
    int ch = infgetc(inpf);     /* read next char */
    int ch_prev = EOF;
    BOOL end = FALSE;           /* flag: end of comment reached? */

    if (ch == '>') {
        hsc_message(hp, MSG_ZERO_COMMENT, "empty sgml comment");
        end = TRUE;
    } else if (ch == '-') {
        ch_prev = ch;
        ch = infgetc(inpf);
        if (ch == '-') {
            BOOL inside_comment = TRUE;
            BOOL warned_text = FALSE;
            
            /* don't keep contents if STRIPCOMMENT was set (but do keep stuff
             * starting in "<!" but not "<!--") */
            if(hp->strip_cmt) {
               HSCTAG dummytag;
               dummytag.name = "!-- ... --";
               content = NULL;
               *stripped = TRUE;
               hsc_msg_stripped_tag(hp, &dummytag, "sgml-comment");
            }

            DS(fprintf(stderr, DHLS "skip sgml comment\n"));
            APP_CONTENT_CH(ch_prev);
            APP_CONTENT_CH(ch);

            ch_prev = EOF;
            ch = infgetc(inpf);

            while (!end && (ch != EOF)) {
                /* append current char to content */
                APP_CONTENT_CH(ch);

                if ((ch == '-') && (ch_prev == '-')) {
                    inside_comment = !inside_comment;
                    warned_text = FALSE;
                    ch_prev = EOF;
                } else if (ch == '-') {
                    ch_prev = '-';
                } else if (ch == '\r') {
                    ch_prev = '\r';
                    msg_lf_in_comment(hp);
                } else {
                    if (ch == '\n') {
                        if (ch_prev != '\r')
                            msg_lf_in_comment(hp);
                    }

                    ch_prev = EOF;
                    if (ch == '>') {
                        if (inside_comment)
                            hsc_message(hp, MSG_GT_IN_COMMENT,
                                        "%q inside sgml-comment", ">");
                        else
                            end = TRUE;
                    } else {
                        if (!inside_comment && !warned_text)
                            hsc_message(hp, MSG_TEXT_IN_COMMENT,
                                        "text outside sgml-comment context");
                        warned_text = TRUE;
                    }
                }

                if (!end) {
                    /* read next char */
                    ch = infgetc(inpf);
                }
            }

            /* push back last char */
            if (!end && (ch != EOF))
                inungetc(ch, inpf);
        } else {
            /* push back chars read until yet */
            inungetc(ch, inpf);
            inungetc(ch_prev, inpf);

            ch_prev = EOF;
        }
    }

    /* skip other "!"-tags (SSI and that bullshit) */
    if (!end) {
        DS(fprintf(stderr, DHLS "skip sgml special\n"));

        APP_CONTENT_CH(ch);
        do {
            ch = infgetc(inpf);
            if (ch != EOF) {
                APP_CONTENT_CH(ch);
                DS(
                      {
                      fprintf(stderr, DHLS "  word starting with: ");
                      dbg_printc(ch);
                      fprintf(stderr, "\n");
                      }
                );

                if (ch == '>')
                    end = TRUE;
                else
                    skip_expression(hp, content, ch);
            }
        } while ((ch != EOF) && !end);
    }

    /* handle unexpected end-of-file */
    if (ch == EOF)
        hsc_msg_eof(hp, "missing end of sgml special tag \"<!..>\"");

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

/*
 * skip_expression
 *
 * skips expressions, string constants, functions calls
 *
 * params:
 *  hp           hsc-process to work with
 *  content      string where to store skipped text; NULL, if text should
 *               not be stored (which is faster)
 *  endmark      char that marks end-of-expression (see note below)
 * result:
 *  TRUE, if no fatal error occured
 *
 * NOTE on endmark:
 *  " .............. skip until next "
 *  ' .............. skip until next '
 *  ` .............. skip until next `
 *  ( .............. skip until next ), or recursively skip subexpression,
 *                   if one of the above shows up before
 *  anything else .. skip until white-space or ">"
 *
 * NOTE:
 *  internally, endmark='(' is immediately converted to endmark=')'
 */

/* decides, if a char is a supported endmark character */
static BOOL is_endmark(int ch)
{
    BOOL it_is = FALSE;
    if (strchr("(`'\"", ch))
    {
        it_is = TRUE;
    }
    return (it_is);
}

/* some debug macros */
#if 1
#define DBG_CH(ch)                               \
    DS(                                          \
          {                                      \
          fprintf(stderr, DHLS "  ch=");         \
          dbg_printc((ch));                      \
          }                                      \
    );
#else
#define DBG_NC                  /* nufin */
#endif

BOOL skip_expression(HSCPRC * hp, EXPSTR * content, int endmark)
{
#define IS_ENDMARK(x) ((BOOL)
    BOOL quit = FALSE;
    BOOL usual_endmark = is_endmark(endmark);
    int ch = EOF;

    DS(fprintf(stderr, DHLS "  skip expression, end=`%c'\n", endmark));

    if (endmark == '(')
    {
        endmark = ')';
    }

    do
    {
        ch = infgetc(hp->inpf);

        if (!usual_endmark)
        {
            /* skip until white-space or ">" */
            if (hsc_whtspc(ch) || (ch == '>'))
            {
                inungetc(ch, hp->inpf);
                quit = TRUE;
            }
            else
            {
                APP_CONTENT_CH(ch);
                DBG_CH(ch);
            }
        }
        else if (endmark == ')')
        {
            APP_CONTENT_CH(ch);
            if (is_endmark(ch))
            {
                DS(fprintf(stderr, DHLS "  skip sub-expression\n"));
                skip_expression(hp, content, ch);
            }
            else if (ch == endmark)
            {
                quit = TRUE;
            }
            else
            {
                DBG_CH(ch);
            }
        }
        else
        {
            APP_CONTENT_CH(ch);
            if (ch == endmark)
            {
                quit = TRUE;
            }
            else
            {
                /* do nufin, just append normal char to expression */
                DBG_CH(ch);
            }
        }
    }
    while (!quit && !(ch == EOF) && !(hp->fatal));

    /* handle unexpected end-of-file */
    if (ch == EOF)
    {
        EXPSTR *expected = init_estr(0);
        if (usual_endmark)
        {
            app_estrch(expected, '`');
            app_estrch(expected, endmark);
            app_estrch(expected, '\'');
        }
        else
        {
            app_estr(expected, "white space or `>'");
        }
        app_estr(expected, " expected");
        hsc_msg_eof(hp, estr2str(expected));
        del_estr(expected);
    }

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

/*
 * skip_tag_attribs
 *
 * skip tag attributes, until ">" shows up
 *
 * params:
 *  hp           hsc-process to work with
 *  content      string where to store skipped text; NULL, if text should
 *               not be stored (which is faster)
 * result:
 *  TRUE, if no fatal error occured
 */
#define STATE_TAGATTR        10 /* parsing tag-attribs */
#define STATE_TAGATTR_EQ     11 /* "=" inside tag */

BOOL skip_tag_attribs(HSCPRC * hp, EXPSTR * content)
{
    /* TODO: on illegal attr name, abort wth message */
    /* TODO: on "\n" in value, display message */
    /* TODO: conditional assignments */
    UBYTE state = STATE_TAGATTR;
    INFILE *inpf = hp->inpf;    /* input file */
    STRPTR nw = NULL;
    BOOL quit = FALSE;          /* flag: exit from skipping */

    do
    {
        /* get next word  or attribute name */
        if (state == STATE_TAGATTR)
        {
            nw = infget_attrid(hp);
        }
        else
        {
            nw = infgetw(inpf);
        }

        if (nw)
        {
            app_estr(content, infgetcws(inpf));
            app_estr(content, infgetcw(inpf));

            switch (state)
            {
            case STATE_TAGATTR:
                {
                    if (!strcmp(nw, "="))
                    {
                        /* normal assignment */
                        state = STATE_TAGATTR_EQ;
                    }
                    else if (!strcmp(nw, "?"))
                    {
                        /* conditional assignment:
                         * just check for succeeding "=",
                         * and push it back into input stream */
                        parse_eq(hp);
                        inungetcw(inpf);
                    }
                    else if (!strcmp(nw, ">"))
                    {
                        DS(fprintf(stderr, DHLS "end-of-tag-call\n"));
                        quit = TRUE;
                    }
                    else
                    {
                        /* just skipped a boolean attribute;
                         * nufin to do about it */
                    }
                    break;
                }

            case STATE_TAGATTR_EQ:
                skip_expression(hp, content, nw[0]);
                DS(fprintf(stderr, DHLS "end-of-tag-expression\n"));
                state = STATE_TAGATTR;
                break;

                /* unhandled state */
            default:
                panic("unhandled state");
                break;
            }
        }
    }
    while (nw && !quit && !(hp->fatal));

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

/*
 * skip_until_tag
 *
 * skip everything, until a specific tag (one of tagstoplist or tagnest)
 * is found. if tagnest occures as a start tag, another instance of the
 * corresponding end tag has to occure to abort the skipping operation.
 *
 * params:
 *  hp           hsc-process to work with
 *  content      string where to store skipped text; NULL, if text should
 *               not be stored (which is faster)
 *  tagfound     destination string that will store name of tag that lead
 *               to abortion of skip (eg "$else"); if this string is NULL,
 *               it will be ignored
 *  tagstoplist  list of tags to stop on, sparated with vertical bars `|'
 *               eg. "$else|$elseif"
 *  tagnest      single tag, that maintains a nesting-counter, depending
 *               on wheter it occures as a start-tag or not; if the
 *               nesting-counter is 0 and it occures as a stop-tag, it
 *               will also stop skipping (eg "$if")
 *  option       options for skipping (see hsclib/skip.h):
 *                 SKUT_NO_SKIP_TAGFOUND
 *                   do not skip last tagnest; when reading from the
 *                   input next, it will show up again
 *                 SKUT_NO_CONTENT_TAGFOUND
 *                   do not append last tagnest to content
 *                 SKUT_CLEAR_CONTENT
 *                   clear content before appending anything
 *                 SKUT_NO_ANALYSE_TAGS
 *                   do not analyse tag attributes and special tags;
 *                   this is more or less only used by <$source>
 */
#define STATE_TEXT            1 /* normal text */
#define STATE_TAG             2 /* after "<" */
#define STATE_COMMENT         3 /* inside hsc-comment */
#define STATE_COMMENT_STAR    4 /* inside hsc-comment, after "*" */
#define STATE_TAG_STOP        5 /* found tag in stoplist */
#define STATE_SKIP            6 /* inside `skip section' "<|..|>" */
#define STATE_VBAR            7 /* inside `skip section', after "|" */
#define STATE_ENDTAG          8 /* after end-tagname */

#define STATE_COMMENT_TAG    14 /* found "<" inside comment (nest comment) */

#define STATE_EXIT_ERROR_EOF 99 /* unexpected eof */

BOOL skip_until_tag(HSCPRC * hp, EXPSTR * content, EXPSTR * tagfound, STRPTR tagstoplist, STRPTR tagnest, ULONG option)
{
#define RESET_TAGSTR(init)
    UBYTE state = STATE_TEXT;   /* */
    INFILE *inpf = hp->inpf;    /* input file */
    LONG nesting = 0;           /* tag-nesting */
    STRPTR nw = NULL;
    BOOL quit = FALSE;          /* flag: exit from skipping */
    EXPSTR *tagstr = init_estr(128);    /* text of current tag */

    /* clear result-var tagfound, if passed */
    if (tagfound)
        clr_estr(tagfound);

    /* clear content on request */
    if (content && (option & SKUT_CLEAR_CONTENT))
        clr_estr(content);

    do {
        /* get next word or tag-id */
        if ((state != STATE_TAG) && (state != STATE_ENDTAG))
            nw = infgetw(inpf);
        else
            nw = infget_tagid(hp);

        if (nw) {
#if 0
            /* optional debugging stuff:
             * display content and tagstr on every change */
            if (content && estrlen(content))
                DS(fprintf(stderr, DHLS "  contnt=`%s'\n", estr2str(content)));

            if (estrlen(tagstr))
                DS(fprintf(stderr, DHLS "  tagstr=`%s'\n", estr2str(tagstr)));
#endif

            switch (state) {
                /* check if tag starts */
            case STATE_TEXT:
                if (!strcmp(nw, "<")) {
                    /* add white spaces to content */
                    APP_CONTENT(infgetcws(inpf));
                    /* reset tag string with "<" */
                    set_estr(tagstr, nw);

                    state = STATE_TAG;
                } else {
                    APP_CONTENT_CWWS(inpf);
                    if (estrlen(tagstr))
                        clr_estr(tagstr);
                }
                break;

                /* check which tag it is and how to act */
            case STATE_TAG:
                if (!strcmp(nw, "<")) {
                   /* this handles constructs like ``<</$source>''
                    * correctly */
                   APP_CONTENT_ESTR(tagstr);

                   /* unget current "<" */
                   inungetcwws(inpf);

                   /* switch back to text-parsing */
                   state = STATE_TEXT;
                } else {
                   /* flag: attribs of tag should be skipped
                    *   (and appended to tagstr) */
                   BOOL skip_attribs = FALSE;
                   /* flag: tagstr should be appended to content */
                   BOOL append_tag = FALSE;

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

                   /* check for end tag */
                   if (!strcmp(nw, "/"))
                      state = STATE_ENDTAG;
                   else if (option & SKUT_NO_ANALYSE_TAGS)
                      /* abort tag scan */
                      append_tag = TRUE;
                   /* check, if hsc-comment reached */
                   else if (!upstrcmp(nw, HSC_COMMENT_STR)) {
                      DS(fprintf(stderr, DHLS "hsc-comment\n"));
                      APP_CONTENT(estr2str(tagstr));
                      skip_hsc_comment(hp, content);
                      state = STATE_TEXT;
                   } else if (!upstrcmp(nw, HSC_VERBATIM_STR)) {
                      /* check, if hsc-verbatim reached */
                      DS(fprintf(stderr, DHLS "hsc-verbatim\n"));
                      APP_CONTENT(estr2str(tagstr));
                      skip_hsc_verbatim(hp, content);
                      state = STATE_TEXT;
                   } else if (!upstrcmp(nw, HSC_SOURCE_STR)) {
                      /* check, if hsc-source reached */
                      DS(fprintf(stderr, DHLS "hsc-source\n"));
                      APP_CONTENT(estr2str(tagstr));
                      skip_tag_attribs(hp, content);
                      skip_until_tag(hp, content, NULL, NULL,
                            HSC_SOURCE_STR,
                            SKUT_NO_ANALYSE_TAGS);
                      state = STATE_TEXT;
                   } else if (!strcmp(nw, "!")) {
                      /* check, if sgml-special-tag reached */
                      BOOL dummy_stripped;
                      DS(fprintf(stderr, DHLS "sgml-special\n"));
                      APP_CONTENT(estr2str(tagstr));
                      skip_sgml_special(hp, content,&dummy_stripped);
                      state = STATE_TEXT;
                   } else {
                      HSCTAG *tag = find_strtag(hp->deftag, nw);
                      DS(fprintf(stderr, DHLS "tag <%s>\n", nw));

                      /* check, if nesting-tag should be incr. */
                      if (!upstrcmp(nw, tagnest)) {
                         DS(fprintf(stderr, DHLS "  nest-tag (%ld)\n", nesting));
                         nesting++;
                         skip_attribs = TRUE;
                         append_tag = TRUE;
                      } else if (!nesting && tagstoplist
                            && strenum(nw, tagstoplist, '|', STEN_NOCASE)) {
                         /* check, if stop-tag reached */
                         DS(fprintf(stderr, DHLS "  stop-tag <%s>\n", nw));
                         if (tagfound)
                            set_estr(tagfound, nw);
                         skip_attribs = TRUE;
                         quit = TRUE;
                      } else if (tag && (tag->option & HT_SPECIAL)) {
                         /* ignore special tags, switch back to text;
                          * TODO: this is ugly, eg a
                          *     <$define sepp:string="<bla">
                          * will cause trouble */
                         DS(fprintf(stderr, DHLS "  special tag; ignore\n"));
                         state = STATE_TEXT;
                         append_tag = TRUE;
                      } else {
                         /* for standard tags, just skip attributes */
                         append_tag = TRUE;
                         skip_attribs = TRUE;
                      }

                      /* skip tag attributes, if requested */
                      if (skip_attribs) {
                         skip_tag_attribs(hp, tagstr);
                         state = STATE_TEXT;
                      }
                   }

                   /* append tag text to content, if requested */
                   if (append_tag) {
                      DS(fprintf(stderr, DHLS "  append `%s'\n",
                               estr2str(tagstr)));
                      APP_CONTENT(estr2str(tagstr));
                      state = STATE_TEXT;
                   }
                }
                break;

           case STATE_ENDTAG:
                DS(fprintf(stderr, DHLS "end tag </%s>\n", nw));
                app_estr(tagstr, infgetcws(inpf));
                app_estr(tagstr, infgetcw(inpf));
                if (!upstrcmp(nw, tagnest)) {
                   if (nesting) {
                      nesting--;
                      DS(fprintf(stderr, DHLS "  nest-tag (%ld)\n", nesting));
                   } else {
                      DS(fprintf(stderr, DHLS "  nest-tag: ending\n"));
                      quit = TRUE;
                   }
                }

                /* skip and check ">" */
                if (quit || !(option & SKUT_NO_ANALYSE_TAGS)) {
                   nw = infgetw(inpf);
                   if (nw) {
                      app_estr(tagstr, infgetcws(inpf));
                      app_estr(tagstr, infgetcw(inpf));
                      inungetcw(inpf);
                   }
                   parse_gt(hp);
                }

                /* append end tag text */
                if (!quit)
                   APP_CONTENT(estr2str(tagstr));

                /* no attr for endtag */
                state = STATE_TEXT;

                break;
                /* unhandled state */
            default:
                panic("unhandled state in skip_until_tag()");
                break;
            }
        }
    } while (nw && !quit && !(hp->fatal));

    if (nw) {
        /* unget end tag */
        if (option & SKUT_NO_SKIP_TAGFOUND)
            inungets(estr2str(tagstr), inpf);

        /* add last tag to content */
        if (!(option & SKUT_NO_CONTENT_TAGFOUND))
            APP_CONTENT(estr2str(tagstr));
    } else {
        /* unexpected end-of-file */
        set_estr(tagstr, "</");
        app_estr(tagstr, tagnest);
        app_estr(tagstr, "> expected");
        hsc_msg_eof(hp, estr2str(tagstr));
    }

    /* cleanup */
    del_estr(tagstr);

    return ((BOOL) (nw != NULL));
}

/* $Id: skip.c,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */
���������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/skip.h������������������������������������������������������������������������0100600�0001750�0000144�00000004747�07732056103�014544� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/skip.h
 *
 * functions for skipping several things
 *
 */

#ifndef HSCLIB_SKIP_H
#define HSCLIB_SKIP_H

#include "ugly/utypes.h"
#include "ugly/infile.h"

#include "hsclib/hscprc.h"

/* options for skip_until_tag(); see "hsclib/skip.c" for explanation */
#define SKUT_NO_SKIP_TAGFOUND    (1<<0)
#define SKUT_NO_CONTENT_TAGFOUND (1<<1)
#define SKUT_CLEAR_CONTENT       (1<<2)
#define SKUT_NO_ANALYSE_TAGS     (1<<3)

/* states for eot_reached() */
#define TGST_TAG     0          /* in tag */
#define TGST_REF     1          /* in attribute reference */
#define TGST_QUOTE   2          /* inside single quote */
#define TGST_DQUOTE  3          /* inside double quote */
#define TGST_END    10          /* end reached */
#define TGST_ERR    99          /* error occured */

/* states for eoc_reached() TODO: remove this */
#define CMST_TEXT     0         /* after normal text (or inside tag) */
#define CMST_STAR     1         /* after "*" */
#define CMST_TAG      2         /* after "<" */
#define CMST_END     10         /* after "*>" */
#define CMST_ERR     99         /* error occured */

#ifndef NOEXTERN_SKIP_H

/*
 * global funcs
 */
extern BOOL skip_next_lf(HSCPRC * hp);
extern BOOL skip_hsc_comment(HSCPRC * hp, EXPSTR * content);
extern BOOL skip_hsc_verbatim(HSCPRC * hp, EXPSTR * content);
extern BOOL skip_sgml_special(HSCPRC * hp, EXPSTR * content, BOOL *stripped);
extern BOOL skip_until_eot(HSCPRC * hp, EXPSTR * logstr);
extern BOOL skip_until_tag(HSCPRC * hp, EXPSTR * content, EXPSTR * tagfound, STRPTR tagstoplist, STRPTR tagnest, ULONG option);

#endif /* NOEXTERN_HSCLIB_SKIP_H */

#endif /* HSCLIB_SKIP_H */

/* $Id: skip.h,v 1.4 2003/09/17 13:04:41 mb Exp mb $ */
/* vi: set ts=4: */

�������������������������hsc-0.934.orig/hsclib/tag.c�������������������������������������������������������������������������0100600�0001750�0000144�00000013726�07772171027�014350� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001-2003  Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/tag.c
 *
 * hsc-tag funcs for hsc
 */

#define NOEXTERN_HSCLIB_TAG_H

#include "hsclib/inc_base.h"

#include "hsclib/defattr.h"
#include "hsclib/tag.h"

/*
 *-------------------------------------
 * constructor/destructor
 *-------------------------------------
 */

/*
 * del_hsctag
 */
void del_hsctag(APTR data)
{
    HSCTAG *tag = (HSCTAG *) data;

    /* release mem */
    ufreestr(tag->name);
    ufreestr(tag->name);
    del_estr(tag->op_text);
    del_estr(tag->cl_text);
    ufreestr(tag->mbi);
    ufreestr(tag->naw);
    del_dllist(tag->attr);
    del_infilepos(tag->start_fpos);
    del_infilepos(tag->end_fpos);

    /* clear values */
    tag->option = 0;
    tag->op_text = NULL;
    tag->cl_text = NULL;
    tag->attr = NULL;
    tag->uri_size = NULL;
    tag->uri_stripext = NULL;

    ufree(tag);
}

/*
 * new_hsctag
 *
 * alloc & init a new hsctag
 */
HSCTAG *new_hsctag(STRPTR newid)
{

    HSCTAG *newtag = (HSCTAG *) umalloc(sizeof(HSCTAG));

    if (newtag)
    {
        /* init new tag item */
        newtag->name = upstr(strclone(newid));  /* set id */
        newtag->option = 0;
        newtag->o_handle = NULL;        /* no handle functions */
        newtag->c_handle = NULL;
        newtag->occured = FALSE;
        newtag->op_text = NULL;
        newtag->cl_text = NULL;
        newtag->attr = init_dllist(del_hscattr);
        newtag->mbi = NULL;
        newtag->naw = NULL;
        newtag->uri_size = NULL;
        newtag->uri_stripext = NULL;
        newtag->start_fpos = NULL;
        newtag->end_fpos = NULL;

        if (!(newtag->name && newtag->attr))
        {
            del_hsctag(newtag);
            newtag = NULL;
        }
    }

    return (newtag);
}

/*
 * cpy_hsctag
 *
 * copy an already existing hsctag
 *
 * NOTE: this is not a 100% clone:
 *  - tag-callbacks are disabled and have to be assigned again.
 *  - the occured-flag is disabled
 */
HSCTAG *cpy_hsctag(HSCTAG * oldtag)
{
    HSCTAG *newtag = new_hsctag(oldtag->name);

    if (newtag)
    {
        DLNODE *nd = NULL;

        /* init new tag item */
        newtag->option = oldtag->option;
        newtag->o_handle = NULL;        /* no handle functions */
        newtag->c_handle = NULL;
        newtag->occured = FALSE;
        newtag->op_text = NULL;
        newtag->cl_text = NULL;
        newtag->attr = init_dllist(del_hscattr);
        newtag->mbi = strclone(oldtag->mbi);
        newtag->naw = strclone(oldtag->naw);
        newtag->uri_size = NULL;
        newtag->uri_stripext = NULL;

        /* copy macro text */
        if (oldtag->op_text)
        {
            newtag->op_text = init_estr(0);
            estrcpy(newtag->op_text, oldtag->op_text);
        }
        if (oldtag->cl_text)
        {
            newtag->cl_text = init_estr(0);
            estrcpy(newtag->cl_text, oldtag->cl_text);
        }

        /* copy attribute list */
        nd = oldtag->attr->first;
        while (nd)
        {
            HSCATTR *attr = (HSCATTR *) nd->data;       /* old attribute */

            /* create copy of old attribute */
            HSCATTR *nattr = cpy_hscattr(attr);

            /* append this copy to new attr-list */
            app_dlnode(newtag->attr, nattr);

            /* check for special uri-attributes */
            if (!upstrcmp(nattr->name, oldtag->uri_size->name))
                newtag->uri_size = nattr;
            if (!upstrcmp(nattr->name, oldtag->uri_stripext->name))
                newtag->uri_size = nattr;
        }
    }

    return (newtag);
}

/*
 *---------------------------
 * find tag string
 *---------------------------
 */

/*
 * cmp_strtag
 *
 * compares a tag-string with the name
 * of a HSCTAG-entry
 */
int cmp_strtag(APTR cmpstr, APTR tagdata)
{
    STRPTR tagstr = NULL;

    if (tagdata)
        tagstr = ((HSCTAG *) tagdata)->name;

    if (tagstr) {
        if (!upstrcmp(cmpstr, tagstr))
            return -1;
        else
            return 0;
    } else return 0;
}

/*
 * find_strtag
 */
HSCTAG *find_strtag(DLLIST * taglist, STRPTR name)
{
    DLNODE *nd = find_dlnode(taglist->first, (APTR) name, cmp_strtag);
    HSCTAG *tag = NULL;

    if (nd)
        tag = (HSCTAG *) nd->data;

    return (tag);
}

/*
 *-------------------------------------
 * append tag functions
 *-------------------------------------
 */

/*
 * app_tag
 *
 * create a new tag and append it to tag-list
 *
 * params: tagid..name of the new tag (eg "IMG")
 * result: ptr to the new tag or NULL if no mem
 */
HSCTAG *app_tag(DLLIST * taglist, STRPTR tagid)
{
    HSCTAG *newtag;

    newtag = new_hsctag(tagid);
    if (app_dlnode(taglist, newtag) == NULL)
    {
        del_hsctag((APTR) newtag);
        newtag = NULL;
    }

    return (newtag);
}

/* decides if a tag is a hsc-tag */
BOOL is_hsc_tag(HSCTAG * tag)
{
    return (BOOL)((!upstrncmp(tag->name, HSC_TAGID, strlen(HSC_TAGID)))
          || (!upstrcmp(tag->name, HSC_COMMENT_STR))
          || (!upstrcmp(tag->name, HSC_VERBATIM_STR))
          || (!upstrcmp(tag->name, HSC_INSEXPR_STR)));
}

/* decides if a tag is a macro-tag */
BOOL is_macro_tag( HSCTAG *tag )
{
    return((BOOL)(((tag->option) & HT_MACRO)>0));
}

/* $Id: tag.c,v 1.6 2003/12/24 01:55:14 mb Exp mb $ */
/* vi: set ts=4: */

������������������������������������������hsc-0.934.orig/hsclib/tag.h�������������������������������������������������������������������������0100600�0001750�0000144�00000016120�07772171500�014340� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001-2003  Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/*
 * hsclib/tag.h
 *
 * tag structure and functions
 *
 */

#ifndef HSCLIB_TAG_H
#define HSCLIB_TAG_H
#include "ugly/dllist.h"
#include "hsclib/attrib.h"

/*
 * defines
 */
#define HSC_TAGID        "$"
#define HSC_COMMENT_STR  "*"
#define HSC_VERBATIM_STR "|"
#define HSC_INSEXPR_STR  "("
#define HSC_CONTENT_STR  HSC_TAGID "content"
#define HSC_DEFENT_STR   HSC_TAGID "defent"
#define HSC_DEFSTYLE_STR HSC_TAGID "defstyle"
#define HSC_DEFICON_STR  HSC_TAGID "deficon"
#define HSC_DEFINE_STR   HSC_TAGID "define"
#define HSC_DEFTAG_STR   HSC_TAGID "deftag"
#define HSC_DEPEND_STR   HSC_TAGID "depend"
#define HSC_ELSE_STR     HSC_TAGID "else"
#define HSC_ELSEIF_STR   HSC_TAGID "elseif"
#define HSC_EXEC_STR     HSC_TAGID "exec"
#define HSC_EXPORT_STR   HSC_TAGID "export"
#define HSC_IF_STR       HSC_TAGID "if"
#define HSC_INCLUDE_STR  HSC_TAGID "include"
#define HSC_INSERT_STR   HSC_TAGID "insert"
#define HSC_LET_STR      HSC_TAGID "let"
#define HSC_LAZY_STR     HSC_TAGID "varlist"
#define HSC_MACRO_STR    HSC_TAGID "macro"
#define HSC_MESSAGE_STR  HSC_TAGID "message"
#define HSC_SOURCE_STR   HSC_TAGID "source"
#define HSC_STRIPWS_STR  HSC_TAGID "StripWS"

#define HSC_TEXT_STR     "TEXT"
#define HSC_TIME_STR     "TIME"

#define STRIPWS_BOTH     "both"
#define STRIPWS_PREV     "prev"
#define STRIPWS_SUCC     "succ"
#define STRIPWS_NONE     "none"

#define STRIPWS_ENUM     \
        STRIPWS_BOTH "|" STRIPWS_PREV "|" STRIPWS_SUCC "|" STRIPWS_NONE

struct hsc_process;             /* forward reference */

/*
 * structure & typdef for tag
 */
typedef struct hsctag
{
    STRPTR name;                /* tag name, eg "TITLE" */
    ULONG option;               /* tag options, eg HT_CLOSE|HT_REQUIRED */
      BOOL(*o_handle) (struct hsc_process * hp, struct hsctag * tag);
    /* callback for start-tag */
      BOOL(*c_handle) (struct hsc_process * hp, struct hsctag * tag);
    /* callback for end-tag */
    DLLIST *attr;               /* list of attributes */
    EXPSTR *op_text;            /* macro text (open/close) */
    EXPSTR *cl_text;
    STRPTR mbi;                 /* string that tells inside which
                                 * tag this tag has to be
                                 * e.g. for <LI>: "ul|ol|dir|menu" */
    STRPTR naw;                 /* "not allowed within */
    HSCVAR *uri_stripext;       /* if this uri attribute's value is
                                 * an external uri, tag is stripped */
    HSCVAR *uri_size;           /* with this uri, values for WIDTH and
                                 * HEIGHT can be evaluated */
    INFILEPOS *start_fpos;      /* for macros: location of def. */
    INFILEPOS *end_fpos;        /* for endtag: location of start tag */
    /* NOTE: end_fpos is also used to store the start-position
     *   of the content text for container macros */
    BOOL occured;               /* TRUE, if tag already occured */
    /* NOTE: the occured-flag is also set by def_tagname(),
     *   if a new macro already exists. the warning message
     *   is displayed later within def_tag_args(), where
     *   also the occured-flag is reset to FALSE. see "deftag.c"
     */
}
HSCTAG;

/*
 * defines for tag options
 */
#define HT_NOCOPY       (1<<0)  /* avoid copying of tag text */
#define HT_CLOSE        (1<<1)  /* closing tag required */
#define HT_REQUIRED     (1<<2)  /* tag required at least once in document */
#define HT_ONLYONCE     (1<<3)  /* tag required at most once in document */
#define HT_SPECIAL      (1<<4)  /* do not evaluate attributes, call handler */
#define HT_OBSOLETE     (1<<5)  /* tag is already obsolete */
#define HT_JERK         (1<<6)  /* netscape extension & co. */
#define HT_AUTOCLOSE    (1<<7)  /* ignore closing tags (e.g. <p>, <li>) */
#define HT_NOBP         (1<<8)  /* TODO: warning if <P> before tag */
#define HT_NOAP         (1<<9)  /* TODO: -"- after tag */
#define HT_MACRO        (1<<10) /* macro tag */
#define HT_NOHANDLE     (1<<11) /* don't call tag handles */
#define HT_WHTSPC       (1<<12) /* warn about pre/succ-ceeding white-spaces */
#define HT_SKIPLF       (1<<13) /* skip possible LF after tag */
#define HT_UNKNOWN      (1<<14) /* unknown tag (temporary created) */
#define HT_RECOMMENDED  (1<<15) /* tag recommended to appear in document */
#define HT_CONTENT      (1<<16) /* auto-enabled for content macros */
#define HT_EMPTY        (1<<17) /* EMPTY SGML content model (must be <foo/> or
                                   <foo /> in XHTML) e.g. <br>, <hr> */

#define HT_KEEP_QUOTES (1<<30)  /* keep quotes for all attributes;
                                 * * auto-enable for all macro tags  */

/* tag options that can be set via DEFTAG */
#define TO_CLOSE_STR       "CLOSE"
#define TO_CLOSE_SHT       "C"
#define TO_SPECIAL_STR     "SPECIAL"
#define TO_SPECIAL_SHT     "SPC"
#define TO_JERK_STR        "JERK"
#define TO_JERK_SHT        "J"
#define TO_LAZY_STR        "LAZY"
#define TO_LAZY_SHT        "L"
#define TO_MBI_STR         "MUST_BE_INSIDE"
#define TO_MBI_SHT         "MBI"
#define TO_NAW_STR         "NOT_ALLOWED_WITHIN"
#define TO_NAW_SHT         "NAW"
#define TO_EMPTY_STR       "EMPTY"
#define TO_EMPTY_SHT       "E"
#define TO_AUTOCLOSE_STR   "AUTOCLOSE"
#define TO_AUTOCLOSE_SHT   "AC"
#define TO_ONLYONCE_STR    "ONLYONCE"
#define TO_ONLYONCE_SHT    "1"
#define TO_OBSOLETE_STR    "OBSOLETE"
#define TO_OBSOLETE_SHT    "O"
#define TO_REQUIRED_STR    "REQUIRED"
#define TO_REQUIRED_SHT    "R"
#define TO_RECOMMENDED_STR "RECOMMENDED"
#define TO_RECOMMENDED_SHT "RCMD"
#define TO_SKIPLF_STR      "SKIPLF"
#define TO_SKIPLF_SHT      "S"
#define TO_WHTSPC_STR      "WHTSPC"
#define TO_WHTSPC_SHT      "W"

/* TODO: think about this tag-option */
#define TO_VERS_STR        "VERS"
#define TO_VERS_SHT        "V"

/*
 *
 * extern references
 *
 */
#ifndef NOEXTERN_HSCLIB_TAG_H

extern HSCTAG *new_hsctag(STRPTR newid);
extern VOID del_hsctag(APTR data);
extern HSCTAG *cpy_hsctag(HSCTAG * oldtag);

extern int cmp_strtag(APTR cmpstr, APTR tagdata);
extern HSCTAG *find_strtag(DLLIST * taglist, STRPTR name);
extern int cmp_strctg(APTR cmpstr, APTR tagstr);

extern HSCTAG *app_tag(DLLIST * taglist, STRPTR tagid);

extern BOOL is_hsc_tag(HSCTAG * tag);
extern BOOL is_macro_tag(HSCTAG * tag);

#endif /* NOEXTERN_HSCLIB_TAG_H */
#endif /* HSCLIB_TAG_H */

/* $Id: tag.h,v 1.6 2003/12/24 02:00:15 mb Exp mb $ */
/* vi: set ts=4: */
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_a.c�����������������������������������������������������������������������0100600�0001750�0000144�00000004465�07732056103�014641� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 *  hsclib/tag_a.c
 *
 *  tag-callback for "<A..>" (anchor)
 */

#include "hsclib/inc_tagcb.h"
#include "hscprj/document.h"

/*
 *  handle_anchor
 *
 *  handle tag <A>:
 *  - check for HREF set
 *  - update value for attribute HSC.ANCHOR
 */
BOOL handle_anchor(HSCPRC * hp, HSCTAG * tag)
{
    HSCVAR *vhref = find_varname(tag->attr, "HREF");
    HSCVAR *vname = find_varname(tag->attr, "NAME");
    HSCVAR *vid   = find_varname(tag->attr, "ID");
    STRPTR href = NULL;
    STRPTR name = NULL;
    STRPTR id = NULL;

    /* set attribute values */
    if (vhref)
    {
        href = vhref->text;
    }
    if (vname)
    {
        name = vname->text;
    }
    if (vid)
    {
        id = vid->text;
    }

    /* tell parser that he is inside an anchor */
    if (href)
    {
        HSCATTR *anchor_attr = find_varname(hp->defattr, ANCHOR_ATTR);

        if (anchor_attr)
        {
            set_vartext(anchor_attr, href);
        }
        else
        {
            panic("no anchor-attribute");
        }

        hp->inside_anchor = TRUE;
    }

    /* check for both HREF and NAME missing */
    if ((!href) && (!name) && (!id))
    {
        hsc_message(hp, MSG_ANCH_NO_NMHR,
                    "%T without HREF, NAME or ID", tag);
    }

    return (TRUE);
}

/*
 *  handle_cancher
 *
 *  closing handle for <A>
 */
BOOL handle_canchor(HSCPRC * hp, HSCTAG * tag)
{
    hp->inside_anchor = FALSE;

    /* write whole tag */

    return (TRUE);

}

/* $Id: tag_a.c,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_a.h�����������������������������������������������������������������������0100600�0001750�0000144�00000002152�07732056103�014635� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * tag_a.h
 *
 * tag handle for "<A xx>"
 *
 */

#ifndef HSCLIB_TAG_A_H
#define HSCLIB_TAG_A_H

extern BOOL handle_anchor(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_canchor(HSCPRC * hp, HSCTAG * tag);

#endif /* HSCLIB_TAG_A_H */

/* $Id: tag_a.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_hsc.c���������������������������������������������������������������������0100600�0001750�0000144�00000062444�07732056103�015177� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001 Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/tag_hsc.c
 *
 * tag callbacks for "<$xx>" and related
 * (for macro callbacks, see "tag_macro.c")
 */

#include "hsclib/inc_tagcb.h"

#include "ugly/fname.h"

#include "hsclib/defattr.h"
#include "hsclib/deftag.h"
#include "hsclib/eval.h"
#include "hsclib/include.h"
#include "hsclib/parse.h"
#include "hsclib/uri.h"
#include "hsclib/css.h"

#include "hsclib/tag_macro.h"
#include "hsclib/tag_if.h"

#define TIMEBUF_INC    20
#define ES_STEP_SOURCE 1024

/* states for handle_hsc_source */
#define SRST_TEXT    0          /* inside text      */
#define SRST_LT      1          /* after "<"        */
#define SRST_SLASH   2          /* after "</"       */
#define SRST_CSOURCE 3          /* after "</$SOURCE" */
#define SRST_TAG     8          /* inside a tag     */
#define SRST_COMT    9          /* inside comment   */
#define SRST_ERR    99          /* error occured    */

/* forward reference */
BOOL handle_hsc_include(HSCPRC * hp, HSCTAG * tag);

/*
 *-------------------------------------
 * comment & skip handle (<* *>, <| |>)
 *-------------------------------------
 */

/*
 * handle_hsc_comment
 *
 * skip text until '*>' occures;
 * nested commets are supported
 *
 */
BOOL handle_hsc_comment(HSCPRC * hp, HSCTAG * tag) {
   skip_hsc_comment(hp, NULL);
   return (FALSE);
}

/*
 * handle_hsc_verbatim
 *
 * copy text until '|>' occurs;
 * no syntax check or whatever is performed
 *
 */
BOOL handle_hsc_verbatim(HSCPRC * hp, HSCTAG * tag) {
   EXPSTR *content = init_estr(256);
   if (skip_hsc_verbatim(hp, content)) {
      /* remove "|>" from content */
      STRPTR strend = estr2str(content) + estrlen(content);
      while (strend[0] != '|')
         --strend;
      strend[0] = 0;

      /* output content */
      if (content && content->es_data && hp->suppress_output)
         hp_enable_output(hp, "some text");

      hsc_output_text(hp, "", estr2str(content));
   }
   del_estr(content);

   return (FALSE);
}

/*
 * handle_hsc_insert_expression
 *
 * insert value of a hsc-expression
 *
 * TODO: what to use as error-location, when inserting expression?
 */
BOOL handle_hsc_insert_expression(HSCPRC * hp, HSCTAG * tag) {
   HSCATTR *dest = new_hscattr(PREFIX_TMPATTR "insert.expression");
   STRPTR value = NULL;

   /* prepare dummy attribute */
   dest->vartype = VT_STRING;

   /* compute expression */
   value = eval_expression(hp, dest, ")");
   if (value) {
      parse_gt(hp);
      hsc_include_string(hp, SPECIAL_FILE_ID "insert expression", value,
            IH_PARSE_HSC | IH_NO_STATUS | IH_POS_PARENT);
   }
   del_hscattr(dest);

   return (FALSE);
}

/*
 *-------------------------------------
 * $INCLUDE handle
 *-------------------------------------
 */

static VOID do_include(HSCPRC * hp, STRPTR filename,
      BOOL nostatus, BOOL temporary, BOOL source, BOOL pre,
      LONG indent, LONG tabsize)
{
   EXPSTR *fname = init_estr(0);
   ULONG optn = 0;

   /* compute options */
   if (!temporary)
      optn |= IH_IS_INCLUDE;

   if (!nostatus)
      optn |= IH_NO_STATUS;

   if (source)
      optn |= IH_PARSE_SOURCE;

   /* compute filename (convert from URI if neccessary) */
   conv_uri2path(fname, filename, hp->weenix);

   /* insert leading <PRE> */
   if (pre) {
      hsc_include_string(hp, SPECIAL_FILE_ID "include <PRE>", "<PRE>",
            IH_PARSE_HSC | IH_NO_STATUS | IH_POS_PARENT);
   }
   /* include main file */
   if (fname)
      hsc_include_file(hp, estr2str(fname), optn);

   /* insert tailing </PRE> */
   if (pre) {
      hsc_include_string(hp, SPECIAL_FILE_ID "include </PRE>", "</PRE>\n",
            IH_PARSE_HSC | IH_NO_STATUS | IH_POS_PARENT);
   }

   del_estr(fname);
}

/*
 * handle_hsc_include
 *
 * include a sub file
 */
BOOL handle_hsc_include(HSCPRC * hp, HSCTAG * tag) {
   STRPTR fname_arg = get_vartext_byname(tag->attr, "FILE");
   LONG indent = get_varnum_byname(tag->attr, "INDENT");
   LONG tabsize = get_varnum_byname(tag->attr, "TABSIZE");
   BOOL source = get_varbool_byname(tag->attr, "SOURCE");
   BOOL pre = get_varbool_byname(tag->attr, "PRE");
   BOOL temporary = get_varbool_byname(tag->attr, "TEMPORARY");

   do_include(hp, fname_arg, FALSE /*nostatus */ , temporary,
         source, pre, indent, tabsize);

   return (FALSE);
}

/*
 *-------------------------------------
 * $MESSAGE handle
 *-------------------------------------
 */

/*
 * handle_hsc_error
 *
 * user error message
 */
BOOL handle_hsc_message(HSCPRC * hp, HSCTAG * tag) {
   STRPTR msg_text = get_vartext_byname(tag->attr, "TEXT");
   STRPTR msg_class = get_vartext_byname(tag->attr, "CLASS");

   if (msg_text)
   {
      ULONG msgid = (MSG_USER_MESSAGE & MASK_MESSAGE);

      /* compute message id */
      if (!upstrcmp(msg_class, "WARNING"))
         msgid |= MSG_WARN;
      else if (!upstrcmp(msg_class, "ERROR"))
         msgid |= MSG_ERROR;
      else if (!upstrcmp(msg_class, "FATAL"))
         msgid |= MSG_FATAL;
      else {
         D(if (upstrcmp(msg_class, "NOTE"))
               panic("illegal user message class")
          );
      }

      /* display message */
      hsc_message(hp, msgid, "user message: %s", msg_text);
   }
   return (FALSE);
}

/*
 *-------------------------------------
 * $EXEC handle
 *-------------------------------------
 */

/*
 * handle_hsc_exec
 *
 * execute shell command
 */
BOOL handle_hsc_exec(HSCPRC * hp, HSCTAG * tag)
{
#ifdef AMIGA
#define TMP_PREFIX "t:hsc"
#else
#define TMP_PREFIX "hsc"
#endif
   STRPTR cmd = get_vartext_byname(tag->attr, "COMMAND");
   HSCATTR *file_attr = find_varname(tag->attr, "FILE");
   HSCATTR *remove_attr = find_varname(tag->attr, "REMOVE");
   HSCATTR *result_attr = find_varname(hp->defattr, RESULT_ATTR);

   if (cmd && file_attr && result_attr && remove_attr)
   {
      int result = 0;
      BOOL remove_file = FALSE;
      BOOL read_file = FALSE;
      STRPTR remove_str = get_vartext(remove_attr);
      EXPSTR *msg = init_estr(0);
      EXPSTR *cmdstr = init_estr(32);

      /* additional attributes */
      HSCATTR *temp_attr = find_varname(tag->attr, "TEMPORARY");
      HSCATTR *include_attr = find_varname(tag->attr, "INCLUDE");
      HSCATTR *attribute_attr = find_varname(tag->attr, "ATTRIBUTE");
      STRPTR attribute_name = NULL;
      BOOL temporary = get_varbool(temp_attr);
      BOOL include = get_varbool(include_attr);
      BOOL pre = get_varbool_byname(tag->attr, "PRE");
      BOOL source = get_varbool_byname(tag->attr, "SOURCE");
      LONG indent = get_varnum_byname(tag->attr, "INDENT");
      LONG tabsize = get_varnum_byname(tag->attr, "TABSIZE");

      INFILE *outfile = NULL;
      STRPTR filename = get_vartext(file_attr);
      BOOL usetmpfile = FALSE;
      ULONG old_msg_count = hp->msg_count;

      /* check if file should be read after execution */
      if (attribute_attr)
         attribute_name = get_vartext(attribute_attr);
      if (attribute_name || include)
         read_file = TRUE;

      /* check if output should be redirected to temp. file */
      if (!filename && read_file) {
         usetmpfile = TRUE;
         set_vartext(file_attr, tmpnamstr(TMP_PREFIX));
         set_varbool(temp_attr, TRUE);
         filename = get_vartext(file_attr);
         D(fprintf(stderr, DHL "  use temp-file `%s'\n", filename));
      } else {
         D(fprintf(stderr, DHL "  use file `%s'\n", filename));
      }

      /* check if output-file should be removed */
      if (remove_str) {
         if (!upstrcmp(remove_str, "ON")) {
            remove_file = TRUE;
            temporary = TRUE;
            D(fprintf(stderr, DHL "  auto-temporary (remove=ON)\n"));
         } else {
            if (!upstrcmp(remove_str, "AUTO")) {
               if (hp->msg_count == old_msg_count) {
                  remove_file = temporary;
                  D(if (!remove_file)
                        fprintf(stderr, DHL "  no auto-remove (temp)\n"));
               } else {
                  D(fprintf(stderr, DHL "  no auto-remove (count)\n"));
               }
            }
         }
      }

      /* status message */
      app_estr(msg, "execute: ");
      app_estr(msg, cmd);
      hsc_status_misc(hp, estr2str(msg));

      /* create command string */
      set_estr(cmdstr, cmd);
      if (usetmpfile) {
#ifdef RISCOS
         app_estr(cmdstr, " {");
#endif
         app_estr(cmdstr, " >");
         app_estr(cmdstr, filename);
#ifdef RISCOS
         app_estr(cmdstr, " }");
#endif
      }

      D(fprintf(stderr, DHL "  command=`%s'\n", estr2str(cmdstr)));

      /* call command */
      result = system(estr2str(cmdstr));

      /* check for non-zero-result */
      if (result) {
         hsc_message(hp, MSG_SYSTEM_RETURN,
               "shell-command returned %d", result);
      }

      /* read output to HSC.STDOUT */
      if (read_file) {
         errno = 0;
         outfile = infopen(filename, 512);
         if (outfile) {
            /* read to attribute */
            if (attribute_name) {
               HSCATTR *output_attr =
                  find_varname(hp->defattr, attribute_name);

               D(fprintf(stderr, DHL "  ATTRIB exec-output to `%s'\n",
                        attribute_name));

               if (output_attr)
                  set_vartext(output_attr, infgetall(outfile));
               else
                  hsc_msg_unkn_attr_ref(hp, attribute_name);
            }
            infclose(outfile);

            /* include output */
            if (include) {
               /*handle_hsc_include(hp, tag); */
               BOOL nostatus = usetmpfile;
               D(fprintf(stderr, DHL "  INCLUDE exec-output\n"));
               do_include(hp, get_vartext(file_attr), nostatus,
                     temporary, source, pre, indent, tabsize);
            }
         } else {
            /* couldn't open exec-output file for input */
            hsc_msg_noinput(hp, filename);
         }

         /* check, if output-file should be removed */
         remove_file = FALSE;
         if (remove_str) {
            if (!upstrcmp(remove_str, "ON"))
               remove_file = TRUE;
            if (!upstrcmp(remove_str, "AUTO")) {
               if (hp->msg_count == old_msg_count) {
                  remove_file = temporary;
                  D(if (!remove_file)
                        fprintf(stderr, DHL "  no auto-remove (temp)\n"));
               } else {
                  D(fprintf(stderr, DHL "  no auto-remove (count)\n"));
               }
            }
         }

         /* remove output file */
         if (remove_file) {
            D(fprintf(stderr, DHL "  remove `%s'\n", filename));
            errno = 0;
            remove(filename);
            if (errno) {
               hsc_message(hp, MSG_REMOVE_FAILED,
                     "error removing file `%s': %s",
                     filename, strerror(errno));
               errno = 0;
            }
         }
      } else {
         D(fprintf(stderr, DHL "  don't read exec-output\n"));
      }

      /* update result-attribute */
      if (result_attr) {
         set_vartext(result_attr, long2str((LONG) result));
      } else {
         D(panic("no result attribute"));
      }

      del_estr(cmdstr);
      del_estr(msg);
   } else
      panic("attribute missing");

   return (FALSE);
}

/*
 *-------------------------------------
 * $EXPORT handle
 *-------------------------------------
 */

/*
 * handle_hsc_export
 *
 * write string to file
 */
BOOL handle_hsc_export(HSCPRC * hp, HSCTAG * tag) {
   STRPTR filename = get_vartext_byname(tag->attr, "FILE");
   STRPTR data = get_vartext_byname(tag->attr, "DATA");
   BOOL append = get_varbool_byname(tag->attr, "APPEND");
   BOOL relsrc = get_varbool_byname(tag->attr, "RELSRC");
   EXPSTR *real_filename = init_estr(1);

   if (filename && data) {
      FILE *outfile = NULL;
      STRPTR writemode = "w";

      if (append)
         writemode = "a";

      if(relsrc)
         set_estr(real_filename,get_vartext(find_varname(hp->defattr,"HSC.SOURCE.PATH")));
      else
         clr_estr(real_filename);
      app_estr(real_filename,filename);
      errno = 0;
      outfile = fopen(estr2str(real_filename), writemode);
      if (outfile) {
         fwrite(data, sizeof(char), strlen(data), outfile);
         fclose(outfile);
      }

      if (errno) {
         hsc_message(hp, MSG_IOERROR, "error opening/writing %q: %s",
               estr2str(real_filename), strerror(errno));
      }
   } else {
      panic("attribute missing");
   }
   del_estr(real_filename);
   return (FALSE);
}

/*
 *-------------------------------------
 * $INSERT handle
 *-------------------------------------
 */

/*
 * handle_hsc_time
 *
 * insert current time
 */
BOOL handle_hsc_time(HSCPRC * hp, HSCTAG * tag) {
   STRPTR timefmt = get_vartext_byname(tag->attr, "FORMAT");
   EXPSTR *timebuf = init_estr(TIMEBUF_INC);
   BOOL strftrc = 0;           /* result of strftime() */
   size_t i;                   /* loop var */

   /* set default time format */
   if (!timefmt)
      timefmt = "%d-%b-%Y, %H:%M";

   while (!(hp->fatal) && !strftrc) {
      /* expand timebuffer */
      for (i = 0; i < TIMEBUF_INC; i++)
         app_estrch(timebuf, '.');

      D(fprintf(stderr, DHL "  timebuf: inc+%d\n", TIMEBUF_INC));

      /* output time */
      strftrc = strftime(estr2str(timebuf), estrlen(timebuf),
            timefmt, localtime(&(hp->start_time)));
   }
   if (strftrc) {
      INFILEPOS *base = new_infilepos(hp->inpf);
      hsc_base_include_string(hp, SPECIAL_FILE_ID "insert time",
            estr2str(timebuf),
            IH_PARSE_HSC | IH_NO_STATUS, base);
      del_infilepos(base);
   }
   del_estr(timebuf);

   return (FALSE);
}

/*
 * handle_hsc_text
 *
 * insert text
 */
BOOL handle_hsc_text(HSCPRC * hp, HSCTAG * tag) {
   STRPTR text = get_vartext_byname(tag->attr, "TEXT");

   /* include text */
   INFILEPOS *base = new_infilepos(hp->inpf);
   hsc_base_include_string(hp, SPECIAL_FILE_ID "insert TEXT", text,
         IH_PARSE_HSC | IH_NO_STATUS, base);
   del_infilepos(base);

   return (FALSE);
}

/*
 * hsc_insert
 *
 * main insert handle
 */
BOOL handle_hsc_insert(HSCPRC * hp, HSCTAG * tag) {
   BOOL insert_text = FALSE;
   BOOL insert_time = get_varbool_byname(tag->attr, HSC_TIME_STR);

   if (get_vartext_byname(tag->attr, HSC_TEXT_STR))
      insert_text = TRUE;

   if (insert_text)
      handle_hsc_text(hp, tag);
   else if (insert_time)
      handle_hsc_time(hp, tag);
   else {

      /* unknown option for $insert */
      hsc_message(hp, MSG_MISS_REQ_ATTR,
            "required attribute for %t missing", HSC_INSERT_STR);
   }                           /* clear attributes */
   clr_varlist(tag->attr);

   return (FALSE);
}

/*
 *-------------------------------------
 * <$DEFTAG> define a new tag
 *-------------------------------------
 */
BOOL handle_hsc_deftag(HSCPRC * hp, HSCTAG * tag) {
   BOOL ok = FALSE;
   BOOL open_tag = FALSE;

   tag = def_tag_name(hp, &open_tag);
   ok = (tag && def_tag_args(hp, tag));

   return (FALSE);
}

/*
 *-------------------------------------
 * <$DEFENT> define a new entity
 *-------------------------------------
 */
static VOID msg_illegal_defent(HSCPRC * hp, STRPTR msg) {
   hsc_message(hp, MSG_ILLG_DEFENT, "illegal entity definition (%s)", msg);
}

static VOID msg_dubious_defent(HSCPRC * hp, STRPTR msg) {
   hsc_message(hp, MSG_DEFENT_WARN, "dubious entity definition (%s)", msg);
}

BOOL handle_hsc_defent(HSCPRC * hp, HSCTAG * tag) {
   STRPTR name = get_vartext_byname(tag->attr, "NAME");
   STRPTR rplc = get_vartext_byname(tag->attr, "RPLC");
   STRPTR nums = get_vartext_byname(tag->attr, "NUM");
   BOOL prefnum= get_varbool_byname(tag->attr, "PREFNUM");
   BOOL nonstd = get_varbool_byname(tag->attr, "NONSTD");
   LONG num = 0;
   char flags = (prefnum ? HSCENTF_PREFNUM : 0) | (nonstd  ? HSCENTF_NONSTD : 0);

   if((NULL == nums) && (NULL == name)) {
      msg_illegal_defent(hp, "specify at least one of NAME and NUM");
      return FALSE;
   }
   if((NULL != nums) && (!str2long(nums, &num))) {
      msg_illegal_defent(hp, "illegal value for NUM");
      return FALSE;
   }
   if ((NULL == rplc) || (strlen(rplc) == 1)) {
      if ((num >= 160) && (num <= 65535)) {
         DLNODE *nd = NULL;

         if((num > 255) && (NULL != rplc) && strlen(rplc)) {
            msg_dubious_defent(hp, "RPLC specified for NUM > 255");
         }
         if((NULL != name) && 
               (NULL != (nd = find_dlnode(hp->defent->first, (APTR)name, cmp_strent))))
         {
            if(num == ((HSCENT*)(dln_data(nd)))->numeric) {
               msg_dubious_defent(hp, "duplicate entity - updating flags");
               ((HSCENT*)(dln_data(nd)))->flags = flags;
               ((HSCENT*)(dln_data(nd)))->replace[0] = *rplc;
            } else
               msg_illegal_defent(hp, "NAME defined with different NUM");
         } else if((NULL != nums) &&
            (NULL != (nd = find_dlnode(hp->defent->first, (APTR)num, cmp_nument))))
         {
            if(0 == strcmp(name,((HSCENT*)(dln_data(nd)))->name)) {
               msg_dubious_defent(hp, "duplicate NUM - updating flags");
               ((HSCENT*)(dln_data(nd)))->flags = flags;
               ((HSCENT*)(dln_data(nd)))->replace[0] = *rplc;
            } else
               msg_illegal_defent(hp, "NUM defined with different NAME");
         } else
            add_ent(hp->defent, name, (NULL == rplc) ? '\0' : rplc[0], num, flags);
      } else
         msg_illegal_defent(hp, "illegal range for NUM (must be 160<=NUM<=65535)");
   } else
      msg_illegal_defent(hp, "RPLC not a single character");

   return (FALSE);
}

/*
 *-------------------------------------
 * <$DEFSTYLE> define a new CSS style
 *-------------------------------------
 */
BOOL handle_hsc_defstyle(HSCPRC *hp, HSCTAG *tag) {
   app_dlnode(hp->defstyle,
         new_styleattr(
            get_vartext_byname(tag->attr, "NAME"),
            get_vartext_byname(tag->attr, "VAL")));
   return FALSE;
}

/*
 *-------------------------------------
 * <$DEFICON> define a new icon-entity
 *-------------------------------------
 */
BOOL handle_hsc_deficon(HSCPRC * hp, HSCTAG * tag) {
   STRPTR name = get_vartext_byname(tag->attr, "NAME");
   DLNODE *nd = NULL;

   nd = find_dlnode(hp->defent->first, (APTR) name, cmp_strent);
   if (nd)
      msg_illegal_defent(hp, "duplicate entity");
   else
      add_ent(hp->defent, name, '\0', ICON_ENTITY, FALSE);

   return (FALSE);
}
/*
 *-------------------------------------
 * <$DEFINE> create a new (global) attribute
 *-------------------------------------
 */
BOOL handle_hsc_define(HSCPRC * hp, HSCTAG * tag) {
   HSCVAR *attr = define_attr_by_hp(hp, NULL, 0);
   if (attr) {
      DDA(prt_varlist(hp->defattr, "attributes after $DEFINE"));

      /* check for closing ">" */
      parse_gt(hp);
   }

   return (FALSE);
}

/*
 *-------------------------------------
 * $LAZY handle
 *-------------------------------------
 */
static HSCTAG *def_lazy_name(HSCPRC *hp) {
   STRPTR nw = NULL;
   HSCTAG *lazy = NULL;
   DLLIST *lazy_list = hp->deflazy;

   /* get lazy name */
   nw = infget_tagid(hp);

   /* create new lazy */
   if (nw) {
      lazy = find_strtag(lazy_list, nw);
      if (lazy)
         hsc_message(hp, MSG_REDEFINE_LAZY, "redefined lazy ", lazy);
      else
         /* create a new opening lazy */
         lazy = app_tag(lazy_list, nw);
   }                           /* err_eof already called in infget_tagid() */
   return (lazy);
}


BOOL handle_hsc_lazy(HSCPRC * hp, HSCTAG * tag) {
   BOOL ok = FALSE;
   HSCTAG *lazy = def_lazy_name(hp);
   if (lazy)
      ok = def_tag_args(hp, lazy);
   return (FALSE);
}


/*
 * handle_hsc_depend
 *
 * add dependency to current document
 */
BOOL handle_hsc_depend(HSCPRC * hp, HSCTAG * tag) {
   STRPTR filename = get_vartext_byname(tag->attr, "ON");
   BOOL file = get_varbool_byname(tag->attr, "FILE");

   if (filename) {
      EXPSTR *dest_fname = init_estr(64);

      /* convert URI to local filename */
      if (!file) {
         conv_hscuri2file(hp, dest_fname, filename);
         filename = estr2str(dest_fname);
      }

      /* add dependency */
      D(fprintf(stderr, DHL "  add dependency `%s'\n", filename));
      app_include(hp->project->document, filename);

      del_estr(dest_fname);
   } else {
      panic("attribute missing");
   }
   return (FALSE);
}

/*
 *
 */

/*
 *-------------------------------------
 * <$LET> set/reset/clear attribute value
 *-------------------------------------
 */
BOOL handle_hsc_let(HSCPRC * hp, HSCTAG * tag) {
   INFILE *inpf = hp->inpf;
   STRPTR varname = infgetw(inpf);
   HSCVAR *attr = NULL;
   BOOL ok = FALSE;

   if (varname) {
      /* create temporary dummy attribute that is
       * used to store the value, if attribute
       * passed is a constant
       */
      HSCVAR *dummy = new_hscattr(PREFIX_TMPATTR "let");

      if('{' == varname[0])
         varname = eval_expression(hp,dummy,"}");

      /* find attribute */
      attr = find_varname(hp->defattr, varname);
      if (attr) {
         STRPTR eq_sign = infgetw(inpf);

         if (attr->varflag & VF_CONST) {
            /* tried to set constant */
            hsc_message(hp, MSG_ATTR_CONST,
                  "attempt to modify constant %A", attr);

            /* assign destination to dummy attribute */
            attr = dummy;
            dummy->vartype = attr->vartype;
            dummy->varflag = attr->varflag;
         }

         /* check if a "=" comes next */
         if (eq_sign) {
            if (!strcmp(eq_sign, "=")) {
               STRPTR brace = infgetw(inpf);
               if(!strcmp(brace,"{")) {
                  /* assigning from a symbolic reference */
                  brace = eval_expression(hp, attr, "}");
                  inungets(brace,inpf);
                  eval_attrref(hp,attr);
               } else {
                  /* normal assignment */
                  inungets(brace,inpf);
                  eval_expression(hp, attr, NULL);
               }
            } else if (!strcmp(eq_sign, "?")) {
               /* conditional assignment */
               if (parse_eq(hp))
                  eval_conditional_assignment(hp, attr);
            } else {
               /* N->clear or reset attribute to default value */
               clr_vartext(attr);
               /* write previous word back (should be ">") */
               inungetcw(inpf);
            }

            DDA(prt_varlist(hp->defattr, "attributes after $LET"));
         }
         /* check for closing ">" */
         ok = parse_gt(hp);
      } else {
         hsc_msg_unkn_attr_ref(hp, varname);
      }

      /* remove dummy attribute */
      del_hscattr(dummy);

   }
   return (FALSE);
}

/*
 *-------------------------------------
 * <$SOURCE> include a source part
 *-------------------------------------
 */
BOOL handle_hsc_source(HSCPRC * hp, HSCTAG * tag) {
   BOOL pre = get_varbool_byname(tag->attr, "PRE");
   BOOL ok = TRUE;
   EXPSTR *source_content = init_estr(ES_STEP_SOURCE);
   INFILEPOS *base = new_infilepos(hp->inpf);

   /* avoid nesting of <PRE> */
   if (hp->inside_pre)
      pre = FALSE;            /* TODO: lauch warning */

   /* insert leading <PRE> */
   if (pre) {
      hsc_include_string(hp, SPECIAL_FILE_ID "insert <PRE>", "<PRE>",
            IH_PARSE_HSC | IH_NO_STATUS | IH_POS_PARENT);
   }

   /* read source text (until </$source> found) */
   ok = skip_until_tag(hp, source_content, NULL, NULL, HSC_SOURCE_STR,
         SKUT_NO_CONTENT_TAGFOUND | SKUT_NO_ANALYSE_TAGS);

   /* include source */
   if (ok) {
      /* include pseudo-file */
      hsc_base_include_string(hp, SPECIAL_FILE_ID "source",
            estr2str(source_content),
            IH_PARSE_SOURCE | IH_NO_STATUS, base);

      /* insert tailing </PRE> */
      if (pre) {
         hsc_include_string(hp, SPECIAL_FILE_ID "insert </PRE>",
               "</PRE>\n",
               IH_PARSE_HSC | IH_NO_STATUS | IH_POS_PARENT);
      }
   }
   del_infilepos(base);
   del_estr(source_content);

   return (FALSE);
}

/*
 *-------------------------------------
 * <$StripWS> strip white spaces
 *-------------------------------------
 */
BOOL handle_hsc_stripws(HSCPRC * hp, HSCTAG * tag) {
   STRPTR strip_type = get_vartext_byname(tag->attr, "TYPE");
   BOOL strip_prev = FALSE;
   BOOL strip_succ = FALSE;

   /* determine what to strip */
   if (!upstrcmp(strip_type, STRIPWS_BOTH)) {
      strip_prev = TRUE;
      strip_succ = TRUE;
   } else if (!upstrcmp(strip_type, STRIPWS_PREV)) {
      strip_prev = TRUE;
   } else if (!upstrcmp(strip_type, STRIPWS_SUCC)) {
      strip_succ = TRUE;
   } else if (!upstrcmp(strip_type, STRIPWS_NONE)) {
      /* nufin, use defaults */
   }

   /* now strip it */
   if (strip_prev) {
      clr_estr(hp->whtspc);
   }

   if (strip_succ) {
      hsc_output_text(hp, NULL, NULL);        /* flush current white spaces */
      hp->strip_next_whtspc = TRUE;
   }

   return (FALSE);
}

/* $Id: tag_hsc.c,v 1.10 2003/09/17 13:04:41 mb Exp mb $ */
/* vi: set ts=4: */
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_hsc.h���������������������������������������������������������������������0100600�0001750�0000144�00000004170�07732056103�015174� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001-2003  Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * tag_hsc.h
 *
 * tag handles for hsc-tags
 *
 */

#ifndef HSCLIB_TAG_HSC_H
#define HSCLIB_TAG_HSC_H

/*
 *
 * extern references
 *
 */
extern BOOL handle_hsc_comment(HSCPRC * hp, HSCTAG * tag);

extern BOOL handle_hsc_defent(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_defstyle(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_deficon(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_define(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_deftag(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_depend(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_exec(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_export(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_insert(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_include(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_lazy(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_let(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_message(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_verbatim(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_source(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_stripws(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_insert_expression(HSCPRC * hp, HSCTAG * tag);

#endif /* HSCLIB_TAG_HSC_H */

/* $Id: tag_hsc.h,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_if.c����������������������������������������������������������������������0100600�0001750�0000144�00000025544�07732056103�015020� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/tag_if.c
 *
 * tag callbacks for <$if>,<$else> and <$elseif>
 */

#include "hsclib/inc_tagcb.h"

#include "hsclib/eval.h"
#include "hsclib/parse.h"
#include "hsclib/skip.h"

/* chars that represent TRUE, FALSE and
 * UNDEF (error in if-expression) on if_stack
 */
#define ISTK_FALSE '0'          /* condition false */
#define ISTK_TRUE  '1'          /* condition true */
#define ISTK_UNDEF 'x'          /* condition unknown (after error, but still parsing input) */
#define ISTK_ELSE  'e'          /* after processing alternative condition
                                 * * read: <$else> or <$elseif> */

typedef BYTE if_t;

/* error message */
static VOID message_unma_else(HSCPRC * hp, HSCTAG * tag)
{
    hsc_message(hp, MSG_UNMA_ELSE,
                "unmatched conditional %T", tag);
}

/* forward references */
BOOL handle_hsc_else(HSCPRC * hp, HSCTAG * tag);
BOOL handle_hsc_elseif(HSCPRC * hp, HSCTAG * tag);
BOOL handle_hsc_cif(HSCPRC * hp, HSCTAG * tag);

/* convert boolean value to value for if-stack */
static if_t bool2ift(BOOL bval)
{
    if (bval)
        return (ISTK_TRUE);
    else
        return (ISTK_FALSE);
}

/*
 *-------------------------------------
 * IF-stack manipulation
 *-------------------------------------
 */

/* is_push: add a new value to the if-stack */
static VOID is_push(HSCPRC * hp, if_t value)
{
    app_estrch(hp->if_stack, (char) value);

    DIF(fprintf(stderr, DHL "push IF-stack: \"%s\"\n", estr2str(hp->if_stack)));
}

/* is_get: get first value from the if-stack */
static if_t is_get(HSCPRC * hp)
{
    if_t value = ISTK_FALSE;

    if (hp->if_stack)
    {
        STRPTR stkstr = estr2str(hp->if_stack);

        DIF(fprintf(stderr, DHL "get  IF-stack: \"%s\"\n", stkstr));

        if (stkstr && (stkstr[0]))
        {
            char lastch = stkstr[strlen(stkstr) - 1];
            if ((lastch != ISTK_TRUE)
                && (lastch != ISTK_FALSE)
                && (lastch != ISTK_ELSE))
            {
                DIF(panic("Illegal value on if_stack"));
            }
            else
                value = (if_t) lastch;
        }
        else
        {
            DIF(panic("if_stack EMPTY"));
        }
    }
    else
    {
        DIF(panic("if_stack UNDEFINED"));
    }

    DIF(fprintf(stderr, DHL "get  IF-stack: value=`%c'\n", (char) value));

    return (value);

}

/* is_pop: remove first value of the if-stack */
static if_t is_pop(HSCPRC * hp)
{
    if_t value = is_get(hp);

    if (!strlen(estr2str(hp->if_stack)))
    {
        DIF(panic("Popping empty if_stack"));
    }

    get_left_estr(hp->if_stack, hp->if_stack, strlen(estr2str(hp->if_stack)) - 1);

    DIF(fprintf(stderr, DHL "pop  IF-stack: \"%s\"\n", estr2str(hp->if_stack)));

    return (value);
}

/* is_empty: check if if-stack is empty */
static BOOL is_empty(HSCPRC * hp)
{
    BOOL result = FALSE;

    if (!strlen(estr2str(hp->if_stack)))
        result = TRUE;

    return (result);
}

/*
 *-------------------------------------
 * SELECT-stack manipulation
 *-------------------------------------
 */

/*
 * del_select_stack_node
 */
VOID del_select_stack_node(APTR data)
{
    STRPTR s = (STRPTR) data;
    ufreestr(s);
}

/*
 * new_select_stack_node
 */
STRPTR new_select_stack_node(STRPTR data)
{
    return (strclone(data));
}

/*
 * cmp_select_stack_node
 */
int cmp_select_stack_node(APTR cmp_data, APTR lst_data)
{
    STRPTR s1 = (STRPTR) cmp_data;
    STRPTR s2 = (STRPTR) lst_data;

#if DEBUG
    if (!cmp_data)
        panic("cmp_data = NULL");
    if (!lst_data)
        panic("lst_data = NULL");
#endif

    if (!strcmp(s1, s2))
        return (-1);
    else
        return (0);
}

/* ss_push: add a new value to the if-stack */
#if 0
static VOID ss_push(HSCPRC * hp, STRPTR value)
{
    app_dlnode(hp->select_stack, new_select_stack_node(value));
    DIF(fprintf(stderr, DHL "push select_stack: \"%s\"\n", value));
}

/* ss_get: get first value from the select-stack */
static STRPTR ss_get(HSCPRC * hp, EXPSTR * dest)
{
    STRPTR value = NULL;

    if (hp->select_stack)
    {
        DLNODE *nd = dll_first(hp->select_stack);

        if (nd)
        {
            value = dln_data(nd);
        }
        else
        {
            DIF(panic("select_stack EMPTY"));
        }
    }
    else
    {
        DIF(panic("select_stack UNDEFINED"));
    }

    DIF(
           if (value)
           fprintf(stderr, DHL "get  select_stack: value=`%s'\n", value)
        );

    return (value);
}

/* ss_pop: remove first value of select-stack */
static STRPTR ss_pop(HSCPRC * hp, EXPSTR * dest)
{
    STRPTR value = ss_get(hp, dest);

    if (!value)
    {
        DIF(panic("popping empty select_stack"));
        value = "";
    }

    DIF(fprintf(stderr, DHL "pop  select_stack: \"%s\"\n", value));

    return (value);
}

/* ss_empty: check if if-stack is empty */
static BOOL ss_empty(HSCPRC * hp)
{
    BOOL result = FALSE;

    if (dll_first(hp->select_stack))
        result = TRUE;

    return (result);
}

/*
 *-------------------------------------
 * misc. functions
 *-------------------------------------
 */

/*
 * remove_cif_tag
 *
 * remove </$IF> from closing tag stack
 */
static VOID remove_cif_tag(HSCPRC * hp)
{
    HSCTAG endiftag;            /* artificial if-tag to remove */

    endiftag.name = HSC_IF_STR;
    remove_end_tag(hp, &endiftag);      /* remove end tag from stack */
    DIF(fprintf(stderr, DHL "</$IF> removed\n"));
}

/*
 * get_condition
 *
 * evaluate if-condition
 */
static if_t get_condition(HSCPRC * hp)
{
    if_t cond = ISTK_UNDEF;     /* boolean result of expression */
    STRPTR condstr = NULL;
    STRPTR nw = infgetw(hp->inpf);

    if (nw)
    {
        /* create temp. attr */
        HSCVAR *condattr = new_hscattr(PREFIX_TMPATTR "if.condition");

        /* skip `COND=' if there (new syntax) */
        if (!upstrcmp(nw, CONDITION_ATTR))
            parse_eq(hp);
        else
            inungetcw(hp->inpf);

        condattr->vartype = VT_BOOL;

        condstr = eval_expression(hp, condattr, NULL);

        /* check for closing ">" */
        parse_gt(hp);

        if (condstr)
            if (get_varbool(condattr))
                cond = ISTK_TRUE;
            else
                cond = ISTK_FALSE;
        else
            cond = ISTK_UNDEF;

        /* remove temp. attribute */
        del_hscattr(condattr);
    }
    return (cond);
}
#endif

/*
 * skip_until_conditional
 *
 * skip text, until <$/IF>, <$ELSEIF> or <$ELSE> is found
 * also handle recursive IFs
 *
 */
static VOID skip_until_conditional(HSCPRC * hp)
{
    EXPSTR *s = init_estr(32);
    /* skip until next conditional tag is found; this specific tag
     * will not be skipped, and be parsed afterwards */
    skip_until_tag(hp, NULL, s,
                   HSC_ELSE_STR "|" HSC_ELSEIF_STR, HSC_IF_STR,
                   SKUT_NO_SKIP_TAGFOUND);
    del_estr(s);
}

/*
 *
 * exported funcs
 *
 */

/*
 *-------------------------------------
 * <$IF> conditional conversion
 *-------------------------------------
 */
BOOL handle_hsc_if(HSCPRC * hp, HSCTAG * tag)
{
    BOOL new_condbool = get_varbool_byname(tag->attr, CONDITION_ATTR);
    if_t new_cond = bool2ift(new_condbool);

    /* store new_cond on stack */
    is_push(hp, new_cond);
    DIF(fprintf(stderr, DHL "  new_cond=`%c'\n", new_cond));

    if (new_cond != ISTK_TRUE)
    {
        DIF(DMSG("IF: refused"));
        skip_until_conditional(hp);
    }
    else
    {
        DIF(DMSG(" IF: GRANTED"));
    }

    return (FALSE);
}

/*
 *-------------------------------------
 * </$IF> conditional conversion
 *-------------------------------------
 */
BOOL handle_hsc_cif(HSCPRC * hp, HSCTAG * tag)
{
    DIF(fprintf(stderr, DHL "IF: standard closing handler\n"));

    if (is_empty(hp))
    {
        /* this can happen, if <$if> had errors in args */
        DIF(fprintf(stderr, DHL "%s: unhandled handler conditional\n",
                 tag->name));
    }
    else
    {
        /* remove if-value from stack */
        is_pop(hp);
    }

    return (FALSE);
}

/*
 *-------------------------------------
 * <$ELSE> conditional conversion
 *-------------------------------------
 */
BOOL handle_hsc_else(HSCPRC * hp, HSCTAG * tag)
{
    if (is_empty(hp))
    {
        /* this can happen, if <$if> had errors in args */
        DIF(fprintf(stderr, DHL "%s: unhandled handler conditional\n", tag->name));
    }
    else
    {
        if_t value = is_pop(hp);

        if (value == ISTK_ELSE)
        {
            message_unma_else(hp, tag);
        }
        else if (value == ISTK_FALSE)
        {
            DIF(fprintf(stderr, DHL "ELSE: GRANTED\n"));
        }
        else
        {
            DIF(fprintf(stderr, DHL "ELSE: refused\n"));
            skip_until_conditional(hp);
        }

        /* mark <$else>-occured on if-stack */
        is_push(hp, ISTK_ELSE);
    }

    return (FALSE);
}

/*
 *-------------------------------------
 * <$ELSEIF> conditional conversion
 *-------------------------------------
 */
BOOL handle_hsc_elseif(HSCPRC * hp, HSCTAG * tag)
{
    BOOL new_condbool = get_varbool_byname(tag->attr, CONDITION_ATTR);
    if_t new_cond = bool2ift(new_condbool);

    if (is_empty(hp))
    {
        /* this can happen, if <$if> had errors in args */
        DIF(fprintf(stderr, DHL "%s: unhandled handler conditional\n", tag->name));
    }
    else
    {
        if_t old_cond = is_pop(hp);     /* condition of previous if/elseif */
        if_t push_cond = old_cond;      /* value to be pushed on stack */

        if (old_cond == ISTK_ELSE)
        {
            message_unma_else(hp, tag);
        }
        else if (old_cond == ISTK_TRUE)
        {
            DIF(fprintf(stderr, DHL "ELSEIF: refused (old_cond was true)\n"));
            skip_until_conditional(hp);
        }
        else if (new_cond == ISTK_TRUE)
        {
            DIF(fprintf(stderr, DHL "ELSEIF: GRANTED\n"));
            push_cond = new_cond;
        }
        else
        {
            DIF(fprintf(stderr, DHL "ELSEIF: refused (new_cond is false)\n"));
            skip_until_conditional(hp);
        }

        /* push new condition to if-stack */
        is_push(hp, push_cond);
    }

    return (FALSE);
}

/* $Id: tag_if.c,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */
������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_if.h����������������������������������������������������������������������0100600�0001750�0000144�00000002474�07732056103�015022� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * tag_if.h
 *
 * tag handles for <$IF> and <$ELSE>
 *
 */

#ifndef HSCLIB_TAG_IF_H
#define HSCLIB_TAG_IF_H

/*
 *
 * extern references
 *
 */
extern BOOL handle_hsc_if(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_cif(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_else(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_elseif(HSCPRC * hp, HSCTAG * tag);

extern VOID del_select_stack_node(APTR data);

#endif /* HSCLIB_TAG_IF_H */

/* $Id: tag_if.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_macro.c�������������������������������������������������������������������0100600�0001750�0000144�00000033075�07732056103�015521� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/tag_macro.c
 *
 * tag callbacks for "<$MACRO>" and "<macro>"
 */

#include "hsclib/inc_tagcb.h"

#include "hsclib/defattr.h"
#include "hsclib/deftag.h"
#include "hsclib/include.h"
#include "hsclib/parse.h"

#include "ugly/ustrlist.h"

/*
 *-------------------------------------
 * handlers for start/end macro
 *-------------------------------------
 */

/*
 * include_macro
 *
 * process macro attributes and text:
 * - set up local attributes
 * - include macro text
 * - remove local attributes
 */
static BOOL include_macro(HSCPRC * hp, HSCTAG * macro, STRPTR macro_text, STRPTR filename, INFILEPOS * fpos)
{
    BOOL ok = TRUE;
    ULONG mci = get_mci(hp);    /* obtain local scope */

    /* copy local attributes to global list */
    ok = copy_local_varlist(hp->defattr, macro->attr, mci);
    DMC(prt_varlist(hp->defattr, "global attr (after copy_local_vars)"));

    if (ok)
    {
        /* include macro file */
        ok = hsc_base_include_string(hp, filename, macro_text,
                                     IH_PARSE_MACRO, fpos);
    }

    /* cleanup */
    if (mci != MCI_ERROR)
    {
        /* remove local attributes */
        remove_local_varlist(hp->defattr, mci);
    }
    unget_mci(hp);              /* restore scope */

    return (ok);
}

/*
 * handle_macro
 *
 * handle for macro tags:
 * - 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
 */

/* just a debugging function */
static VOID dbg_print_macro(HSCPRC * hp, HSCTAG * macro, BOOL open_mac, STRPTR prefix)
{
    DMC(fprintf(stderr, DHL "--%s ", prefix));
    if (open_mac)
    {
        if ((macro)->option & HT_CLOSE)
        {
            DMC(fprintf(stderr, "start macro <%s>\n", (macro)->name));
        }
        else
        {
            DMC(fprintf(stderr, "simple macro <%s>\n", (macro)->name));
        }
    }
    else
    {
        DMC(fprintf(stderr, "end macro </%s>\n", (macro)->name));
    }
}

static BOOL handle_macro(HSCPRC * hp, HSCTAG * macro, BOOL open_mac)
{
    BOOL ok = TRUE;
    EXPSTR *text = NULL;        /* macro text */
    INFILEPOS *fpos = NULL;     /* file position of macro text */

    /* debugging message */
    dbg_print_macro(hp, macro, open_mac, "BEGIN");

    /* determine relative file position and macro text */
    if (open_mac)
    {
        text = macro->op_text;
        fpos = macro->start_fpos;
    }
    else
    {
        text = macro->cl_text;
        fpos = macro->end_fpos;
    }

    /* include macro file */
    ok = include_macro(hp, macro, estr2str(text),
                       SPECIAL_FILE_ID "macro", fpos);

    /* debugging message */
    dbg_print_macro(hp, macro, open_mac, "END");

    return (FALSE);
}

/*
 * handle_op_macro
 *
 * handle for opening macro
 */
static BOOL handle_op_macro(HSCPRC * hp, HSCTAG * tag)
{
    return (handle_macro(hp, tag, TRUE));
}

/*
 * handle_cl_macro
 *
 * handle for closing macro
 */
static BOOL handle_cl_macro(HSCPRC * hp, HSCTAG * tag)
{
    return (handle_macro(hp, tag, FALSE));
}

/*
 *-------------------------------------
 * handlers for content macros
 *-------------------------------------
 */

/*
 * handle_content_macro
 *
 * handle for content macros
 * (with /CLOSE set at declaration)
 *
 * - scan macro content until corresponding end macro
 *   tag is found
 * - increase scope
 * - define local HSC.CONTENT
 * - include macro text (not content!)
 * - remove HSC.CONTENT
 *
 */
static BOOL handle_content_macro(HSCPRC * hp, HSCTAG * tag)
{
    EXPSTR *macro_content = init_estr(2048);    /* contains macro contents */
    /* attribute that contains contents, too */
    HSCATTR *macro_content_attr = find_varname(hp->defattr, CONTENT_ATTR);
    HSCTAG *end_macro = NULL;
    STRPTR old_content = NULL;  /* to store old value of content attr */

    /* position where content starts */
    INFILEPOS *start_content_fpos = new_infilepos(hp->inpf);

    DMC(fprintf(stderr, DHL "--BEGIN content macro <%s>\n", tag->name));

    if (!macro_content_attr)
        panic("no content attribute");

    /* skip macro content until corresponding end macro is found; store
     * content in macro_content, but without the tag call for the end macro */
    skip_until_tag(hp, macro_content, NULL,
                   NULL, tag->name, SKUT_NO_CONTENT_TAGFOUND);

    /* store current value of content attribute */
    {
        STRPTR old = get_vartext(macro_content_attr);
        if (old)
            old_content = strclone(old);
    }

    /* set content attribute with current macro content */
    set_vartext(macro_content_attr, estr2str(macro_content));

    /* push content to content stack */
    add_strnode(hp->content_stack, estr2str(macro_content));

    /* some debuggin info */
    DMC(fprintf(stderr, DHL "  content=`%s'\n", estr2str(macro_content)));
    DMC(fprintf(stderr, DHL "  text   =`%s'\n", estr2str(tag->op_text)));

    /* push current tag on container stack; this is
     * only necessary for tag modifiers /MCI and
     * /NAW, which would not work otherwise */
    end_macro = append_end_tag(hp, tag);

    /* assign position of start of content to macro-tag */
    end_macro->end_fpos = start_content_fpos;

    /* now include the macro text */
    include_macro(hp, tag, estr2str(tag->op_text),
                  SPECIAL_FILE_ID "content-macro", tag->start_fpos);

    /* pull macro tag from container stack */
    end_macro->end_fpos = NULL;
    remove_end_tag(hp, tag);

    /* restore content attribute to previous value */
    set_vartext(macro_content_attr, old_content);

    /* remove content from stack */
    del_dlnode(hp->content_stack, dll_first(hp->content_stack));

    /* cleanup */
    ufreestr(old_content);
    del_estr(macro_content);
    del_infilepos(start_content_fpos);

    DMC(fprintf(stderr, DHL "--END content macro <%s>\n", tag->name));

    return (FALSE);
}

/*
 * handle_hsc_content
 *
 * handle content inside a content macro
 * (insert text of attribute HSC.CONTENT)
 */
static VOID hsc_msg_no_content(HSCPRC *hp) {
    hsc_message(hp, MSG_NO_CONTENT,
                "no content within current context");
}

BOOL handle_hsc_content(HSCPRC * hp, HSCTAG * tag) {
    HSCATTR *content_attr = find_varname(hp->defattr, CONTENT_ATTR);
    HSCTAG *macro = find_end_container_macro(hp);

    /* use current fileposition as base for including content */
    INFILEPOS *fpos = new_infilepos(hp->inpf);

    if (!macro) {
        DMC(fprintf(stderr, DHL "  no container macro on stack\n"));
        hsc_msg_no_content(hp);
    } else if (content_attr) {
        /* position where content text started */
        INFILEPOS *start_content_fpos = macro->end_fpos;

        /* first node on content stack contains current content text */
        DLNODE *first_content_text_node = dll_first(hp->content_stack);

        if (first_content_text_node) {
            /* pull first entry from content stack */
            STRPTR content = (STRPTR) detach_dlnode(hp->content_stack,
                                                    first_content_text_node);
            STRPTR old_content = strclone(get_vartext(content_attr));
            DLLIST *old_attribs = init_dllist(del_hscattr);
            ULONG scope_id = get_current_mci(hp);

            DMC(fprintf(stderr, DHL "  content=`%s'\n", content));

            /* update content attribute */
            set_vartext(content_attr, content);

#ifndef EXPERIMENTAL_CONTAINER
            /* move local attributes from global list to buffer list */
            move_local_varlist(old_attribs, hp->defattr, scope_id);
/*
            DDA(prt_varlist(hp->defattr, "attributes after move_local_varlist"));
            DDA(prt_varlist(old_attribs, "moved attributes"));
*/
            /* switch back to above scope */
            unget_mci(hp);
#endif

            /* now include the macro content */
            hsc_base_include_string(hp, SPECIAL_FILE_ID "macro-content",
                                    content,
                                    IH_NO_STATUS | IH_PARSE_MACRO,
                                    start_content_fpos);
            /* TODO: why IH_PARSE_MACRO? */

            /* push entry pulled above back to content stack */
            add_dlnode(hp->content_stack, content);

#ifndef EXPERIMENTAL_CONTAINER
            /* restore local attribs and scope from before */
            move_local_varlist(hp->defattr, old_attribs, scope_id);
            get_mci(hp);
/*
            DDA(prt_varlist(hp->defattr, "attributes after move_local_varlist/restore"));
*/
#endif
            /* restore content attribute */
            set_vartext(content_attr, old_content);

            /* free resources */
            del_dllist(old_attribs);
            ufreestr(old_content);
        } else {
            DMC(fprintf(stderr, DHL "  no content\n"));
            hsc_msg_no_content(hp);
        }
    } else {
        panic("no content attribute");
    }

    /* cleanup */
    del_infilepos(fpos);

    return (FALSE);
}

/*
 *-------------------------------------
 * macro creation functions
 *-------------------------------------
 */

/*
 * read_macro_text
 */
static BOOL read_macro_text(HSCPRC * hp, HSCTAG * macro, BOOL is_start_macro)
{
    BOOL ok = FALSE;
    EXPSTR *macstr = NULL;

    /* skip first LF if any */
    skip_next_lf(hp);

    /* init an EXPSTR for macro text,
     * remember location of macro-def (for messages) */
    if (is_start_macro)
    {
        macro->op_text = init_estr(ES_STEP_MACRO);
        macstr = macro->op_text;
        macro->start_fpos = new_winfilepos(hp->inpf);
    }
    else
    {
        macro->cl_text = init_estr(ES_STEP_MACRO);
        macstr = macro->cl_text;
        macro->end_fpos = new_winfilepos(hp->inpf);
    }

    /* read macro text */
    ok = skip_until_tag(hp, macstr, NULL, NULL,
                        HSC_MACRO_STR, SKUT_NO_CONTENT_TAGFOUND);

    /* if last char of macrotext is LF, CR or CR/LF, remove it */
    if (ok)
    {
        STRPTR ms = estr2str(macstr);
        size_t len = strlen(ms);
        size_t oldlen = len;

        /* NOTE: this is a bit ugly, it would be nicer to
         * call leftstr() here and strip last ch, but this
         * a lot faster */
        if (len && (ms[len - 1] == '\n'))
        {
            ms[len - 1] = '\0';
            len = strlen(ms);
        }

        if (len && (ms[len - 1] == '\r'))
        {
            ms[len - 1] = '\0';
            len = strlen(ms);
        }

        if (oldlen != len)
        {
            DMC(fprintf(stderr, DHL "  stripped cr/lf at end\n"));
        }

        DMC(fprintf(stderr, DHL "Macro text: \"%s\"\n", estr2str(macstr)));
    }

    return (ok);
}

/*
 *-------------------------------------
 * main handler function for creation
 *-------------------------------------
 */

/*
 * handle_hsc_macro
 *
 * define a new macro tag
 */
BOOL handle_hsc_macro(HSCPRC * hp, HSCTAG * tag)
{
    BOOL ok = FALSE;
    BOOL is_start_macro = FALSE;

    /* get name and argumets */
    tag = def_tag_name(hp, &is_start_macro);
    if (tag) {
        /* enable macro-flag */
        tag->option |= HT_MACRO;
        DDT(fprintf(stderr, DHL "def macro %s\n", tag->name));
    }

    ok = (tag && def_tag_args(hp, tag));

    if (ok) {
        /* assign macro text to tag structure */
        ok = read_macro_text(hp, tag, is_start_macro);
        if (ok) {
            /* set tag handles & flags */
            tag->option |= HT_NOCOPY;

            if (is_start_macro) {
                if (tag->option & HT_CLOSE) {
                    /* if macro is declared using a name not starting with "/",
                     * it must be a content macro; therfor, assign callback
                     * for content macros */
                    tag->o_handle = handle_content_macro;

                    /* disable the HT_CLOSE flag because the end tag is
                     * used to mark the end of the macro.content and is
                     * skipped anyway */
                    tag->option &= ~HT_CLOSE;
                    tag->option |= HT_CONTENT;
                    DMC(fprintf(stderr, DHL "  kind: container macro\n"));
                } else {
                    /* assign callback which processed macro text for
                     * start macros; this is the same for container macros
                     * and non-containers that have not been declared as
                     * content macros */
                    tag->o_handle = handle_op_macro;
                    DMC(fprintf(stderr, DHL "  kind: simple macro (for now)\n"));
                }
            } else {
                /* assign callback which processes the macro text
                 * for the end macro */
                tag->c_handle = handle_cl_macro;
                DMC(fprintf(stderr, DHL "  kind: container macro (old style)\n"));
            }
        }
    }

    return (FALSE);
}

/* $Id: tag_macro.c,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */
�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_macro.h�������������������������������������������������������������������0100600�0001750�0000144�00000002255�07732056103�015522� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * tag_macro.h
 *
 * tag handle for "<$MACRO>" (macro definition)
 *
 */

#ifndef HSC_TAG_MACRO_H
#define HSC_TAG_MACRO_H

/*
 * extern references
 */
extern BOOL handle_hsc_macro(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_hsc_content(HSCPRC * hp, HSCTAG * tag);

#endif /* HSC_TAG_MACRO_H */

/* $Id: tag_macro.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_misc.c��������������������������������������������������������������������0100600�0001750�0000144�00000006332�07770472405�015360� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/tag_misc
 *
 * misc. tag-callbacks
 */

#include "hsclib/inc_base.h"

#include "hsclib/parse.h"
#include "hsclib/skip.h"

/*
 *
 * global funs
 *
 */

/*
 * handle_base: tag handle for <BASE>
 *
 * enable switch docbase_set; this affects "uri.c"
 * and from now on, all relative uris will be absolute
 */
BOOL handle_base(HSCPRC * hp, HSCTAG * tag)
{
    STRPTR href_arg = get_vartext_byname(tag->attr, "HREF");

    if (href_arg)
    {
        D(fprintf(stderr, DHL "BASE SET `%s'\n", href_arg));
        hp->docbase_set = TRUE;
    }

    return TRUE;
}

/*
 * handle_blink: tag handle for <BLINK>
 *
 * just tell the user that blink sucks
 */
BOOL handle_blink(HSCPRC * hp, HSCTAG * tag)
{
    hsc_message(hp, MSG_BLINK_SUX, "%t sucks", "BLINK");

    return TRUE;
}

/*
 * handle_heading: tag handle for <H1>..<H6>
 *
 * compute number of haeding,
 * compare it with previous heading,
 * check first heading to be <H1>
 *
 */
BOOL handle_heading(HSCPRC * hp, HSCTAG * tag)
{
    BYTE num = (tag->name[1] - '0');    /* num of heading (1..6) */

    D(fprintf(stderr, DHL "  heading %d\n", num));

    /* check for <Hx> inside <A> */
    if (find_strtag(hp->container_stack, "A"))
    {
        hsc_message(hp, MSG_ANCHOR_HEADING, "heading inside anchor");
    }

    if ((hp->prev_heading_num - num) < (-1))
    {
        char hstr[4];

        sprintf(hstr, "H%ld", hp->prev_heading_num + 1);
        hsc_message(hp, MSG_WRONG_HEADING,
                    "expected heading %t", hstr);
    }

    hp->prev_heading_num = num;
    return TRUE;
}

/*
 * handle_img: tag handle for <IMG>
 *
 *
 */
BOOL handle_img(HSCPRC * hp, HSCTAG * tag)
{
    /* ...and I'm happy when it rains */
    return TRUE;
}

/*
 * handle_pre: tag handle for <PRE>
 *
 * enable switch inside_pre; this avoid stripping
 * of whtspcs with option "compact" enabled
 */
BOOL handle_pre(HSCPRC * hp, HSCTAG * tag)
{
    hp->inside_pre = TRUE;
    return TRUE;
}

/*
 * handle_end_pre: tag handle for </PRE>
 *
 * disable switch inside_pre
 */
BOOL handle_end_pre(HSCPRC * hp, HSCTAG * tag)
{
    hp->inside_pre = FALSE;
    return TRUE;
}

/*
 * handle_sgml_comment: tag handle for <!..>
 *
 */
BOOL handle_sgml_comment(HSCPRC * hp, HSCTAG * tag)
{
    BOOL stripped = FALSE;
    EXPSTR *content = hp->tag_attr_str;

    /* skip data */
    skip_sgml_special(hp, content, &stripped);

    return !stripped;
}

/* $Id: tag_misc.c,v 1.3 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/tag_misc.h��������������������������������������������������������������������0100600�0001750�0000144�00000002727�07732056103�015360� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/tag_misc.h
 *
 * misc. tag-callbacks
 *
 */

#ifndef HSC_TAG_MISC_H
#define HSC_TAG_MISC_H

/*
 *
 * extern references
 *
 */
extern BOOL handle_sgml_comment(HSCPRC * hp, HSCTAG * tag);

extern BOOL handle_base(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_blink(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_frame(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_heading(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_img(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_pre(HSCPRC * hp, HSCTAG * tag);
extern BOOL handle_end_pre(HSCPRC * hp, HSCTAG * tag);

#endif /* HSC_TAG_MISC_H */

/* $Id: tag_misc.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������hsc-0.934.orig/hsclib/throwback.c�������������������������������������������������������������������0100600�0001750�0000144�00000003057�07732056103�015546� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsc/throwback.c
 *
 * Throwback support routines for message browsers
 */

#if defined AMIGA
#include "amiga/throwback.c"
#elif defined RISCOS
#include "riscos/throwback.c"
#else

#include "hsc/global.h"
/*
 * Generic throwback functions that do nothing but ignore the THROWBACK
 * option. They will not even be called, but the linker needs them.
 */
BOOL hsc_init_throwback(HSCPRC * hp)
{
    return TRUE;
}

VOID hsc_del_throwback(HSCPRC * hp)
{
    /* Do nufin */
}

VOID hsc_throwback(HSCPRC * hp,
                   HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
                   STRPTR fname, ULONG x, ULONG y,
                   STRPTR msg_text)
{
    /* Do nufin */
}

#endif

/* $Id: throwback.c,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/throwback.h�������������������������������������������������������������������0100600�0001750�0000144�00000002201�07732056103�015541� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
BOOL hsc_init_throwback(HSCPRC * hp);
VOID hsc_del_throwback(HSCPRC * hp);
VOID hsc_throwback(HSCPRC * hp,
                   HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
                   STRPTR fname, ULONG x, ULONG y,
                   STRPTR msg_text);

/* $Id: throwback.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/uri.c�������������������������������������������������������������������������0100600�0001750�0000144�00000037034�10010444130�014343� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001-2003  Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * uri.c
 *
 * functions for uri parsing of tag arguments
 */

#define NOEXTERN_HSCLIB_URI_H

#include "ugly/fname.h"
#include "ugly/ufile.h"

#include "hsclib/inc_base.h"
#include "hsclib/idref.h"
#include "hscprj/project.h"
#include "hsclib/uri.h"
#ifdef UNIX
#include "hsclib/tcpip.h"
#endif

#define PARENT_URI "../"        /* string for parent dir within URIs */

/*
 * conv_path2uri
 *
 * convert a path for local (system-dependant)
 * file system to URI
 */
VOID conv_path2uri(EXPSTR * dest, STRPTR path)
{
    clr_estr(dest);

#if defined(AMIGA) || defined(AROS)
    /* 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 NEXTSTEP) || (defined BEOS) || (defined UNIX) || (defined WINNT) || (defined RISCOS)
    /* simply copy path */
    set_estr(dest, path);
#else
#error "system not supported: conv_path2uri"
#endif
}

/*
 * 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);

#if defined(AMIGA) || defined(AROS)
    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 NEXTSTEP) || (defined BEOS) || (defined UNIX) || (defined WINNT) || defined(RISCOS)
    set_estr(dest, uri);
#else
#error "system not supported: conv_uri2path"
#endif
}

/*
 * uri_kind
 *
 * evaluate kind of uri
 */
URIKIND uri_kind(STRPTR uri)
{
    URIKIND kind = URI_abs;

    if (upstrncmp(uri, ABSURI_ID, strlen(ABSURI_ID))) {
        if (uri[0] == '/')
            kind = URI_relserv;
        else {
            STRPTR colon_pos = strchr(uri, ':');
            STRPTR slash_pos = strchr(uri, '/');

            if (colon_pos) {
                if (slash_pos) {
                    if (colon_pos < slash_pos)
                        kind = URI_ext;
                    else
                        kind = URI_rel;
                } else kind = URI_ext;
            } else kind = URI_rel;
        }
    }
    return (kind);
}

/*
 * convert uri to filename in destination-dir
 *
 * TODO: optimize or rewrite this mess
 */
VOID conv_hscuri2fileNuri(HSCPRC * hp, EXPSTR * dest_uri, EXPSTR * dest_fname, STRPTR uri)
{
   EXPSTR *rel_path = init_estr(32);   /* relative path */
   EXPSTR *turi = init_estr(32);   /* modifiable URI */
   URIKIND kind = uri_kind(uri);
   
   clr_estr(dest_uri);
   clr_estr(dest_fname);

   D(fprintf(stderr, DHL "conv_hscuri2fileNuri('%s')\n",uri));
   /* check for empty URI first */
   if(0 == strlen(uri)) {
      set_estr(dest_uri,uri);
   } else {
      if (kind == URI_relserv) {
         /* skip "/" in URI */
         STRPTR uri2 = uri + 1;

         /* debug */
         D(fprintf(stderr, DHL "exists `%s' [relserv]\n", uri));

         /* convert server relative URI to local filename
          * by preceding server_dir */
         conv_uri2path(rel_path, uri2, hp->weenix);
         estrcpy(dest_fname, hp->server_dir);
         estrcat(dest_fname, rel_path);

         /* debug */
         D(fprintf(stderr, DHL "  server-dir=`%s'\n", estr2str(hp->server_dir)));
         D(fprintf(stderr, DHL "  rel. path =`%s'\n", estr2str(rel_path)));

         /* keep URI untouched */
         set_estr(dest_uri, uri);
      } else {
         /* convert relative/project uris */

         /* if a <BASE HREF="..."> was found before,
          * treat all relative URIs as absolute
          */
         if (hp->docbase_set)
            kind = URI_ext;

         if (kind == URI_abs) {
            uri += strlen(ABSURI_ID);  /* skip ":" */
            /*
             * parse absolute uri
             */
            D(fprintf(stderr, DHL "exists `%s' [abs]\n", uri));

            /* check if local uri exists */
            estrcpy(dest_fname, hp->destdir);
            if('\0' != uri[0]) {
               EXPSTR *dest_relfname = init_estr(32);

               conv_uri2path(dest_relfname, uri, hp->weenix);
               estrcat(dest_fname, dest_relfname);
               del_estr(dest_relfname);
            }

            D(fprintf(stderr, DHL "  -> file `%s'\n",
                     estr2str(dest_fname)));

            /* create path of destination file */
            estrcpy(dest_uri, hp->reldir);
            app_estr(dest_uri, uri);

            /* dir correction, so path collapsing will always work */
            set_estr(turi,uri);
            if(FE_DIR == fgetentrytype(uri)) {
               /* make sure there's a training slash */
               if('/' != uri[strlen(uri) - 1])
                  app_estr(turi,"/");
            }
            get_relfname(rel_path, estr2str(turi), estr2str(hp->reldir));
            D(fprintf(stderr, DHL "  -> rel. path `%s' (`%s')\n",
                     estr2str(rel_path),
                     estr2str(hp->reldir)));

            /* handle special case of paths that reference the directory
             * they are relative to */
            if('\0' == estr2str(rel_path)[0]) {
               set_estr(rel_path,".");
               set_estr(dest_fname,".");
            }

            /* debug */
            D(fprintf(stderr, DHL "  -> real path `%s'\n", uri));

            /* convert (filesystem depending) path to uri */
            conv_path2uri(dest_uri, estr2str(rel_path));
         } else if (kind == URI_rel) {
            /*
             * parse relative uri
             */
            EXPSTR *uri_path = init_estr(32);
            EXPSTR *docdir = init_estr(32);
            STRPTR optimized_name = NULL;

            /* debug */
            D(fprintf(stderr, DHL "exists `%s' [rel]\n", uri));

            /* create local filename */
            conv_uri2path(uri_path, uri, hp->weenix);
            estrcat(dest_fname, hp->destdir);
            estrcat(dest_fname, hp->reldir);
            estrcat(dest_fname, uri_path);

            /* dir correction, so path collapsing will always work */
            if(FE_DIR == fgetentrytype(estr2str(dest_fname))) {
               /* make sure there's a training slash */
               if(0 != strcmp(PATH_SEPARATOR,
                               estr2str(dest_fname) + strlen(estr2str(dest_fname)) -
                                 strlen(PATH_SEPARATOR)))
                  app_estr(dest_fname, PATH_SEPARATOR);
            }
            /* make document directory name */
            estrcpy(docdir, hp->destdir);
            estrcat(docdir, hp->reldir);

            /* optimize complete target URI */
            optimize_fname(&optimized_name, estr2str(dest_fname));
            if(optimized_name) {
               /* dest_uri is relative to target dir */
               get_relfname(dest_uri, optimized_name, estr2str(docdir));
               if(0 == estrlen(dest_uri))
                  set_estr(dest_uri, ".");
               ufree(optimized_name);
            } else {
               /* something wrong with the optimization - just jopy URI */
               set_estr(dest_uri,uri);
            }

            del_estr(docdir);
            del_estr(uri_path);
         } else {
            set_estr(dest_uri, uri);
            set_estr(dest_fname, "");
         }
      }

      /* If there is a filename, optimize it */
      if (estrlen(dest_fname) > 0) {
         STRPTR optimized_name = NULL;
         optimize_fname(&optimized_name, estr2str(dest_fname));
         set_estr(dest_fname, optimized_name);
         if(optimized_name)
            ufree(optimized_name);
         /* dir correction for the final URI */
         if(FE_DIR == fgetentrytype(estr2str(dest_fname))) {
            /* make sure there's a training slash */
            if('/' != estr2str(dest_uri)[strlen(estr2str(dest_uri)) - 1])
               app_estr(dest_uri,"/");
         }
      }

      /* debug */
      D(
            {
            fprintf(stderr, DHL "  -> real file `%s'\n",
               estr2str(dest_fname));
            fprintf(stderr, DHL "  -> real uri  `%s'\n",
               estr2str(dest_uri));
            }
       );
   } 
   /* free resources */
   del_estr(turi);
   del_estr(rel_path);
}

VOID conv_hscuri2file(HSCPRC * hp, EXPSTR * dest_fname, STRPTR uri)
{
   EXPSTR *dest_uri = init_estr(64);
   conv_hscuri2fileNuri(hp, dest_uri, dest_fname, uri);
   del_estr(dest_uri);
}

/*
 * parse_uri
 *
 * check uri-string for syntatic correctnes;
 * if the uri refers to an local file, convert its absolute
 * path to a relative path and check its existence.
 *
 * uri = "rsrc_type://host.domain:port/pathname#id"
 */
VOID parse_uri(HSCPRC * hp, EXPSTR * dest_uri, STRPTR uri)
{
   /* sample URI could be:
    * http://www.host.at:80/file.html#name
    */
   STRPTR protocol = NULL;     /* "http://" */
   STRPTR host = NULL;         /* "www.sepp.at" */
   STRPTR port = NULL;         /* ":80" */
   STRPTR path = NULL;         /* "file.html" */
   STRPTR name = NULL;         /* stuff after "#" */
   STRPTR cgiargs = NULL;      /* stuff after "?"  */
   /* STRPTR p;
    EXPSTR *tmp_uri = init_estr(32); */

   clr_estr(dest_uri);

   if (uri) {
      /* check for valid uri */
      URIKIND kind = uri_kind(uri);
      if ((kind == URI_ext) ||
            ((kind == URI_relserv) && !(estrlen(hp->server_dir)))) {
         if (kind == URI_ext) {
            /*
             * check global uri
             */
            if (!protocol) protocol = "";
            if (!host) host = "";
            if (!port) port = "";

            /*
            p = uri;
            while(*p && (':' != *p)) ++p;
            if(':' == *++p)
              if('/' == *++p)
                if('/' == *++p) {
                   while(*p && (':' != *p) && ('/' != *p)) ++p;
                }
              */

            /*
             * TODO: parse global uris
             */
#ifdef UNIX
            if(hp->checkext) check_ext_uri(hp,uri);
#endif
         } else if (kind == URI_relserv) {
            hsc_message(hp, MSG_SERVER_URI, "server relative URI to %q", uri);
         } else {
            panic("what kind of uri now?");
         }
         set_estr(dest_uri, uri);
      } else {
         /*
          * check local uri
          */

         /* destination file name that's existence is checked if
          * chkuri is enabled */
         EXPSTR *dest_fname = init_estr(32);
         STRPTR noabsuri = uri;

         /* evaluate kind of URI */
         if (kind == URI_abs)
            noabsuri += strlen(ABSURI_ID);     /* skip ":" */

         /* extract path and #name or ?args */
         if (noabsuri[0] == '#') {
            path = NULL;
            name = noabsuri + 1;    /* skip '#' for "#id" */
         } else {
            path = uri;
            name = strchr(uri, '#');
            if (name) {
               /* blank out '#' */
               name[0] = '\0';
               name++;
            } else {
#if 1
               cgiargs = NULL;
#else
               cgiargs = strchr(uri, '?');     /* TODO: conformant? */
#endif
               if (cgiargs) {
                  /* blank out '?' */
                  cgiargs[0] = '\0';
                  cgiargs += 1;
               }
            }
         }

         if (path) {
            FILE *exist = NULL;

            /*
             * check existence of local uri
             */
            conv_hscuri2fileNuri(hp, dest_uri, dest_fname, path);

            if (hp->chkuri && !(hsc_get_msg_ignore(hp, MSG_NO_URIPATH)))
            {
               exist = fopen(estr2str(dest_fname), "r");
               if (!exist) {
                  /* URIs ":" and "" won't open correctly */
                  if(('\0' != uri[0]) && (0 != strcmp(":",uri)))
                     hsc_msg_nouri(hp, estr2str(dest_fname), uri, NULL);
               } else {
                  fclose(exist);

                  /* check id */
                  if (hp->chkid && name) {
                     STRPTR doc_fname = estr2str(dest_fname);

                     if (!fnamecmp(hp->project->document->docname, doc_fname)) {
                        /* filename references current document */
                        add_local_idref(hp, name);
                     } else {
                        /* filename reference other document;
                         * lookup project-data */
                        switch (check_document_id(hp->project,
                                 doc_fname, name))
                        {
                           case ERR_CDI_OK:
                              D(fprintf(stderr, DHL "  id ok\n"));
                              break;
                           case ERR_CDI_NoID:
                              hsc_msg_unknown_id(hp, NULL, name);
                              break;
                           case ERR_CDI_NoDocumentEntry:
                              hsc_message(hp, MSG_NO_DOCENTRY,
                                    "no entry for document %q "
                                    "in project data to check %i",
                                    estr2str(dest_fname),
                                    name);
                              break;
                           default:
                              panic("unknown returncode");
                              break;
                        }
                     }   /* if fnamecmp */
                  }       /* if hp->chkid */
               }           /* if exists */
            }               /* if hp->chkuri */
         } else {
            /* check existence ID referencing into current file */
            if (hp->chkid && name)
               add_local_idref(hp, name);
         }

         /* add #name or ?args part */
         if (name) {
            app_estrch(dest_uri, '#');
            app_estr(dest_uri, name);
         } else if (cgiargs) {
            app_estrch(dest_uri, '?');
            app_estr(dest_uri, cgiargs);
         }

         /* free resources */
         del_estr(dest_fname);
      }                       /* else (rsrc) */
   }                           /* if (uri) */
}

/* $Id: uri.c,v 1.9 2004/02/05 13:42:39 mb Exp mb $ */
/* vi: set ts=4: */
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsclib/uri.h�������������������������������������������������������������������������0100600�0001750�0000144�00000003521�07732056103�014362� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001 Matthias Bethke 
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * uri.h
 *
 * functions for parsing URIs
 *
 */

#ifndef HSCLIB_URI_H
#define HSCLIB_URI_H

#define ABSURI_ID ":"

typedef enum
{
    URI_abs=0,                  /* starts with ":" */
    URI_ext,                    /* contains ":" before first "/" */
    URI_rel,                    /* no ":" */
    URI_relserv                 /* starts with "/"; server relative */
}
URIKIND;                        /* uri kinds */

/*
 * global funcs
 */
#ifndef NOEXTERN_HSCLIB_URI_H

extern VOID conv_path2uri(EXPSTR * dest, STRPTR path);
extern VOID conv_uri2path(EXPSTR * dest, STRPTR uri, BOOL weenix);

extern VOID conv_hscuri2file(HSCPRC * hp, EXPSTR * dest_fname, STRPTR uri);
extern VOID conv_hscuri2fileNuri(HSCPRC * hp, EXPSTR * dest_uri, EXPSTR * dest_fname, STRPTR uri);

extern VOID parse_uri(HSCPRC * hp, EXPSTR * dest_uri, STRPTR uri);
extern URIKIND uri_kind(STRPTR uri);

#endif /* NOEXTERN_HSCLIB_URI_H */

#endif /* HSCLIB_URI_H */

/* $Id: uri.h,v 1.2 2003/07/06 04:37:34 mb Exp mb $ */
/* vi: set ts=4: */

�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hscprj/������������������������������������������������������������������������������0040700�0001750�0000144�00000000000�10010442131�013416� 5����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hscprj/document.c��������������������������������������������������������������������0100600�0001750�0000144�00000021157�07772064313�015434� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/document.c
 *
 * document routines for hsc
 *
 * updated: 20-Feb-1997
 * created:  7-Jul-1996
 */

#include <stdio.h>
#include <string.h>

#include "hscprj/document.h"

/* debuggin define */
#ifdef D
#undef D
#endif
#if defined DEBUG
#if DEBUG
#define D(x) x
#else
#define D(x)                    /* nufin */
#endif
#else
#define D(x)                    /* nufin */
#endif

/*
 * del/new_document
 */

/* del_document: remove document */
VOID del_document(APTR data)
{
    if (data)
    {
        HSCDOC *document = (HSCDOC *) data;

        ufreestr(document->docname);
        ufreestr(document->sourcename);
        del_estr(document->title);
        del_dllist(document->iddefs);
        del_dllist(document->includes);
        del_dllist(document->references);
        ufree(document);
    }
}

/* new_document: create new document */
HSCDOC *new_document(STRPTR docname)
{
    HSCDOC *newdoc = (HSCDOC *) umalloc(sizeof(HSCDOC));

#if 0
    DP(fprintf(stderr, DHP "new document `%s'\n", docname));
#endif
    newdoc->docname = strclone(docname);
    newdoc->sourcename = NULL;
    newdoc->title = init_estr(0);
    newdoc->iddefs = init_dllist(del_iddef);
    newdoc->includes = init_dllist(del_include);
    newdoc->references = init_dllist(del_reference);

    return (newdoc);
}

/*
 * cmp_document: compare document
 */
int cmp_document(APTR cmp_data, APTR list_data)
{
    HSCDOC *document = (HSCDOC *) list_data;
    STRPTR fname1 = NULL;
    STRPTR fname2 = (STRPTR) cmp_data;

#if DEBUG
    if (!document)
    {
        panic("documant = NULL");
    }
    else if (!document->docname)
    {
        panic("fname1 = NULL");
    }
    if (!fname2)
    {
        panic("fname2 = NULL");
    }
#endif
    fname1 = document->docname;

    if (!strcmp(fname1, fname2))
    {
        return (-1);
    }
    else
    {
        return (0);
    }
}

/* find_document_node: scans document list for a specific document */
DLNODE *find_document_node(DLLIST * list, STRPTR name)
{
    return (find_dlnode(dll_first(list), (APTR) name, cmp_document));
}

/* find_document: scans document list for a specific document */
HSCDOC *find_document(DLLIST * list, STRPTR name)
{
    DLNODE *nd = find_document_node(list, name);
    HSCDOC *document = NULL;

    if (nd)
        document = (HSCDOC *) dln_data(nd);

    return (document);
}

/*
 * functions for caller
 */
CALLER *new_caller(STRPTR name, ULONG posx, ULONG posy)
{
    CALLER *caller = (CALLER *) umalloc(sizeof(CALLER));

    caller->name = strclone(name);
    caller->posx = posx;
    caller->posy = posy;

    return (caller);
}

VOID del_caller(APTR data)
{
    if (data)
    {
        CALLER *caller = (CALLER *) data;
        ufreestr(caller->name);
        ufree(caller);
    }
}

CALLER *fpos2caller(INFILEPOS * fpos)
{
    CALLER *cal = NULL;

    if (fpos)
    {
        cal = new_caller(ifp_get_fname(fpos),
                         ifp_get_x(fpos), ifp_get_y(fpos));
    }
    else
        cal = new_caller("", 0, 0);

    return (cal);
}

/*
 * functions for references
 */

/* del_reference: remove a reference */
VOID del_reference(APTR data)
{
    HSCREF *ref = (HSCREF *) data;

    ufreestr(ref->name);
    del_caller(ref->caller);
    ufree(ref);
    /* NOTE: ref->fpos is removed whith the
     * corresponding file automatically */
}

/* new_reference: create a new reference */
HSCREF *new_reference(STRPTR newname)
{
    HSCREF *ref = (HSCREF *) umalloc(sizeof(HSCREF));

    if (ref)
    {
        ref->name = strclone(newname);
        ref->caller = NULL;
    }
    return (ref);
}

/*
 * cmp_reference: compare reference
 */
int cmp_reference(APTR cmp_data, APTR list_data)
{
    HSCREF *reference = (HSCREF *) list_data;
    STRPTR fname1 = NULL;
    STRPTR fname2 = (STRPTR) cmp_data;

#if DEBUG
    if (!reference)
    {
        panic("reference = NULL");
    }
    else if (!reference->name)
    {
        panic("fname1 = NULL");
    }
    if (!fname2)
    {
        panic("fname2 = NULL");
    }
#endif
    fname1 = reference->name;

    if (!strcmp(fname1, fname2))
    {
        return (-1);
    }
    else
    {
        return (0);
    }
}

/*
 * app_reference: append new reference to reflist of a document;
 *   if reference already exists, no new ref is added
 */
HSCREF *app_reference(HSCDOC * document, STRPTR ref_name)
{
    HSCREF *ref = NULL;

    /* append new reference */
    ref = new_reference(ref_name);
    app_dlnode(document->references, (APTR) ref);
#if 0
    DP(fprintf(stderr, DHP "new reference `%s'\n", ref_name));
#endif

    return (ref);
}

/*
 * functions for includes
 */

/* del_include: remove a include */
VOID del_include(APTR data)
{
    HSCINC *inc = (HSCINC *) data;

    ufreestr(inc->name);
    del_caller(inc->caller);
    ufree(inc);
}

/* new_include: create a new include */
HSCINC *new_include(STRPTR newname)
{
    HSCINC *inc = (HSCINC *) umalloc(sizeof(HSCINC));

    if (inc)
    {
        inc->name = strclone(newname);
        inc->caller = NULL;
    }
    return (inc);
}

/*
 * cmp_include: compare include
 */
int cmp_include(APTR cmp_data, APTR list_data)
{
    HSCINC *include = (HSCINC *) list_data;
    STRPTR fname1 = NULL;
    STRPTR fname2 = (STRPTR) cmp_data;

#if DEBUG
    if (!include)
    {
        panic("include = NULL");
    }
    else if (!include->name)
    {
        panic("fname1 = NULL");
    }
    if (!fname2)
    {
        panic("fname2 = NULL");
    }
#endif
    fname1 = include->name;

    if (!strcmp(fname1, fname2))
        return (-1);
    else
        return (0);
}

/*
 * app_include: append new include to inclist of a document;
 *   even append multiple instancies of the same include
 */
HSCINC *app_include(HSCDOC * document, STRPTR inc_name)
{
    DLNODE *nd = NULL;
    /* append new include */
    HSCINC *inc = new_include(inc_name);
    nd = app_dlnode(document->includes, (APTR) inc);

    return (inc);
}

/*
 * functions for id-definitions
 */

/* del_iddef: remove an id-definition */
VOID del_iddef(APTR data)
{
    HSCIDD *iddef = (HSCIDD *) data;

    ufreestr(iddef->name);
    del_caller(iddef->caller);
    if (iddef->fpos)
        del_infilepos(iddef->fpos);
    ufree(iddef);
}

/* new_iddef: create a new id-definition */
HSCIDD *new_iddef(STRPTR newname)
{
    HSCIDD *iddef = (HSCIDD *) umalloc(sizeof(HSCIDD));

    if (iddef)
    {
        iddef->name = strclone(newname);
        iddef->caller = NULL;
        iddef->fpos = NULL;
    }
    return (iddef);
}

/*
 * debugging printf functions
 */
VOID prt_iddef(FILE * stream, APTR data)
{
    HSCIDD *iddef = (HSCIDD *) data;
    INFILEPOS *fpos = iddef->fpos;

    fprintf(stream, "`%s' at (%lu,%lu)\n",
            iddef->name, ifp_get_y(fpos), ifp_get_x(fpos));
}

/*
 * cmp_iddef: compare id-definition
 */
int cmp_iddef(APTR cmp_data, APTR list_data)
{
    HSCIDD *iddef = (HSCIDD *) list_data;
    STRPTR fname1 = NULL;
    STRPTR fname2 = (STRPTR) cmp_data;

#if DEBUG
    if (!iddef)
    {
        panic("id-definition = NULL");
    }
    else if (!iddef->name)
    {
        panic("fname1 = NULL");
    }
    if (!fname2)
    {
        panic("fname2 = NULL");
    }
#endif
    fname1 = iddef->name;

    if (!strcmp(fname1, fname2))
    {
        return (-1);
    }
    else
    {
        return (0);
    }
}

/* find_iddef: scans document list for a specific id */
HSCIDD *find_iddef(HSCDOC * document, STRPTR name)
{
    DLNODE *nd = find_dlnode(dll_first(document->iddefs),
                             (APTR) name, cmp_iddef);
    HSCIDD *iddef = NULL;

    if (nd)
    {
        iddef = (HSCIDD *) dln_data(nd);
    }

    return (iddef);
}

/*
 * app_iddef: append new id-definition to iddef-list of a document
 */
HSCIDD *app_iddef(HSCDOC * document, STRPTR iddef_name)
{
    HSCIDD *iddef = NULL;

    /* append new id-definition */
    iddef = new_iddef(iddef_name);
    app_dlnode(document->iddefs, (APTR) iddef);
#if 0
    DP(fprintf(stderr, DHP "new id-definition `%s'\n", iddef_name));
#endif

    return (iddef);
}
�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hscprj/document.h��������������������������������������������������������������������0100600�0001750�0000144�00000006731�07772064313�015442� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsclib/document.h
 *
 * document managment routines for hsc
 *
 */

#ifndef HSCPRJ_DOCUMENT_H
#define HSCPRJ_DOCUMENT_H

#include "hsclib/ldebug.h"

#include "ugly/utypes.h"
#include "ugly/dllist.h"
#include "ugly/expstr.h"
#include "ugly/umemory.h"
#include "ugly/ustring.h"
#include "ugly/infile.h"

/* document structure */
typedef struct document_node {
    STRPTR docname;             /* document name */
    STRPTR sourcename;          /* main sourcefile name */
    EXPSTR *title;              /* title specified with <TITLE> */
    DLLIST *iddefs;             /* list of IDs defined in this file */
    DLLIST *includes;           /* list of included files */
    DLLIST *references;         /* list of docs/images/.. references
                                 *   within this document */
    ULONG  flags;               /* document flags */
} HSCDOC;

/* document flags */
#define DF_INFO_IDDEF     (1<<0)
#define DF_CALL_IDDEF     (1<<1)
#define DF_INFO_REFERENCE (1<<2)
#define DF_CALL_REFERENCE (1<<3)
#define DF_INFO_INCLUDE   (1<<4)
#define DF_CALL_INCLUDE   (1<<5)

/* caller structure */
typedef struct caller_node {
    STRPTR name;
    ULONG posx;
    ULONG posy;
} CALLER;

/* reference structure */
typedef struct reference_node {
    STRPTR name;
    CALLER *caller;
} HSCREF;

/* include structure */
typedef struct include_node {
    STRPTR name;
    CALLER *caller;
} HSCINC;

/* id-definition structure */
typedef struct iddef_node {
    STRPTR name;
    CALLER *caller;
    INFILEPOS *fpos; /* only used by local IDs for error-position */
} HSCIDD;

extern CALLER *new_caller(STRPTR fname, ULONG posx, ULONG posy);
extern VOID del_caller(APTR data);
extern CALLER *fpos2caller(INFILEPOS * fpos);

extern HSCDOC *new_document(STRPTR docname);
extern VOID del_document(APTR data);
extern int cmp_document(APTR cmp_data, APTR list_data);
extern DLNODE *find_document_node(DLLIST *list, STRPTR name);
extern HSCDOC *find_document(DLLIST * list, STRPTR name);

extern VOID del_reference(APTR data);
extern HSCREF *new_reference(STRPTR newname);
extern int cmp_reference(APTR cmp_data, APTR list_data);
extern HSCREF *app_reference(HSCDOC * document, STRPTR ref_name);

extern VOID del_include(APTR data);
extern HSCINC *new_include(STRPTR newname);
extern int cmp_include(APTR cmp_data, APTR list_data);
extern HSCINC *app_include(HSCDOC * document, STRPTR inc_name);

extern VOID del_iddef(APTR data);
extern HSCIDD *new_iddef(STRPTR newname);
extern VOID prt_iddef(FILE * stream, APTR data);
extern int cmp_iddef(APTR cmp_data, APTR list_data);
extern HSCIDD *app_iddef(HSCDOC * document, STRPTR iddef_name);
extern HSCIDD *find_iddef(HSCDOC * document, STRPTR name);

#endif /* HSCPRJ_DOCUMENT_H */

���������������������������������������hsc-0.934.orig/hscprj/license.c���������������������������������������������������������������������0100600�0001750�0000144�00000003707�07772064313�015241� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscprj/license.c
 *
 * routines to display license
 *
 * updated:  6-Jan-1998
 * created: 17-Nov-1996
 */

#include <stdio.h>

#include "ugly/utypes.h"

STRPTR hsc_license =            /* the usual boring text */
"\nThis program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation; either version 2 of the License, or\n"
"(at your option) any later version.\n\n"

"This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
"GNU General Public License for more details.\n\n"

"You should have received a copy of the GNU General Public License\n"
"along with this program; if not, write to the Free Software\n"
"Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n\n"

/* support w3page */
"For support, visit `http://www.linguistik.uni-erlangen.de/~msbethke/software.html'.\n\n"
;



/*
 * show_license
 *
 * display short description of GNU GPL
 */
VOID show_license(VOID)
{
    fprintf(stderr, hsc_license);
}

���������������������������������������������������������hsc-0.934.orig/hscprj/license.h���������������������������������������������������������������������0100600�0001750�0000144�00000001772�07772064313�015246� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscprj/license.h
 *
 * routines to show license
 *
 */

#ifndef HSCPRJ_LICENSE_H
#define HSCPRJ_LICENSE_H

extern STRPTR hsc_license;
extern VOID show_license(VOID);

#endif /* HSCPRJ_LICENSE_H */

������hsc-0.934.orig/hscprj/pdebug.h����������������������������������������������������������������������0100600�0001750�0000144�00000002476�07772064314�015075� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscprj/pdebug.h
 *
 * debugging defines for hsc's project-functions
 */

#ifndef HSCPRJ_PDEBUG_H
#define HSCPRJ_PDEBUG_H

#include "hsclib/ldebug.h"

/* this debugging info is displayed only
 * if the  switch "-debug" has been enabled
 */

/* debugging control */
#define DEBUG_PRJ 1

/* debugging define */
#if (DEBUG & DEBUG_PRJ)
#define DP(x) if ( hp->debug ) x
#else
#define DP(x)                 /* nufin */
#endif

/* debug message prefix for hscprj-modules */
#define DHP "*hscprj* "

#endif /* HSCPRJ_PDEBUG_H */

��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hscprj/pdefs.h�����������������������������������������������������������������������0100600�0001750�0000144�00000004043�07772064314�014720� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001 Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscprj/pdefs.h
 *
 * project-managment-defines for hsc
 *
 */

/*
 * project_file:
 *
 * line 1  : "HSC_PROJECT"                   to identify prokect file
 * line 2  : "VERSION x"                     file format version
 * comments: "# xxx"                         some comment lines
 *
 * fileinfo: "DOCUMENT"   len uri            document
 *                                           start document-info block
 *           "SOURCE"     len file           hsc-source used to create
 *                                           this document
 *           "TITLE"      len title          document title
 *           "ID"         len idname         ID defined in this doc.
 *           "INCLUDE     len file"          file included during
 *                                           processing this document
 */

/*
 * IDs in project file
 */
#define FILEID_HSCPRJ    "HSC_PROJECT"
#define VERSION_HSCPRJ   3

#define LINE_VERSION_STR  "VERSION"
#define LINE_REM_STR      "#"

#define LINE_DOCUMENT_STR  "DOCUMENT"
#define LINE_SOURCE_STR    "SOURCE"
#define LINE_TITLE_STR     "TITLE"
#define LINE_ID_STR        "ID"
#define LINE_INCLUDE_STR   "INCLUDE"
#define LINE_REFERENCE_STR "REFERENCE"

#define ID_CALLER_STR "FROM"

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hscprj/project.c���������������������������������������������������������������������0100600�0001750�0000144�00000013762�07772064314�015270� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscprj/project.c
 *
 * project managment routines for hsc
 *
 * updated: 12-Jan-1997
 * created: 13-Apr-1996
 */

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <time.h>

#include "hsclib/ldebug.h"
#include "hscprj/pdebug.h"

#include "ugly/utypes.h"
#include "ugly/dllist.h"
#include "ugly/expstr.h"
#include "ugly/umemory.h"
#include "ugly/infile.h"
#include "ugly/ustring.h"

#include "hscprj/document.h"
#include "hscprj/project.h"

/*
 * new_project
 */
HSCPRJ *new_project(VOID)
{
    HSCPRJ *hp = (HSCPRJ *) umalloc(sizeof(HSCPRJ));

    if (hp)
    {
        memset(hp, 0, sizeof(HSCPRJ));
        hp->documents = init_dllist(del_document);
    }

    return (hp);
}


/*
 * del_project
 */
VOID del_project(HSCPRJ * hp)
{
    if (hp)
    {
        del_dllist(hp->documents);
        del_document(hp->document);
        ufree(hp);
    }
}


/*
 * check_document_id
 *
 * append id to id_ref-list so it as checked when
 * check_all_local_id_ref() is called
 */
int check_document_id(HSCPRJ * hp, STRPTR docname, STRPTR id)
{
    int err = ERR_CDI_OK;
    HSCDOC *document = find_document(hp->documents, docname);

    DP(fprintf(stderr, DHP "  check id: `%s#%s'\n", docname, id));

    if (document)
    {
        HSCIDD *iddef = NULL;

        iddef = find_iddef(document, id);
        if (!iddef)
        {
            DP(fprintf(stderr, DHP "    id unknown\n"));
            err = ERR_CDI_NoID;
        }
        else
        {
            DP(fprintf(stderr, DHP "    id ok\n"));
            err = ERR_CDI_OK;
        }
    }
    else
    {
        DP(fprintf(stderr, DHP "    no file-entry in project\n"));
        err = ERR_CDI_NoDocumentEntry;
    }

    return (err);
}

/*
 * hsc_project_set_filename
 *
 * set project-filename (used by hsc_project_write_file())
 */
BOOL hsc_project_set_filename(HSCPRJ * hp, STRPTR new_prjname)
{
    BOOL ok = TRUE;
    DP(fprintf(stderr, DHP "set project `%s'\n", new_prjname));

    if (hp->document->sourcename)
    {
        panic("project-name already set");
    }

    hp->document->sourcename = strclone(new_prjname);

    return (ok);
}

/*
 * hsc_project_add_document
 *
 * add current document to project
 */
BOOL hsc_project_add_document(HSCPRJ * hp)
{
    BOOL ok = TRUE;

    if (hp->document)
    {
        if (hp->document->docname)
        {
            DP(fprintf(stderr, DHP "  add document `%s'\n",
                       hp->document->docname));
            app_dlnode(hp->documents, hp->document);
        }
        else
        {
            DP(fprintf(stderr, DHP "  add document <stdout>: skipped\n"));
            del_document(hp->document);
        }

        hp->document = NULL;
    }
    else
    {
        panic("no document to replace");
    }

    return (ok);
}

/*
 * hsc_project_del_document
 *
 * remove document from project
 */
BOOL hsc_project_del_document(HSCPRJ * hp, STRPTR docname)
{
    BOOL deleted = FALSE;
    DLNODE *docnd = find_document_node(hp->documents, docname);

    if (docnd)
    {
        DP(fprintf(stderr, DHP "  remove document `%s'\n", docname));
        del_dlnode(hp->documents, docnd);
        deleted = TRUE;
    }
    else
    {
        DP(fprintf(stderr, DHP "  remove document `%s': FAILED\n", docname));
    }

    return (deleted);
}

/*
 * hsc_project_set_document
 *
 * Remove document from project's document list and
 * create a new empty document with this name and
 * make it the current document of the project.
 * The new document is added to the project when the
 * project-file is updated.
 */
BOOL hsc_project_set_document(HSCPRJ * hp, STRPTR new_docname)
{
    BOOL ok = TRUE;
    DLNODE *nd = NULL;
    if (new_docname)
    {
        DP(fprintf(stderr, DHP "set document `%s'\n", new_docname));

        /* dettach document from project */
        nd = find_document_node(hp->documents, new_docname);
        if (nd)
        {
            DP(fprintf(stderr, DHP "  remove old document `%s'\n",
                       ((HSCDOC *) dln_data(nd))->docname));
            del_dlnode(hp->documents, nd);
        }
        else
        {
            DP(fprintf(stderr, DHP "  new document `%s'\n", new_docname));
        }
    }
    else
    {
        DP(fprintf(stderr, DHP "set document <stdout>\n"));
    }

    /* remove current document */
    if (hp->document)
    {
        DP(fprintf(stderr, DHP "  remove current document `%s'\n",
                   hp->document->docname));
        del_document(hp->document);
    }

    hp->document = new_document(new_docname);

    return (ok);
}

/*
 * hsc_project_set_source
 *
 * set main source for project's current document
 */
BOOL hsc_project_set_source(HSCPRJ * hp, STRPTR new_sourcename)
{
    BOOL ok = TRUE;
    DP(fprintf(stderr, DHP "set source `%s'\n", new_sourcename));

    if (!hp->document->sourcename)
        hp->document->sourcename = strclone(new_sourcename);
    else
    {
        panic("sourcename already set");
        ok = FALSE;
    }

    return (ok);
}

/*
 * hsc_project_add_include
 *
 * add include-file to project's current document
 */
BOOL hsc_project_add_include(HSCPRJ * hp, STRPTR new_includename)
{
    BOOL ok = TRUE;
    DP(fprintf(stderr, DHP "add include `%s'\n", new_includename));
    app_include(hp->document, new_includename);
    return (ok);
}
��������������hsc-0.934.orig/hscprj/project.h���������������������������������������������������������������������0100600�0001750�0000144�00000004545�07772064344�015277� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscprj/project.h
 *
 * project managment routines for hsc
 *
 */

#ifndef HSCPRJ_PROJECT_H
#define HSCPRJ_PROJECT_H
#include "hscprj/document.h"

/*
 * project-structure
 */
typedef struct hscproject
{
    HSCDOC *document;           /* current document */
    DLLIST *documents;          /* other documents */
    INFILE *inpf;
    BOOL debug;
    BOOL fatal;
    APTR user_data;             /* user data; hsclib assigns the current
                                 * hsc-process to it */

    /* callbacks */
      VOID(*CB_msg_unknown_id) (struct hscproject * hp,
                                STRPTR document, STRPTR id);
      VOID(*CB_msg_corrupt_pf) (struct hscproject * hp, STRPTR reason);
}
HSCPRJ;

/* return-codes for check_document_id */
#define ERR_CDI_OK              0
#define ERR_CDI_NoID            1
#define ERR_CDI_NoDocumentEntry 2

extern int check_document_id(HSCPRJ * hp, STRPTR docname, STRPTR id);

extern HSCPRJ *new_project( VOID );
extern VOID del_project(HSCPRJ *hp);

extern BOOL hsc_project_read_data(HSCPRJ * hp, INFILE * inpf);
extern BOOL hsc_project_write_data(HSCPRJ * hp, STRPTR project_fname, BOOL force);

extern BOOL hsc_project_add_document(HSCPRJ *hp);
extern BOOL hsc_project_del_document(HSCPRJ * hp, STRPTR docname);

extern BOOL hsc_project_set_filename( HSCPRJ *hp, STRPTR new_prjname);
extern BOOL hsc_project_set_document( HSCPRJ *hp, STRPTR new_docname);
extern BOOL hsc_project_set_source( HSCPRJ *hp, STRPTR new_sourcename);
extern BOOL hsc_project_add_include( HSCPRJ *hp, STRPTR new_includename);

#endif /* HSCPRJ_PROJECT_H */

�����������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hscprj/readprj.c���������������������������������������������������������������������0100600�0001750�0000144�00000026164�07772064314�015251� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscprj/readprj.c
 *
 * project managment input-routines for hsc
 *
 * updated: 17-Dec-1997
 * created: 10-Sep-1996
 */

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <time.h>

#include "hsclib/ldebug.h"
#include "hscprj/pdebug.h"
#include "hscprj/pdefs.h"

#include "ugly/utypes.h"
#include "ugly/dllist.h"
#include "ugly/expstr.h"
#include "ugly/umemory.h"
#include "ugly/infile.h"
#include "ugly/ustring.h"

#include "hscprj/document.h"
#include "hscprj/project.h"

/*
 * hsc_msg_project_corrupt: display error message about
 * corrupt project file
 */
static VOID hsc_msg_project_corrupt(HSCPRJ * hp, STRPTR descr)
{
    hp->fatal = TRUE;
    if (hp->CB_msg_corrupt_pf)
        (*(hp->CB_msg_corrupt_pf)) (hp, descr);
}

/* convert hex-digit to int */
static int x2int(char c)
{
    if ((c >= '0') && (c <= '9'))
        return (c - '0');
    if ((c >= 'A') && (c <= 'F'))
        return (c - 'A' + 10);
    if ((c >= 'a') && (c <= 'f'))
        return (c - 'a' + 10);
    return (EOF);
}

/*
 * read_long: read (unsigned) long integer value
 */
static ULONG read_ulong(HSCPRJ * hp)
{
    INFILE *inpf = hp->inpf;
    ULONG num = 0;
    int ch;
    int digit = EOF;

    do
    {
        ch = infgetc(inpf);
        if (ch != ' ')
        {
            digit = x2int((char)ch);
            if (digit == EOF)
                num = 0;
            else
                num = (num << 4) + digit;
        }
        if (digit == EOF)
            hsc_msg_project_corrupt(hp, "hex digit expected");
    }
    while ((digit != EOF) && (ch != ' '));

    if (digit == EOF)
        num = 0;

    return (num);
}

/*
 * read_string:
 *
 * read string length, alloc mem and read string into it
 */
static STRPTR read_string(HSCPRJ * hp, BOOL len_format) {
    STRPTR dest = NULL;
    ULONG len;

    if(!len_format) {
      STRPTR s;
      s = infreadtoeol(hp->inpf);
      inungetc(0x0a,hp->inpf);
      return s;
    }

    len = read_ulong(hp);
    if (len) {
        ULONG i;
        int ch = 'x';           /* dummy init */

        /* alloc mem */
        dest = umalloc((size_t) (len + 1));
        dest[len] = '\0';

        for (i = 0; ((i < len) && (ch != EOF)); i++) {
            ch = infgetc(hp->inpf);
            if (ch != EOF)
                dest[i] = ch;
            else
                hsc_msg_project_corrupt(hp, "string expected");
        }
        if (ch != EOF)
            dest[len] = 0;
        else {
            ufree(dest);
            dest = NULL;
        }
    }
    return (dest);
}

/*
 * read_caller: read file position
 */
static CALLER *read_caller(HSCPRJ * hp, BOOL v2format) {
    CALLER *caller = NULL;
    STRPTR callerid = infgetw(hp->inpf);

    if (callerid && !upstrcmp(callerid, ID_CALLER_STR)) {
        int ch = infgetc(hp->inpf);     /* skip blank */

        if (ch == ' ') {
            STRPTR fname = read_string(hp,v2format);
            caller = new_caller(fname, read_ulong(hp), read_ulong(hp));
            ufreestr(fname);
        } else
            hsc_msg_project_corrupt(hp, "blank expected");
    } else if (callerid && !strcmp(callerid, "\n")) {
        /* skip empty caller */
        inungetcw(hp->inpf);
        DP(fprintf(stderr, DHP "skip EMPTY CALLER\n"));
    }
    return caller;
}

/*
 * read_lf: read linefeed
 */
static BOOL read_lf(HSCPRJ * hp) {
    int ch = infgetc(hp->inpf);
    BOOL ok = TRUE;

    if (ch != '\n') {
        hsc_msg_project_corrupt(hp, "linefeed expected");
        ok = FALSE;
    }
    return (ok);
}

/*
 * read command
 *
 * returns next command or NULL if eof reached
 */
static STRPTR read_command(HSCPRJ * hp) {
    STRPTR command;

    do
        command = infgetw(hp->inpf);
    while (command && !strcmp(command, "\n"));

    if (command) {
        /* skip blanks */
        infskip_ws(hp->inpf);
        DP(fprintf(stderr, DHP "command `%s'\n", command));
    } else
        DP(fprintf(stderr, DHP "command EOF\n"));

    return (command);
}

/*
 * read header
 */
static int read_header(HSCPRJ * hp) {
    STRARR fileid[1 + sizeof(FILEID_HSCPRJ)];
    BOOL ok = FALSE;
    STRPTR cmd = NULL;
    ULONG version=0;
    size_t i;

    /* read fileid */
    for (i = 0; i < strlen(FILEID_HSCPRJ); i++) {
        int ch = infgetc(hp->inpf);

        fileid[i] = (UBYTE) ch;
    }
    fileid[i] = '\0';

    DP(fprintf(stderr, DHP "fileid: `%s'\n", fileid));

    /* check fileid */
    if (!strcmp(fileid, FILEID_HSCPRJ)) {
        DP(fprintf(stderr, DHP "fileid: `%s'\n", fileid));
        ok = read_lf(hp);
    } else
        hsc_msg_project_corrupt(hp, "wrong file-id");

    if (ok) {

        ok = FALSE;

        /* read version */
        cmd = read_command(hp);

        /* check version */
        if (cmd && !strcmp(cmd, LINE_VERSION_STR)) {
            version = read_ulong(hp);

            DP(fprintf(stderr, DHP "version: %lu\n", version));

            if (version && (version <= 3))
                ok = read_lf(hp);
            else
                hsc_msg_project_corrupt(hp, "wrong version");
        } else
            hsc_msg_project_corrupt(hp, "unknown version");
    }
    return (int)(ok ? version : 0UL);
}


/*
 * hsc_project_read_data
 *
 * read project file
 *
 * params: hp....HSCPRJ created using new_project()
 *         inpf..input file opened using infopen();
 *               this has to be opened and closed by
 *               you outside this function.
 */
BOOL hsc_project_read_data(HSCPRJ * hp, INFILE * inpf) {
    BOOL ok = FALSE;
    BOOL v2format;

    if (inpf) {
        int version;
        
        hp->inpf = inpf;

        DP(fprintf(stderr, DHP "read project-file from `%s'\n",
                     infget_fname(inpf)));

        if (0 != (version = read_header(hp))) {
            HSCDOC *document = NULL;
            STRPTR cmd = NULL;

            v2format = (BOOL)(version <= 2);
            do {
                cmd = read_command(hp);
                DP(fprintf(stderr,"HSC READ CMD: '%s'\n",cmd);)
                if (cmd) {
                    if (!strcmp(cmd, LINE_REM_STR)) {
                        /* skip comment */
                        int ch;
                        DP(fprintf(stderr, DHP "comment `"));
                        do {
                            ch = infgetc(inpf);
                            DP(
                                    {
                                    if (ch != '\n')
                                    fprintf(stderr, "%c", ch);
                                    }
                            )
                        } while ((ch != EOF) && (ch != '\n'));
                        DP(fprintf(stderr, "'\n"));
                    } else if (!strcmp(cmd, LINE_DOCUMENT_STR)) {
                        /* begin new DOCUMENT */
                        STRPTR docname = read_string(hp,v2format);
                        if (docname) {
                            document = new_document(docname);
                            app_dlnode(hp->documents, (APTR) document);
                            /* free mem allocated by read_string() */
                            ufree(docname);
                        }
                    } else if (!strcmp(cmd, LINE_SOURCE_STR)) {
                        /* assign SOURCE */
                        if (document) {
                            STRPTR sourcename = read_string(hp,v2format);
                            if (sourcename) {
                                reallocstr(&(document->sourcename),
                                           sourcename);
                                /* free mem allocated by read_string() */
                                ufree(sourcename);
                            }
                        } else
                            hsc_msg_project_corrupt
                                (hp, LINE_SOURCE_STR " without "
                                 LINE_DOCUMENT_STR);
                    } else if (!strcmp(cmd, LINE_TITLE_STR)) {
                        /* assign TITLE */
                        if (document) {
                            STRPTR titlename = read_string(hp,v2format);
                            if (titlename) {
                                set_estr(document->title, titlename);
                                /* free mem allocated by read_string() */
                                ufree(titlename);
                            }
                        } else
                            hsc_msg_project_corrupt
                                (hp, LINE_TITLE_STR " without "
                                 LINE_DOCUMENT_STR);
                    } else if (!strcmp(cmd, LINE_ID_STR)) {
                        /* append new ID */
                        if (document) {
                            STRPTR idname = read_string(hp,v2format);
                            if (idname) {
                                HSCIDD *iddef =
                                app_iddef(document, idname);
                                iddef->caller = read_caller(hp,v2format);
                                /* free mem allocated by read_string() */
                                ufree(idname);
                            }
                        } else
                            hsc_msg_project_corrupt
                                (hp, LINE_ID_STR " without "
                                 LINE_DOCUMENT_STR);

                    } else if (!strcmp(cmd, LINE_INCLUDE_STR)) {
                        /* store new INCLUDE */
                        if (document) {
                            STRPTR incname = read_string(hp,v2format);
                            if (incname) {
                                HSCINC *inc =
                                app_include(document, incname);
                                inc->caller = read_caller(hp,v2format);
                                /* free mem allocated by read_string() */
                                ufree(incname);
                            }
                        } else
                            hsc_msg_project_corrupt
                                (hp, LINE_INCLUDE_STR " without "
                                 LINE_DOCUMENT_STR);
                    } else
                        /* unknown command */
                        hsc_msg_project_corrupt(hp, "unknown tag");
                } else
                    DP(fprintf(stderr, DHP "EOF\n"));
            } while (cmd && !hp->fatal);
            ok = !hp->fatal;
        }
        hp->inpf = NULL;
    }

    return (ok);
}

/* vi: set ts=2 sw=2 expandtab: */
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hscprj/writeprj.c��������������������������������������������������������������������0100600�0001750�0000144�00000021677�07772064314�015474� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 * Copyright (C) 2001 Matthias Bethke
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscprj/writeprj.c
 *
 * project-managment output-routines for hsc
 *
 * updated: 28-Mar-1997
 * created: 10-Sep-1996
 */

#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <time.h>

#include "hsclib/ldebug.h"
#include "hscprj/pdebug.h"
#include "hscprj/pdefs.h"

#include "ugly/utypes.h"
#include "ugly/dllist.h"
#include "ugly/expstr.h"
#include "ugly/umemory.h"
#include "ugly/infile.h"
#include "ugly/ustring.h"

#include "hscprj/document.h"
#include "hscprj/project.h"

#define TIMEBUFSIZE 40
static STRARR timebuf[TIMEBUFSIZE];

/*
 *-------------------------------------
 * write project file
 *-------------------------------------
 */

/*
 * hsc_project_write_data
 *
 * write ids to file
 */
static VOID append_ulong(EXPSTR * dest, ULONG num)
{
    STRARR lenbuf[20];

    sprintf(lenbuf, "%lx ", num);
    app_estr(dest, lenbuf);
}

static VOID append_string(EXPSTR * dest, STRPTR s)
{
/*    append_ulong(dest, (ULONG) strlen(s)); */
    app_estr(dest, s);
}

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
}

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");
}

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");
    }
}

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");
    }
}

#if 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");
}
#endif

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
}

#if 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
}
#endif

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");
}

/*
 * 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');
}

/* append included files */
static VOID append_doc_includes(EXPSTR * prjstr, DLLIST * inclist)
{
    DLNODE *nd = dll_first(inclist);
    while (nd)
    {
        append_include(prjstr, (HSCINC *) dln_data(nd));
        nd = dln_next(nd);
    }
}

/* append other documents referered */
#if 0
static VOID append_doc_references(EXPSTR * prjstr, DLLIST * reflist)
{
    DLNODE *nd = dll_first(reflist);
    while (nd)
    {
        append_reference(prjstr, (HSCREF *) dln_data(nd));
        nd = dln_next(nd);
    }
}
#endif

/* append ids defined within documents */
static VOID append_doc_iddefs(EXPSTR * prjstr, DLLIST * iddefs)
{
    DLNODE *nd = dll_first(iddefs);
    while (nd)
    {
        append_iddef(prjstr, (HSCIDD *) dln_data(nd));
        nd = dln_next(nd);
    }
}

/* append all document-related data */
static VOID append_document(EXPSTR * prjstr, HSCDOC * document)
{
    STRPTR docname = document->docname;

    append_docname(prjstr, docname);
    append_sourcename(prjstr, document->sourcename);
    append_title(prjstr, estr2str(document->title));

    append_doc_iddefs(prjstr, document->iddefs);
    append_doc_includes(prjstr, document->includes);
#if 0
    append_doc_references(prjstr, document->references);
#endif
}

/****** hscprj.lib/hsc_project_write_data ************************************
*
*   NAME
*       hsc_project_write_data -- store project data in a file
*
*   SYNOPSIS
*       ok = hsc_project_write_data( project, filename, force )
*
*       BOOL hsc_project_write_data
*            ( HSCPRJ * project, STRPTR filename, BOOL force )
*
*   FUNCTION
*       Store all project data in a file. If the file already exists, it
*       will be overwritten without asking back.
*
*   INPUTS
*       project  - project data
*       filename - filename of project file
*       force    - write data even if no new documents have been atteched;
*                  enable this, if e.g. you only have removed some documents
*
*   RESULT
*       ok - TRUE, if file could have been written successfully
*
*   EXAMPLE
*       ok = hsc_project_write_data( project, "sepp.project", FALSE );
*
*   SEE ALSO
*
*
******************************************************************************
*/
BOOL hsc_project_write_data(HSCPRJ * hp, STRPTR project_fname, BOOL force)
{
    BOOL written = FALSE;

    if (hp && !hp->fatal && project_fname)
    {
        EXPSTR *prjstr = init_estr(256);
        DLNODE *nd = NULL;
        FILE *outfile = NULL;
        BOOL write_it = force; /* really write it? */

        DP(fprintf(stderr, DHP "update project file `%s'\n",
                   project_fname));

        /* append header information */
        append_header(prjstr);

        if ((hp->document) && (hp->document->docname))
        {
            /* append current document to project */
            hsc_project_add_document(hp);

            /* now it needs an update.. */
            write_it = TRUE;
        }

        if (write_it)
        {
            /*
             * append all old project info of other files
             */
            nd = dll_first(hp->documents);
            while (nd)
            {
                HSCDOC *document = (HSCDOC *) nd->data;

                append_document(prjstr, document);

                nd = dln_next(nd);
            }

            DP(fprintf(stderr, DHP "project file contains:\n%s", estr2str(prjstr)));

            /* write new project file */
            errno = 0;
            outfile = fopen(project_fname, "w");
            if (outfile)
            {
                errno = 0;
                fwrite(estr2str(prjstr), sizeof(char),
                       estrlen(prjstr), outfile);

                if (errno)
                {
                    DP(fprintf(stderr, DHP "can't write project file\n"));
                    /* TODO: show message "can't write project file" */
                }
                else
                    written = TRUE;
            }
            else
            {
                DP(fprintf(stderr, DHP "can't open project file for output\n"));
                /* TODO: show message "can't open project file" */
            }
        }
        else
        {
            DP(fprintf(stderr, DHP "  no document or docname to add\n"));
            del_document(hp->document);
            hp->document = NULL;
        }

        del_estr(prjstr);
    }
    else
    {
        D(fprintf(stderr, DHP "no update project\n"));
    }

    return (written);
}
�����������������������������������������������������������������hsc-0.934.orig/hsctools/����������������������������������������������������������������������������0040700�0001750�0000144�00000000000�10010442131�013763� 5����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsctools/all_depp.c������������������������������������������������������������������0100600�0001750�0000144�00000001514�07732056117�015735� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
#include "hsctools/hscdepp.c"
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsctools/all_pitt.c������������������������������������������������������������������0100600�0001750�0000144�00000001514�07732056117�015765� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
#include "hsctools/hscpitt.c"
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsctools/depp_rev.h������������������������������������������������������������������0100600�0001750�0000144�00000002403�07732056117�015764� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#define STRINGIFY(x) _STRINGIFY(x)
#define _STRINGIFY(x) #x

#define VERSION		1
#define REVISION	4
#define DATE	"17.11.01"
#define TIME	"20:22:17"

#define __VSTR STRINGIFY(VERSION)
#define __RSTR STRINGIFY(REVISION)

#define PRGNAME	"hscdepp"
#define VERS	PRGNAME __VSTR "." __RSTR
#define VSTRING	PRGNAME __VSTR "." __RSTR DATE "\r\n"
#define VERSTAG	"\0$VER: " PRGNAME  __VSTR "." __RSTR DATE
#define BASENAME "HSCDEPP"
#define VSTR	PRGNAME __VSTR "." __RSTR DATE

�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsctools/hscdepp.c�������������������������������������������������������������������0100600�0001750�0000144�00000041666�07732056117�015617� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hsctools/hscdepp.c
 *
 * hsc dependency procreator
 *
 * updated: 28-Mar-1997
 * created:  8-Jul-1996
 */

/* ANSI includes */
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <time.h>

/* include revision data */
#include "hsctools/depp_rev.h"

/* ugly includes */
#include "ugly/ustring.h"
#include "ugly/dllist.h"
#include "ugly/expstr.h"
#include "ugly/infile.h"
#include "ugly/uargs.h"
#include "ugly/prginfo.h"
#include "ugly/returncd.h"

/* hsclib includes */
#include "hscprj/document.h"
#include "hscprj/project.h"
#include "hscprj/license.h"

#ifdef AMIGA
/* AmigaOS version string
 * (imported from "hscdepp_rev.h")
 */
static const STRPTR AmigaOS_version = VERSTAG;
#endif

/* prefix for messages */
#define HD ""
#define DHD "*hscdep* "
#define SHIT "*** "             /* prefix for total failure */

/* debugging define */
#ifdef DEBUG
#undef DEBUG
#define DEBUG 1
#endif

#ifdef D
#undef D
#endif

#if DEBUG
#define D(x) if (debug) {x;}
#else
#define D(x) {/*nufin*/}
#endif

/* step-sizes for input-file/depency-string */
#define CHUNKSIZE_INPUTFILE (64*1024)
#define CHUNKSIZE_DEPENDSTR (16*1024)

/* default parameters */
#define DEFAULT_PROJECT "hsc.project"   /* project-filename */
#define DEFAULT_NAMEALL "all_hsc"       /* "all"-rule */

/* size of buffer for fgets() */
#define MAXBUFSIZE 1024

#define STR_DEPENDS_PRECEDE \
    "# --- DO NOT MODIFY THIS LINE -- hsc-dependencies precede ---\n"
#define STR_DEPENDS_FOLLOW \
    "# --- DO NOT MODIFY THIS LINE -- hsc-dependencies follow ---\n"

/*
 * global vars
 */
static int return_code = RC_FAIL;       /* exit code of program */

static STRPTR makefile = NULL;
static STRPTR prjfile = NULL;
static STRPTR nameall = NULL;
static BOOL verbose = FALSE;
static BOOL nobackup = FALSE;
static BOOL notaglines = FALSE;
static BOOL debug = FALSE;

static EXPSTR *lines_precede = NULL;
static EXPSTR *lines_follow = NULL;
static EXPSTR *lines_depend = NULL;

static HSCPRJ *project = NULL;

/*
 * cleanup: free all resources
 * (called in any case)
 */
static VOID cleanup(VOID)
{
    D(fprintf(stderr, "(cleanup)\r"));
    del_project(project);
    del_estr(lines_precede);
    del_estr(lines_follow);
    del_estr(lines_depend);
    D(fprintf(stderr, "         "));
}

static VOID set_return_code(int new_code)
{
    if (new_code > return_code)
        return_code = new_code;
}

/*
 * hsc_nomem_handler
 *
 * called from ugly/umalloc, if malloc() did return NULL
 */
static BOOL hscdepp_nomem_handler(size_t size)
{
    fputs(SHIT "out of memory\n", stderr);

    return_code = RC_FAIL;

    exit(return_code);

    return (FALSE);             /* immediatly abort */
}

VOID msg_corrupt_pf(HSCPRJ * hp, STRPTR reason)
{
    fprintf(stderr, "project-file corrupt: %s\n", reason);
}

/*
 * args_ok
 *
 * prepare args, check & parse user args, display error and
 * help message if neccessary
 *
 * result: TRUE, if all args ok and no request for HELP or
 *         LICENSE has been detected
 */
static BOOL args_ok(int argc, char *argv[])
{
    struct arglist *hscdepp_args;       /* argument structure */
    BOOL arg_help = FALSE;
    BOOL arg_license = FALSE;
    BOOL ok = FALSE;

    /* create arg-table */
    hscdepp_args = prepare_args
        ("HSCDEPP_ARGS",
         "FILE/T", &makefile, "makefile to update",
         "PRJFILE/T/K", &prjfile, "project file",
         "NAMEALL/T/K", &nameall, "name for `all_hsc' rule",
         "VERBOSE/S", &verbose, "verbose output",
         "NOBACKUP/S", &nobackup, "do not backup makefile",
         "NOTAGLINES/S", ¬aglines, "do not write taglines",
         "-DEBUG/S", &debug, "enable debugging output",
         "HELP=?=-h=--help/S", &arg_help, "display this text",
         "LICENSE/S", &arg_license, "display license",
         NULL);

    ok = (hscdepp_args != NULL);

    /* set & test args */
    if (ok)
    {
        ok = set_args(argc, argv, hscdepp_args);

        /* display argument error message */
        if (!ok)
        {
            pargerr();
            set_return_code(RC_ERROR);
        }
        else if (arg_help || arg_license)
        {
            /*
             * display help or license text
             */
            fprintf_prginfo(stderr);
            if (arg_help)
                fprintf_arghelp(stderr, hscdepp_args);
            else
                show_license();
            set_return_code(RC_WARN);
            ok = FALSE;
        }
        else
        {
            /* auto-enable verbose in debug-mode */
            if (debug)
                verbose = TRUE;

            /* display copyright in verbose-mode */
            if (verbose)
                fprintf_prginfo(stderr);

            /* set default-parameters if neccessary */
            if (!prjfile)
            {
                prjfile = DEFAULT_PROJECT;
                if (verbose)
                    fprintf(stderr, HD "%s: using default project-file\n",
                            prjfile);
            }
            if (!nameall)
            {
                nameall = DEFAULT_NAMEALL;

            }

            /* debugging control output */
            D(
                 if (makefile)
                 {
                 fprintf(stderr, DHD "makefile=`%s'\n", makefile);
                 fprintf(stderr, DHD "makefile=DEFAULT\n");
                 fprintf(stderr, DHD "prjfile =`%s'\n", prjfile);
                 fprintf(stderr, DHD "nameall =`%s'\n", nameall);
                 }
            );
        }

        /* release mem used by args */
        free_args(hscdepp_args);
    }
    else
    {
        /* only for developer */
        D(fprintf(stderr, SHIT "ArgDef error: %lu\n", prep_error_num));
    }

#if 1
    return (ok);
#else
    return (FALSE);             /* for arg-debugging */
#endif
}

/*
 * read_makefile
 *
 * scan for fitting makefile, read all it's data into a list
 * of strings, exept those which are between taglines
 */
static BOOL read_makefile(VOID)
{
    STRPTR scanfile[] =
    {"GNUmakefile", "Makefile", "makefile", NULL};
    FILE *file = NULL;
    BOOL ok = FALSE;

    lines_precede = init_estr(1024);
    lines_follow = init_estr(1024);

    /*
     * open makefile
     */
    errno = 0;
    if (!makefile)
    {
        /* scan for makefile */
        int i = 0;

        D(fprintf(stderr, DHD "scanning makefile\n"));
        makefile = scanfile[0];
        while (!file && makefile)
        {
            D(fprintf(stderr, DHD "  try `%s'\n", makefile));
            file = fopen(makefile, "r");
            if (!file)
            {
                i += 1;
                makefile = scanfile[i];
            }
        }

    }
    else
    {
        /* use makefile specified by user */
        D(fprintf(stderr, DHD "makefile `%s' specified by user\n", makefile));
        file = fopen(makefile, "r");
    }

    if (!file)
    {
        if (!makefile)
            makefile = "Makefile";
        fprintf(stderr, HD "%s: creating new makefile\n", makefile);
        ok = TRUE;
    }
    else
    {
        static STRARR buf[MAXBUFSIZE];  /* buffer for fgets() */
        BOOL found = FALSE;     /* flag: tag-line found */
        STRPTR line = NULL;     /* current line read */

        /*
         * read Makefile
         */

        /* reset error variable */
        errno = 0;

        /*
         * read preceding lines
         */
        do
        {
            line = fgets(buf, MAXBUFSIZE, file);
            if (line) {
                if (!strcmp(line, STR_DEPENDS_FOLLOW))
                    found = TRUE;
                else
                    app_estr(lines_precede, line);
            }
        }
        while (!found && !errno && line);

        if (errno)
        {
            fprintf(stderr, HD "error reading `%s': %s\n", makefile, strerror(errno));
            set_return_code(RC_ERROR);
        }
        else if (!line)
        {
            /* tag-line not found */
            if (verbose)
                fprintf(stderr, HD "%s: no starting tag-line; "
                        "appending dependencies\n", makefile);
        }
        else
        {
            /*
             * skip old dependencies
             */
            D(fprintf(stderr, DHD "starting tagline found\n"));

            found = FALSE;
            do
            {
                line = fgets(buf, MAXBUFSIZE, file);
                if (line)
                    if (!strcmp(line, STR_DEPENDS_PRECEDE))
                        found = TRUE;
            }
            while (!found && !errno && line);

            if (errno)
            {
                fprintf(stderr, HD "error reading `%s': %s\n", makefile, strerror(errno));
                set_return_code(RC_ERROR);
            }
            else if (!line)
            {
                /* tag-line not found */
                if (verbose)
                    fprintf(stderr, HD "%s: no ending tag-line; "
                            "appending dependencies\n", makefile);
            }
            else
            {
                /*
                 * read following lines
                 */
                D(fprintf(stderr, DHD "ending tagline found\n"));
                do
                {
                    line = fgets(buf, MAXBUFSIZE, file);
                    if (line)
                        app_estr(lines_follow, line);
                }
                while (!errno && line);

                if (errno)
                {
                    fprintf(stderr, HD "error reading `%s': %s\n", makefile, strerror(errno));
                    set_return_code(RC_ERROR);
                }
            }
        }

        if (!errno)
        {
            if (verbose)
                fprintf(stderr, HD "%s: makefile read\n", makefile);
            ok = TRUE;
        }
        /* close makefile */
        fclose(file);
    }

    return (ok);
}

/*
 * read_project
 *
 * read data from project file
 */
static BOOL read_project(VOID)
{
    BOOL ok = FALSE;
    INFILE *inpf = NULL;

    if (verbose)
    {
        fprintf(stderr, HD "%s: reading..\r", prjfile);
        fflush(stderr);
    }

    /* assign message-callback for corrupt project-file */
    project->CB_msg_corrupt_pf = msg_corrupt_pf;

    /* read project-file */
    errno = 0;
    inpf = infopen(prjfile, CHUNKSIZE_INPUTFILE);
    if (inpf)
    {
        if (hsc_project_read_data(project, inpf))
        {
            if (verbose)
                fprintf(stderr, HD "%s: project-file read\n", prjfile);
            ok = TRUE;
        }
        infclose(inpf);
    }

    if (!ok)
    {
        fprintf(stderr, HD "error reading `%s'", prjfile);
        if (errno)
            fprintf(stderr, HD ": %s", strerror(errno));
        fprintf(stderr, "\n");
    }

    return (ok);
}

/*
 * update_makefile
 *
 * create dependency-lines from project-info,
 */


/* append string to dependency-line */
static VOID depline_appstr(STRPTR s, ULONG * linelen)
{
#define LEADING_BLANKS "   "
    size_t slen = strlen(s);

    /* check if line would become too long after appending
     * the current word */
    if ((*linelen + slen) >= 75)
    {
        D(fprintf(stderr, DHD "break line after %lu chars to avoid %lu\n",
                  *linelen, *linelen + slen));

        app_estr(lines_depend, " \\\n");
        app_estr(lines_depend, LEADING_BLANKS);
        *linelen = strlen(LEADING_BLANKS);
    }

    app_estrch(lines_depend, ' ');
    app_estr(lines_depend, s);
    *linelen = *linelen + slen + 1;
}

/*
 * update_makefile - main function
 */
static BOOL update_makefile(VOID)
{
    BOOL ok = FALSE;
    ULONG linelen = 0;          /* length of current line */
    DLNODE *docnode = dll_first(project->documents);
    BOOL bak_ok = TRUE;

    lines_depend = init_estr(CHUNKSIZE_DEPENDSTR);

    /* append tagline */
    if (!notaglines)
    {
        app_estr(lines_depend, STR_DEPENDS_FOLLOW);
    }

    /* append some header info */
    if (!notaglines)
    {
#define MAXTIMEBUF 40
        time_t now = time(NULL);
        STRARR timebuf[MAXTIMEBUF];

        if (strftime(timebuf, MAXTIMEBUF, "%A %d-%b-%Y %H:%M:%S",
                     localtime(&now)))
        {
            app_estr(lines_depend, "\n# dependencies updated: ");
            app_estr(lines_depend, timebuf);
            app_estr(lines_depend, "\n\n");
        }
    }

    /*
     * append all-rule
     */
    app_estr(lines_depend, nameall);
    app_estr(lines_depend, " :");
    linelen = strlen(nameall) + 2;

    while (docnode)
    {
        HSCDOC *document = dln_data(docnode);
        depline_appstr(document->docname, &linelen);

        docnode = dln_next(docnode);
    }
    app_estr(lines_depend, "\n\n");

    /*
     * append document data
     */
    docnode = dll_first(project->documents);
    while (docnode)
    {
        HSCDOC *document = dln_data(docnode);
        DLNODE *incnode = dll_first(document->includes);

        D(fprintf(stderr, DHD "document `%s'\n", document->docname));

        app_estr(lines_depend, document->docname);
        app_estr(lines_depend, " :");

        linelen = strlen(document->docname) + 2;

        /* dependency for main source */
        depline_appstr(document->sourcename, &linelen);

        /* dependencies for includes */
        while (incnode)
        {
            HSCINC *include = dln_data(incnode);
            depline_appstr(include->name, &linelen);

            incnode = dln_next(incnode);
        }

        /* append linefeed after dependency-list */
        app_estr(lines_depend, "\n\n");

        docnode = dln_next(docnode);
    }

    /* append tagline */
    if (!notaglines)
        app_estr(lines_depend, STR_DEPENDS_PRECEDE);

    /*
     * create backup
     */
    if (!nobackup)
    {
        EXPSTR *makefile_bak = init_estr(32);   /* filename for backup */

        set_estr(makefile_bak, makefile);
        app_estr(makefile_bak, ".bak");

        /* remove old backup */
        remove(estr2str(makefile_bak));

        /* rename old makefile to backup
         *
         * NOTE: if this fails, this can also be because
         * there wasn't any earlier copy, therefor no
         * error-message is displayed */
        if (!rename(makefile, estr2str(makefile_bak)))
        {
            if (verbose)
                fprintf(stderr, HD "%s: backup created\n",
                        estr2str(makefile_bak));
        }

        del_estr(makefile_bak);
    }

    /*
     * write makefile
     */
    if (bak_ok)
    {
        FILE *outf = NULL;

        /* open output makefile */
        errno = 0;
        outf = fopen(makefile, "w");
        if (outf)
        {
            /* write output */
            errno = 0;
            fprintf(outf, "%s%s%s",
                    estr2str(lines_precede), estr2str(lines_depend),
                    estr2str(lines_follow));

            if (errno)
            {
                /* write error */
                fprintf(stderr, "error writing to `%s': %s\n",
                        makefile, strerror(errno));
            }
            else
                ok = TRUE;

            /* close output */
            fclose(outf);
        }
        else
        {
            /* error opening output */
            fprintf(stderr, "error opening `%s' for output: %s\n",
                    makefile, strerror(errno));
        }
    }

    return (ok);
}

/*
 *
 * main function
 *
 */
int main(int argc, char *argv[])
{
#ifndef BETA
#define BETA 0
#endif
    /* set program information */
    set_prginfo("hscdepp", UGLY_AUTHOR, VERSION, REVISION, BETA,
                "hsc dependency procreator",
                "Freeware, type `hscdepp LICENSE' for details.");

#if DEBUG
    /* display a memory tracking report */
    /* at end of execution */
    atexit(atexit_uglymemory);
#endif

    /* install nomem-handler */
    ugly_nomem_handler = hscdepp_nomem_handler;

    /* use cleanup() as additional exit func */
    if (!atexit(cleanup))
    {
        /*
         * main procedure
         */
        return_code = RC_OK;
        project = new_project();
        if (project
            && args_ok(argc, argv)
            && read_makefile()
            && read_project()
            && update_makefile()
        )
        {
            if (verbose)
            {
                fprintf(stderr, HD "%s: updated using `%s'\n",
                        makefile, prjfile);
            }
            return_code = RC_OK;
        }
    }
    else
    {
        fputs(SHIT "atexit() failed ", stderr);
    }
    return (return_code);
}
��������������������������������������������������������������������������hsc-0.934.orig/hsctools/hscpitt.c�������������������������������������������������������������������0100600�0001750�0000144�00000052616�07732056117�015644� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * hscpitt
 *
 * hsc project interfering'n'trashing tool
 *
 *-------------------------------------------------------------------
 *
 * hsctools/hscpitt.c
 *
 * updated: 14-Oct-1997
 * created: 15-Oct-1996
 */

/* ANSI includes */
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <time.h>

/* include revision data */
#include "hsctools/pitt_rev.h"

/* ugly includes */
#include "ugly/ustring.h"
#include "ugly/dllist.h"
#include "ugly/expstr.h"
#include "ugly/infile.h"
#include "ugly/ufile.h"
#include "ugly/uargs.h"
#include "ugly/ustrlist.h"
#include "ugly/prginfo.h"
#include "ugly/returncd.h"

/* hsclib includes */
#include "hscprj/document.h"
#include "hscprj/project.h"
#include "hscprj/license.h"

#ifdef AMIGA
/* AmigaOS version string
 * (imported from "pitt_rev.h")
 */
static const STRPTR AmigaOS_version = VERSTAG;
#endif

/* prefix for messages */
#define HP ""
#define DHP "*hscpit* "
#define SHIT "*** "             /* prefix for total failure */

/* debugging define */
#ifdef DEBUG
#undef DEBUG
#define DEBUG 1
#endif

#ifdef D
#undef D
#endif

#if DEBUG
#define D(x) if (debug) {x;}
#else
#define D(x) {/*nufin*/}
#endif

/* default parameters */
#define DEFAULT_PROJECT "hsc.project"   /* project-filename */

/* commands supported */
#define CMD_COUNT_STR   "count"
#define CMD_LIST_STR    "list"
#define CMD_EXTRACT_STR "extract"
#define CMD_DELETE_STR  "delete"
#define CMD_ERASE_STR   "erase"
#define CMD_ADD_STR     "add"
#define CMD_NEW_STR     "new"
#define CMD_COPY_STR    "copy"
#define CMD_MOVE_STR    "move"

#define COMMAND_NONE    0
#define COMMAND_COUNT   1
#define COMMAND_LIST    2
#define COMMAND_EXTRACT 3
#define COMMAND_DELETE  4
#define COMMAND_ERASE   5
#define COMMAND_ADD     6
#define COMMAND_NEW     7
#define COMMAND_COPY    8
#define COMMAND_MOVE    9

#define COMMAND_ENUMSTR     \
        CMD_COUNT_STR   "|" \
        CMD_LIST_STR    "|" \
        CMD_EXTRACT_STR "|" \
        CMD_DELETE_STR  "|" \
        CMD_ERASE_STR   "|" \
        CMD_ADD_STR     "|" \
        CMD_NEW_STR

/*
 * global vars
 */

/* command strings */
static STRPTR command_name[] =
{
    "***NONE***",
    CMD_COUNT_STR,
    CMD_LIST_STR,
    CMD_EXTRACT_STR,
    CMD_DELETE_STR,
    CMD_ERASE_STR,
    CMD_ADD_STR,
    CMD_NEW_STR,
    NULL
};

static int return_code = RC_FAIL;       /* exit code of program */

static STRPTR prjfile = NULL;
static LONG command = COMMAND_LIST;
static LONG cmdArgNum = 0;      /* number of args for command (ARG/M) */
static DLLIST *command_arglist = NULL;
static BOOL force = FALSE;
static BOOL quiet = FALSE;
static BOOL debug = FALSE;

static HSCPRJ *project = NULL;

/*
 * cleanup: free all resources
 * (called in any case)
 */
static VOID cleanup(VOID)
{
    D(fprintf(stderr, "(cleanup)\r"));
    del_dllist(command_arglist);
    del_project(project);
    D(fprintf(stderr, "         \r"));
}

static VOID set_return_code(int new_code)
{
    if (new_code > return_code)
        return_code = new_code;
}

/*
 * hsc_nomem_handler
 *
 * called from ugly/umalloc, if malloc() did return NULL
 */
static BOOL hscpitt_nomem_handler(size_t size)
{
    fputs(SHIT "out of memory\n", stderr);

    return_code = RC_FAIL;
    exit(return_code);          /* abort immediatly */

    return (FALSE);
}

VOID msg_corrupt_pf(HSCPRJ * hp, STRPTR reason)
{
    fprintf(stderr, "project-file corrupt: %s\n", reason);
    set_return_code(RC_ERROR);
}

/*
 * update_project_file
 *
 * write updated project file, handle errors
 */
BOOL update_project_file(HSCPRJ * project)
{
    BOOL ok = FALSE;

    D(fprintf(stderr, DHP "update_project_file()\n"));
    /* TODO: create backup */

    errno = 0;
    ok = hsc_project_write_data(project, prjfile, TRUE);

    if (!ok)
    {
        fprintf(stderr, HP "error writing `%s'", prjfile);
        if (errno)
            fprintf(stderr, HP ": %s", strerror(errno));
        fprintf(stderr, "\n");
        set_return_code(RC_ERROR);
    }

    return (ok);
}

/*-------------------------------------------------------------------
 *
 * functions for arguments
 *
 *-------------------------------------------------------------------*/

/*
 * check_min_cmd_args
 *
 * check, if at least a specific num of args has been specified
 * for the command
 */
BOOL check_min_cmd_args(LONG minArgNum, DLLIST * list)
{
    BOOL ok = TRUE;
    DLNODE *nd = dll_first(list);
    LONG argNum = 0;

    /* count arguments */
    while (nd)
    {
        argNum++;
        nd = dln_next(nd);
    }

    if (argNum < minArgNum)
    {
        fprintf(stderr, "command %s requires at least %ld arguments\n",
                command_name[command], minArgNum);
        ok = FALSE;
    }

    return (ok);
}

/*
 * args_ok
 *
 * prepare args, check & parse user args, display error and
 * help message if neccessary
 *
 * result: TRUE, if all args ok and no request for HELP or
 *         LICENSE has been detected
 */
static BOOL args_ok(int argc, char *argv[])
{
    struct arglist *hscpitt_args;       /* argument structure */
    BOOL arg_help = FALSE;
    BOOL arg_license = FALSE;
    BOOL ok = FALSE;

    /* create arg-table */
    hscpitt_args = prepare_args
        ("HSCPITT_ARGS",
         "COMMAND/E", COMMAND_ENUMSTR, &command,
         "command to perform (" COMMAND_ENUMSTR ")",
         "ARG/T/M", &command_arglist, "command argument(s)",
         "PRJFILE/T/K", &prjfile, "project file",
         "FORCE/S", &force, "disable certain checks",
         "QUIET/S", &quiet, "act quietly",
         "-DEBUG/S", &debug, "enable debugging output",
         "HELP=?=-h=--help/S", &arg_help, "display this text",
         "LICENSE/S", &arg_license, "display license",
         NULL);

    ok = (hscpitt_args != NULL);

    /* set & test args */
    if (ok)
    {
        ok = set_args(argc, argv, hscpitt_args);

        /* display argument error message */
        if (!ok)
        {
            pargerr();
            set_return_code(RC_ERROR);
        }
        else if (arg_help || arg_license)
        {
            /*
             * display help or license text
             */
            fprintf_prginfo(stderr);
            if (arg_help)
                fprintf_arghelp(stderr, hscpitt_args);
            else
                show_license();
            set_return_code(RC_WARN);
            ok = FALSE;
        }
        else
        {
            /* display copyright in verbose-mode */
            if (!quiet)
                fprintf_prginfo(stderr);

            /* set default-parameters if neccessary */
            if (!prjfile)
            {
                prjfile = DEFAULT_PROJECT;
                if (!quiet)
                {
                    fprintf(stderr, HP "%s: using default project-file\n",
                            prjfile);
                }
            }

            if (command)
            {
                /* debugging control output */
                D(
                     {
                     fprintf(stderr, DHP "prjfile =`%s'\n", prjfile);
                     fprintf(stderr, DHP "command =`%ld'\n", command);
                     }
                );
            }
            else
            {
                fprintf(stderr, "no command specified\n");
                ok = FALSE;
            }
        }

        /* set error return code if neccessary */
        if (!ok)
        {
            set_return_code(RC_ERROR);
        }

        /* release mem used by args */
        free_args(hscpitt_args);
    }
    else
    {
        /* only for developer */
        D(fprintf(stderr, SHIT "ArgDef error: %lu\n", prep_error_num));
    }

#if 1
    return (ok);
#else
    return (FALSE);             /* for arg-debugging */
#endif
}

/*
 * read_project
 *
 * read data from project file
 */
static BOOL read_project(VOID)
{
    BOOL ok = FALSE;
    INFILE *inpf = NULL;

    if (!quiet)
    {
        fprintf(stderr, HP "%s: reading..\r", prjfile);
        fflush(stderr);
    }

    /* assign message-callback for corrupt project-file */
    project->CB_msg_corrupt_pf = msg_corrupt_pf;

    /* read project-file */
    errno = 0;
    inpf = infopen(prjfile, 1024);
    if (inpf)
    {
        if (hsc_project_read_data(project, inpf))
        {
            if (!quiet)
            {
                fprintf(stderr, HP "%s: project-file read\n", prjfile);
            }
            ok = TRUE;
        }
        infclose(inpf);
    }

    if (!ok)
    {
        fprintf(stderr, HP "error reading `%s'", prjfile);
        if (errno)
            fprintf(stderr, HP ": %s", strerror(errno));
        fprintf(stderr, "\n");
    }

    /* set error return code if neccessary */
    if (!ok)
    {
        set_return_code(RC_ERROR);
    }

    return (ok);
}

/*-------------------------------------------------------------------
 *
 * functions for commands arguments
 *
 *-------------------------------------------------------------------*/

/* check for no args */
static BOOL chkArg0(STRPTR command)
{
    BOOL ok = TRUE;
    if (cmdArgNum)
    {
        fprintf(stderr, "no arguments allowed for command `%s'\n", command);
        set_return_code(RC_ERROR);
        ok = FALSE;
    }
    return (ok);
}

/* check for two args */
static BOOL chkArg2(STRPTR command, STRPTR arg1, STRPTR arg2)
{
    BOOL ok = TRUE;
    if (cmdArgNum != 2)
    {
        fprintf(stderr, "two arguments required for command `%s': "
                "%s and %s\n", command, arg1, arg2);
        set_return_code(RC_ERROR);
        ok = FALSE;
    }
    return (ok);
}

/* check for at least one arg (or more) */
static BOOL chkArgAny(STRPTR command)
{
    BOOL ok = TRUE;
    if (!cmdArgNum)
    {
        fprintf(stderr, "arguments required for command `%s'\n", command);
        set_return_code(RC_ERROR);
        ok = FALSE;
    }
    return (ok);
}

/*-------------------------------------------------------------------
 *
 * functions for commands
 *
 *-------------------------------------------------------------------*/

/*-------------------------------------------------------------------*/

/*
 * command_new
 *
 * write an empty project file
 */
BOOL command_new(HSCPRJ * project, DLLIST * arglist)
{
    BOOL ok = TRUE;

    if (chkArg0(CMD_NEW_STR))
    {
        if (fexists(prjfile) && !force)
        {
            printf("project file `%s' already exists\n", prjfile);
            set_return_code(RC_ERROR);
            ok = FALSE;
        }
        else
        {
            /* write new project file */
            if (update_project_file(project))
            {
                if (!quiet)
                {
                    printf("Created new project file `%s'\n", prjfile);
                }
            }
        }
    }

    return (ok);
}

/*-------------------------------------------------------------------*/

/*
 * command_add
 *
 * add new document and source to project
 */
VOID command_add(HSCPRJ * project, DLLIST * arglist)
{
    if (chkArg2(CMD_ADD_STR, "DOCUMENT", "SOURCE"))
    {
        BOOL deleted = FALSE;
        DLNODE *docNameNd = dll_first(arglist);
        DLNODE *docSourceNd = dln_next(docNameNd);
        STRPTR docName = (STRPTR) dln_data(docNameNd);
        STRPTR docSource = (STRPTR) dln_data(docSourceNd);

        /* try to remove document */
        deleted = hsc_project_del_document(project, docName);

        if (!deleted || force)
        {
            D(fprintf(stderr, DHP " add doc=`%s'\n    src=`%s'\n",
                      docName, docSource));

            /* set document as current document */
            hsc_project_set_document(project, docName);
            hsc_project_set_source(project, docSource);
            hsc_project_add_document(project);

            /* update project file */
            if (update_project_file(project))
            {
                if (!quiet)
                {
                    STRPTR operation = "Added";
                    if (deleted)
                    {
                         operation = "Replaced";
                    }
                    printf("%s document `%s'\n", operation, docName);
                }
            }
        }
        else
        {
            printf("Document `%s' already in project\n", docName);
            set_return_code(RC_WARN);
        }
    }
}

/*-------------------------------------------------------------------*/

/*
 * command_delete
 *
 * remove document(s) from project
 */
VOID command_delete(HSCPRJ * project, DLLIST * arglist)
{
    if (chkArgAny(CMD_DELETE_STR))
    {
        DLNODE *docNode = dll_first(arglist);

        while (docNode)
        {
            STRPTR docName = (STRPTR) dln_data(docNode);
            BOOL deleted = FALSE;

            /* remove document */
            deleted = hsc_project_del_document(project, docName);

            /* output message */
            if (deleted)
            {
                if (!quiet)
                {
                    printf("Delete `%s'\n", docName);
                }
            }
            else
            {
                printf("Delete `%s': no such document\n", docName);
                set_return_code(RC_WARN);
            }
            docNode = dln_next(docNode);
        }

        /* update project file */
        update_project_file(project);
    }
}

/*-------------------------------------------------------------------*/

/*
 * command_erase
 *
 * remove document(s) and corresponding files from project
 */
static BOOL uremove(STRPTR fname)
{
    BOOL erased = FALSE;

    /* TODO: convert URI to filename */
    errno = 0;
    erased = !remove(fname);
    if (erased)
    {
        if (!quiet)
        {
            printf("Delete `%s'\n", fname);
        }
    }
    else
    {
        printf("Error deleting `%s': %s\n", fname, strerror(errno));
    }

    return (erased);
}

VOID command_erase(HSCPRJ * project, DLLIST * arglist)
{
    if (chkArgAny(CMD_ERASE_STR))
    {
        DLNODE *argNode = dll_first(arglist);
        BOOL erasedAny = FALSE;

        while (argNode)
        {
            STRPTR docName = (STRPTR) dln_data(argNode);
            HSCDOC *document = find_document(project->documents, docName);
            BOOL erased = FALSE;

            /* remove document and source file */
            if (document)
            {
                uremove(document->docname);
                uremove(document->sourcename);
                erased = hsc_project_del_document(project, docName);
                if (!erased)
                    panic("no document entry");
            }

            /* output message */
            if (!erased)
            {
                printf("Delete `%s': no such document\n", docName);
                set_return_code(RC_WARN);
            }
            else
            {
                /* project file needs to be updated */
                erasedAny = TRUE;
            }

            argNode = dln_next(argNode);
        }

        /* update project file */
        if (erasedAny)
        {
            update_project_file(project);
        }
    }
}

/*-------------------------------------------------------------------*/

/*
 * command_extract
 *
 * display detailed information about documents found in project
 */
static VOID printfVar(STRPTR var, STRPTR value)
{
    if (!value)
        value = "";
    printf("%s=\"%s\"\n", var, value);
}

static VOID extract_document(HSCPRJ * project, HSCDOC * document, BOOL emptyLine)
{
    /* show empty line; not for first document */
    if (emptyLine)
    {
        puts("");
    }

    /* display document name and source used */
    printfVar("DOCUMENT", document->docname);
    printfVar("SOURCE", document->sourcename);

#if 1
    /* display includes */
    if (document->includes)
    {
        DLNODE *nd = dll_first(document->includes);
        while (nd)
        {
            HSCINC *include = (HSCINC *) dln_data(nd);
            printfVar("INCLUDE", include->name);
            nd = dln_next(nd);
        }
    }
#endif
}

VOID command_extract(HSCPRJ * project, DLLIST * arglist)
{
    if (cmdArgNum)
    {
        /* extract document(s) specified in args */
        DLNODE *argNode = dll_first(arglist);
        BOOL emptyLine = FALSE;

        while (argNode)
        {
            STRPTR docName = (STRPTR) dln_data(argNode);
            HSCDOC *document = find_document(project->documents, docName);

            /* remove document and source file */
            if (document)
            {
                extract_document(project, document, emptyLine);
                emptyLine = TRUE;
            }
            else
            {
                fprintf(stderr, "Extract `%s': no such document\n", docName);
                set_return_code(RC_WARN);
            }

            argNode = dln_next(argNode);
        }
    }
    else
    {
        /* extract all documents */
        DLNODE *docNode = dll_first(project->documents);
        BOOL emptyLine = FALSE;

        while (docNode)
        {
            HSCDOC *document = (HSCDOC *) dln_data(docNode);

            extract_document(project, document, emptyLine);
            emptyLine = TRUE;

            /* process next node, show empty line if
             * further data exist */
            docNode = dln_next(docNode);
        }
    }
}

/*-------------------------------------------------------------------*/

/*
 * command_count
 *
 * display number of documents currently stored in project file
 */
VOID command_count(HSCPRJ * project, DLLIST * arglist)
{
    DLNODE *docNode = dll_first(project->documents);
    ULONG docNum = 0;

    if (chkArg0(CMD_COUNT_STR))
    {
        while (docNode)
        {
            docNum++;
            docNode = dln_next(docNode);
        }

        /* display number of documents */
        printf("%lu\n", docNum);
    }
}

/*-------------------------------------------------------------------*/

/*
 * command_list
 *
 * display list of documents found in project
 */
VOID command_list(HSCPRJ * project, DLLIST * arglist)
{
    if (chkArg0(CMD_COUNT_STR))
    {
        DLNODE *docNode = dll_first(project->documents);

        while (docNode)
        {
            HSCDOC *document = (HSCDOC *) dln_data(docNode);

            printf("%s\n", document->docname);
            docNode = dln_next(docNode);
        }
    }
}

/*-------------------------------------------------------------------*/

/*
 * process_command
 *
 */
BOOL process_command(HSCPRJ * project, LONG command, DLLIST * arglist)
{
    BOOL ok = TRUE;
    DLNODE *nd = NULL;

    D(fprintf(stderr, DHP "process_command()\n"));
    D(fprintf(stderr, DHP "command: %s\n", command_name[command]));

    /* count number of args */
    if (arglist)
        nd = dll_first(arglist);
    if (nd)
    {
        D(fprintf(stderr, DHP "command args:\n"));
        while (nd)
        {
            D(fprintf(stderr, DHP "  `%s'\n", (STRPTR) dln_data(nd)));
            cmdArgNum++;
            nd = dln_next(nd);
        }
    }
    else
    {
        D(fprintf(stderr, DHP "command args: NONE\n"));
    }
    D(fprintf(stderr, DHP "cmdarg#: %ld\n", cmdArgNum));

    switch (command)
    {
    case COMMAND_COUNT:
        command_count(project, arglist);
        break;
    case COMMAND_LIST:
        command_list(project, arglist);
        break;
    case COMMAND_EXTRACT:
        command_extract(project, arglist);
        break;
    case COMMAND_DELETE:
        command_delete(project, arglist);
        break;
    case COMMAND_ERASE:
        command_erase(project, arglist);
        break;
    case COMMAND_ADD:
        command_add(project, arglist);
        break;
    case COMMAND_NEW:
        ok = command_new(project, arglist);
        break;
    default:
        {
            D(fprintf(stderr, DHP "unknown command\n"));
            ok = FALSE;
            break;
        }
    }

    return (ok);
}

/*-------------------------------------------------------------------
 *
 * main function
 *
 *-------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
#ifndef BETA
#define BETA 0
#endif
    /* set program information */
    set_prginfo("hscpitt", UGLY_AUTHOR, VERSION, REVISION, BETA,
                "hsc project interfering'n'trashing tool",
                "Freeware, type `hscpitt LICENSE' for details.");

#if DEBUG
    /* display a memory tracking report */
    /* at end of execution */
    atexit(atexit_uglymemory);
#endif

    /* install nomem-handler */
    ugly_nomem_handler = hscpitt_nomem_handler;

    /* use cleanup() as additional exit func */
    if (!atexit(cleanup))
    {
        /*
         * main procedure
         */
        return_code = RC_OK;
        project = new_project();
        if (project && args_ok(argc, argv))
        {
            BOOL ok = TRUE;

            if (command != COMMAND_NEW)
            {
                ok = read_project();
            }

            if (ok && process_command(project, command, command_arglist))
            {
                return_code = RC_OK;
            }
        }
    }
    else
    {
        fputs(SHIT "atexit() failed ", stderr);
    }
    return (return_code);
}

������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/hsctools/pitt_rev.h������������������������������������������������������������������0100600�0001750�0000144�00000002403�07732056117�016014� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1995-1998  Thomas Aglassinger
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

#define STRINGIFY(x) _STRINGIFY(x)
#define _STRINGIFY(x) #x

#define VERSION		1
#define REVISION	3
#define DATE	"17.11.01"
#define TIME	"20:25:20"

#define __VSTR STRINGIFY(VERSION)
#define __RSTR STRINGIFY(REVISION)

#define PRGNAME	"hscpitt"
#define VERS	PRGNAME __VSTR "." __RSTR
#define VSTRING	PRGNAME __VSTR "." __RSTR DATE "\r\n"
#define VERSTAG	"\0$VER: " PRGNAME  __VSTR "." __RSTR DATE
#define BASENAME "HSCPITT"
#define VSTR	PRGNAME __VSTR "." __RSTR DATE

�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/riscos/������������������������������������������������������������������������������0040700�0001750�0000144�00000000000�07776512741�013465� 5����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/riscos/MakeStubs���������������������������������������������������������������������0100600�0001750�0000144�00000001107�07642675506�015305� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Patch for UnixStubs
# Changes the symbols for
#   fopen   --> gopen
#   freopen --> greopen
#   rename  --> gename
#   remove  --> gemove
# So that they can be easily redefined

Application:UnixStubs &FFD
Description:SharedCLibrary Stubs
Patch:Patches Cv5 stubs for use with UnixNames
File:UnixStubs &FFD

Location:&33A0
# Change 'fopen' to 'gopen'
ChangeWord:&6F6D6572 &6F6D6567
# Change 'freopen' to 'greopen'
ChangeWord:&72006576 &67006576

Location:&33D0
# Change 'rename' to 'gename'
ChangeWord:&706F6600 &706F6700
# Change 'remove' to 'gemove'
ChangeWord:&66006E65 &67006E65
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/riscos/Makefile����������������������������������������������������������������������0100600�0001750�0000144�00000016754�07642675506�015142� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������#
# Makefile for hsc ("html sucks completely")
#
# Copyright (C) 1994,95,96  Thomas Aglassinger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#====================================================================
#
# This Makefile should work on most Unixoid systems, but no
# optimisation is performed. Feel free to fool around with the
# compiler-flags.
#
# (1) Use "make -f Makefile.dodl" to compile.
#
# (2) Copy "hsc/hsc", "hsctools/hscdepp" and "hsctools/hscpitt" to
#     anywhere in your search-path.
#
# (3) Use "make -f Makefile.dodl sterile" for a total cleanup. Maybe
#     you also have to pass an option to make to ignore the
#     return-code of the "rm"-command; usually, this is "-i".
#
# (4) Read the docs, section "Installation" what to do with
#     "hsc.prefs".
#
# IMPORTANT: Don't forget to hit the return-key after typing commands
#            in the shell!
#

#------------------------------------------------
# this one should always work
#
#CC	= cc
#CFLAGS	=

#------------------------------------------------
# this one should also work and even optimise
#
CC	= cc
CFLAGS	= -Otime

#------------------------------------------------
# create a debugging version
#
#CC	= cc
#CFLAGS	= -DDEBUG -DDEBUG_UGLY -g

#------------------------------------------------
# works with gcc
#
#CC	= gcc
#CFLAGS = -s -O2

#------------------------------------------------
# create a debugging version for gcc and gdb
#
#CC	= gcc
#CFLAGS	= -DDEBUG -DDEBUG_UGLY -ggdb

#--------------------------------------------------------------------
# avoid fooling around below this line
#--------------------------------------------------------------------

SYS	= -DRISCOS -throwback
COMP	= $(CC) -o $@ $(SYS) -I. -c
LINK	= link -o $@
MOVE	= rename
COPY	= copy
DELETE	= wipe
SQUEEZE = squeeze

#--------------------------------------------------------------------
# do not touch anything below this line
#--------------------------------------------------------------------

#
# symbols for objects and executables
#
OBJ_TOOLS	= ugly.o.all_ugly hscprj.o.all_hscp riscos.o.unixname riscos.o.UnixStubs
OBJ_HSC		= $(OBJ_TOOLS) hsclib.o.all_hscl hsc.o.all_hsc
OBJ_ALL		= $(OBJ_HSC)
EXE_ALL		= hsc.all_hsc hsctools.all_depp hsctools.all_pitt

#
# compile all tools
#
all : $(EXE_ALL)

# implict rule for object-files
# (old-style implicit rule)
.c.o :
	$(COMP) $*.c $(CFLAGS)

hsc/all_hsc : $(OBJ_HSC)
	$(LINK) $(OBJ_HSC) $(CMODE)
	$(SQUEEZE) hsc.all_hsc ^.hsc

hsctools/all_depp : $(OBJ_TOOLS) hsctools.o.all_depp
	$(LINK) hsctools.o.all_depp $(OBJ_TOOLS) $(CMODE)
	$(SQUEEZE) hsctools.all_depp ^.hscdepp

hsctools/all_pitt : $(OBJ_TOOLS) hsctools.o.all_pitt
	$(LINK) hsctools.o.all_pitt $(OBJ_TOOLS) $(CMODE)
	$(SQUEEZE) hsctools.all_pitt ^.hscpitt

### UnixName stuff ###
riscos/unixname.o: riscos/unixname.c riscos/unixname.h

#
# cleanup - remove all objects and executables
#
clean :
	create hsc.o.void 0
	wipe hsc.o.* V~C
	create hsctools.o.void 0
	wipe hsctools.o.* V~C
	create hsclib.o.void 0
	wipe hsclib.o.* V~C
	create hscprj.o.void 0
	wipe hscprj.o.* V~C
	create ugly.o.void 0
	wipe ugly.o.* V~C
	wipe riscos.o.unixname V~C

all_clean :
	$(DELETE) $(OBJ_ALL) $(EXE_ALL)

sterile : clean all_clean
	$(DELETE) hsc/hsc
	$(DELETE) hsctools/hscdepp
	$(DELETE) hsctools/hscpitt

#
# the dependencies below are created using `MkDepend' by Lars Düning,
# available from amient:dev/c/MkDepend.lha
#

# --- DO NOT MODIFY THIS LINE -- AUTO-DEPENDS FOLLOW ---
hsc/all_hsc.o : hsc/args.c hsc/callback.c hsc/global.c hsc/hsc.c \
    hsc/output.c hsc/status.c hsc/global.h hsc/status.h hscprj/license.h \
    ugly/fname.h ugly/prginfo.h ugly/returncd.h ugly/uargs.h \
    amiga/msgbrowser.c hsc/callback.h hsc/output.h riscos/msgbrowser.c \
    hsclib/hsclib.h hsc/args.h hsc/hsc_rev.h hscprj/project.h \
    riscos/unixname.h hsc/hdebug.h ugly/dllist.h ugly/expstr.h \
    ugly/infile.h ugly/umemory.h ugly/ustring.h ugly/utypes.h ugly/expstr.h \
    ugly/utypes.h ugly/umemory.h hsclib/inc_base.h hsclib/include.h \
    hsclib/linit.h ugly/dllist.h ugly/udebug.h hsclib/attrib.h \
    hsclib/entity.h hsclib/hscprc.h hsclib/ldebug.h hsclib/lmessage.h \
    hsclib/lstatus.h hsclib/msgid.h hsclib/tag.h hscprj/document.h

hsclib/all_hscl.o : hsclib/tag_macro.c hsclib/tag_if.c hsclib/tag_hsc.c \
    hsclib/tag_a.c hsclib/tag_misc.c hsclib/size.c hsclib/linit.c \
    hsclib/include.c hsclib/parse.c hsclib/deftag.c hsclib/defattr.c \
    hsclib/posteval.c hsclib/eval.c hsclib/uri.c hsclib/skip.c \
    hsclib/input.c hsclib/lstatus.c hsclib/hscprc.c hsclib/idref.c \
    hsclib/attrib.c hsclib/tag.c hsclib/entity.c hsclib/lmessage.c \
    ugly/ustring.h ugly/infile.h ugly/umemory.h ugly/expstr.h ugly/dllist.h \
    ugly/utypes.h hsclib/msgid.h hsclib/ldebug.h hsclib/parse.h \
    hsclib/include.h hsclib/deftag.h hsclib/defattr.h hsclib/inc_tagcb.h \
    hsclib/skip.h hsclib/eval.h hsclib/tag_if.h hsclib/tag_macro.h \
    hsclib/uri.h ugly/fname.h hscprj/document.h hsclib/inc_base.h \
    hsclib/tag_misc.h hsclib/tag_hsc.h hsclib/tag_a.h hsclib/input.h \
    ugly/ufile.h hsclib/size.h hscprj/project.h hsclib/posteval.h \
    hsclib/idref.h ugly/returncd.h ugly/ustrlist.h hsclib/tag.h \
    hsclib/entity.h ugly/utypes.h ugly/dllist.h ugly/expstr.h ugly/udebug.h \
    hsclib/hscprc.h hsclib/lstatus.h hsclib/lmessage.h hsclib/attrib.h \
    ugly/ustring.h

hscprj/all_hscp.o : hscprj/writeprj.c hscprj/readprj.c hscprj/project.c \
    hscprj/license.c hscprj/document.c hscprj/project.h hscprj/document.h \
    ugly/ustring.h ugly/infile.h ugly/umemory.h ugly/expstr.h ugly/dllist.h \
    ugly/utypes.h hscprj/pdefs.h hscprj/pdebug.h hsclib/ldebug.h \
    ugly/utypes.h ugly/dllist.h ugly/expstr.h ugly/udebug.h

hsctools/all_depp.o : hsctools/hscdepp.c hscprj/license.h hscprj/project.h \
    hscprj/document.h ugly/returncd.h ugly/prginfo.h ugly/uargs.h \
    ugly/infile.h ugly/expstr.h ugly/dllist.h ugly/ustring.h \
    hsctools/depp_rev.h ugly/umemory.h ugly/utypes.h hsclib/ldebug.h \
    ugly/umemory.h ugly/utypes.h ugly/dllist.h ugly/expstr.h ugly/udebug.h

hsctools/all_pitt.o : hsctools/hscpitt.c hscprj/license.h hscprj/project.h \
    hscprj/document.h ugly/returncd.h ugly/prginfo.h ugly/ustrlist.h \
    ugly/uargs.h ugly/infile.h ugly/expstr.h ugly/dllist.h ugly/ustring.h \
    hsctools/pitt_rev.h ugly/umemory.h ugly/utypes.h hsclib/ldebug.h \
    ugly/dllist.h ugly/ustring.h ugly/utypes.h ugly/umemory.h ugly/expstr.h \
    ugly/udebug.h

ugly/all_ugly.o : ugly/prginfo.c ugly/infile.c ugly/ustrlist.c ugly/uargs.c \
    ugly/ufile.c ugly/dllist.c ugly/fname.c ugly/expstr.c ugly/ustring.c \
    ugly/umemory.c ugly/udebug.h ugly/utypes.h ugly/umemory.h ugly/infile.h \
    ugly/fname.h ugly/ustring.h ugly/expstr.h ugly/ustrlist.h \
    ugly/args_hlp.c ugly/args_prp.c ugly/args_set.c ugly/args_fre.c \
    ugly/uargs.h ugly/dllist.h ugly/ufile.h ugly/udebug.h

# --- DO NOT MODIFY THIS LINE -- AUTO-DEPENDS PRECEDE ---

# Dynamic dependencies:
o.unixname:	c.unixname
o.unixname:	h.unixname
��������������������hsc-0.934.orig/riscos/ReadMe������������������������������������������������������������������������0100600�0001750�0000144�00000004224�07642675506�014547� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������Preparing the sources for compilation
=====================================

The sources of hsc come in Unix filename conventions (ie. '/c' and '/h'
extensions) so you need to convert them to RISC OS format (ie. directories
'c', 'h' and 'o'). The RunMe1st Obey file does this automatically, it scans
all the source directory, renames the files accordingly and creates the 'o'
directories where needed. It also sets the filetype of MakeStubs (see below)
and copies the Makefile from the 'riscos' directory to the upper directory
from where you can run it.

Note that you need a filing system that supports names longer than 10
characters in order to compile hsc (eg. use LongFiles on FileCore discs or
an image filing system such as X-Files or SparkFS). Actually names longer
than 10 characters are only present before the files are moved to the 'c' and
'h' directories, once you have executed the RunMe1st file you can copy the
sources to any filing system.


Making o.UnixStubs
==================

You will need to make o.UnixStubs before you can compile this program.  This
is a patched SharedCLibrary.


Semi-Automatic
--------------

Copy your Cv5 o.Stubs from their normal place into the o directory as
UnixStubs.

Show the Filer the !Patch application (comes with all versions of RISCOS)

Double click on the MakeStubs patch file.

Drag o.UnixStubs onto Patch, tick the patch and then choose to patch all
from the menu.


Manual
------

Copy your Cv5 o.Stubs from their normal place into the o directory as
UnixStubs.

Load it into a text editor.

Change the occurrence of
  fopen   --> gopen
  freopen --> greopen
  rename  --> gename
  remove  --> gemove

Save the file.  Note that you shouldn't have made the file any longer in the
process and you should only have changed 4 bytes.


Compiling the sources
=====================

Just set the CSD in the 'source' directory and execute 'amu' or double click
the Makefile. At the end of the compilation you'll find the three executables
'hsc', 'hscdepp' and 'hscpitt' in the main hsc directory (ie. one level above
'source').

Currently only the Acorn C V5 compiler has been tested but probably also
Acorn C V4 will be able to compile hsc.
����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/riscos/RunMe1st����������������������������������������������������������������������0100600�0001750�0000144�00000001256�07642675506�015072� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������| This file renames the sources file to RISC OS style,
| creates the 'o' directories and puts the Makefile in
| its correct place.

| Set the correct type of 'srcrename' so that the only requirement 
| for the user is to set 'RunMe1st' to Obey
SetType <Obey$Dir>.srcrename FF8

| Set the correct type of MakeStubs
SetType <Obey$Dir>.MakeStubs FC3

| Set the correct type of ReadMe
SetType <Obey$Dir>.ReadMe FFF

| Run 'srcrename' on the main hsc directory with recursion enabled
/<Obey$Dir>.srcrename -ro -e c:h:s:o <Obey$Dir>.^

| Put the Makefile in its correct place and set the correct filetype
SetType <Obey$Dir>.Makefile FE1
Copy <Obey$Dir>.Makefile <Obey$Dir>.^.Makefile ~C ~V F
��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/riscos/msgbrowser.c������������������������������������������������������������������0100600�0001750�0000144�00000006733�07772072723�016030� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1997  Sergio Monesi and Nick Craig-Wood
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * riscos/msgbrowser.c
 *
 * throwback support for RiscOS
 */

#ifndef RISCOS
/* Avoid that anything is attempted to be compiled on none-RiscOS systems.
 * A dummy symbol is declared to keep the linker from whining. */
char riscos_message_browser_dummy = 0;
#else

#include "hsc/global.h"

#include "riscos/unixname.h"
#include <kernel.h>

#undef  DDEUtils_ThrowbackStart
#define DDEUtils_ThrowbackStart         0x42587
#undef  XDDEUtils_ThrowbackStart
#define XDDEUtils_ThrowbackStart        0x62587
#undef  DDEUtils_ThrowbackSend
#define DDEUtils_ThrowbackSend          0x42588
#undef  XDDEUtils_ThrowbackSend
#define XDDEUtils_ThrowbackSend         0x62588
#undef  DDEUtils_ThrowbackEnd
#define DDEUtils_ThrowbackEnd           0x42589
#undef  XDDEUtils_ThrowbackEnd
#define XDDEUtils_ThrowbackEnd          0x62589

#define ddeutils_SEVERITY_WARNING       0
#define ddeutils_SEVERITY_ERROR         1
#define ddeutils_SEVERITY_SERIOUS_ERROR     2
#define ddeutils_THROWBACK_PROCESSING       0
#define ddeutils_THROWBACK_ERROR_DETAILS    1
#define ddeutils_THROWBACK_INFO_DETAILS     2

BOOL init_msg_browser(HSCPRC * hp, STRPTR filename)
{
    BOOL success = TRUE;

    if (!upstrcmp(msg_browser, "THROWBACK"))
    {
        _kernel_swi_regs r;

        _kernel_swi(XDDEUtils_ThrowbackStart, &r, &r);
    }

    return success;
}

VOID del_msg_browser(HSCPRC * hp)
{
    if (!upstrcmp(msg_browser, "THROWBACK"))
    {
        _kernel_swi_regs r;

        _kernel_swi(XDDEUtils_ThrowbackEnd, &r, &r);
    }
}

VOID send_msg_browser(HSCPRC * hp,
                     HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
                     STRPTR fname, ULONG x, ULONG y,
                     STRPTR msg_text)
{
    if (!upstrcmp(msg_browser, "THROWBACK"))
    {
        if (fname != NULL)
        {
            _kernel_swi_regs r;
            char *riscosname = unixname_to_riscos(fname);

            r.r[0] = ddeutils_THROWBACK_ERROR_DETAILS;
            r.r[2] = (int) riscosname;
            r.r[3] = (int) y;
            switch (msg_class)
            {
            case MSG_NOTE:
            case MSG_STYLE:
            case MSG_PORT:
            case MSG_WARN:
                r.r[4] = ddeutils_SEVERITY_WARNING;
                break;
            case MSG_ERROR:
                r.r[4] = ddeutils_SEVERITY_ERROR;
                break;
            case MSG_FATAL:
                r.r[4] = ddeutils_SEVERITY_SERIOUS_ERROR;
                break;
            default:
                r.r[4] = ddeutils_SEVERITY_WARNING;
                break;
            }
            r.r[5] = (int) msg_text;

            _kernel_swi(XDDEUtils_ThrowbackSend, &r, &r);

            free(riscosname);
        }
    }
}

#endif /* RISCOS */

�������������������������������������hsc-0.934.orig/riscos/srcrename���������������������������������������������������������������������0100600�0001750�0000144�00000011377�07642675506�015400� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������'�ë�� á�� á�ë��ï¨�����������������€����������������������� áÀNàÀà�œéÀLâ0 œåã4Àœ�ÀŒ�ÀŒà�� ã��Sãð Ñ�Œä0Sâûÿÿê
�êT¹D#«bÿº®€«“V»Rä»oëš}u«Š„«Uịã»™}©Š…«?Pª¸jºxךS¹×9«pc™•¹f{«»åùºŒ›èΙª¿·™€¹`%»Úg«fT¹h{º•\ºnl»LäšIæšsÚšCt™]Kš‚æšÜ«/t™,äš>.™ ”«Ýg«ÚD©–‘¹Úk«ôŽ©}u«Š‰«OŽªj>ªpªà»XךÚe«gk™q–™–W©WbªÏUºìUºOƒš[§ª¿D«™« é™èÏ™ª²³™Yµ™(°×G«WN©ÔUªUΫƒê«§I©D[ºÞ—º›Sºg©h{«®_ªÝÒº¸ºUºcß»WaªÌ¯º×F«dE©Ä²ªÜ»d¥ª·|«�»âüº¹ªG-™²¦ªÁ@«RÚ«´›
åö™» ™»¦™	© é™å÷™ ™½¼™ô©}«Šˆ«=Pª‘jªT«ƒÛ«:5™ýU©ô2«a«|1»³¶ªRXª¹Å«a…šb”™N†¹RךòM«SG©tÖ«òM«s©RYªNç»2˜º¨H©ÑpºšFª¢»ÒSºôº:$»xךˆ4©„}ºPŠªÕ<ªÃѪÄЫÅÙ«ÆØ«Ê׫ÍÕ«ÎÔ«ÐÓ«Ÿz»Å®™Ä$™ û©šØ©¢šÆ™Ëã™ûù™£æ™¦'šžÌ™œü™
ç™ûšõ¾™×Í™ôšÍ©
šäÖ™¡ÿ™	á©&ª›š™ÉÇ™%©
ª§î™ÓÕ™ó™Ñšþšº©ïš°$šà©ñš˜—™ªðšâ©™Þٙܙ"#ªšŠ}ºŠª;Oªkmª•ºì«-^™A¹oCºÛd«œŠ©×i«jV¹.íš<6™@R©FÞš1ßšàP©è„¹Íôºá˜«7.™H;™.âš98™ÀC©mȻךœ«õ¤™™¶™À
šè©ÊJ¹Ë™º^&»Çp»š»Séš[•ª	»×µ«ÂE©õ«²É«Uº´	»fך“n™º«—«�ªýšÁ™½ÉºÆõºN«ªè/ªÇE©õ¼«éÄ«ËE©õ»«'û×?«Ìƒ©™À«_Á»ÓºYº»UW««»wך›G©È;«õ¹«ô¿«ô¾«¥‘›)ªÃš­™ÝšÚ(šôš¨ª™¸Ÿ™Âš­™%ªÒ«™Ÿ¯™¹!šªZ	ÉÇ™ÊÈ™!™ß™Ôšåò™±Û™Yµ™} Š„«:Pªiª|]º»öÿªaª»-Öš‹y¹ˆ}ºŒŠª9Oªqjª‘oª”º8»A7»K㚀ªŒ×š×P«O‹¹Qòšýº5
»¶|«³¤ª°£ª­Rº×¹ªP‡¹hךCˆ¹dãši`™qj™ô…©45»×P«O‰¹Tòšýº5
»¶|«³¤ª°£ª¬Rº×¹ªQ¹w©ªG·«šº‰P«B5»eãši`™qj™¡[¹×P«ƒh™ ôºp©ªF¶«šº‰P«E5»Øšª•ªUWª`©«UZª×ë«\+™}«Š…«8Pª}jºE³«Ù*«’M©R[ª¦»BךµŒ«R[ª£é»Rdªèþº}Œ«„~»P‹ª“7ªþ¬ªH3»A몡Q«¢«)6»I´ªLžª2,«±dª®I»JþºBQ«¢«"6»Dãš=Jºž,«MJ«‹1º‡}ºŠª6Oªnpª•lª¤[º¥Tº_eªUXªŽ¨»…}ºPŠª‚5ª-q™V?©±RºRºþ²«=ךR€©}Œ«Š†«4Pª‚mª-v™@¹×°«l)™¯RºRº…}ºPŠª3ª?-™®»(ךŒk¹r†š-u™ *¹zäš
’¹!»予’©ƒ}º>r»^<«úVªíï›sôº.-»~y«Ðò›{䚇ôª|«oº^«ûVªëó›êôªw|¹r‚«oºV^ªúºìï›Fåš.çª+ôºôx«ðx»X^º»Ï«ï]«}3™vuªô«ðvª+*ª-,ªî»º"&™#'™y€«æ»ñ«~0™_™÷m©êñ›,0»LzºK­ºZHº\¾º2ïšu}©õ„ºvø©0ðªqŸºj’«ž½ºøVªñcº/ôºtQº€óºêí›§»¼v«xºï[«}3™�›™™™™ö¹™™¹»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»™™	™™��¬ ™ú šš	����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������(%+e°Œ7‡iòb
c_¨\ü]ðcø^Ì\À^Ø2&]^gHµþpÑ-µà
¯��²öç*7½-ž�sñl¾	à�óëÜ��ÿ#£����o�kÿ|‹õc�_�íÿ•�?o0N�\éa�½(�¾ÜÿÑø��p9�(^�*_À�T¤�	
3×±W³M!�B†Ñ�D�‰ÿÿ��ˆ0E��ÐZký®ó_®pkó�ÿß�l�± ·õÛ¯ÿók	�÷ð �¯��8®Ñÿ±��é�Ýÿÿ��0,�ÿ϶�·�P¸�¶ákôÎô¾�˜›�ðW¤�

�ÿÿ�
%^©]\·�Hûÿ��¤h
ý·µC³<
¯÷hü¹ÄþÆûÛÀT_õ\ø²±
ü¯ý®å÷`ÌX°øú®öefò®íõ¯�±ôñagü�ÿǦšÿ»³ù�N­ù��üMø�gòµ³’K·®Ã±þ�þM­��²7�?û�ÀRÌ�êMò¯ï·³ü�Ì»¼��	ð����2/²�°úÿ¯ð5�°ààÔ�% �Ôò*ù©}�0oóSP]ö»®�úTï��­ªÊ�—�Ó‰ÅÀwA±�±Aõ®
ø±²¯N­¤Ö*°¯éiÛ�ݰ©�£Ng÷�ðÿ@ºö�þ¶ôŽ_î0�JÐ÷äoÿóó¦°»V³A÷²®ñþ¯
¯Þþ*�›‰��fi�G·�ïþ¿�
®�îó¦²L±	´°ÜM±Ë±‰��³�ÛõãER´
õgü²ûó²Ü
¯ ñ�»¼«»��â�P°S³­ñ³E¼¨»Obþ³ï��½¯�c»bS�ûDû�îò²ï¹¿±M²³ï�E	÷�`Â�ù¬°�»��æN��²@´O¿�æMö��ûü�µ
ø�“Þ1(�QÏî��¯ �VÐ_�¢ÿÿ��£ÿÿF#
\ü:)\\Ñ\vO\„X�žûÿ���
\]�–ÿ
°ú]�¹���Ï¥�Ëÿÿ´�³�¯��ð÷ÿ
kókò
kókókþkþ\`À^Àcúlkô‹ô
|kó½þOkÿtcú¬�Œ�ó�º°¯\¯N
\{Bf®\ÿ¯3®äðÞ��
l�®ý®pkä®p®íŸfþ¯�\ÿ®ä¯��®à¯��|�«ä±¯ü®øïgý`*gÙ`&"kÈk:®Âgù¯$FNjd


k¸k×�ñЀ�Íþÿ,®Üÿ70
®Šÿ¯��C®Æÿ°��°��²��Â��¯n�®‘ÿ²��d°ú÷Å�Ü�ò¯ÿ

$\Ök%kÑ0\¿f`þ'\Tg_ÿl�l�g`þkÿ®ÿoÍpl�¯�°Ìý|�®�p�pë�³��¯��íðµò²Ôñh@bЌ䕸Àl®ËýÏà�‹ð±��¯�°�À±� ®�àVc°tLc°°ü×{ü°�¯��l�®À‹ô®�ðkø¯Юðÿ°üÿ{ü®øÿ®� œ�cütL¯Üß&kÀ2\¤\¸{H‹d\Œ\¬¯Œž±��»� ¹üß±øœ�½�À®ÿϯ�0|�´�Ðl�Ç�|�´�б��ñ—l��yð±àþ¯��Π?î�@9J˄翘]ñš�:J®„—*J\€]�^�ÛÌ*J\€]�^�ÞU²†þ�úÿn�_`�8üÿ�0+@
9."\p!
"\t"'N@M
4\�ÈÖÿ�u @�_��¯áÿ¶X�}ùõ�¸#��Á	��G��÷������¨���û ã?Îã�å,�Oâ�?è
 @à	Jà€‰à‰oâ�Vá` ±‹àq†à
P á�@ ã  á�0àã°[â)��ºÕä
�Qâ��ª��Qã
���ÕäÕä€áÕä€á��TãÕ€�0ƒà0†äíÿÿê°Kà°‹â0ƒâ0†äQâûÿÿÊæÿÿê\�Qã�0ƒ°0†´âÿÿº®�Qâ��ºÕä�áÕä€á�0ƒà0†äÙÿÿê\�QâÕä�á�0ƒà0†äÓÿÿê��Tã��° áÀ á  á@ ãÊÿÿê° áPâMoâ@ á�µè�§è�Uáûÿÿºð á
‰à€Hâ	�Zá5��Ú`zå0â	�Sâ��ºzå�á�Aœç��ê�Sâ��ºzå�á�›çzå�Dá��ê@°á��
�zåzå€ázå€ázåL€á&2 á	�Sâ��ºzå�á�Qœç0�(éÜÿÿê�Sâ��ºzå�á�›çzå�Tá0�(éÓÿÿêP°á0�(	Ðÿÿ
�zåzå€ázå€ázå\€á0�(éÇÿÿê��]ã��Ú
`Ià á
 ‰à�¶è�§èÐ]âûÿÿʽÿÿê|€Hâð árcc 5.00
      �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/riscos/throwback.c�������������������������������������������������������������������0100600�0001750�0000144�00000006126�07772072723�015616� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1997  Sergio Monesi and Nick Craig-Wood
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/*
 * riscos/throwback.c
 *
 * throwback support for RiscOS
 */

#ifdef RISCOS /* Hide this stuff from Non-RiscOS compilers */

#include "riscos/unixname.h"
#include <kernel.h>

#undef  DDEUtils_ThrowbackStart
#define DDEUtils_ThrowbackStart         0x42587
#undef  XDDEUtils_ThrowbackStart
#define XDDEUtils_ThrowbackStart        0x62587
#undef  DDEUtils_ThrowbackSend
#define DDEUtils_ThrowbackSend          0x42588
#undef  XDDEUtils_ThrowbackSend
#define XDDEUtils_ThrowbackSend         0x62588
#undef  DDEUtils_ThrowbackEnd
#define DDEUtils_ThrowbackEnd           0x42589
#undef  XDDEUtils_ThrowbackEnd
#define XDDEUtils_ThrowbackEnd          0x62589

#define ddeutils_SEVERITY_WARNING       0
#define ddeutils_SEVERITY_ERROR         1
#define ddeutils_SEVERITY_SERIOUS_ERROR     2
#define ddeutils_THROWBACK_PROCESSING       0
#define ddeutils_THROWBACK_ERROR_DETAILS    1
#define ddeutils_THROWBACK_INFO_DETAILS     2

BOOL hsc_init_throwback(HSCPRC * hp)
{
    BOOL success = TRUE;

    if (hsc_get_throwback(hp))
    {
        _kernel_swi_regs r;

        _kernel_swi(XDDEUtils_ThrowbackStart, &r, &r);
    }

    return success;
}

VOID hsc_del_throwback(HSCPRC * hp)
{
    if (hsc_get_throwback(hp))
    {
        _kernel_swi_regs r;

        _kernel_swi(XDDEUtils_ThrowbackEnd, &r, &r);
    }
}

VOID hsc_throwback(HSCPRC * hp,
                   HSCMSG_CLASS msg_class, HSCMSG_ID msg_id,
                   STRPTR fname, ULONG x, ULONG y,
                   STRPTR msg_text)
{
    if (fname != NULL)
    {
        _kernel_swi_regs r;
        char *riscosname = unixname_to_riscos(fname);

        r.r[0] = ddeutils_THROWBACK_ERROR_DETAILS;
        r.r[2] = (int) riscosname;
        r.r[3] = (int) y;
        switch (msg_class)
        {
        case MSG_NOTE:
        case MSG_STYLE:
        case MSG_PORT:
        case MSG_WARN:
            r.r[4] = ddeutils_SEVERITY_WARNING;
            break;
        case MSG_ERROR:
            r.r[4] = ddeutils_SEVERITY_ERROR;
            break;
        case MSG_FATAL:
            r.r[4] = ddeutils_SEVERITY_SERIOUS_ERROR;
            break;
        default:
            r.r[4] = ddeutils_SEVERITY_WARNING;
            break;
        }
        r.r[5] = (int) msg_text;

        _kernel_swi(XDDEUtils_ThrowbackSend, &r, &r);

        free(riscosname);
    }
}

#endif /* RISCOS */
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/riscos/unixname.c��������������������������������������������������������������������0100600�0001750�0000144�00000007061�07772072723�015455� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1997  Sergio Monesi and Nick Craig-Wood
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "unixname.h"

extern FILE *gopen(const char *, const char *);
extern FILE *greopen(const char *, const char *, FILE *);
extern int gemove(const char *);
extern int gename(const char *, const char *);

/************************************************************
This translates a unix file name to a riscos filename

.. -> ^
/ <-> .
************************************************************/

char *unixname_to_riscos(const char *unix)
{
    int len = strlen(unix) + 1;
    char *_riscos = malloc(len);
    char *riscos;
    
/* fprintf(stderr, "unix   = '%s'\n", unix); */
    
    if (_riscos == 0)
    {
        fprintf(stderr, "Couldn't allocate memory for file name\n");
        exit(EXIT_FAILURE);
    }
    
    for (riscos = _riscos; *unix; unix++)
    {
        int c = *unix;
        switch (c)
        {
        case '.':
            if (unix[1] == '.')
            {
                unix++;
                *riscos++ = '^';
            }
            else
            {
                *riscos++ = '/';
            }
            break;
        case '/':
            *riscos++ = '.';
            break;
        default:
            *riscos++ = c;
            break;
        }
        
        *riscos = 0;
    }
    
/* fprintf(stderr, "riscos = '%s'\n\n", _riscos); */

    return _riscos;
}

/************************************************************
************************************************************/

FILE *fopen(const char *unix_filename, const char *mode)
{
    char *riscos_filename = unixname_to_riscos(unix_filename);
    FILE *handle = gopen(riscos_filename, mode);
    free(riscos_filename);
    return handle;
}

/************************************************************
************************************************************/

FILE *freopen(const char *unix_filename, const char *mode, FILE *stream)
{
    char *riscos_filename = unixname_to_riscos(unix_filename);
    FILE *handle = greopen(riscos_filename, mode, stream);
    free(riscos_filename);
    return handle;
}

/************************************************************
************************************************************/

int remove(const char *unix_filename)
{
    char *riscos_filename = unixname_to_riscos(unix_filename);
    int error = gemove(riscos_filename);
    free(riscos_filename);
    return error;
}

/************************************************************
************************************************************/

int rename(const char *unix_old, const char *unix_new)
{
    char *riscos_old = unixname_to_riscos(unix_old);
    char *riscos_new = unixname_to_riscos(unix_new);
    int error = gename(riscos_old, riscos_new);
    free(riscos_old);
    free(riscos_new);
    return error;
}
�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/riscos/unixname.h��������������������������������������������������������������������0100600�0001750�0000144�00000001721�07772072723�015457� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*
 * This source code is part of hsc, a html-preprocessor,
 * Copyright (C) 1997  Sergio Monesi and Nick Craig-Wood
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */
/* unixname.h */

#ifndef __unixname_h
#define __unixname_h


#endif /* __unixname_h */

/* Auto */

extern char *unixname_to_riscos(const char *unix)
;
�����������������������������������������������hsc-0.934.orig/starter-project/���������������������������������������������������������������������0040700�0001750�0000144�00000000000�07776512741�015313� 5����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/starter-project/include/�������������������������������������������������������������0040700�0001750�0000144�00000000000�07776512741�016736� 5����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������hsc-0.934.orig/starter-project/include/page.hsc�����������������������������������������������������0100600�0001750�0000144�00000002260�07642675506�020351� 0����������������������������������������������������������������������������������������������������ustar  �lory����������������������������users������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������<****** page ****************************************************************
* NAME
*   page -- Macro to insert the dull html stuff for a page.
* SYNOPSIS
*   <$macro page section:string heading:string/required>
* FUNCTION
*   This macro inserts the dull <head> and <body> stuff and computes a
*   document title consisting of a optional section and a required heading.
* INPUTS
*   section - Optional name of the section of your site (e.g. "Support"),
*       used in title but not in heading. If this is omitted, the title is
*       equal to the heading.
*   heading - Heading displayed at top of document; also used for title
****************************************************************************>
<$macro page /close
    section:string
    heading:string/required
>
<* Figure out the title (usually displayed in the browser window title) *>
<$define title:string="">
<$if cond=(set section)>
   <$let title=(section + " - ")>
</$if>
<$let title=(title + heading)>

<* Insert head *>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html><head>
<title><(title)>


<* Insert body including macro contents *>

<(heading)>

<$content> hsc-0.934.orig/starter-project/include/standard.hsc0100600000175000001440000000062607642675506021241 0ustar loryusers<* Your standard macros and includes for the new project can be stored here * This is intended to be used for project dependant macros that differ * between projects. * * Store standard macros you want to reuse somewhere else and use the * CLI-option INCLUDEDIR when invoking hsc. *> <* A little example *> <$macro mail-to-hugo>
hugo@resi.sepp.org hsc-0.934.orig/starter-project/Makefile0100600000175000001440000000163207642675506016755 0ustar loryusers# # Generic Makefile for hsc projects # # # DESTDIR - destination directory (usually relative to source directory) # HSCMESSAGE - hsc message options # HSCPROJECT - project file # HSCINCLUDE - standard includes for all sources # HSCMISC - miscellaneous flags and options # # HSC - shell command that invokes hsc # HSCFLAGS - hsc options # # HSCDEPP - shell command that invokes hscdepp # DESTDIR = HSCMESSAGE =MsgMode=normal Ignore=46 HSCPROJECT =hsc.project HSCINCLUDE =include/standard.hsc include/page.hsc HSCMISC =RplcEnt HSC =hsc HSCFLAGS=$(HSCMISC) $(HSCMESSAGE) PrjFile=$(HSCPROJECT) to=$(DESTDIR) $(HSCINCLUDE) HSCDEPP =hscdepp # # rule to update whole docs # (all_hsc will be created by hscdepp) # all : all_hsc # # implicit rule for html-files # $(DESTDIR)%.html : %.hsc $(HSC) $(HSCFLAGS) $< # # update dependencies # depend : $(HSCDEPP) file=Makefile PrjFile=$(HSCPROJECT) verbose hsc-0.934.orig/starter-project/README0100600000175000001440000000225007642675506016172 0ustar loryusersAbout `starter-project' ======================= Amiga users, ignore this material and double-click "hsc-Tschak". This will spare you the CLI-crap below. For all others: this drawer contains some files and material that can be used as a template for new projects. Included are a Makefile, a first hsc source called "welcome.html" and a directory containing include files you want to use for every new project. You can start a new project by copying the directory contents to the location where you want to start you new project. To for example setup a new project in "work:web/dogstuff" with the source code located in "work:web/dogstuff/source", do the following: - "cd" to work:web/dogstuff/source - copy the contents of starter-project to it, so you should then have a "work:web/dogstuff/source/welcome.hsc" - edit the Makefile, set DESTDIR to "/" (or "../" on various other systems) - invoke "hscpitt new" - invoke "hscpitt add /welcome.html welcome.hsc" - invoke "make depend" - invoke "make" to create "work:web/dogstuff/welcome.html" Then you can view the document in "work:web/dogstuff/welcome.html" For more information, refer to the manual, section "Project Mangament". hsc-0.934.orig/starter-project/Welcome.hsc0100600000175000001440000000014307642675506017403 0ustar loryusers Welcome

Welcome

Hello world! hsc-0.934.orig/test/0040700000175000001440000000000007776512741013142 5ustar loryusershsc-0.934.orig/test/.xvpics/0040700000175000001440000000000007776512741014534 5ustar loryusershsc-0.934.orig/test/.xvpics/test.jfif0100600000175000001440000001073007642675506016354 0ustar loryusersP7 332 #IMGINFO:320x256 RGB (2237 bytes) #END_OF_COMMENTS 75 60 255 Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÛÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶ÚnHÛÛ¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶ÚInÚÛ¶Ú·ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÚÛ¶Û¶ÚÛ¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú“lÛÛ¶Ú·ÚÚ·Ú·Ú¶Û¶ÚÛ¶Û¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·ÚÛ¶¶‘n‘n‘nÛÚ¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·µ·mÚ·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·¶m$n¶Ú·Ú¶Û¶$IÛÚ·ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·HÛmÛ¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶$$%II$$$Û¶Û¶Im$ÚÛ¶¶·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·ÚIÛmÚÛ¶Û¶‘n$Û¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶ÚÛ¶Ú·I¶’$Û¶ÚÛ¶Úÿ·Ú¶Û¶ÛÚ¶Û¶Ú·ÚÛ¶Ú·Ú’mÛ¶Ú·Ú¶ÛÿIÚÛ¶Ú·$ÛÚ·Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Ú%þ·Ú·Ú¶Û¶Û¶Úÿ·¶$$¶ÚÛ¶Ú·¶¶’HI%ÚÛ¶IHÛIÛÚ·ÚmIÛ$ÛÚ¶Û¶ÛÚ¶Û¶Û¶Ú·ÚÚ·Ú·Ú$ÿ·Ú¶Û¶Û¶Û¶Úÿ·m$%m$%$’’‘ÛÚ·Ú·Ú¶Û¶ÚÛ¶ÿ¶¶·Úmn$$’nÚ¶ÿ¶·ÚÛ¶Ú·Ú¶ÛÚ’IH·¶Û¶Ú%þ·Ú·Ú¶Û¶Û¶Úÿ·µ’Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Û¶HÛÛ¶ÚÛIÚÛ¶Ú·Ú$$·Ú¶Û¶ÚÛ¶Û¶ÚÛ$ÿ·Ú¶Û¶Û¶Û¶Ú%ÛÚ’’Ú·ÚÚ·Ú·Ú¶Û¶ÚÛ¶Û¶Ú·Ú’ÛÚÚ·Ú·Ú¶Û¶ÚÛ’Ú·ÚÚ·µnm%ÿ¶Ú¶n¶Û¶Ú·IÛÚ¶Û¶Ú·ÚÛ¶ÚmÛ¶·’Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Ú·mmÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·$$nmHnÚ·Ún¶ÛÚ·Ú¶¶’¶Û¶ÚÛ¶Û¶Û¶ÚmÛ¶ÛIÚÛ¶Û¶Ú·ÚÚ·Ú·Ú¶ÛÚ’$·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶¶Û¶Û¶ÚÛ¶’’¶Û¶ÚÛ’’Ú·Ú¶ÛÚ¶ÛÛ¶ÚmÛ¶Û$ÿ¶Û¶Û‘ÛÚ·ÚI$%$$nÛ¶Ú·lJÚ¶·Ú¶¶’¶ÛÚ¶Û¶Û¶’‘IÛÚ·ÚÚ·mÛ¶Û¶’¶ÛÚ¶Û¶Ú·Û¶ÚmÛ¶ÛHÛÛ¶Ú·mÛÚ·ÛÚ¶·$Û¶Ú’m%H%H%m“ÚÚ·Ú¶m%$¶·Ú·Ú¶$ÛÛ¶¶’Ú·Ú¶Û¶Ú·Û¶Úm·¶Úm’·Ú¶·ÿmÛ¶Ú’¶Û¶Ú·Úm·ÚÛ¶Ú’IÛÚ¶m%Ú·HIÛ¶ÛÚ¶ÛÛ¶Ú·’¶ÛÚ¶Û¶Ú·Û¶Ú·$IÚ·mIHI’Û¶ÛÚ¶n$ÛÚ¶ÛÚIÛÚ·Ú¶ÛÚIÛÚ·Ú¶ÛmHÛ·Ú¶I$ÛÛ¶ÚÛ¶Ûÿ¶Ún’Ú·Ú¶Û¶Ú·Û¶Ú·‘Û¶¶mÛÚ·Ú·ÚÚ·ÚÛ¶Ú·ÚÛ¶$ÛÚ·Ú·ÚÚIÛÚ·Ú¶Û‘%ÛÚ¶Û’$Û$ÛÚ¶Û¶ÛH’Û¶$ÛÚ·ÚÛ¶Ú·ÚÛ¶Ú·‘Û¶Ú%þ·Ú·Ú¶Û¶Ú·$¶$ÿ·ÚmIÛ¶Ú·Ú·ÚmÛ¶Ú·Ú·Ú$ÛÚ·Ú¶ÛImÚ·Ú·ÚÚ“’Ú¶IÛÚ¶Û¶Ú·Ú·Û¶Ú·µnÛÚÿ¶Û¶Ú·Ú·Ú¶Û‘IÛ¶ÚnHÛ¶Û¶Û¶ÚmÛ¶Û¶Û¶ÚIÛÚ¶·H%¶Úÿ·Ú¶·’Ú’’Ú·Ú¶Û¶ÛÚ¶Û¶Ú·ÚmÛÚÛ¶ÛÚ¶Û¶Û¶Ú·Ú¶·ÚÚ¶·Ú·ÚÚ·ÚIÛÚ·ÚÚ·ÚIÚ·Ú·Ú·ÚÛÚ¶Û¶’¶¶’Ú·Ú¶Û¶ÛÚ¶Û¶Ú·ÚmÛÚÛ¶ÛÚ¶Û¶Û¶Ú·‘ÛÚ·Ú$’Û¶Ú·Ú¶ÛmÛ¶Ú·Ú¶ÛHÛÛ¶Ú%mÛ¶ÿ¶Ú·¶’¶¶’Ú·Ú¶ÛÚ·Ú¶Û¶Ú·Ú$ÛÛÛ¶ÚÛ¶Û¶Ú·Ú¶$ÛÛ¶Ú$“Ú¶Û¶ÛÚ¶mÛ¶Û¶Ú·ÚIÛÚ¶Ûm$Û·ÿ¶Ú·¶’¶mÛ¶ÛÚ¶Û¶Ú·ÚÛ¶Ú·Ú$ÛÛ$Ûµ%mInÚÛ¶Ú·$ÛÚ¶Û$’Ú·Ú·Ú¶ÛmÚ·Ú·Ú¶ÛÛÚ¶Û¶$ÿ·ÛÚ¶Û$¶·lÛ·Ú¶ÛÚ·Ú¶ÛÛ¶Ú·ÚÛ¶‘%Ú·Ú·Úÿ¶Û¶ÛÚ¶Û¶Ú·ÚmÛ¶Û¶Ú·ÚÛÚ¶Û¶¶Û¶ÛÚ¶’Û¶$ÛÚ·ÚÚ·Ú·Ú¶Û¶Ú·ÚÛ¶Ú·‘’Ú·Ú·Ú¶ÛÚ¶$Û·Ú¶ÛÚ·ÚÚ·Ú·lÛ·ÚÚ·Ú’ÿ¶Û¶Ú·µÛ$$ÛÚ¶ÿ¶Û¶Û¶Ú·Ú¶Û¶Ú·ÚÛ¶Ú·ÚÛ¶Ú·Ú¶ÛÚ·Úÿ¶Û¶ÛÚ¶ÛH“Ú¶ÿ¶¶nÚ·‘$ÿ·¶ÚÛ¶IÚ·Ú¶¶·¶ÚÛ¶ÚÛ¶ÛÚ¶Û¶Û¶ÚÛ¶Ú·ÚÛ¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·µÛÛ¶Ú·Ú¶%m$’¶·Ú¶’Ú%‘Û¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚÛÚ·Ú¶Û¶ÚÛ¶Û¶Ú·ÚÛ¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·µÛÛ¶Ú$“Ú¶%‘%‘nH“ÚIÚ·¶ÛÚ·Ú¶Û$’Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶Ú·ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛµÛ·ÚÚ·¶Ún$ÛHnmÛmÿ¶¶Û¶ÛÚ¶Û$’Ú·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·Ú¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛµÛ·ÚÚn$ÿ¶Û¶Û¶$’ÛÚ¶ÛÚ¶Û¶Û¶Ú’HnÛÚ·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú¶Û¶Û¶ÚÛ¶Ú·ÚÛÛÛ¶Ú·Ú$Û¶Û¶Ú·H“Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÚÛÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶Û¶Úÿ¶Û¶Û¶$ÛÛ¶Ú·ÚmÛ¶ÛÚ¶ÛI‘Û¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶Û¶ÚImnÚÛ¶ÚIÛ¶¶ÛÚ·‘Û¶Ú·Ú¶$·ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶Û¶ÚÛ¶m·ÚÚ·‘Û’$I$ÛÚ·ÚÛ¶$Û$ÛÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶$IÛÚ·µ‘¶ÛÚ·Ú·Ú¶Û¶ÛÚ¶Û$ÛÚIÛ¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶I$Û¶ÛÚI$’Û¶Ú·ÚÚ·Ú·Ú¶ÛH%Ûµ·ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Ú·Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶ÛHÛÚ·Ú·ÚÚ·Ú¶m·ÚÛ¶Û¶mIm¶Û¶¶ÛÚ¶Û¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶Û‘ÛÚ·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶IÚÛ¶ÛµÚÛ¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶Û‘ÛÚ·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶’ÚÛ¶Ú’$Û¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶Û‘ÛÚ·Ú¶ÛÚ·Ú¶ÛIÚ·ÚÛHÛ¶Û¶$mÛ¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶Ûµ·ÚInÚÛ¶Ú·Ú’$¶mIn$ÛÚ·ÚÛÚ¶ÛÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶ÛÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú’$Û¶Û¶$IÚ·µ·Ú·Ú·‘$ÛÛ¶ÚÛ‘Û¶Û¶$ÛÚ·Ú·Ú¶Û¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú¶Û¶ÛÚ¶Û¶ÚnÚ·Ú¶ÛmIÚ·ÚÛ¶Ú·Ú¶IÛÚ·Ú¶Û¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú¶Û¶Û¶ÚÛ¶ÚIÛ¶Û¶ÚIIÛÚ¶Û¶Û¶ÚÛÛÚ¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·$ÛÚ¶Û¶ÛÚ¶ÛÚ·Ú¶I‘·ÚÛ¶Û¶Ú·$‘·ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·$ÛÚ¶Û¶Û¶Ú$“ÚÚ·Ú¶Û¶Û¶Ú·ÚÚÛ¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·$ÛÚ¶Û¶ÛÚ¶’$%‘·ÚÛ¶Ú·Ú¶ÛIÚÛ¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·HÛ¶ÚÛ¶Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÛÚ¶Û¶ÚnÚÛ¶Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÚÛ¶Û¶Ú·Ú¶ÛÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚIþ·Ú·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶’Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶ÛÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚHÛ·Ú¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶$ÛÚ·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·Ú$ÛÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶$ÛÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·Ú‘ÛÛ¶Ú·Ú¶ÛÚ·Ú¶Û¶Ú·ÚÛ¶Ú·$ÛÚ¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·HÛÛ¶Ú·Ú·ÚÚ·Ú¶Û¶ÛÚ¶Û¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶ÛÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶I$%‘nÚ·Ú¶Û¶Û¶ÚÛI$%þ·Ú·Ú¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛm’$I$I%$I$ÿ·¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Û¶ÚÛ¶ÚÛ¶Ú·ÚÛ¶Ú·Ú¶Û¶ÛÚ¶Û¶Ú·Ú·ÚÚ·Ú¶Û¶Û¶ÚÛ¶Ú·Ú·Ú¶ÛÚ¶Û¶Û¶Ú·ÚÚ·Ú·Ú¶Û¶ÚÛ¶Û¶Ú·Ú¶ÛÚ·Ú¶Û¶Úhsc-0.934.orig/test/assign.expected0100600000175000001440000000045207642675506016152 0ustar loryusers check conditional assignment RESI=resi HINZ=hinz SEPP=no hugo SEPP=seppHUGO=hugo SEPP=resiHUGO=resi SEPP=hinz RESI=hinz RESI=hinz RESI unsetRESI unset RESI=hinz RESI=hinz RESI=hinz hsc-0.934.orig/test/assign.hsc0100600000175000001440000000172207642675506015127 0ustar loryusers check conditional assignment <$macro CheckCA sepp:string hugo:string> <$if cond=(set sepp)>SEPP=<(sepp)> <$if cond=(set hugo)>HUGO=<(hugo)> <$define resi:string="resi"> <$define hinz:string="hinz"> <$define kunz:string> RESI=<(resi)> HINZ=<(HINZ)> <$let resi=(hinz)> RESI=<(resi)> <$let resi?=resi> RESI=<(resi)> <$let resi> <$if cond=(set resi)>RESI set<$else>RESI unset <$let resi?=resi> <$if cond=(set resi)>RESI set<$else>RESI unset <$let resi?=hinz> RESI=<(resi)> <$let resi?=kunz><* kunz does not exist *> <$if cond=(set resi)>RESI=<(resi)><$else>RESI unset <* compute assignment *> <$let resi="resi again"> <$let resi?=("hi"+"nz")> <$if cond=(set resi)>RESI=<(resi)><$else>RESI unset hsc-0.934.orig/test/assign.html0100600000175000001440000000045207642675506015315 0ustar loryusers check conditional assignment RESI=resi HINZ=hinz SEPP=no hugo SEPP=seppHUGO=hugo SEPP=resiHUGO=resi SEPP=hinz RESI=hinz RESI=hinz RESI unsetRESI unset RESI=hinz RESI=hinz RESI=hinz hsc-0.934.orig/test/assign.mex0100600000175000001440000000000007642675506015127 0ustar loryusershsc-0.934.orig/test/assign.msg0100600000175000001440000000000007642675506015124 0ustar loryusershsc-0.934.orig/test/autoclose.expected0100600000175000001440000000036107642675506016663 0ustar loryusers autoclose
  • eins
  • zwei
    • bla

sepp

hugo

hsc-0.934.orig/test/autoclose.hsc0100600000175000001440000000036107642675506015637 0ustar loryusers autoclose
  • eins
  • zwei
    • bla

sepp

hugo

hsc-0.934.orig/test/autoclose.html0100600000175000001440000000036107642675506016026 0ustar loryusers autoclose
  • eins
  • zwei
    • bla

sepp

hugo

hsc-0.934.orig/test/autoclose.mex0100600000175000001440000000000007642675506015641 0ustar loryusershsc-0.934.orig/test/autoclose.msg0100600000175000001440000000000007642675506015636 0ustar loryusershsc-0.934.orig/test/err_autoclose.hsc0100600000175000001440000000067307642675506016515 0ustar loryusers autoclose
  • eins
  • zwei
    • bla

sepp

hugo

<* now for some errors *>

sepp.

hugo ist fett

  • eins
  • <* ok *>
  • zwei
    • bla
    • <* error *>
hsc-0.934.orig/test/eval.expected0100600000175000001440000000135707642675506015622 0ustar loryusers check operators susi susi-double susi-single susi-double-in-brackets susi-double-in-brackets IN IN -NOT IN [] + [] = [] = [] [] + [] = [] = [] [hugo ] + [ist doof] = [hugo ist doof] = [hugo ist doof] [hugo ist ] + [doof] = [hugo ist doof] = [hugo ist doof] susi and sepp hugo, susi and sepp CheckBool2: error handling 1*1=1=0 ERROR! Check AND (2): 0*0=0=0 0*1=0=0 1*0=0=0 1*1=1=1 Check OR (2): 0*0=0=0 0*1=1=1 1*0=1=1 1*1=1=1 Check XOR (2): 0*0=0=0 0*1=1=1 1*0=1=1 1*1=0=0 CheckNumeric2: error handling 1 + 2 = 12 = 17 ERROR! Check "+" (2): 1 & 2 = 3 = 3 1 & -2 = -1 = -1 -1 & 2 = 1 = 1 -1 & -2 = -3 = -3 hsc-0.934.orig/test/eval.hsc0100600000175000001440000001063407642675506014574 0ustar loryusers check operators <************************************** * * * test string constants * * * **************************************> <$define susi:string> <$let susi=susi><(susi)> <$let susi="susi-double"><(susi)> <$let susi='susi-single'><(susi)> <$let susi=("susi-double-in-brackets")><(susi)> <$let susi=(susi)><(susi)> <************************************** * * * test string operators * * * **************************************> <************************************** * checkIn * **************************************> <$macro checkIn little:string/r big:string/r> <$if cond=(little IN big)>IN<$else>-NOT IN <************************************** * checkConcat * **************************************> <$macro CheckConcat v1:string/r v2:string/r vu:string/r> <$define vc:string=(v1+v2)><$stripws type=prev> [<(v1)>] + [<(v2)>] = [<(vc)>] = [<(vu)>] <$if cond=(vu<>vc)><$stripws type=prev> ERROR! <$let susi="susi"> <$let susi=(susi+" and sepp")><(susi)> <$let susi=("hugo, "+susi)><(susi)> <************************************** * * * test boolean operators * * * **************************************> <************************************** * printBool: * * insert boolean value as "0" or "1" * **************************************> <$macro printBool v:bool><$if cond=(v)>1<$else>0 <************************************** * check boolean function, 2 operands * * * * inputs: * * v1, v2...boolean operands * * vc.......result (computed) * * vu.......result (user suggestion)* **************************************> <$macro checkBool2 v1:bool v2:bool op:string vu:bool> <$define vc:bool> <("<$let vc=(v1 "+op+" v2)>")><$stripws type=prev> *== <$if cond=(vc xor vu)><$stripws type=prev> ERROR! CheckBool2: error handling <************************************** * check AND,OR,XOR with 2 operands * **************************************> Check AND (2): Check OR (2): Check XOR (2): <************************************** * * * test numeric operators * * * **************************************> <************************************** * check numeric function, 2 operands * * * * inputs: * * v1, v2...numeric operands * * vc.......result (computed) * * vu.......result (user suggestion)* **************************************> <$macro checkNumeric2 v1:num/r v2:num/r op:string vu:num/r> <$define vc:num> <("<$let vc=(v1 "+op+" v2)>")><$stripws type=prev> <$if cond=(op="&")><$let op="&"> <(v1)> <(op)> <(v2)> = <(vc)> = <(vu)> <$if cond=(vc<>vu)><$stripws type=prev> ERROR! CheckNumeric2: error handling <$message text="checking error handling"> <************************************** * check numeric with 2 operands * **************************************> Check "+" (2): hsc-0.934.orig/test/eval.html0100600000175000001440000000135707642675506014765 0ustar loryusers check operators susi susi-double susi-single susi-double-in-brackets susi-double-in-brackets IN IN -NOT IN [] + [] = [] = [] [] + [] = [] = [] [hugo ] + [ist doof] = [hugo ist doof] = [hugo ist doof] [hugo ist ] + [doof] = [hugo ist doof] = [hugo ist doof] susi and sepp hugo, susi and sepp CheckBool2: error handling 1*1=1=0 ERROR! Check AND (2): 0*0=0=0 0*1=0=0 1*0=0=0 1*1=1=1 Check OR (2): 0*0=0=0 0*1=1=1 1*0=1=1 1*1=1=1 Check XOR (2): 0*0=0=0 0*1=1=1 1*0=1=1 1*1=0=0 CheckNumeric2: error handling 1 + 2 = 12 = 17 ERROR! Check "+" (2): 1 & 2 = 3 = 3 1 & -2 = -1 = -1 -1 & 2 = 1 = 1 -1 & -2 = -3 = -3 hsc-0.934.orig/test/eval.mex0100600000175000001440000000010707642675506014602 0ustar loryuserstest/eval.hsc (125,42): Note 39: user message: checking error handling hsc-0.934.orig/test/eval.msg0100600000175000001440000000010707642675506014577 0ustar loryuserstest/eval.hsc (125,42): Note 39: user message: checking error handling hsc-0.934.orig/test/hsc-test.project0100600000175000001440000000163407642675506016270 0ustar loryusersHSC_PROJECT VERSION 2 # Contains all data relevant for project. # Maintained by hsc, DO NOT MODIFY! # updated: 24-Oct-2001 23:55:44 DOCUMENT 10 test/simple.html SOURCE f test/simple.hsc TITLE 0 DOCUMENT f test/macro.html SOURCE e test/macro.hsc TITLE 0 DOCUMENT 10 test/macro2.html SOURCE f test/macro2.hsc TITLE 0 DOCUMENT 13 test/msg_macro.html SOURCE 12 test/msg_macro.hsc TITLE 0 DOCUMENT 10 test/assign.html SOURCE f test/assign.hsc TITLE 0 DOCUMENT e test/eval.html SOURCE d test/eval.hsc TITLE 0 DOCUMENT 13 test/autoclose.html SOURCE 12 test/autoclose.hsc TITLE 0 DOCUMENT 12 test/redefine.html SOURCE 11 test/redefine.hsc TITLE 0 DOCUMENT 12 test/sgmlspec.html SOURCE 11 test/sgmlspec.hsc TITLE 0 DOCUMENT 11 test/stripws.html SOURCE 10 test/stripws.hsc TITLE 0 DOCUMENT 15 test/opt_getsize.html SOURCE 14 test/opt_getsize.hsc TITLE 0 DOCUMENT 15 test/opt_rplcent.html SOURCE f test/simple.hsc TITLE 0 hsc-0.934.orig/test/illgnest.hsc0100600000175000001440000000032407642675506015461 0ustar loryusersillegal nesting nufin<**> ; forgot to close nufin ; now close twice hsc-0.934.orig/test/illgnest.mex0100600000175000001440000000061207642675506015475 0ustar loryuserstest/illgnest.hsc (3,34): Warning 21: file `test/probably-not-there.html' for URI `probably-not-there.html' not found test/illgnest.hsc (4,3): Error 61: tag not allowed within tag test/illgnest.hsc (4,34): Warning 21: file `test/probably-not-there.html' for URI `probably-not-there.html' not found test/illgnest.hsc (5,4): Portability problem 79: preceding white space for end tag hsc-0.934.orig/test/illgnest.msg0100600000175000001440000000061207642675506015472 0ustar loryuserstest/illgnest.hsc (3,34): Warning 21: file `test/probably-not-there.html' for URI `probably-not-there.html' not found test/illgnest.hsc (4,3): Error 61: tag not allowed within tag test/illgnest.hsc (4,34): Warning 21: file `test/probably-not-there.html' for URI `probably-not-there.html' not found test/illgnest.hsc (5,4): Portability problem 79: preceding white space for end tag hsc-0.934.orig/test/macro.expected0100600000175000001440000000176207642675506015774 0ustar loryuserskack ----simple resi---- simple_resi. sepp(simple)=sepp_simple sepp(simple)=sepp_simple_2 (after <$let>) ----old-style container---- resi_start: sepp=sepp_resi (inside resi) resi_end : sepp=sepp_resi ----paired resi---- (start paired resi) sepp(paired)=sepp_paired resi_start: sepp=sepp_resi sepp(paired)=sepp_global resi_end : sepp=sepp_resi sepp(paired)=sepp_paired (end paired resi)-- ----recursive resi---- recursive_start: sepp=sepp_recursive recursive_start: sepp=sepp_recursive_x recursive_start: sepp=sepp_recursive_x_x recursive_start: sepp=sepp_recursive_x_x_x ABORT recursion. recursive_end : sepp=sepp_recursive_x_x_x recursive_end : sepp=sepp_recursive_x_x recursive_end : sepp=sepp_recursive_x recursive_end : sepp=sepp_recursive sepp(global)=sepp_global ----nesting a container---- twice: (pag(lnk(hrf#hrf)lnk)pag) once : (lnk(hrf*hrf)lnk) hsc-0.934.orig/test/macro.hsc0100600000175000001440000000301407642675506014740 0ustar loryusers<* simple macro without attributes *> <$macro simple_resi SEPP:string="sepp_simple"> simple_resi. sepp(simple)=<(sepp)> <$let sepp="sepp_simple_2"> sepp(simple)=<(sepp)> (after <$source><$let>) <* macro that will be called recursively *> <$macro recursive_resi SEPP:string="sepp_recursive"> recursive_start: sepp=<(sepp)> <$if cond=(sepp="sepp_recursive_x_x_x")> ABORT recursion. <$else> recursive_end : sepp=<(sepp)> <* old-style container *> <$macro resi SEPP:string="sepp_resi"> resi_start: sepp=<(sepp)> <$macro /resi> resi_end : sepp=<(sepp)> <* new style container *> <$macro paired_resi /CLOSE SEPP:string="sepp_paired"> (start paired resi) sepp(paired)=<(sepp)> <$content> sepp(paired)=<(sepp)> (end paired resi) <***************************************> kack ----simple resi---- ----old-style container---- (inside resi) <* comm <* comm2 *> *> <**** sepp ****> <*** sepp ***> <$define sepp:string="sepp_global"> ----paired resi---- sepp(paired)=<(sepp)> -- ----recursive resi---- sepp(global)=<(sepp)> ----nesting a container---- <$macro pag /close>(pag<$content>pag) <$macro lnk /close>(lnk<$content>lnk) <$macro hrf /close>(hrf<$content>hrf) twice: # once : * hsc-0.934.orig/test/macro.html0100600000175000001440000000176207642675506015137 0ustar loryuserskack ----simple resi---- simple_resi. sepp(simple)=sepp_simple sepp(simple)=sepp_simple_2 (after <$let>) ----old-style container---- resi_start: sepp=sepp_resi (inside resi) resi_end : sepp=sepp_resi ----paired resi---- (start paired resi) sepp(paired)=sepp_paired resi_start: sepp=sepp_resi sepp(paired)=sepp_global resi_end : sepp=sepp_resi sepp(paired)=sepp_paired (end paired resi)-- ----recursive resi---- recursive_start: sepp=sepp_recursive recursive_start: sepp=sepp_recursive_x recursive_start: sepp=sepp_recursive_x_x recursive_start: sepp=sepp_recursive_x_x_x ABORT recursion. recursive_end : sepp=sepp_recursive_x_x_x recursive_end : sepp=sepp_recursive_x_x recursive_end : sepp=sepp_recursive_x recursive_end : sepp=sepp_recursive sepp(global)=sepp_global ----nesting a container---- twice: (pag(lnk(hrf#hrf)lnk)pag) once : (lnk(hrf*hrf)lnk) hsc-0.934.orig/test/macro.mex0100600000175000001440000000000007642675506014744 0ustar loryusershsc-0.934.orig/test/macro.msg0100600000175000001440000000000007642675506014741 0ustar loryusershsc-0.934.orig/test/macro2.expected0100600000175000001440000000010507642675506016044 0ustar loryusers blub mist hsc-0.934.orig/test/macro2.hsc0100600000175000001440000000032607642675506015025 0ustar loryusers<$macro hinz title:string> <(title)> <$macro page /close title:string> blub <$content> hsc-0.934.orig/test/macro2.html0100600000175000001440000000010507642675506015207 0ustar loryusers blub mist hsc-0.934.orig/test/macro2.mex0100600000175000001440000000000007642675506015026 0ustar loryusershsc-0.934.orig/test/macro2.msg0100600000175000001440000000000007642675506015023 0ustar loryusershsc-0.934.orig/test/msg_macro.expected0100600000175000001440000000021607642675506016633 0ustar loryuserskack sepp_simple: sepp_nested: sepp_out(sepp_in( )) sepp_out( blub fasel ) hsc-0.934.orig/test/msg_macro.hsc0100600000175000001440000000076407642675506015617 0ustar loryuserskack <$macro sepp_simple><$message TEXT="sepp_simple" CLASS=note> <$macro sepp_nested> <$macro sepp_out /CLOSE>sepp_out(<$content>) <$macro sepp_in /MBI="sepp_out"> sepp_in( <$message TEXT="this is sepp_in" CLASS=note> ) sepp_simple: sepp_nested: blub <$message TEXT="inside sepp_out" CLASS=note> fasel hsc-0.934.orig/test/msg_macro.html0100600000175000001440000000021607642675506015776 0ustar loryuserskack sepp_simple: sepp_nested: sepp_out(sepp_in( )) sepp_out( blub fasel ) hsc-0.934.orig/test/msg_macro.mex0100600000175000001440000000140707642675506015626 0ustar loryuserstest/msg_macro.hsc (3,61): Note 39: user message: sepp_simple test/msg_macro.hsc (13,27): Note 39: (location of previous call) test/msg_macro.hsc (3,61): Note 39: user message: sepp_simple test/msg_macro.hsc (5,18): Note 39: (location of previous call) test/msg_macro.hsc (14,27): Note 39: (location of previous call) test/msg_macro.hsc (10,45): Note 39: user message: this is sepp_in test/msg_macro.hsc (16,20): Note 39: (location of previous call) test/msg_macro.hsc (7,44): Note 39: (location of previous call) test/msg_macro.hsc (16,31): Note 39: (location of previous call) test/msg_macro.hsc (18,61): Note 39: user message: inside sepp_out test/msg_macro.hsc (7,44): Note 39: (location of previous call) test/msg_macro.hsc (18,79): Note 39: (location of previous call) hsc-0.934.orig/test/msg_macro.msg0100600000175000001440000000140707642675506015623 0ustar loryuserstest/msg_macro.hsc (3,61): Note 39: user message: sepp_simple test/msg_macro.hsc (13,27): Note 39: (location of previous call) test/msg_macro.hsc (3,61): Note 39: user message: sepp_simple test/msg_macro.hsc (5,18): Note 39: (location of previous call) test/msg_macro.hsc (14,27): Note 39: (location of previous call) test/msg_macro.hsc (10,45): Note 39: user message: this is sepp_in test/msg_macro.hsc (16,20): Note 39: (location of previous call) test/msg_macro.hsc (7,44): Note 39: (location of previous call) test/msg_macro.hsc (16,31): Note 39: (location of previous call) test/msg_macro.hsc (18,61): Note 39: user message: inside sepp_out test/msg_macro.hsc (7,44): Note 39: (location of previous call) test/msg_macro.hsc (18,79): Note 39: (location of previous call) hsc-0.934.orig/test/opt_getsize.expected0100600000175000001440000000052407642675506017222 0ustar loryusersTest Image sizes test test test test test hsc-0.934.orig/test/opt_getsize.hsc0100600000175000001440000000047707642675506016205 0ustar loryusersTest Image sizes test test test <* gif with a #26/EOF in header - should still work *> test test <* will be ignored *> hsc-0.934.orig/test/opt_getsize.html0100600000175000001440000000052407642675506016365 0ustar loryusersTest Image sizes test test test test test hsc-0.934.orig/test/opt_getsize.mex0100600000175000001440000000012607642675506016210 0ustar loryuserstest/opt_getsize.hsc (10,33): Warning 68: filetype of `test/test.ilbm' not recognised hsc-0.934.orig/test/opt_getsize.msg0100600000175000001440000000012607642675506016205 0ustar loryuserstest/opt_getsize.hsc (10,33): Warning 68: filetype of `test/test.ilbm' not recognised hsc-0.934.orig/test/opt_rplcent.expected0100600000175000001440000000053307642675506017217 0ustar loryusersSimple test just a "simple" test with no special features & <tags>;. And now something German (sort of): Nur fürß Teßten der dööfen Ümläutä. And numeric : åbla å sülzå Beyond 8-bit: И fasel 水 laber hsc-0.934.orig/test/opt_rplcent.html0100600000175000001440000000053307642675506016362 0ustar loryusersSimple test just a "simple" test with no special features & <tags>;. And now something German (sort of): Nur fürß Teßten der dööfen Ümläutä. And numeric : åbla å sülzå Beyond 8-bit: И fasel 水 laber hsc-0.934.orig/test/opt_rplcent.mex0100600000175000001440000000062507642675506016211 0ustar loryuserstest/simple.hsc (7,7): Note 46: replaced `ü' by `ü' test/simple.hsc (7,9): Note 46: replaced `ß' by `ß' test/simple.hsc (7,29): Note 46: replaced `ö' by `ö' test/simple.hsc (7,40): Note 46: replaced `Ü' by `Ü' test/simple.hsc (7,43): Note 46: replaced `ä' by `ä' test/simple.hsc (7,46): Note 46: replaced `ä' by `ä' test/simple.hsc (9,34): Note 46: replaced `ü' by `ü' hsc-0.934.orig/test/opt_rplcent.msg0100600000175000001440000000062507642675506016206 0ustar loryuserstest/simple.hsc (7,7): Note 46: replaced `ü' by `ü' test/simple.hsc (7,9): Note 46: replaced `ß' by `ß' test/simple.hsc (7,29): Note 46: replaced `ö' by `ö' test/simple.hsc (7,40): Note 46: replaced `Ü' by `Ü' test/simple.hsc (7,43): Note 46: replaced `ä' by `ä' test/simple.hsc (7,46): Note 46: replaced `ä' by `ä' test/simple.hsc (9,34): Note 46: replaced `ü' by `ü' hsc-0.934.orig/test/optim_tag.hsc0100600000175000001440000000062607642675506015630 0ustar loryusersOptimise inside tags normal multiple blanks before attribute blanks around "=" blank before ">" < A HREF="#sepp">blank after "<" end tag optimisations so what? this is sepp hsc-0.934.orig/test/redefine.expected0100600000175000001440000000021007642675506016437 0ustar loryusersredefining sepp1: sepp1 sepp2: sepp2 hugo-open(inside)hugo-close hugo-simple hsc-0.934.orig/test/redefine.hsc0100600000175000001440000000043307642675506015422 0ustar loryusersredefining <$macro sepp>sepp1 sepp1: <$macro sepp>sepp2 sepp2: <$macro hugo>hugo-open <$macro /hugo>hugo-close (inside) <$macro hugo>hugo-simple hsc-0.934.orig/test/redefine.html0100600000175000001440000000021007642675506015602 0ustar loryusersredefining sepp1: sepp1 sepp2: sepp2 hugo-open(inside)hugo-close hugo-simple hsc-0.934.orig/test/redefine.mex0100600000175000001440000000016707642675506015442 0ustar loryuserstest/redefine.hsc (4,13): Warning 59: redefined tag test/redefine.hsc (12,13): Warning 59: redefined tag hsc-0.934.orig/test/redefine.msg0100600000175000001440000000016707642675506015437 0ustar loryuserstest/redefine.hsc (4,13): Warning 59: redefined tag test/redefine.hsc (12,13): Warning 59: redefined tag hsc-0.934.orig/test/sgmlspec.expected0100600000175000001440000000065607642675506016511 0ustar loryusers Special sgml tags bold bold bold bold bold hsc-0.934.orig/test/sgmlspec.hsc0100600000175000001440000000105307642675506015455 0ustar loryusers Special sgml tags bold bold bold bold <* some portability problems *> bold <* some Server Side Includes *> <* legal switching context *> <$macro sepp> hsc-0.934.orig/test/sgmlspec.html0100600000175000001440000000065607642675506015654 0ustar loryusers Special sgml tags bold bold bold bold bold hsc-0.934.orig/test/sgmlspec.mex0100600000175000001440000000023307642675506015470 0ustar loryuserstest/sgmlspec.hsc (11,15): Portability problem 49: `>' inside sgml-comment test/sgmlspec.hsc (13,1): Portability problem 48: line feed inside sgml-comment hsc-0.934.orig/test/sgmlspec.msg0100600000175000001440000000023307642675506015465 0ustar loryuserstest/sgmlspec.hsc (11,15): Portability problem 49: `>' inside sgml-comment test/sgmlspec.hsc (13,1): Portability problem 48: line feed inside sgml-comment hsc-0.934.orig/test/simple.expected0100600000175000001440000000046707642675506016165 0ustar loryusersSimple test just a "simple" test with no special features & <tags>;. And now something German (sort of): Nur fürß Teßten der dööfen Ümläutä. And numeric : åbla å sülzå Beyond 8-bit: И fasel 水 laber hsc-0.934.orig/test/simple.hsc0100600000175000001440000000046707642675506015141 0ustar loryusersSimple test just a "simple" test with no special features & <tags>;. And now something German (sort of): Nur fürß Teßten der dööfen Ümläutä. And numeric : åbla å sülzå Beyond 8-bit: И fasel 水 laber hsc-0.934.orig/test/simple.html0100600000175000001440000000046707642675506015330 0ustar loryusersSimple test just a "simple" test with no special features & <tags>;. And now something German (sort of): Nur fürß Teßten der dööfen Ümläutä. And numeric : åbla å sülzå Beyond 8-bit: И fasel 水 laber hsc-0.934.orig/test/simple.mex0100600000175000001440000000000007642675506015134 0ustar loryusershsc-0.934.orig/test/stripws.expected0100600000175000001440000000017207642675506016400 0ustar loryusersStrip White Spaces ab c a b c a b c a b c hsc-0.934.orig/test/stripws.hsc0100600000175000001440000000032407642675506015353 0ustar loryusersStrip White Spaces a <$stripws type=both> b c a <$stripws type=prev> b c a <$stripws type=succ> b c a <$stripws type=none> b c hsc-0.934.orig/test/stripws.html0100600000175000001440000000017207642675506015543 0ustar loryusersStrip White Spaces ab c a b c a b c a b c hsc-0.934.orig/test/stripws.mex0100600000175000001440000000000007642675506015356 0ustar loryusershsc-0.934.orig/test/stripws.msg0100600000175000001440000000000007642675506015353 0ustar loryusershsc-0.934.orig/test/test.gif0100600000175000001440000000536507642675506014621 0ustar loryusersGIF87a@ðÊÊÊ,@þ„©Ëí£œ´Ú‹³Þ¼û†âH–扦êʶî ÇòL×öçúÎ÷þ ‡Ä¢ñˆœɦóYZJ™Ðªõ™N±Ü.V»õŠÇGéÁLN«}h@{ +—gºüŽgµßù¾ÿóÆ÷7HXhW˜¨øpHµøiÐI©È'XVÙw‰x*¶ Õé(7ªºŠ™ÂÊZZ‡êæ©öz‹‹‚{[z· ¼»é»Fœ,¬¡œ)ØÚÕ<Í+AýJ ];,y] ñ½š½-­¹!Nê .Z©=›¦ÕѾÍ0J;Ϩ_V†iŽ™½/èt³Æ/ß:nþ¶˜n!P÷ÀEL(¦á¼þ‡ñ(`cˆ±b(@3(1_† S¾ ØòDH•–µ<©¦–íá¹à§sf*™€gσ[ UÀÑÒD³h|º/ÙÑX ú„x¥*Õ©A¯Š‚o‚Ë®Þ:Ò$sö%Ù¤fãêK—+ÞQ¥ua·mÝ¿wÝB…xRUYà v)k0[8£w˜qع€9 –Œã'cx6½j¶øñe–JL6ýÙñbi-¤^qûvã‹ =óÝ+·vSÙ9}÷¾ùtVãYw´ÇÜ•qÝÉ—’,-ý9»èº¦s¯òZðue”‹©ýn"7ú'áßrø&‚ØyâÙ!Gno¤=þÈVþÍ_}ÝÉF]XôŒ‡’pó%4R€ö©¶š€¦ìç…˜ 'u Ò°¡H&‡\NÚF–€õ`ìQHV'Ê‚!‹ôø¦b2ÚàŸƒ.xãRxÕØOˆAÈ#‹@¦Gãz-î8„V1 „¦¨äRºÆ$”Ç)W$—Å9v$–W²ÑcfLê¨%’`†é\•b¦Ù%lŽÚ‹Ažy§—$ŽùŸåèæ .©çV~šYæJÞZ£E$ºe¡Û9*ç¢xæ@i~pF9ç}›Òi)¤h*v_—vyj^©¢h¦5ó™‰Z§ ¡Š:)¬ú \l3bÇ)®†&Ö©‹BéþŒ‡É£à«Àæ*ì“ÊÍ)¡±lIFê¯Ù&ØìrÑÖê-œve¨´Ê^õR«ªÚmŸë‚J\ÏÎÆn9!V»í¨ÜzXa¾áJªæŽÁ`½§Lû.ÎN!ÀçšÈk¥ñ64œÁööǬå–»\Æ»ªí‡U [[ÎÆ÷i¬ ìñ±'²?[•lòžðö+¤½µô(ïË07,ŽÍ0t2ÊgÆ­' #z¯Ï8¯IðJ§þ§øŸTrñÍš_ç7Òˆk¶wÞ—/½'ãž;N¶¢:·ì5Õ–·núÜ©£>;Ç‘ŸýokÎ2ç|?~½¬ƒÎ;î¹wæºä¾×þëë`….:±˜ë˜×̬;áÛ= êMæq$ÿl‰<´âäÈHDեЀ]tâÛgüyï{Y,ڡؼ9~Q‡{ûX:A²sŠ #ãÆ+"Ëgľ°‚‘|ã [À°8žn‚t$MiÈIRòvĤØ*i°G汓 Ô¤[YJ42RŽ.”%*É41 FÉ‹Ô"/)­Y ³p›Ë¼p9ÌKâš±ÛƒHì® _#&5IJKÞ‘ŠU\¦$›4c²²Žà<&6»rÍwŠÒ‡ÛŒš7ÅYLwÞÓ4—ЧÕè)/ù‹ŸÙÔ&åþҩ΂꒠ÝÒ¨F×Ð1ÂÑIÍåD#ZÑzh²IÜ¡ÕGÍ(Ív‚4¡ÍØ(IñµJ”~S¥»ìh5ÉãR!Ä4¥O4(BaÉÒnöR§;õ©ð¸8M F V}©9“*S£Îš8M&¡2zRÀ qƒ2j#SÉù(ZÒÔ£d5“+• !€ÊPh=´¢ ×±"«UkV×T·R0®5Þ<VF¹6UýóêåÎú%º”­?M Bä ¸¿ðì¯`tªbŸVQUUiüaþV J±žÓ®á,_Ý£¾xµPM,iëúÚ46v³ET‰jY»Ú¾î1¶‹%ê&¨¨Ö2 ìDŠþŠØ¨jµˆÿøŠˆ{Kã6橺•(^»YŽp2º”ErK«Üåâ¶¹nIÛ¬ºëêÚ´¬ÿì ds^Þîä»­ o;2‰ßœV¶±øçKA«×Qâ'¾ýª•Ž6YT ¸¸èõ®tõ¹Î¾¾Mª½hpríÑ ¨¶^‘ÿâh¶ÌâóÁæi„!¬áW’¸Ä¾.ESœ Ï²8Hë­dxŒ„ˆÏøÂ¶ñ§pì︾¦¥éi¸ yDö1‚‘œc%/ÙÄS•艘dùNù®û½ç•³—å-ÛˆjñÃ了e-‹¼]Fè—S'ä5‹˜½~³ï.+g‡°£«2âœþçÙVRNIšÿ,å@³y£tq›çhEWùI'îͤáiI÷tÑŸíVúò«iß"•ÎK}¦3ê"³S¼ÿj—QjVëùZz$+¬c}ÔUc“6ýÃ5~¸Ce&šªÃöµ ÝW<7öÖÆæðMÉéÏÐZÍÍ®tŽLß%ʺÚÒNœ³½h«ùQ›Û›î±¦.ähr7*gÅ>Ÿ«e¬î¼]zÛ»³ÉýH-ȪŽ÷º;8OrzÛþ¾À£[˜ž¼Û•fìÂÎðyóú·ã†xº ÖßZ<âÖ=·ÃîïF{xÎoÛÁÁ#®v—<×ÖCͽò/5ÜäM†yÌ™ÜñþÇ@8ç7—¹ÄYGò]÷\Þ?¯Ÿ ;;ôÝÎ|«¹µ¹f“Ntžã¼¤ZyÁEÞ« î{éP§2Ƴc1HZå]Ç-†ygXí8½ìº&x­[®õSYÝßXªžKmM²wžn›Å¡Ót¶ßÝî£|yÀ¼S²|çSªxÙ¿,v~×ñYµá±GùÊ·¸ß8Ï|™.XË{ì ¯néGïs¯ƒ›ô¨7¹]÷cܹoW°/¶ì-.¬kYÙ­7ûÀ/ÀÞ‡–´º§¹ð‡ßùÀ›þø¢o»ÔÏüË/¿Ü›~Íù{tÉ[_úÜ_|õ·¯|ÆSŸËàŸþÏÚ ýògŸ™ÂÀ3ÄiÞ|^ýªw·Ú¿Oÿ¢³~þù'*ôÞz·‡|ý×| €1w€ûG€þç xz€Ç÷~mXr—€Á瀈8t 8xˆ~òx‚JG‚õ×€+x>èxà7áæ‚[ƒWƒ6h*)"Ø}9ˆ5ÿwƒù7ƒ*„7„x„€öýÿþ?€ýðÿüÿÿ¸àú?þÿ?€ýðÿÀøÿÿ?ÿüþ ÿ€?ÿ€?€ýðàðûÿ €ÿÀÿ€?€ýðððàýÿ àÁàÿÀ?€ý#ðÿðàpÿðøðÿÀ?€ýðÿÿððx>þð~xþÿà?€ýðþÿàð0pþp<<þà?€ýøþÿàpàþp€xþà?€ýøþÿÀ8pÀþpÀ0<þà?€ýüþÿ€8 ÀþpÀþþà?€ýüÿÿü8Àþpþàþþà?€ýüÿÿ€<ÀþpþpÎþà€ýüàý€þpþpÎþà€ýþ€ý €þpþpŽþðüþ€ýþ€þpþpþðüÿþ?€ýþ€þpþpþøÿüÿþ?€ýþ€þpþpþøÿüÿþ?Àýþýpþ8<þøþüÿþ?Àýþýpþ8þøþüÿþÀý€ýpþ8þþøþüÿþÀýààýpþ<þþøþüÿþÀýûðýpþþ8þøþüÿþÀüÿàýpþþðþøüüÿÿÀü?àýpþ ðøüüÿÿÀüàýpþ àøüüÿàûàýpþ ÿ€?€øüüÿàüàýpþ þ?€øüüÿàüÀýpþ ø?€øüüÿàüÀýpþ `?€øüüÿðü€ýpþ ð?€øüüÿðü€ýpþ p?€øüüÿðü€ýpþ x?€øüüÿðüýpþ 8?€øüüÿðüýpþ 8?€øüüÿ€ðüýpþ 8?€øüüÿ€ðüýpþ 8?€øøüÿ?€ðüýpþ <?€øøüÿ?€ðüýpþ ?€øøüÿ?€øüýpþ ?€øøüÿ?€øüýpþ 8?€øøüÿ?€øüýpþ 8?€øøüÿ ?€üÿàýpþ 8?€øøüÿ ?€üÿðýpþ 8?€ðøüÿ?€þÿøýpþ 8?€ðøüÿ?Àþÿøýpþ 8?€?àøüÿ?Àþÿø8ýpþ 8€?€ÿàøüÿÀþÿð8ýpþ 8€?€ÿÀøüÿÀþÿà8ýpþ8€?þÿ€ðüÿÀÿý8ýpþp€?þÿðüÿÀ?àý8ýpþ p€?ÿÿþðüÿÀú8ýpþ p€ÿÿüðüÿàú8ýpþ pÀÿÿøðüÿàú8ýpþpþàÿÿÀðüÿàú8ýpþpþàÿÿ€àüÿàú8àðþpþàüàüÿàú 8øðàpþàüàüÿàú 8üøøpþàüàüÿàú 8þøüpþpüàüÿðú 8Ïø¾àþpüàüÿðú øŽàþpüàüÿðú ÜÀþ8üÀüÿðú ÜÀþ8ü€üÿðú ÜÀþ8õÿðú œœÀþ8õÿðú œüÀþ8õÿðú œüÀþ8õÿðú þžøÀþ8õÿðú ü`Àþ8õÿðú øÀþ8õÿðúþÀþ8õÿàúþÿÿÀþ8õÿÀúþÿÿÀ8õöþÿÿÀ8õöþ À8õöþ À8õöþ €8õöþ €8õöþ €8õöþ €8õöþþ8õö €þ8õö €þ8õö €þ8õö €þxõö ð€þpõö ÿ€€þàõöþÿÀÀþàõöþÀðþ8àõöþÀÿ€þþpàõöþÀ8ÿÿüþÿàõöý à8ÿøÀàõöý à8ÿ€€àõöýàxûàõö<üðûàõö~ÿãÀûÀõöÿÿ€û<€õöçþúx€õöÀ<ûð€õö€ùÿà€õö€ùÿÀ€õö€ýþð€õö€þ þ€õöÀþpþ€õöÀþ ý€õöÀùôöÀùôöÀùôöÀùôöÀùôöÀùôöÀüôöÀüôöÀü<ôöÀü~<ôöÀüÿxôöÀüçðôöÀüãðàôöÀüáÿ€àôöÀüàÿÀàôöÀ€ÀÿüàôöÀ?ÀÀÿüàôöÀÀÀ?øàôöþàÿÀ0àôö ÀpÀýàôö ?€pÀýÀôö pÀý€ôöýpÀýóöýpÀýóöý8Àýóöý8Àýóöý8Àýóöý8€ýóöý8€ýóöý€ý<óöý€ýxóöý€ýàóöý€ýàóöý€ýàóöý€ýàóöý€ýàóöýýÀóöýýÀóöýÀýÀóöýÿÿžýÀóöýÿÿüý€óöü?ÿøý€óöúàý€óöõ€óöõ€óöõ€óöõòö€öòöÀöòöàöòõàöòõàöòõàöòõàöòõàöòõàöòõàöòõðöòõxöòõ<öòõöòõöòõÀ÷òõà÷òôü÷8òô>÷8òô€ø8òôøø8òôÿàúøòóÿú?øòóÿÿàýÿðòòÿÿàþðññúÿàñðýÿþðïþÿüðÙÙÙÙÙÙÙÙÙÙÙÙhsc-0.934.orig/test/test.jfif0100600000175000001440000000427507642675506014771 0ustar loryusersÿØÿàJFIFHHÿÛCÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÛCÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÀ@"ÿÄÿÄ+1!qðAQaÑ2‘¡±"ÁBRáñÿÄÿÄÿÚ ? 9Î°Ï èSz·ÔÎ(ëûs˜œm2LL\8£¯ì⎿´E3'öH˜›Hˆ¦qè°Å¡ÍáŽçw߀goÏülUòMQ„‘LÌc:DÄØrÂzÏYûQ”ã†mòóý-òóýh·•Y4[ËfÓ 3Ž:oòÎ9蘌gðÀ3±Ç=Á÷àáŽàž9í¿+‰Æéûm€132"¨´Æü(ÿ>Ó¿ ‰›N]Ê£Ÿ°jk·–Äã-ÃdeÊoV¾ÔˆÇ°ë~—˜ÇXûO ÍêúßôÞéûÄDã3ÔÂ8²åïéxD#Š1™‰ãŽûòÞ(ëû…ÀDÕÓíœSÔDâÐs®þM£|Ñ]ü.›Fùƒ@]£{²“]¼ƒ(æ¹´é(£Ÿís`s¦ñ¾NŽQxÕÔ1ޱöccí“1©™Ç(¿ã ›å`"0ŒÃòÆ9XLÍ1Ê>”Œöúì þ=ÿ ¦sŒ1úÀ °M§I(ÎaÒi‰ìç„î8ØL`Ð:®ºmªó¾N‘hÒMvò¦UÄý‚hçãû[3› 9NS¤ºqGW9¼ë-ŠfA|QÕ3_FpOmøoYÓ37ûQ€ œêˆåÿ¬žå¿¶ÏÊ4ögÅŽÇèLÛ"˜Îq¼.# {€2g”F?Ñ9D”Ú˜U7«ëpaW)ûܨãWHß–DÕ8ç†ü­4Þ­}…]c~åÖ'¶ðP âå9Oã{ÅDÄMÓO8è EYå dá΃0«ý½oÃbyMÓœLc7›6¬¦'Äïì"iéôŒã³²+åçúDã MTu^wÉÒ-C•W—X´håaÕÊo:ºƒWÕtÚ]ã{»h¶€ Ts‹ÁFŠdÄ_"qk)Œ#\Ú «”u•&oLyßÒ€Ózµö¤Ózµö ÆULußµ&~Q§°P fÎ=92”ÄrŒç{ü21œbf×Þ[丈‹9Õ9égH´hj²™U§|Á_äÙ΋øt›N’QœÃ«7òtr›Ë¬Z4sªò¸´h ®ÞYG? ªÒç„⣟œS×ô‚i™›ý¨ÕÊ:Ê“Ué×Ð(Lü£OjOùGhÏ~T&›Õ¯µ&›Õ¯°P&~Q§µ&>S§ P›U­”š¹OIP9Õyß'H´iu^wÉÒ-@ ªÓ¾msª¬r‹Eü.«JhŽjªÀŠo££ðèŠï6›hÊùyþ›G0Rxa@'†„t Ué×Ò“?(;ú ”ééIµZÆÿJM\£«&8p˜Zi½ZûTÚt”S”ëýÆU8Gá9Ó1Þð M7«_jM<ç¨(dÆ1LãdÔÓ”Ìyý*‰ÇNÒ~@rÂzOÒ¢ž¿KMvîêMQ3†Ê9­”ÆÐ×É”sð°Lü£OjLü£O` 3ò‰ñ¿µ&«FªLckÅ™„Îåî Uµdå4φÕþ1ÖJíä1Šbœ'›Y@iÒYM£|Ê­%6€h&>S§¢rª>ˆùNž@™ùFžÔ™ùFžÁ@Ìc1Ì £dUf¢b$ ˆ¦c %xÅñÏÊ>÷ôUb3«Xe¿µæ'‡¤ÌoÁ…]c~ªÑeIŠyÌâ “8w™´&ôÇýœÌò³b0ÎoÎwÉ”[È(?(ÓÚ“?(ÓØ)3LD(›N’Z4M£|Ú Â:3†?ç%eË‘3€ ™œp‹µ3•Q>7öòž‘¿-ˆÃ9ÎZ*´ï›bѤ&sª#—þ¨Lü£OjLü£O`¢m:H)´o›S9ax8qÎoØ&žqÑ@6$œÿ.q6ooþ6›Fù·韔iìáŽäS8‚“8#9âé”)”ÆÐ3•Q>7ö¤Õzuô 6ª{Æÿµ&r˜ï5Ê­-MVÓhi3Q7éI¦À Õþ3ÒTNy&›(˜ÆéáŽê<ß~§ æ U¥±hÑ5g1TŽ’±8LZ|r âÂñ;ßSŠAŒu°LÕß@'å{R"qªg¶ÿµ€aÃ?lá…ž“1¿ ÿ´ïÊ€O ÿ´ïÉÃ?í;ò ÃÖfc¦åQÿÙhsc-0.934.orig/test/test.png0100600000175000001440000000544207642675506014634 0ustar loryusers‰PNG  IHDR@ PLTEÊÊʯAztEXtSoftwaregif2png 0.6 (beta)ªÝi’ °IDATxœíšM#G€ßêöºzWŽ{25v=DŠw"E­½ HˆU~€C pà`)‡ø°L×$#v%V"9 ²âÀê‘О"ò8ô²i„„Œd\yߪêîªvûcÑ"!A+é¼~ü¸º¾ºê힘ã `À–·® {=mãùœ~ð Ü`ðÆ=ðàÕSŸÀuð®pðZ´ @ç—¼ô÷ÎAŒç¯¨ÒTÇ}ºXkJgô™ï§1ý'P‚ g“ ¨sK—ðš*`à/`oã§o‹ xþ&À{1pÏø1¼>ô¾Ã®<„‡,À³Çn`[éüê! ±¬Ã –þœjxCjFLçç¯Òe^H©nª]‰<ÏuG*.T<³+'Ê3K7Ô¿hŸ9Ø @¦ªí_@/ÉnxÁ6@é©þü2¥BYG‡¼j…àöÙ•Ï/“Ð9¹€ü£pŠcð9õ?œá¯¦¶cÖÖRáøCx÷])xIO‡oáUuxÓ3£É å]0¡×‚"„³Ñ%ÀþT…­2< LØQ„0U¡UÓuNª°S…Ou´«Ð«ÂKNèÓr¶h,h‚„jÀzIzr¨ð«2e‡_×]ßnBÏ»ž©ZÔ騫5šAASžã†ž ÂCN¡y­˜á°K »@a'Åþ7ᤅ!èÐ?Cåö}n°2lf`‡ŸšÐk©09-ÂÖø4ÀPêáÆNLxõªg&ܹcB€w&^ѡߋ¾l]€*lµBV†8cÊ~¿?<4Ñ0‡ë&Äõã÷…X7‰µªXa”¬_„Eˆó¨œg§ÕÏY1Ïܮ“‹Ê_í9)ªXa\…½ê ¶°¦ß3>Ž›àõ&ø=+irÓñ uHú,e®¡îýñ_‰~RÌåê |…G‰_ÁAÊÎà- ñ_?•r‰sᣠž¯ð®&.äÔcfJmU‘$µ 4Nàoéœ>i¨º¯  U=)„.@fA_5˧}¡€b؉¿e H„†ÊôÚ#ŽkÉÌÃè e‰¯Lhºðw¬Œ*=ÇóUÉÎßß œpˆulaµÞêÊ䨄0"ôè†ÑpFƒ£![ÌY–á‚GfZÂÔ”$8³Ç Î#jІq ûƒTÃ6 羡Ì|˜*Ø›‡ç Žx ¶pÕ’z:VÝ£ag°ðm8èv Cñº7/]¨ÿ™°àå—ûAµ¤F á2àLtÚïo"|eöàMö€R Å1„×\b*3ÚÔ,؆ +íwxQPmŽ{ÄvÜV—sʦ kзoig8Fkð‹ uá=⤇”õ,µZ4%h3ú3ávg;u8dP­wÄ)ï¶²X4]h*8l‚ñpØUnäv }“Õ øå²ó_~DMðnüÑÞð[{C=ßC¹kõÖp¬Vïo &ª[eh¨–ô¡‹ë¼ÐåËfôæI1Qñ!à¬4„b „,8ƪ—x ZðTR}ÛÏêÐ÷;.Õ6Ïå´ßß2PÕ“‰PДO\ØÁÊR¾Vƒ½pY´‚çÒ$='6Ô7[›=³ š]†e`A5ê– Õ>ЪMJ¯¯mêë`ª–Wpü0UX˜31ô&•c3 ôÓiÇ¿‡Æ?ÅÞÖPÊôŸ·ñÒYÛ_Bñ>fAâ³€¯ Ë¤Ä ¿‡°®`ï+Øa¿B˜+ˆçïâҋпF×¥Êe3º}„ ªoˆ¨…¿0[³ ±ñç%üZ#l#6öM.4Œb ‚†,Ÿp¤·H‚i ißÄJÑÏwCßÀÉ&¨F‹öbÏÀé:lA\Âþ@TÐ7p Óg\ù‚fáÇâ-[ÂDêvÎhØA¸2PÍ {ÉRуq®ï@£*‚â¶4ðVÔ'×Àc51§oDGÁ¼Ö?¢üÆl|ñÍ^•xxôbö‚5ÃX°gà6‡8¹zNbjà›ÂnÃ:<À¤l|Í…x«õCúâÝT½D°!\3ï»Ä$¤§[¶áqŠàÂ$ýçÀÕrsìB5þb úª ¦àtOè5ÀiÌš~þë¶›Û(øYÛ~"xØÇ«:ü™`ân Â"ÅX κ©öA¯'ÍÐyönm‚Á^0n„~=³òôR¿ùÜÁ,jíB¿ šÎÍÖLŸÕR8 §ÿ.L›à´ ›`¯ ê>Ÿ¸Pï›5¨îžÖ ÇóÿÃ9¦{zá¾ùw4Ûí<8zæâÌÃt?QÊâ)GTŽÝ,†²41Á–+GÌ,q õ!tÙ›Å0ÓrFÙyÆÊKcR/ÿ©^8t­RS=×éGvÕÿEâXÚ"SÏ–¨2 Nb²´E«é€~Ò58eŒ³¨QT SZÌE¿±óZ™6‹B}â¸ÎÆ2m™UsZ7>\錇¾”ÛDzLKtÿ`Ù[Dl úÐ÷4ÎÍ"­˜±îQš+2´ÄÜÍ ¦Öw좕ŸÁ؈Ü«1ær©þ€)“XMÍ„Äå&±xFQ]¬æ£53ﮋÕ×~V‰4Úµ:Ñ—«AåAH'š–¨G'Ùo­Zò1è²ÄD]4¢g"VÞL! MSGd8TQˆ·^CAosªNêˆj:Fƒ|¨ž±fdaÎJYë «Ä…SˆpÑQ»ÓLõð8Ò[ˆþ’Dì°h¥vM×±SÕÒ¨o²o}yÿFL qeBº’-vé™bã›ý5±»—ì+ï{i©¬ùnñINb¶[ÌdºS¤¬uJo¶‰Ñ0©ÜáQ½ÂÖX{°wD„+eój±È»ìg¤M¢~“º¹¿u£b~íˉ¸y`jb¶Cì>…¨2¹Í7«ñéw?ÑWiì¶[«êâl_v‰|ã‡ÚáÔ›ètÝ–9áŠ[†ú?!Úf«ØßW´ï§­"XO’÷7u Äž"+_¾ Û¼ê=Ûý÷^óò$Ûå~w²Ü­ýO_ÜËE‡ò‚…BIEND®B`‚hsc-0.934.orig/test/test_eof.gif0100600000175000001440000000436107642675506015445 0ustar loryusersGIF89a8.÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ùÀ,8.@ÿQ ìE°Í—P†:t¨W¨…C)RÄEK-ÚX«V²Û¶µÙn[²Ž·IDõP™Ë'môÈ<JO›'rêÜÉ€LÒõñä(;L`À‘ÆcQeÞH¶ó†JQ!)8(è €ƒÖžO¾àÀdT²µ,9U«Ý¿´£~0qêvªK¨ Cµ›“C ˜\yþøG2BÅȱcÑdÿþ)SÈ2T/eŠ8Ω …/v,ÙIc§ôз“¹¥ñ£F¶7NuhùîHo¸½)»LP™eE¾½,ùï¤êZÛÚ:þè±ã6¶i1²$xy[›6Óó"¬ªHâB™m®0ÿùñ†„ó#”ʽ’¦½x&W!g^kÔ—›_ô’©?±Y)°Õfž§ ñRH‘ý³%%CHyi(óQTv)3Õ~ýµ*:m£›XòñöZ}£°çTdº)t™"| _t÷Ð~_hfãÝ)‚Š\paG-vbPñ9õØc„õv—K]æ*‡<á#O Œ°Þ‘lý£ Ioµ•Ìsl%“F»ÕdЇyYnR¹ÕàªdÒ™!=¹\G€&Ã!Qç:îH[¢Þ1 cIw¶çIõÕ²*½à† qº£Oà°åfýdž#tiGIEÕÿòÅ}1Ñ4‘6}ñ„8¤Â€:qðY’„XRlFDõéØ?–´×RL<æn½TuÈuO”ª°¨ê”L€bžíÔ§³¥QžSPÝ•2ûq«Sg)ðÄL:! ¬ûcjGˆxD%ƒ¡n.µ£H;‡œÚ`ÝÙHzü` ?\ÁiÅn$_QuµÉi/zà€ùzr§ò$AnʘU$ klZc€Öcµ]vH`zvA'©Ñj„$ct¯ýZl£D6¾–…²É8Í+DX1éaQiI š"H–”–G¬Õ§‘%:å6»\]wX¾ù|CA(r£8ÿûœq'¡‰F„´ãÛB4͉aïNUnÃ1ø¤IÉÅJßG±YbYµ.)òDDAæå¨wÞ)²æÓN.H©žôm”Ìæ¨L›Â!UAäY:¤Ž¡¤¢±i„Ü¥,rÊé´ž/Deî Ù”-¯-G\ —LØÑ'¦•$¢280§"½PÔ†¼ÏëåÆäu C[{ÖRëJ+=ax_`…ª_*Yì|ägIK,ô‘ÄYÅ{ ùË®zõ+nyfW\PÔ2)’`d„!„R`` îFzЭl"!xå+\¹Qz2Àœ\Ág" s"¡·g. nìò] ˆ@õ_ÿtR¢³ŒÀu!1!d¢õåp‡$éÅ~jÔ“!îdKm¸Yq;°†(ærKÒÀU°ƒíÐ7z zÅTdí qã!gAj#S̸CŠ|¡ŠÿÙLH¢ ~¥=Çj [„R”ƒí/íèEÖúò—6”0‘Ùì“ö-M±ê! E=Hä Bü‹XºŠ©è¦#¨C¸^˜·§AG”v™Kô°àÀ”ÑÃÖþÈ X i(R{ôƒ‚%xkº mzã KîäF¾Ì–º³Ÿ˜\¡HE²^;þ'¡š…i8ËT[ ÷éðf’)äLA8èm§ùˆÏμDbÄ-Ô©’@!„+â€WØìÌ ÁÕ<ˆ(5TÀÒÆÙD²ZÕ%*¶a•ieem {6¡ŽyBg√^óÏHŽ,vÛ«B\R“'üj'? Š|Ê•¿ ª\˜t~7›Bu*7p»ÒotCºÉ¨©‚É™Òr”6‡o°!;ƒT:¹RDÛè oL¾¿!‡§É ¦šÖx#|ÝLœ¡X¯N¥§“JÖ¥Òꔾ²•M·[ÈUôƒ;+ÍÕNwòjàt)æ<P ;hsc-0.934.orig/test/unknattr.hsc0100600000175000001440000000043107642675506015505 0ustar loryusersunknown attributes <$macro sepp resi:string>do nufin bold name <$let undefined-attr="sepp"> hsc-0.934.orig/test/unknattr.mex0100600000175000001440000000102707642675506015523 0ustar loryuserstest/unknattr.hsc (4,13): Warning 11: unknown tag test/unknattr.hsc (5,20): Error 85: unknown attribute hugo for tag test/unknattr.hsc (5,29): Error 85: unknown attribute susi for tag test/unknattr.hsc (6,8): Warning 84: unknown attribute resi for tag test/unknattr.hsc (6,13): Warning 84: unknown attribute hugo for tag test/unknattr.hsc (7,21): Error 20: unknown attribute hugo test/unknattr.hsc (8,21): Error 20: unknown attribute undefined-attr test/unknattr.hsc (8,29): Error 30: unmatched `>' hsc-0.934.orig/test/unknattr.msg0100600000175000001440000000102707642675506015520 0ustar loryuserstest/unknattr.hsc (4,13): Warning 11: unknown tag test/unknattr.hsc (5,20): Error 85: unknown attribute hugo for tag test/unknattr.hsc (5,29): Error 85: unknown attribute susi for tag test/unknattr.hsc (6,8): Warning 84: unknown attribute resi for tag test/unknattr.hsc (6,13): Warning 84: unknown attribute hugo for tag test/unknattr.hsc (7,21): Error 20: unknown attribute hugo test/unknattr.hsc (8,21): Error 20: unknown attribute undefined-attr test/unknattr.hsc (8,29): Error 30: unmatched `>' hsc-0.934.orig/test2/0040700000175000001440000000000010010410621013165 5ustar loryusershsc-0.934.orig/test2/99bottles-iter.hsc0100600000175000001440000000272207642675506016525 0ustar loryusers<* 99-bottles-of-beer in HSC, by Matthias Bethke Pseudo-iterative version, process using: hsc xhtml compact 99bottles-iter.hsc *> <$define PAGE:string/C="99 Bottles of Beer"> <$macro BOB N:num/R OTW:bool> <$if COND=(N = '0')>No more<$else><(N)> <$if COND=(N <> '1')>bottles<$else>bottle of beer <$if COND=(set OTW)>on the wall <$macro ITERATE COND:string/R CONTENT:string/R> <( "<$if COND=(" + COND + ")>" + "<(CONTENT)>" + "" + "" )> <$macro FOR /CLOSE VAR:string/R START:num=1 TO:num/R STEP:num=1> <("<$define " + VAR + ":num=" + START + ">")> <$if COND=(STEP < "0")> ='" + TO +"'") CONTENT=(HSC.Content + "<$let " + VAR + "=(" + VAR + "&'" + STEP + "')>")> <$else> ")> <*** Page starts here ***> <(PAGE)>

<(PAGE)>

<$if COND=(bottles = '0')>

Go to the store, buy some more...

<$else>

,

Take <$if COND=(bottles = '1')>it<$else>one down, pass it around,
.

hsc-0.934.orig/test2/99bottles.hsc0100600000175000001440000000155307642675506015565 0ustar loryusers<* 99-bottles-of-beer in HSC, by Matthias Bethke Recursive version *> <$define PAGE:string/C="99 Bottles of Beer"> <$macro BOB N:num/R OTW:bool> <$if COND=(N = '0')>No more<$else><(N)> <$if COND=(N <> '1')>bottles<$else>bottle of beer <$if COND=(set OTW)>on the wall <$macro BINGE BOTTLES:num/R> <$if COND=(BOTTLES = '0')>

Go to the store, buy some more...

<$else>

,

Take <$if COND=(BOTTLES = '1')>it<$else>one down, pass it around,
<$let BOTTLES=(BOTTLES - '1')> .

<*** Page starts here ***> <(PAGE)>

<(PAGE)>

hsc-0.934.orig/test2/README0100600000175000001440000000043007642675506014101 0ustar loryusersThis directory contains various files I used for testing HSC during development. They are here both because I'm to lazy to remove them every time just to save a few bytes and because I think even undocumented as they are they can serve as examples for advanced HSC hacking. --mb hsc-0.934.orig/test2/accessibility.hsc0100600000175000001440000000065207642675506016555 0ustar loryusers W3C Accessibility Guidelines <* a table w/o summary *>
Cell
<* a table with summary *>
Cell
The no-summary table
The table with a summary
<* vi: set et ts=2: *> hsc-0.934.orig/test2/arrays.hsc0100600000175000001440000000031107642675506015217 0ustar loryusers<$include FILE="macros.hsc">
<(DEFARRAY_PRE)> <(DEFARRAY_POST)> hsc-0.934.orig/test2/autoclose.hsc0100600000175000001440000000020107652765141015706 0ustar loryusersAutoclose
foo
bar
baz
blah
<* barf! *> hsc-0.934.orig/test2/colors.hsc0100600000175000001440000000130607650265721015215 0ustar loryusers<$define ROWCOUNT:num="-1"> <$define COLORS-0:string/c="red"> <$define COLORS-1:string/c="green"> <$define COLORS-2:string/c="yellow"> <$macro COLORTR /CLOSE> <$let ROWCOUNT=(ROWCOUNT & "1")> <$content> <$if cond=("1")> Colored Rows
Blah Fasel Foo Bar Baz
hsc-0.934.orig/test2/docuri.hsc0100600000175000001440000000002507642675506015205 0ustar loryusers<(hsc.document.uri)> hsc-0.934.orig/test2/dump0100600000175000001440000000050107642675506014110 0ustar loryusers<$if COND=(not defined rowgroup_l1r0)><$define rowgroup_l1r0:string=''><$else><$let rowgroup_l1r0=''><$if COND=(not defined rowgroup_l1r1)><$define rowgroup_l1r1:string=''><$else><$let rowgroup_l1r1=''><$if COND=(not defined rowgroup_l1r2)><$define rowgroup_l1r2:string=''><$else><$let rowgroup_l1r2=''>hsc-0.934.orig/test2/exturis.hsc0100600000175000001440000000104207772065772015425 0ustar loryusersExternal URI checking

http ok http ok http noserver unsupported protocol mail ftp ftp noserver gopher ok gopher noserver

hsc-0.934.orig/test2/exturis.html0100600000175000001440000000104207777714145015614 0ustar loryusersExternal URI checking

http ok http ok http noserver unsupported protocol mail ftp ftp noserver gopher ok gopher noserver

hsc-0.934.orig/test2/filedate.hsc0100600000175000001440000000024307642675506015477 0ustar loryusers File date Last change of <(hsc.source.file)>: <(getfiledate(hsc.source.file))> / <* vi: set et ts=2: *> hsc-0.934.orig/test2/foo.png0100600000175000001440000000061607642675506014520 0ustar loryusers‰PNG  IHDR ±ˆ?¾3PLTEÿÿÿ2222fΚ—•fÎfÎþÙÎÍËff2šÎ¥þΚffgfšÆþþþffÎþÎÏššÎÎÎþÐDQtRNS@æØfbKGDˆH pHYs½½<¯tIMEÒ6¸\9ÔIDATxœ}[„ M@Ø)õþ§ÝðX Vaw˜„ãè‹èØÑÞ ‚ßäá,Є•!ü£€¥!, Q借õ+4EÛ~¸Á cLÇ]Ÿ"ý¾åIx ‚QTHªtR…—ýœëpâÞ¯8sÿ>#øŽi]…2`äà”!\W^f{sšRŸÆãrïŠà2c4ä ÓûÉçúãÁÈ)¥9ÿ5ÎÖú³a«ñžÇ”²í¤¿4ð{Â۸ôd¾áfð=çy[^ó¢^ãtÇ–‹1þø Ù°êIEND®B`‚hsc-0.934.orig/test2/groups-ng.hsc0100600000175000001440000000517207703242075015636 0ustar loryusers<$include FILE="macros.hsc"> <$macro GROUPCONTENTS> Cell 1 Cell 2 Cell 3: A nested table
<(i*j)>
Cell 4 Cell 5:
This group has NELEMS=<(NELEMS)>

Groups

The following two groups have been created with exactly the same contents, but they get arranged differently:

<*----------------------------------------------*>

Column groups lay out their contents in a fixed number of columns.

<*----------------------------------------------*>
<*

Row groups lay out their contents - guess how! :-)

<*----------------------------------------------*>

Complex layouts...

This is a columngroup with a nested rowgroup One Two Three And another single-row rowgroup and 5 cells And another columngroup <*----------------------------------------------*>
<$macro NESTGROUPS> C1 C2 C3 R1 <$if COND=(nestit > '0')> <$let nestit=(nestit - '1')> <$else> END R3 C5 Deep nesting... <$define nestit:num='15'> *>
<* vi: set ts=2: *> hsc-0.934.orig/test2/groups-ng.html0100600000175000001440000000226007704753203016021 0ustar loryusers Dynamic layout groups - Next Generation

Groups

The following two groups have been created with exactly the same contents, but they get arranged differently:

Column groups lay out their contents in a fixed number of columns.

Cell 1
Cell 2
Cell 3: A nested table
1 2 3 4
2 4 6 8
3 6 9 12
4 8 12 16
Cell 4
Cell 5:
This group has NELEMS=2

hsc-0.934.orig/test2/groups.hsc0100600000175000001440000000470507703241612015231 0ustar loryusers<$include FILE="macros.hsc"> <$macro GROUPCONTENTS> Cell 1 Cell 2 Cell 3: A nested table
<(i*j)>
Cell 4 Cell 5:
This group has NELEMS=<(NELEMS)>

Groups

The following two groups have been created with exactly the same contents, but they get arranged differently:

<*----------------------------------------------*>

Column groups lay out their contents in a fixed number of columns.

<*----------------------------------------------*>

Row groups lay out their contents - guess how! :-)

<*----------------------------------------------*>

Complex layouts...

This is a columngroup with a nested rowgroup One Two Three And another single-row rowgroup and 5 cells And another columngroup <*----------------------------------------------*>
<$macro NESTGROUPS> C1 C2 C3 R1 <$if COND=(nestit > '0')> <$let nestit=(nestit - '1')> <$else> END R3 C5 Deep nesting... <$define nestit:num='15'> <* vi: set ts=2: *> hsc-0.934.orig/test2/hsc.options0100600000175000001440000000003307703241674015403 0ustar loryusersIDIR=/home/mb/lib COMPACT hsc-0.934.orig/test2/hscexpr.pl0100700000175000001440000000030707642675506015236 0ustar loryusers#!/usr/bin/perl -n # Converts strings from STDOUT to correctly quoted (though unoptimized) # HSC expressions on STDOUT chomp; %t=('"'=>'\'','\''=>'"'); s/("|')/'+$t{$1}$1$t{$1}+'/g; print "('$_')"; hsc-0.934.orig/test2/imgsize.hsc0100600000175000001440000000044507642675506015375 0ustar loryusers<$include file=macros.hsc> <$macro foo width:num style:string> foo Imagesize <* vi: set et ts=2: *> hsc-0.934.orig/test2/jens.hsc0100600000175000001440000000023307651050071014640 0ustar loryusers<* *> STYLE handling <$define foobar:string="blahfasel">

&foobar;

<* vi: set et ts=2: *> hsc-0.934.orig/test2/loops.hsc0100600000175000001440000000100107642675506015047 0ustar loryusers<$include FILE="macros.hsc"> Loopz! <(i)> <(i)> <$let i=(i - "1")> <$if COND=(i > "100")> <(j+i)> <$if COND=(i < '-50')> <$define foo:num=10> <(foo)><$let foo=(foo - "2")> hsc-0.934.orig/test2/lowercasetags.hsc0100600000175000001440000000030207642675506016561 0ustar loryusers Lowercasetags test

fOo FoO! hsc-0.934.orig/test2/multinclude.hsc0100600000175000001440000000007707642675506016254 0ustar loryusers<$include file="macros.hsc"> 1 <$include file="macros.hsc"> 2 hsc-0.934.orig/test2/nesting.hsc0100600000175000001440000000054007650270607015361 0ustar loryusers <$macro testib foo:bool=''> <$if COND=(foo)><$else>testib<$if COND=(foo)><$else> Nesting tests i-b-wrong hsc-0.934.orig/test2/pathattrs.hsc0100600000175000001440000000070407642675506015736 0ustar loryusers File/Path related attributes Hsc.Document.Name: <(Hsc.Document.Name)>
Hsc.Document.Path: <(Hsc.Document.Path)>
Hsc.Document.URI: <(Hsc.Document.URI)>
Hsc.Source.Name: <(Hsc.Source.Name)>
Hsc.Source.Path: <(Hsc.Source.Path)>
Hsc.Source.File: <(Hsc.Source.File)>
Hsc.DestPath: <(Hsc.DestPath)>
<* vi: set et ts=2: *> hsc-0.934.orig/test2/perl.hsc0100600000175000001440000000163407642675506014671 0ustar loryusers<$include FILE="macros.hsc"> PERL! #Kickstart from http://www.perlmonks.com/ #note: a slight valentine variation :) $LOVE= AMOUR. true.cards. ecstacy.crush .hon.promise.de .votion.partners. tender.truelovers. treasure.affection. devotion.care.woo.baby.ardor.romancing. enthusiasm.fealty.fondness.turtledoves. lovers.sentiment.worship.sweetling.pure .attachment.flowers.roses.promise.poem; $LOVE=~ s/AMOUR/adore/g; @a=split(//, $LOVE); $o.= chr (ord($a[1])+6). chr (ord($a[3])+3). $a[16]. $a[5]. chr (32). $a[0]. $a[(26+2)]. $a[27]. $a[5].$a[25]. $a[8].$a[3].chr (32).$a[29]. $a[8].$a[3]. $a[62].chr(32).$a[62]. $a[2].$a[38].$a[4]. $a[3].'.'; print $o; <* shamelessly ripped from http://www.cpan.org/misc/japh --mb *> hsc-0.934.orig/test2/sections.hsc0100600000175000001440000000111407642675506015547 0ustar loryusers<$include FILE="macros.hsc"> <$define PROJECT_GENERATE_TOC:bool> Sections

hsc-0.934.orig/test2/sections.html0100600000175000001440000000434507642675506015747 0ustar loryusersSections

1 First chapter

1.1 A section

1.2 Another section

1.2.1 First subsection

1.2.1.1 Going deeper

1.2.2 Second subsection

1.3 One more section

1.3.1 Guess what: a subsection

2 Chapter number two!

2.1 On it goes...


Table of contents
1First chapter
1.1A section
1.2Another section
1.2.1First subsection
1.2.1.1Going deeper
1.2.2Second subsection
1.3One more section
1.3.1Guess what: a subsection
2Chapter number two!
2.1On it goes...
hsc-0.934.orig/test2/sectionstyles.hsc0100600000175000001440000000075407642675506016641 0ustar loryusers<$include file="macros.hsc"> Sections <$define dst:string> <_STYLE-SECTION-NUMBER STYLE="numeric" DEST=dst N=(i)> <_STYLE-SECTION-NUMBER STYLE="roman" DEST=dst N=(i)> <_STYLE-SECTION-NUMBER STYLE="upperalpha" DEST=dst N=(i)> <_STYLE-SECTION-NUMBER STYLE="loweralpha" DEST=dst N=(i)>
<(dst)><(dst)><(dst)><(dst)>
hsc-0.934.orig/test2/setup_addrdb.sql0100600000175000001440000000144507642675506016411 0ustar loryusers-- -- Table structure for table 'addresses' -- CREATE TABLE addresses ( first varchar(30) default NULL, last varchar(40) default NULL, street varchar(80) default NULL, city varchar(30) default NULL, zip varchar(10) default NULL, country varchar(20) default NULL, phone varchar(20) default NULL ) TYPE=MyISAM; -- -- Dumping data for table 'addresses' -- INSERT INTO addresses VALUES ('John','Doe','13 Mulholland Drive','LA','1234','USA',NULL); INSERT INTO addresses VALUES ('Avacon','AG','Schöninger Str. 10','Helmstedt','38350','Germany','0180-3282266'); INSERT INTO addresses VALUES ('Jose','Velarde','Malacañang','Metro Manila','1000','Philippines','N.N.'); INSERT INTO addresses VALUES ('Carbonos de Portugal','S.A.','Apartado 215','Sines','7520-903','Portugal','+351-26-9630180'); hsc-0.934.orig/test2/simon.hsc0100600000175000001440000000055207642675506015052 0ustar loryusers<$macro SIMON-SAYS /CLOSE> <$if COND=(defined SIMONSUCKS)>Muhammad says: <$else>Simon says: <$content> <$macro NOSIMON /CLOSE> <$define SIMONSUCKS:bool='1'> <(hsc.content)> Simon use HSC! use HSC! hsc-0.934.orig/test2/sql.hsc0100600000175000001440000000533707642675506014532 0ustar loryusers<$include file=macros.hsc> <$macro ADDRESS_QUERY COLUMNS:string COND:string FORMATTER:string/R SPCATTR:bool> <$macro SQL_QUERY COLUMNS:string='*' TABLE:string/R DATABASE:string/R COND:string='' FORMATTER:string/R NULL:string=' ' DBMS:string/R USER:string='' PASSWORD:string='' HOST:string='localhost' SPCATTR:bool> <$define QUERY:string/C=("SELECT " + COLUMNS + " FROM " + TABLE + " " + COND + ";")> use DBI; my ($dbms,$host,$user,$pw,$query,$db,$fmt,$null,$spcattr) = @ARGV; my $dbh = DBI->connect("DBI:$dbms:database=$db;host=$host",$user,$pw) || die "Error connecting to $dbms database \"$db\" on $host"; my $sth = $dbh->prepare($query) || die "Error preparing query: $dbh->err"; $sth->execute; defined($dbh->err) && die "Error reading from database $db: $dbh->err"; $null = quotestring($null); my $i=0; while(my $res = $sth->fetchrow_hashref) { ++$i; print "<$fmt"; print " _ROW_='$i'" if($spcattr); foreach(keys %$res) { print " $_=" . (defined($res->{$_}) ? quotestring($res->{$_}) : $null); } print ">"; } $dbh->disconnect; sub quotestring { my $s = shift; my $sq = (-1 != substr($s,'\'')); if(-1 != substr($s,'"') and $sq) { my %t=('"'=>'\'','\''=>'"'); $s =~ s/("|')/'+$t{$1}$1$t{$1}+'/g; return "('$s')"; } $sq && return "\"$s\""; return "'$s'"; } <$macro _ADDRESS-TABLE-FORMATTER FIRST:string LAST:string STREET:string CITY:string ZIP:string COUNTRY:string PHONE:string _ROW_:string> <(_ROW_)> <(first)> <(last)> <(street)> <(zip)> <(city)> <(country)> <(phone)> <$macro _ADDRESS-LIST-FORMATTER FIRST:string LAST:string STREET:string CITY:string COUNTRY:string>
    • Name: <(last)>, <(first)>
    • Street: <(street)>
    • City: <(city)>
    • Country: <(country)>
  • <* Webpage proper starts here *> HSC and SQL Databases <* A tabular layout for the addresses *>
    <* Something similar with nested lists *>
    <* vi: set et ts=2: *> hsc-0.934.orig/test2/style.hsc0100600000175000001440000000046107642675506015064 0ustar loryusers <$macro mystyle foo:string>

    STYLE handling

    <* vi: set et ts=2: *> hsc-0.934.orig/test2/symlink.hsc0100600000175000001440000000174007642675506015413 0ustar loryusers<$include file="macros.hsc"> <$define PROJECT_SYMLINK_DB:string="symlinks.db"> <$macro SYMLINK /CLOSE TGT:string/R> <$define link:string> my ($file,$tgt,%db,$sym,$path,$subpath,$line); $tgt = shift; $file = shift; open(DB,$file) or die "Cannot open symlink database $file"; $line = 1; while() { chomp; ($sym,$path) = split /\s*=\s*/; while(($subpath) = $path =~ m/.*%(.+)%/) { die "Unknown symbolic path '$subpath' used on line $line" unless(defined $db{$subpath}); $path =~ s/%$subpath%/$db{$subpath}/; } $db{$sym} = $path; last if($sym eq $tgt); $line++; } die "Symbolic path '$tgt' not defined in $file" unless(defined $db{$tgt}); print $db{$tgt}; <$content> Symbolic Links link link link <* vi: set ts=2 et: *> hsc-0.934.orig/test2/symlinks.db0100600000175000001440000000014607642675506015405 0ustar loryusersroot = :root foo = %root%/foo.html bar = %root%/bar.html sub = %root%/subdir baz = %sub%/baz.html hsc-0.934.orig/test2/table.hsc0100600000175000001440000000072407642675506015015 0ustar loryusers<$include file="macros.hsc"> <$define COLUMNS:num=10> <$define ROWS:num=20> Table Forms
    hsc-0.934.orig/test2/tts.hsc0100600000175000001440000000047507642675506014543 0ustar loryusers<$macro CONTENT-TO-STRING /CLOSE VAR:string/R> <$define c:string=("<$let " + VAR + "=(HSC.Content)>")> <(c)> Text-to-String <$define test:string> Test <$export file=foo data=(test)> hsc-0.934.orig/test2/varlist.hsc0100600000175000001440000000031707642675506015410 0ustar loryusers Varlist <$varlist vl foo:string="foo" blah:num> <$deftag foo [vl]> <$macro bar [vl]> <* vi: set et ts=2: *> hsc-0.934.orig/test2/vars.hsc0100600000175000001440000000047507642675506014704 0ustar loryusers <$macro outer> <$define var:num='10'> <("outer 1: "+var)> <("outer 2: "+var)> <("outer 3: "+var)> <$macro inner> <("inner 1: "+var)> <$if cond=('1')><$let var=(var - '1')> <("inner 2: "+var)> Variable scope hsc-0.934.orig/test2/xhtml.hsc0100600000175000001440000000060207642675506015055 0ustar loryusers<$include file=macros.hsc> XHTML/HSC test foo
    bar
    baz


    fOo FoO! <* attr after
    attr after nospace
    *> foo


    hsc-0.934.orig/ugly/0040700000175000001440000000000010010444127013114 5ustar loryusershsc-0.934.orig/ugly/args_fre.c0100600000175000001440000000362507770470775015110 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/args_fre.c * * ugly argument freeing functions * sub-module for ugly/args.c * * updated: 15-Nov-1996 * created: 3-Jul-1994 * */ /* * includes */ #include #include #include #include #include #include "utypes.h" #include "umemory.h" #include "ustring.h" #include "dllist.h" #include "uargs.h" /* * del_arginfo * ( called by _free_args() ) * */ void del_arginfo(APTR data) { struct arginfo *arg = (struct arginfo *) data; if (arg) { /* type dependent cleanup */ if (arg->ai_type == ARG_ENUM) ufreestr(arg->ai_misc1.ai_enum); /* cleanup entities */ ufreestr(arg->ai_id); ufreestr(arg->ai_help); arg->ai_type = 0; arg->ai_dest = NULL; arg->ai_func = NULL; /* cleanup whole structure */ ufree(arg); } } /* * free_args * * free all memory allocated by _prepare_args() * * MUST be called after _set_args() * */ void free_args(struct arglist *al) { if (al) { del_dllist(al->al_list); ufree(al); } } hsc-0.934.orig/ugly/args_hlp.c0100600000175000001440000000777607770470775015132 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/args_hlp.c * * sub-module for ugly/args.c * * ugly argument handling help functions * * updated: 10-Sep-1996 * created: 3-Jul-1994 * */ /* * includes */ #include #include #include #include #include #include "utypes.h" #include "umemory.h" #include "ustring.h" #include "dllist.h" #define NOEXTERN_UGLY_ARGS_H #include "uargs.h" /* * strcat_flag */ static VOID strcat_flag(STRPTR s, struct arginfo *ai, ULONG chk_flag, char ch) { char flag[3] = "/x"; if ((ai->ai_flags) & chk_flag) { flag[1] = ch; strcat(s, flag); } } static STRPTR ai2str(struct arginfo *ai) { static STRARR s[100]; strncpy(s, ai->ai_id, 100 - 20); switch (ai->ai_type) { case ARG_SWITCH: strcat(s, "/S"); break; case ARG_LONG_RANGE: case ARG_LONG: strcat(s, "/N"); break; case ARG_TEXT: case ARG_ENUM: case ARG_HANDLEFUNC: break; default: strcat(s, "/?"); break; } strcat_flag(s, ai, ARG_KEYWORD, 'K'); strcat_flag(s, ai, ARG_REQUIRED, 'A'); strcat_flag(s, ai, ARG_MULTIPLE, 'M'); strcat_flag(s, ai, ARG_CASESENS, 'C'); return (s); } /* * fprintf_arghelp */ int fprintf_arghelp(FILE * stream, struct arglist *al) { int err = 0; if (al) { struct dlnode *nd; struct arginfo *ai; size_t maxidlen = 0; /* max. length if arg id */ /* compute maximum length */ nd = al->al_list->first; while (nd) { ai = (struct arginfo *) dln_data(nd); if (ai) { if (ai->ai_help) { STRPTR s = ai2str(ai); if (strlen(s)>maxidlen) maxidlen = strlen(s); } } nd = dln_next(nd); } /*while */ maxidlen += 2; nd = al->al_list->first; while (nd) { ai = (struct arginfo *) dln_data(nd); if (ai) { if (ai->ai_help) { STRPTR s = ai2str(ai); if (ai->ai_help) fprintf(stream, " %-*s %s", (int) maxidlen, s, ai->ai_help); else fprintf(stream, "%s", s); fprintf(stream, "\n"); } } nd = dln_next(nd); } /*while */ } return err; } /* * fprintf_arghelp_short * * print short template line help */ int fprintf_arghelp_short(FILE * stream, struct arglist *al) { int err = 0; if (al) { struct dlnode *no; struct arginfo *ai; no = al->al_list->first; if (no) fprintf(stream, "Usage: "); while (no) { ai = (struct arginfo *) no->data; if (ai) fprintf(stream, "%s", ai2str(ai)); no = no->next; if (no) fprintf(stream, ","); } /*while */ fprintf(stream, "\n"); } return err; } hsc-0.934.orig/ugly/args_prp.c0100600000175000001440000002734307770470775015140 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/args_prp.c * * ugly argument preparation functions * * updated: 15-Nov-1996 * created: 3-Jul-1994 * *=================================================================== * TODO: * - free all memory in error case * */ /* * includes */ #include #include #include #include #include #include "utypes.h" #include "umemory.h" #include "ustring.h" #include "dllist.h" #define NOEXTERN_UGLY_UARGS_H #include "uargs.h" /* * error vars */ LONG prep_error_num; /* error number */ int prep_error_idx; /* # of template causing error */ size_t prep_error_pos; /* pos in arg */ BOOL no_preperr, any_preperr; /* error flags for _prepare_args() */ /* * error functions for _prepare_arg() * */ void set_preperr(LONG num, size_t pos) { if (no_preperr) { no_preperr = FALSE; any_preperr = TRUE; prep_error_num = num; prep_error_pos = pos; } } void clr_preperr(void) { no_preperr = TRUE; any_preperr = FALSE; prep_error_num = 0; prep_error_pos = 0; } /* * fprintf_arginfo (debugging aid) */ void fprintf_arginfo(FILE * stream, APTR data) { struct arginfo *arg = (struct arginfo *) data; fprintf(stream, " %-15s %2lx %2lx", arg->ai_id, arg->ai_type, arg->ai_flags); if (arg->ai_help) printf(" \"%s\"", arg->ai_help); fprintf(stream, "\n"); } /* * prepare_args * * convert argument definitions to dllist of struct arginfo * */ struct arglist *prepare_args(STRPTR arglist_name,...) { va_list ap; struct dllist *newlist; struct arginfo *newarg; struct arglist *new_arglist = NULL; DA(fprintf(stderr, DUA "prepare_args()\n")); clr_preperr(); /* clear error vars */ /* * alloc & init _new_arglist */ new_arglist = (struct arglist *) umalloc(sizeof(struct arglist)); if (new_arglist) { new_arglist->al_name = arglist_name; new_arglist->al_list = NULL; new_arglist->al_multiple = NULL; new_arglist->al_nokeywd = NULL; } else set_preperr(APE_NO_MEM, 0); /* * convert template to double linked list */ newlist = init_dllist(del_arginfo); if(new_arglist && newlist) { STRPTR nxtdef = NULL; /* next template definition */ va_start(ap, arglist_name); do { ufreestr(nxtdef); nxtdef = va_arg(ap, STRPTR); /* get next definition */ /* clone nxtdef: this is necessary because on unix-systems, */ /* you can not let strtok() run on strings received with */ /* va_arg() -> bus error */ nxtdef = strclone(nxtdef); prep_error_idx++; if (nxtdef) { DA(fprintf(stderr, DUA " `%s'\n", nxtdef)); newarg = (struct arginfo *) umalloc(sizeof(struct arginfo)); if (newarg) { STRPTR new_id; STRPTR typestr; STRPTR flagstr = NULL; STRPTR enumstr = NULL; /* enum string for type 'E' */ LONG new_type = 0; LONG new_flags = 0; LONG rnlolim = 0; LONG rnhilim = 0; /* init _newarg */ newarg->ai_id = NULL; newarg->ai_type = 0; newarg->ai_flags = 0; newarg->ai_misc1.ai_lolim = 0; newarg->ai_misc2.ai_uplim = 0; newarg->ai_dest = NULL; newarg->ai_func = NULL; newarg->ai_help = NULL; new_id = strtok(nxtdef, "/"); typestr = strtok(NULL, "/"); /* * get argument type */ if (typestr) { if (strlen(typestr) == 1) { switch (toupper(typestr[0])) { case 'T': new_type = ARG_TEXT; break; case 'S': new_type = ARG_SWITCH; break; case 'N': new_type = ARG_LONG; break; case 'R': new_type = ARG_LONG_RANGE; break; case 'E': new_type = ARG_ENUM; break; } if (new_type) /* arg-type specified? */ flagstr = strtok(NULL, "/"); /* Y-> get next flag */ else { flagstr = typestr; /* N-> must be flag */ new_type = ARG_TEXT; /* set type to text */ } } else set_preperr(APE_INVALID_TEMPLATE, 0); } else { /* no type at all */ flagstr = NULL; /* -> no flags also */ new_type = ARG_TEXT; /* set type to text */ } /* if typestr */ /* * get argument flags */ while (flagstr && flagstr[0] && no_preperr) { switch (toupper(flagstr[0])) { case 'M': new_flags |= ARG_MULTIPLE; break; case 'A': new_flags |= ARG_REQUIRED; break; case 'K': new_flags |= ARG_KEYWORD; break; case 'O': new_flags |= ARG_OVERWRITE; break; case '$': new_flags |= ARG_HANDLEFUNC; break; default: set_preperr(APE_ILLEGAL_FLAG, 0); break; } /* switch */ flagstr = strtok(NULL, "/"); } /* while */ if (no_preperr) { /* * get additional arguments */ if (new_flags & ARG_HANDLEFUNC) { /* * get handler function */ APTR func_tmp = va_arg(ap, STRPTR); newarg->ai_func = (STRPTR(*)(STRPTR)) func_tmp; #if 0 /* tricky type-cast, 1-step-version, does */ /* not work with several compilers */ newarg->ai_func = va_arg(ap, STRPTR(*)(STRPTR)); #endif } if (new_type == ARG_LONG_RANGE) { /* * get range limits */ rnlolim = va_arg(ap, LONG); rnhilim = va_arg(ap, LONG); } else if (new_type == ARG_ENUM) { /* * get enum string */ enumstr = va_arg(ap, STRPTR); } if (no_preperr) { newarg->ai_id = strclone(new_id); /* sux */ newarg->ai_type = new_type; newarg->ai_flags = new_flags; newarg->ai_dest = va_arg(ap, APTR); newarg->ai_help = strclone(va_arg(ap, STRPTR)); /* * set additional argument information * (->misc1, ->misc2) */ switch (new_type) { case ARG_ENUM: newarg->ai_misc1.ai_enum = strclone(enumstr); if (!(newarg->ai_misc1.ai_enum)) set_preperr(APE_NO_MEM, 0); break; case ARG_LONG_RANGE: newarg->ai_misc1.ai_lolim = rnlolim; newarg->ai_misc2.ai_uplim = rnhilim; break; } /* * check for NULL as destination var */ if (newarg->ai_dest == NULL) set_preperr(APE_DESTVAR_IS_NULL, 0); } /* * check, if arg multiple arg without keyword */ if (new_flags & ARG_MULTIPLE) if (!(new_flags & ARG_KEYWORD)) { if (new_arglist->al_multiple) set_preperr(APE_DOUBLE_MULTIPLE, 0); else new_arglist->al_multiple = newarg; } /* * append new argument entry to list */ if (no_preperr) if (app_dlnode(newlist, (APTR) newarg) == NULL) set_preperr(APE_NO_MEM, 0); /* free _newarg if any error occured */ if (any_preperr) del_arginfo((APTR) newarg); } } else set_preperr(APE_NO_MEM, 0); } else { DA(fprintf(stderr, DUA " (end prepare)\n")); } } while (nxtdef && no_preperr); /* free last value of nxtdef */ ufreestr(nxtdef); va_end(ap); } else set_preperr(APE_NO_MEM, 0); /* * check for empty template */ if (no_preperr) if (newlist->first == NULL) set_preperr(APE_EMPTY_TEMPLATE, 0); /* * free newlist, if any error occured */ if (any_preperr) { /* free newlist */ del_dllist(newlist); ufree(new_arglist); newlist = NULL; new_arglist = NULL; } else new_arglist->al_list = newlist; return new_arglist; } hsc-0.934.orig/ugly/args_set.c0100600000175000001440000004651307770470775015132 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/args_set.c * * ugly set arguments handling functions * * updated: 18-Dec-1997 * created: 3-Jul-1994 * *=================================================================== * TODO: * - support ARG_LONG_RANGE * - support ARG_INV_SWITCH (set switch value to FALSE if NOxxx found) * - or better: support ARG_TOGGLE (set to YES/NO) * */ /* * includes */ #include #include #include #include #include #include "utypes.h" #include "ufile.h" #include "umemory.h" #include "ustring.h" #include "dllist.h" #define NOEXTERN_UGLY_UARGS_H #include "uargs.h" #if 0 #undef DA #define DA(x) x #endif /* * global export vars * * TODO: why the heck should this be global, if it is declared static? */ static int arg_error_num = -1; /* error number */ static STRPTR arg_error_arg = NULL; /* argument causing error */ static STRPTR arg_error_hfs = NULL; /* error string returned by handle function */ /* * result string for _strargerr() */ #define SIZE_ARGERRSTR 60 static STRARR argerrstr[SIZE_ARGERRSTR]; /* * local global vars */ static BOOL no_argerr = TRUE; /* error flags for _set_args() */ static BOOL any_argerr = FALSE; static int argidx = -1; /* index in _argv[] currently examing */ /* * compare_arginfo * ( called by _set_args() ) * */ static int compare_arginfo(APTR cmp_data, APTR list_data) { struct arginfo *ai = (struct arginfo *) list_data; STRPTR lst_arg = strclone(ai->ai_id); /* TODO: possible enforcer hit */ STRPTR cmp_arg = ((struct arginfo *) cmp_data)->ai_id; /* TODO: possible enforcer hit */ BOOL eq = FALSE; char lastch; if (lst_arg && cmp_arg) { STRPTR nxt_arg = strtok(lst_arg, "="); while (nxt_arg && (eq == FALSE)) { if (ai->ai_flags & ARG_CASESENS) { eq = (strncmp(nxt_arg, cmp_arg, strlen(nxt_arg)) == 0); } else { eq = (upstrncmp(nxt_arg, cmp_arg, strlen(nxt_arg)) == 0); } #if 0 if (eq) { if (ai->ai_type != ARG_SWITCH) eq = (cmp_arg[strlen(nxt_arg)] == '='); } #endif lastch = cmp_arg[strlen(nxt_arg)]; eq &= (lastch == '\0') || (lastch == '='); nxt_arg = strtok(NULL, "="); } /* while */ } else { eq = FALSE; } ufreestr(lst_arg); return eq; } /* * clr_ai_set * * clear all ai_set bits in all _arginfo entries of an _arglist * */ static VOID clr_ai_set(ARGLIST * al) { #if 0 struct dlnode *nd; struct arginfo *ai; if (al) if (al->al_list) if (nd = al->al_list->first) while (nd) { if (ai = (struct arginfo *) nd->data) ai->ai_set = FALSE; nd = nd->next; } #endif if (al && (al->al_list)) { struct dlnode *nd = al->al_list->first; while (nd) { struct arginfo *ai = (struct arginfo *) nd->data; if (ai) ai->ai_set = FALSE; nd = nd->next; } } } /* * reset_nokeywd * * set al_nokeywd to first entry w/o ARG_KEYWORD flag * */ static VOID reset_nokeywd(ARGLIST * al) { /* * NOTE: _al must be fully initialised _arglist, * otherwise _set_args() would have rejeceted * it. therefor no "al == NULL" check is done * when setting _nd and _ai. */ struct dlnode *nd = al->al_list->first; struct arginfo *ai = (struct arginfo *) nd->data; if (ai->ai_flags & ARG_KEYWORD || (ai->ai_type == ARG_SWITCH)) { al->al_nokeywd = NULL; do { if ((ai->ai_flags & ARG_KEYWORD) || (ai->ai_type == ARG_SWITCH)) { nd = nd->next; if (nd) ai = (struct arginfo *) nd->data; } else al->al_nokeywd = ai; } while (nd && !(al->al_nokeywd)); } else { al->al_nokeywd = ai; } } /* * find_nxt_nokeywd * * find next entry w/o ARG_KEYWORD flag set * */ static VOID find_nxt_nokeywd(ARGLIST * al) { if (al->al_nokeywd) { #if 0 /* * find entry in al_list pointing to al_nokeywd */ struct dlnode *nd = al->al_list->first; struct arginfo *ai; while (al->al_nokeywd != (struct arginfo *) nd->data) nd = nd->next; /* * find next entry in al_list w/o ARG_KEYWORD */ nd = nd->next; al->al_nokeywd = NULL; while (nd && (al->al_nokeywd == NULL)) { ai = (struct arginfo *) nd->data; if ((ai->ai_flags & ARG_KEYWORD) || (ai->ai_type == ARG_SWITCH) ) nd = nd->next; else al->al_nokeywd = ai; }; #endif /* * find entry in al_list pointing to al_nokeywd */ struct dlnode *nd = al->al_list->first; struct arginfo *ai; /* * find next entry in al_list w/o ARG_KEYWORD */ al->al_nokeywd = NULL; while (nd && (al->al_nokeywd == NULL)) { BOOL is_keywd = FALSE; BOOL multiple_nokeywd = FALSE; ai = (struct arginfo *) nd->data; is_keywd = (BOOL)(ai->ai_flags & ARG_KEYWORD); multiple_nokeywd = (ai->ai_flags & ARG_MULTIPLE) && !is_keywd; if (((ai->ai_flags & ARG_KEYWORD) || (ai->ai_type == ARG_SWITCH) || (ai->ai_set)) && !multiple_nokeywd) { nd = nd->next; } else { al->al_nokeywd = ai; } } } } /* * * error functions for _set_args() * */ static VOID set_argerr(int num, STRPTR arg) { if (no_argerr) { no_argerr = FALSE; any_argerr = TRUE; arg_error_num = num; arg_error_arg = arg; } } static VOID clr_argerr(VOID) { no_argerr = TRUE; any_argerr = FALSE; arg_error_num = 0; arg_error_arg = NULL; } /* * strargerr * * returns string containing detailed error message of * error occured in last call of _set_args() * */ STRPTR strargerr(VOID) { STRPTR str = "unknown error"; switch (arg_error_num) { case ASE_NO_MEM: str = "out of memory"; break; case ASE_OCCURED_TWICE: str = "argument occured twice"; break; case ASE_UNKNOWN_KEYWORD: str = "unknown keyword"; break; case ASE_INVALID_NUM: str = "invalid numeric argument"; break; case ASE_INVALID_ENUM: str = "invalid enumerator value"; break; case ASE_REQUIRED_MISS: str = "required argument missing"; break; case ASE_EMPTY_TEMPLATE: str = "empty template"; break; case ASE_OUT_OF_RANGE: str = "numeric argument out of range"; break; case ASE_NO_VAL_AFTER_KW: str = "value after keyword missing"; break; case ASE_HANDLE_FUNC: /* error in handle function */ str = arg_error_hfs; break; } /* switch */ strcpy(argerrstr, str); if (arg_error_arg) { strncat(argerrstr, ": ", SIZE_ARGERRSTR - strlen(str) - 1); strncat(argerrstr, arg_error_arg, SIZE_ARGERRSTR - strlen(str) - 3); } if (arg_error_num) { return argerrstr; } else { return NULL; } } /* * pargerr * * printf error message from last call of _set_args() * */ VOID pargerr(VOID) { if (arg_error_num) { fprintf(stderr, "%s\n", strargerr()); } } /* * set_arg_value * * sets argument _ai->ai_dest with value specified in _arg * */ static UBYTE set_arg_value(struct arginfo *ai, STRPTR arg, STRPTR arg2, BOOL keywd) { APTR dest = ai->ai_dest; STRPTR param; UBYTE arg_incr = 0; /* set to 1 if arg2 is used */ BOOL arg2used = FALSE; /* evaluate parameter: */ /* if arg is equal to arg-id of ai (no other chars */ /* following), the param is taken from the next arg. */ /* otherwise, the arg is scanned for '=' and the */ /* rest of the arg is taken as param */ if (keywd && !(ai->ai_type == ARG_SWITCH)) { param = arg; while (param[0] && (param[0] != '=')) param++; if (param[0]) param++; else { param = arg2; arg2used = TRUE; if (!param) set_argerr(ASE_REQUIRED_MISS, arg); } } else param = arg; /* * set switch/arg-value */ if (no_argerr) { if (ai->ai_func) { /* call handle function with arg value */ arg_error_hfs = (*(ai->ai_func)) (param); if (arg_error_hfs) set_argerr(ASE_HANDLE_FUNC, param); } else if (ai->ai_type == ARG_SWITCH) /* switch */ { *((BOOL *) dest) = TRUE; } else { /* * check if argument already set by this set_args() */ if ((ai->ai_set == AIS_SET_LOCAL) && !((ai->ai_flags & ARG_OVERWRITE) || (ai->ai_flags & ARG_MULTIPLE))) { set_argerr(ASE_OCCURED_TWICE, arg); } else { ai->ai_set = AIS_SET_LOCAL; } if (no_argerr) { APTR aparam = NULL; DLLIST **dest_list = (DLLIST **) dest; LONG along; /* * get new value and store it in aparam */ if (!param) { /* missing param */ set_argerr(ASE_NO_VAL_AFTER_KW, arg); } if (ai->ai_type == ARG_TEXT) { /* text */ aparam = (APTR) param; } else if (ai->ai_type == ARG_LONG) { /* long */ if (!str2long(param, &along)) set_argerr(ASE_INVALID_NUM, arg); else aparam = (APTR) along; /* what a pervert! */ } else if (ai->ai_type == ARG_ENUM) { LONG aenum = strenum(param, ai->ai_misc1.ai_enum, '|', STEN_NOCASE); if (!aenum) set_argerr(ASE_INVALID_ENUM, arg); else aparam = (APTR) aenum; /* what a pervert! */ } #if 0 if (!param) /* missing param */ set_argerr(ASE_NO_VAL_AFTER_KW, arg); if (ai->ai_type == ARG_TEXT) /* text */ *((STRPTR *) dest) = param; else if (ai->ai_type == ARG_LONG) { /* long */ if (!str2long(param, (LONG *) dest)) set_argerr(ASE_INVALID_NUM, arg); } #endif /* * set new value */ if (no_argerr) { if (ai->ai_flags & ARG_MULTIPLE) { if (!(*dest_list)) *dest_list = init_dllist(NULL); if (*dest_list) { if (!app_dlnode(*dest_list, aparam)) set_argerr(APE_NO_MEM, arg); } else set_argerr(APE_NO_MEM, arg); } else { if (ai->ai_type == ARG_LONG) *((LONG *) dest) = (LONG) aparam; else if (ai->ai_type == ARG_ENUM) *((LONG *) dest) = (LONG) aparam; else if (ai->ai_type == ARG_TEXT) *((STRPTR *) dest) = (STRPTR) aparam; } } } } if (arg2used) /* set return value that arg2 */ arg_incr = 1; /* is skipped outside this func */ } return (arg_incr); } /* * check_required_set * * check, if all required arguments are set * */ static VOID check_required_set(ARGLIST * al) { DLNODE *nd = al->al_list->first; ARGINFO *ai; do { ai = (struct arginfo *) dln_data(nd); if ((ai->ai_flags & ARG_REQUIRED) && (ai->ai_set == AIS_UNSET)) set_argerr(ASE_REQUIRED_MISS, ai->ai_id); else nd = dln_next(nd); } while (nd && no_argerr); } /* * set_args_file * * set args from argument file */ ARGFILE *new_argfile(char *argfname) { #define SIZE_FGETSBUF 1024 ARGFILE *argf = (ARGFILE *) umalloc(sizeof(ARGFILE)); BOOL no_argerr = TRUE; if (argf) { FILE *file = NULL; argf->argc = 0; argf->argv = (char **) umalloc(2 * sizeof(char *)); argf->argv[0] = NULL; argf->argv[1] = NULL; if (argfname) { argf->argv[0] = strclone(argfname); file = fopen(argfname, "r"); } if (file) { STRPTR fgetsbuf = (STRPTR) umalloc(SIZE_FGETSBUF); /* alloc buf for fgets() */ if (fgetsbuf) { STRPTR argline = NULL; no_argerr = FALSE; do { argline = fgets(fgetsbuf, SIZE_FGETSBUF, file); if (argline) { int i = 0; /* loop var */ /* increse argv-array */ char **old_argv = argf->argv; argf->argc++; argf->argv = (char **) umalloc((argf->argc + 2) * sizeof(char *)); /* copy old argv-array */ for (i = 0; i <= (argf->argc); i++) { argf->argv[i] = old_argv[i]; } /* free old argv-array */ ufree(old_argv); /* strip succeeding linefeed */ while (fgetsbuf[0] && strchr("\r\n", fgetsbuf[strlen(fgetsbuf) - 1])) { fgetsbuf[strlen(fgetsbuf) - 1] = '\0'; } /* assign new argv */ argf->argv[argf->argc] = strclone(fgetsbuf); argf->argv[argf->argc + 1] = NULL; } } while (argline); argf->argc++; } ufree(fgetsbuf); /* cleanup resources */ fclose(file); } } return (argf); } ARGFILE *new_argfilev(STRPTR fname[]) { int i=0; while(fname[i] && !fexists(fname[i])) { i++; } return(new_argfile(fname[i])); } /* * del_argfile: release all resources allocated by new_argfile */ VOID del_argfile(ARGFILE * argf) { if (argf) { while (argf->argc+1) { ufreestr(argf->argv[argf->argc]); argf->argc--; } ufree(argf->argv); ufree(argf); } } /* * set_args_argv * * check and set arguments according to template specified in _al * * params: argc, argv[]...arguments from _main * al.............argument template (result from _prepare_args()) * result: TRUE, if no error occured * errors: return FALSE, error information in _arg_error_??? * */ BOOL set_args_argv(int argc, char *argv[], ARGLIST * al) { #if 0 DA(fprintf(stderr, DUA "set_args()\n")); #endif clr_argerr(); clr_ai_set(al); reset_nokeywd(al); argidx = 1; if (al == NULL) set_argerr(ASE_EMPTY_TEMPLATE, argv[argidx]); else if (al->al_list == NULL) set_argerr(ASE_EMPTY_TEMPLATE, argv[argidx]); while ((argidx < argc) && no_argerr) { struct arginfo search_ai; struct arginfo *found_ai; struct dlnode *ainode; STRPTR arg2 = NULL; /* passed to set_arg_value */ #if 0 /* TODO:remove */ STRARR sas_c_is_buggy[20]; #endif /* * search for entry in arginfo-list */ search_ai.ai_id = argv[argidx]; ainode = find_dlnode(al->al_list->first, &search_ai, compare_arginfo); /* evaluate next argument (passed to set_arg_value) */ /* TODO: check if "<" or "<=" */ if (argidx < argc - 1) arg2 = argv[argidx + 1]; DA(fprintf(stderr, DUA " arg: `%s'\n", argv[argidx])); if (ainode) { found_ai = (struct arginfo *) ainode->data; argidx += set_arg_value(found_ai, argv[argidx], arg2, TRUE); } else { find_nxt_nokeywd(al); if (al->al_nokeywd) { argidx += set_arg_value(al->al_nokeywd,argv[argidx],arg2,FALSE); } else { set_argerr(ASE_UNKNOWN_KEYWORD, argv[argidx]); } } argidx++; } /* while */ /* mark all arguments that have been set locally * (with ai_set==AIS_SET_LOCAL) as set */ if (no_argerr) { DLNODE *nd = dll_first(al->al_list); while (nd) { ARGINFO *ai = (struct arginfo *) dln_data(nd); if (ai->ai_set == AIS_SET_LOCAL) ai->ai_set = AIS_SET_PREVIOUS; nd = dln_next(nd); } } return no_argerr; } /* * check_args * * check for required args missing */ BOOL check_args(ARGLIST * al) { /* check, if all required arguments were set */ if (no_argerr) { check_required_set(al); } return no_argerr; } /* * set_args * * set and check args from arg-vector */ BOOL set_args(int argc, char *argv[], ARGLIST * al) { return( (BOOL)(set_args_argv(argc,argv,al) && check_args(al))); } /* * set_args_file * * set args read from file */ BOOL set_args_file(ARGFILE *argf, ARGLIST *argl) { return(set_args_argv((argf)->argc, (argf)->argv, argl)); } hsc-0.934.orig/ugly/dllist.c0100600000175000001440000002101007770470775014577 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/dllist.c * * double linked list processing functions * * updated: 18-Dec-1997 * created: 1-Mar-1994 * */ #include #include #include "utypes.h" #include "umemory.h" /* include header file without external prototypes */ #define NOEXTERN_UGLY_DLLIST_H #include "dllist.h" /* * init_dllist * * alloc & initialise new double linked list * * result: ptr to new list * errors: return NULL (out of mem) * */ DLLIST *init_dllist(void (*fn_del_data) (APTR data)) { DLLIST *newlist; newlist = (DLLIST *) /* alloc mem for list */ umalloc(sizeof(DLLIST)); if (newlist) { newlist->first = NULL; /* init new list */ newlist->last = NULL; newlist->entry_num = 0; newlist->user_data = NULL; newlist->del_data = fn_del_data; } return newlist; /* return new list */ } /* * new_dlnode() * * alloc & init new double linked list node * * result: new list node * errors: return NULL (out of mem) * */ DLNODE *new_dlnode(void) { DLNODE *newnode; newnode = (DLNODE*)umalloc(sizeof(DLNODE)); /* alloc mem for new node */ if (newnode) { /* alloc successful? */ newnode->prev = NULL; /* Y-> init node */ newnode->next = NULL; newnode->data = NULL; } return newnode; } /* * detach_dlnode() * * remove entry from double linked list, * but do not delete the entriy's data * */ APTR detach_dlnode(DLLIST * list, DLNODE * node) { APTR nd_data = NULL; if (list && node) { /* list & node node defined? */ nd_data = node->data; /* remember data */ if (node->prev) /* remove node from list */ node->prev->next = node->next; else list->first = node->next; list->entry_num--; if (node->next) node->next->prev = node->prev; else list->last = node->prev; ufree(node); /* free node */ } return nd_data; } /* * del_dlnode() * * remove entry from double linked list * */ void del_dlnode(DLLIST * list, DLNODE * node) { if (list && node) { /* list & node defined? */ void (*dd) (APTR) = list->del_data; if (node->data && dd) /* Y-> call destructor */ (*dd)(node->data); dll_detach_node(list,node); node->prev = NULL; /* clear node */ node->next = NULL; node->data = NULL; ufree(node); /* free node */ } } /* * move_dlnode() * Move from list to the end of without * copying/reallocating anything. */ void move_dlnode(DLLIST *dest, DLLIST *src, DLNODE *node) { /* detach node w/o deleting it */ dll_detach_node(src,node); dll_append_node(dest,node); } /* * del_all_dlnodes() * * remove all nodes from a list */ VOID del_all_dlnodes(DLLIST * list) { while (list->first) del_dlnode(list, list->first); } /* * ins_dlnode() * * insert a data entry into double linked list BEFORE node * */ static DLNODE *ins_dlnode(DLLIST * list, DLNODE * node, APTR data) { DLNODE *newnode = NULL; if (list) { newnode = new_dlnode(); if (newnode) { newnode->data = data; list->entry_num++; if (node) { if (dll_first(list) == node) { /* insert as first entry */ list->first = newnode; } else { /* insert somewhere in the list */ dln_next(dln_prev(node)) = newnode; dln_prev(newnode) = node->prev; } dln_prev(node) = newnode; dln_next(newnode) = node; } else { /* append as last entry */ if (dll_last(list)) list->last->next = newnode; dln_prev(newnode) = dll_last(list); dll_last(list) = newnode; } if (dll_first(list) == NULL) dll_first(list) = newnode; if (dll_last(list) == NULL) dll_last(list) = newnode; } } return newnode; } /* * app_dlnode * * append new node to list (at end) * * result: * errors: return NULL (out of mem) * */ DLNODE *app_dlnode(DLLIST * list, APTR data) { return ins_dlnode(list, NULL, data); } /* * add_dlnode * * add new node to list (as first entry) * * result: new node * errors: return NULL (out of mem) * */ DLNODE *add_dlnode(DLLIST * list, APTR data) { return ins_dlnode(list, list->first, data); } /* * del_dllist * * free whole list and its nodes and data * */ void del_dllist(DLLIST * list) { if (list) { /* remove all nodes */ while (list->first) del_dlnode(list, list->first); /* remove list structure */ list->first = NULL; list->last = NULL; list->entry_num = 0; list->user_data = NULL; list->del_data = NULL; ufree(list); } } /* * do_dllist * * call a function with every node of a list */ void do_dllist(DLLIST * list, void (*func) (APTR data)) { if (list) { DLNODE *nd = list->first; while (nd) { (*func) (nd->data); nd = nd->next; } } } /* * fprintf_dllist * * output a whole list to a stream * (more or less only a debugging function) */ void fprintf_dllist(FILE * stream, DLLIST * list, void (*fprintf_data) (FILE * stream, APTR data)) { if (list) { DLNODE *node; ULONG i = 1; node = list->first; if (node) { while (node) { fprintf(stream, "%4lu: ", i++); if (fprintf_data) (*fprintf_data) (stream, node->data); else fprintf(stream, "%s\n", (STRPTR) node->data); node = node->next; } } else fprintf(stream, " [empty list]\n"); } else fprintf(stream, " [no list]\n"); } /* * find_dlnode * * search for specific data in a list, starting at a specific node * * params: start....startnode to begin search with * data.....data to be found * compare..funtions that compares two data-items; * returns -1 if items are equal, else 0 * result: ptr to node that contains requested data * or NULL if not found */ DLNODE *find_dlnode(DLNODE * start, APTR data, int (*compare) (APTR cmp_data, APTR list_data)) { DLNODE *search = start; int found = 0; while (search && !(found)) { found = (*compare) (data, search->data); if (!found) search = search->next; } return search; } /* * find_dlnode_bw * * search for specific data in a list, starting at a specific node, * search directions set to backwards * * params: start....startnode to begin search with * data.....data to be found * compare..funtions that compares two data-items; * returns -1 if items are equal, else 0 * result: ptr to node that contains requested data * or NULL if not found */ DLNODE *find_dlnode_bw(DLNODE * start, APTR data, int (*compare) (APTR cmp_data, APTR list_data)) { DLNODE *search = start; int found = 0; while (search && !(found)) { found = (*compare) (data, search->data); if (!found) search = search->prev; } return search; } /* * empty_dllist * * check if a list is empty * * params: list..list to check for emptyness * result: TRUE, if list contains no nodes */ BOOL empty_dllist(DLLIST * list) { if (list->first) return FALSE; else return TRUE; } hsc-0.934.orig/ugly/dllist.h0100600000175000001440000000671307770470740014611 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef UGLY_DLLIST_H #define UGLY_DLLIST_H /* avoid include twice */ /* * dllist.h * * doubel linked list functions, header * * (W) by Tommy-Saftwörx in 1994,95 * */ #include #include "utypes.h" /* * * double linked list structs * */ struct dlnode { struct dlnode *prev; /* previous entry */ struct dlnode *next; /* next entry */ APTR data; /* ptr to data */ }; struct dllist { /* PRIVATE (read-only) */ struct dlnode *first; /* first entry */ struct dlnode *last; /* last entry */ LONG entry_num; /* num of entries in list */ void (*del_data) (APTR data); /* func that removes data */ /* PUBLIC */ APTR user_data; /* user data */ }; typedef struct dllist DLLIST; typedef struct dlnode DLNODE; /* * access methodes */ #define dll_first( list ) ((list)->first) #define dll_last( list ) ((list)->last) #define dln_prev( node ) ((node)->prev) #define dln_next( node ) ((node)->next) #define dln_data( node ) ((node)->data) #define dll_detach_node(list,node) { \ if(NULL != dln_prev(node)) dln_next(dln_prev(node)) = dln_next(node); \ else dll_first(list) = dln_next(node); \ if(NULL != dln_next(node)) dln_prev(dln_next(node)) = dln_prev(node); \ else dll_last(list) = dln_prev(node); \ --(list)->entry_num; \ } #define dll_append_node(list,node) { \ dln_next(node) = NULL; \ if(NULL != (dln_prev(node) = dll_last(list))) dln_next(dln_prev(node)) = (node); \ dll_last(list) = (node); \ if(NULL == dll_first(list)) dll_first(list) = (node); \ } /* * * external functions prototypes * */ #ifndef NOEXTERN_UGLY_DLLIST_H extern DLLIST *init_dllist(void (*del_data) (APTR data)); extern DLNODE *new_dlnode(void); extern DLNODE *app_dlnode(DLLIST * list, APTR data); extern DLNODE *add_dlnode(DLLIST * list, APTR data); extern APTR detach_dlnode(DLLIST * list, DLNODE * node); extern void del_dlnode(DLLIST * list, DLNODE * node); void move_dlnode(DLLIST *dest, DLLIST *src, DLNODE *node); extern VOID del_all_dlnodes(DLLIST * list); extern void del_dllist(DLLIST * list); extern BOOL empty_dllist(DLLIST * list); extern void fprintf_dllist(FILE * stream, DLLIST * list, void (*fprintf_data) (FILE * stream, APTR data)); extern void do_dllist(DLLIST * list, void (*func) (APTR data)); extern DLNODE *find_dlnode(DLNODE * start, APTR data, int (*compare) (APTR cmp_data, APTR list_data)); extern DLNODE *find_dlnode_bw(DLNODE * start, APTR data, int (*compare) (APTR cmp_data, APTR list_data)); #endif /* NOEXTERN_UGLY_DLLIST_H */ #endif /* UGLY_DLLIST_H */ hsc-0.934.orig/ugly/expstr.c0100600000175000001440000006210607770470775014644 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/expstr.c * * ugly expandable-string functions * * updated: 26-Feb-1997 * created: 12-Sep-1995 * */ /****** ugly.lib/--background-- ********************************************** * * PURPOSE * It is a known fact, that the programming langage C comes with one of * the most useless string concept ever. * * This function library implements a simple concept to use strings * which allocate new memory themself if data will not fit in the * current anymore. * * All operations work with a internal structure EXPSTR, which is * private and must not be accessed by the programmer. For all * interessting information, access functions exist. (See estrlen() * and estr2str().) * * An interface with standard strings is provided. (See estr2str() and * set_estr().) * * EXAMPLE * * A sample session of including and using some of the functions of * this collection can be found below: * * #include "ugly/expstr.h" * ... * * EXPSTR * sepp = init_estr( 0 ); \* an expandable string *\ * EXPSTR * hugo = init_estr( 0 ); \* an expandable string *\ * STRPTR resi = "this is resi"; \* a standard string *\ * BOOL ok = ((BOOL) (sepp && hugo); \* result variable *\ * * if (ok) * { * ok &= set_estr( sepp, "sepp" ); \* set data *\ * ok &= set_estr( hugo, "hugo" ); * * ok &= app_estr( sepp, ". "); \* append data *\ * ok &= app_estr( hugo, " and "); * ok &= estrcat( hugo, sepp ); \* ("hugo and sepp.") *\ * * ok &= clr_estr( sepp ); \* clear sepp *\ * * printf( "sepp=%s\nhugo=%s\n", \* output data *\ * estr2str( sepp ), estr2str( hugo )); * } * * if (!ok) * { * printf( "out of resources\n" ); * } * * del_estr( hugo ); \* cleanup (in any case) *\ * del_estr( sepp ); * * NOTES * Internally, expandable string still contain a zero-character ('\0') * at the end of data. * * BUGS * Currently, expandable strings can not hold data which contain a * zero-character ('\0'). This is because at several locations I have * used functions like strcpy() instead of memcpy(). * * Currently, strings expand very stupid in a linear way and not * exponentially. That means, if a string runs out of memory, * it will only increase by a constant size, instead of eg. increase * to twice as large as before. Altough this also works, it is quite * slow for long strings. * ****************************************************************************** */ #include #include #include #include #include "utypes.h" #include "ustring.h" #include "umemory.h" #define NOEXTERN_UGLY_STRING_H #include "expstr.h" #if DEBUG_UGLY_EXPSTR #define D(x) x #define DEXP "*expstr* " #else #define D(x) /* nufin */ #endif /* some functions that perform consistency checks and panic if necessary */ static void es_null(STRPTR func, STRPTR file, ULONG line) { fprintf(stderr, "\n##\n## panic: es=NULL in %s()\n## called from %s (%lu)\n##\n", func, file, line); } static void s_null(STRPTR func, STRPTR file, ULONG line) { fprintf(stderr, "\n##\n## panic: string=NULL in %s()\n## called from %s (%lu)\n##\n", func, file, line); } /* *------------------------------------- * set/clear expstr *------------------------------------- */ /* * set_estr_mem * * set new mem for es_data * * params: es........expstr where to assign the new mem to * new_size..new size for data part * result: TRUE if all ok, new mem in es->es_data; * errors: return FALSE, leave es->es_data untouched * */ static BOOL do_set_estr_mem(EXPSTR * es, STRPTR new_data, size_t new_size) { BOOL ok = TRUE; if (new_data) { #if DEBUG_UGLY_EXPSTR == 2 D(fprintf(stderr, DEXP "set to %lu (%p->%p)\n", new_size, es->es_data, new_data)); #endif es->es_size = new_size; es->es_data = new_data; } else ok = FALSE; return (ok); } BOOL ugly_set_estr_mem(EXPSTR * es, size_t new_size) { return (do_set_estr_mem(es, (STRPTR) umalloc(new_size), new_size)); } BOOL ugly_dbg_set_estr_mem(EXPSTR * es, size_t new_size, STRPTR file, ULONG line) { BOOL ok = FALSE; if (!es) es_null("set_estr_mem", file, line); else { ok = do_set_estr_mem(es, (STRPTR) ugly_malloc_tracking(new_size, file, line), new_size); } return (ok); } /****** ugly.lib/set_estr() ************************************************** * * NAME * set_estr -- set new data for an expandable string. * * SYNOPSIS * ok = set_estr( string, data ) * * BOOL set_estr * ( EXPSTR * string, STRPTR data ) * * FUNCTION * Reset data of an expandable string to an empty string (""). If * necessary, the buffer to store the string data will be expanded. * * INPUTS * string - string to clear * data - new data to store, represented as a normal zero-terminated * C-string * * RESULT * ok - TRUE, if string could be updated. If there have not been enough * resources available to allocate a new buffer for the new data, * it will still contain the old data, and FALSE will be returned. * * EXAMPLE * ok = set_estr( sepp, "data for sepp" ); * * SEE ALSO * app_estr(), estrcpy() * ****************************************************************************** */ BOOL ugly_set_estr(EXPSTR * es, CONSTRPTR s) { BOOL ok = FALSE; size_t new_len = strlen(s) + 1; STRPTR old_data = es->es_data; if ((es->es_size == es->es_step) && (es->es_size > new_len)) { strcpy(es->es_data, s); /* copy new data */ es->es_len = new_len; /* set new len */ ok = TRUE; } else if (set_estr_mem(es, modadj(new_len, es->es_step))) { strcpy(es->es_data, s); /* copy new & release old data */ ufreestr(old_data); es->es_len = new_len; /* set new len */ ok = TRUE; } return (ok); } BOOL ugly_dbg_set_estr(EXPSTR * es, CONSTRPTR s, STRPTR file, ULONG line) { BOOL ok = FALSE; if (!es) es_null("set_estr_mem", file, line); else if (!s) s_null("set_estr_mem", file, line); else { size_t new_len = strlen(s) + 1; STRPTR old_data = es->es_data; #if DEBUG_UGLY_EXPSTR == 2 uglymem_wallcheck("setestr()", file, line); #endif if ((es->es_size == es->es_step) && (es->es_size > new_len)) { strcpy(es->es_data, s); /* copy new data */ es->es_len = new_len; /* set new len */ ok = TRUE; } else if (ugly_dbg_set_estr_mem(es, modadj(new_len, es->es_step), file, line)) { strcpy(es->es_data, s); /* copy new & release old data */ ufree(old_data); es->es_len = new_len; /* set new len */ ok = TRUE; } #if DEBUG_UGLY_EXPSTR == 2 uglymem_wallcheck("setestr()", file, line); #endif } return (ok); } /****** ugly.lib/clr_estr() ************************************************** * * NAME * clr_estr -- clear data of an expandable string. * * SYNOPSIS * ok = clr_estr( string ) * * BOOL clr_estr * ( EXPSTR * string ) * * FUNCTION * Reset data of an expandable string to an empty string (""). This * will reset the amount of memory to be used by this string to the * initial size passed with init_estr(). * * INPUTS * string - string to clear * * RESULT * ok - TRUE, if string could be cleared. If there have not been enough * resources available to allocate a new buffer for the empty * string, it will still contain the old data, and FALSE will be * returned. * * EXAMPLE * ok = clr_estr( sepp ); * * SEE ALSO * init_estr(), set_estr() * ****************************************************************************** */ BOOL ugly_clr_estr(EXPSTR * es) { return (set_estr(es, "")); } BOOL ugly_dbg_clr_estr(EXPSTR * es, STRPTR file, ULONG line) { #if DEBUG_UGLY_EXPSTR == 2 STRPTR s = es->es_data; if (!s) s = ""; fprintf(stderr, DEXP "clr_estr(%p,`%s')\n", es, s); uglymem_wallcheck("clr_estr()", file, line); #endif return (ugly_dbg_set_estr(es, "", file, line)); } /* * set_estrn * * set expstr with first n chars of string */ BOOL set_estrn(EXPSTR * es, CONSTRPTR s, size_t n) { BOOL ok = FALSE; STRPTR s1 = NULL; size_t len = strlen(s); if (n > len) n = len; s1 = (STRPTR) umalloc(n + 1); if (s1) { memcpy(s1, s, n); s1[n] = 0; ok = set_estr(es, s1); ufree(s1); } return (ok); } /* *------------------------------------- * constructor / destructor *------------------------------------- */ /****** ugly.lib/init_estr() ************************************************* * * NAME * init_estr -- create a new expandable string. * * SYNOPSIS * new_string = init_estr( initial_size ) * * EXPSTR * init_estr * ( size_t initial_size ) * * FUNCTION * Creates a new expandable string. Initialises the data that it * represents an empty string. * * INPUTS * initial_size - * Initial size to use for the string. This amount of memory * will immdediately be allocated and is used to store the * string data. If the string grows and data will not fit in * this memory area any more, new memory will be allocated * * If a value of `0' is used, a reasonable value will be * used. This usualy depend on your OS, but will not be * smaller than 8. * * RESULT * new_string - pointer to new string, or NULL if not enough * memory available * * EXAMPLE * EXPSTR * sepp = init_estr( 20 ); * * SEE ALSO * del_estr(), clr_estr(), set_estr() * ****************************************************************************** */ EXPSTR *ugly_dbg_init_estr(size_t step_size, STRPTR file, ULONG line) { EXPSTR *es = (EXPSTR *) ugly_malloc_tracking(sizeof(EXPSTR), file, line); if (es) { if (step_size < ES_MIN_MEMSTEP) step_size = ES_MIN_MEMSTEP; es->es_data = NULL; es->es_size = 0; es->es_step = step_size; if (!clr_estr(es)) { ufree(es); es = NULL; } } return (es); } EXPSTR *ugly_init_estr(size_t step_size) { EXPSTR *es = (EXPSTR *) umalloc(sizeof(EXPSTR)); if (es) { if (step_size < ES_MIN_MEMSTEP) step_size = ES_MIN_MEMSTEP; es->es_data = NULL; es->es_size = 0; es->es_step = step_size; if (!clr_estr(es)) { ufree(es); es = NULL; } } return (es); } /****** ugly.lib/del_estr() ************************************************** * * NAME * del_estr -- release all resources used by an expandable string * * SYNOPSIS * del_estr( string ) * * VOID * init_estr * ( EXPSTR * string ) * * FUNCTION * Releases all resources allocated by an expandable string. The data * are no more valid afterwards and must not be accessed any more. * * INPUTS * string - expandable string to remove * * EXAMPLE * del_estr( sepp ); * * SEE ALSO * init_estr() * ****************************************************************************** */ VOID del_estr(EXPSTR * es) { #if DEBUG_UGLY_EXPSTR if (es) { if (es->es_data) { #if DEBUG_UGLY_EXPSTR == 2 STRARR s[17]; strncpy(s, es->es_data, 17); s[16] = 0; D(fprintf(stderr, DEXP "del_estr(%p,`%s')\n", es, s)); umem_wallcheck("del_estr()"); #endif } else { D(fprintf(stderr, DEXP "attempt to free null-data-estr\n")); } } else { #if DEBUG_UGLY_EXPSTR == 2 D(fprintf(stderr, DEXP "attempt to free null-estr\n")); #endif } #endif if (es) { ufree(es->es_data); es->es_len = 0; es->es_size = 0; es->es_step = 0; ufree(es); } } /****** ugly.lib/app_estrch() ************************************************** * * NAME * app_estrch -- append single character to an expandable string. * * SYNOPSIS * ok = app_estrch( string, ch ) * * BOOL app_estrch * ( EXPSTR * string, int ch ) * * FUNCTION * At the end of a string, a single character will be appended. * * INPUTS * string - string to which data should be appended * ch - character to append * * RESULT * ok - TRUE, if string could be updated. If there have not been enough * resources available to allocate a new buffer for the new data, * it will still contain the old data, and FALSE will be returned. * * EXAMPLE * ok = app_estrch( sepp, 'x' ); * * BUGS * Result is undefined, if (ch > 255) or (ch < 0). * * SEE ALSO * app_estr() * ****************************************************************************** */ BOOL ugly_app_estrch(EXPSTR * es, int ch) { BOOL ok = TRUE; if (es->es_len >= es->es_size) { /* enough mem left? */ STRPTR old_data = es->es_data; /* N->remeber old data ptr */ if (set_estr_mem(es, es->es_size + es->es_step)) { /* set new mem sucessful? */ strcpy(es->es_data, /* Y->copy old data */ old_data); ufree(old_data); /* release old data */ } else { /* N->return error */ ok = FALSE; } } if (ok) { STRPTR s; s = es->es_data; s[es->es_len - 1] = ch; /* append new char to expstr */ s[es->es_len] = 0; es->es_len++; /* incr. expstr length */ } return (ok); } BOOL ugly_dbg_app_estrch(EXPSTR * es, int ch, STRPTR file, ULONG line) { BOOL ok = TRUE; if (!es) { es_null("app_estrch", file, line); ok = FALSE; } else if (es->es_len >= es->es_size) { /* enough mem left? */ STRPTR old_data = es->es_data; /* N->remeber old data ptr */ if (ugly_dbg_set_estr_mem(es, es->es_size + es->es_step, file, line)) { /* set new mem sucessfully? */ strcpy(es->es_data, /* Y->copy old data */ old_data); ufree(old_data); /* release old data */ } else { /* N->return error */ ok = FALSE; } } if (ok) { STRPTR s; s = es->es_data; s[es->es_len - 1] = ch; /* append new char to expstr */ s[es->es_len] = 0; es->es_len++; /* incr. expstr length */ } return (ok); } /****** ugly.lib/app_estr() ************************************************** * * NAME * app_estr -- append data to an expandable string. * * SYNOPSIS * ok = app_estr( string, data ) * * BOOL app_estr * ( EXPSTR * string, STRPTR data ) * * FUNCTION * At the end of a string, new data will be appended. * * INPUTS * string - string to which data should be appended * data - new data to append, represented as a normal zero-terminated * C-string * * RESULT * ok - TRUE, if string could be updated. If there have not been enough * resources available to allocate a new buffer for the new data, * it will still contain the old data, and FALSE will be returned. * * EXAMPLE * ok = app_estr( sepp, "data to append" ); * * SEE ALSO * estrcat(), set_estr(), estrcpy() * ****************************************************************************** */ BOOL ugly_app_estr(EXPSTR * es, CONSTRPTR s) { BOOL ok = TRUE; size_t slen = strlen(s); ok = TRUE; if ((es->es_len + slen - 1) >= es->es_size) { /* enough mem left? */ STRPTR old_data = es->es_data; /* N->remeber old data ptr */ if (ugly_set_estr_mem(es, modadj(es->es_len + slen + 1, es->es_step))) { /* set new mem sucessful? */ strcpy(es->es_data, /* Y->copy old data */ old_data); ufree(old_data); /* release old data */ } else { /* N->return error */ ok = FALSE; } } if (ok) { STRPTR ds; ds = es->es_data + (es->es_len - 1); strcat(ds, s); /* append new char to expstr */ es->es_len += slen; /* incr. expstr length */ es->es_data[es->es_len - 1] = 0; } return (ok); } BOOL ugly_dbg_app_estr(EXPSTR * es, CONSTRPTR s, STRPTR file, ULONG line) { BOOL ok = FALSE; if (!es) es_null("app_estr", file, line); else if (!s) s_null("app_estr", file, line); else { /* faster, but maybe buggy */ size_t slen = strlen(s); ok = TRUE; if ((es->es_len + slen - 1) >= es->es_size) { /* enough mem left? */ STRPTR old_data = es->es_data; /* N->remeber old data ptr */ if (ugly_dbg_set_estr_mem(es, modadj(es->es_len + slen + 1, es->es_step), file, line)) { /* set new mem sucessful? */ strcpy(es->es_data, /* Y->copy old data */ old_data); ufree(old_data); /* release old data */ } else { /* N->return error */ ok = FALSE; } } if (ok) { STRPTR ds; ds = es->es_data + (es->es_len - 1); strcat(ds, s); /* append new char to expstr */ es->es_len += slen; /* incr. expstr length */ es->es_data[es->es_len - 1] = 0; } } return (ok); } /* *------------------------------------- * get part of expstr *------------------------------------- */ /* * todo: handle special cases like * get_right_estr( .., "hugo", 99 ); */ /* * get_mid_estr * * get a part from a expstr; compare BASIC's "MID$()" * * params: dest...destination expstr where to store result part * src....source expstr where to get part from * from...position of char where to begin part (0=first char) * num....number of chars to get * result: TRUE and result in dest if ok; else FALSE is returned an * dest is left untouched * * NOTE: it is possible to use the source-exstr as destination-expstr, * because the result is copied to a temp. expstr before * ( example: get_mid_estr( hugo, hugo, 3, 4 ); ) */ BOOL get_mid_estr(EXPSTR * dest, EXPSTR * src, size_t from, size_t num) { BOOL ok = FALSE; EXPSTR *tmp = init_estr(dest->es_step); if (tmp) { STRPTR old_data = tmp->es_data; /* check size */ if (from >= src->es_len) from = src->es_len - 1; if (from + num >= src->es_len) num = src->es_len - from - 1; /* set new mem for tmp */ ok = set_estr_mem(tmp, modadj(num + 1, tmp->es_step)); if (ok) { /* copy data */ strncpy(estr2str(tmp), estr2str(src) + from, num); tmp->es_data[num] = 0; tmp->es_len = num + 1; ufree(old_data); ok = estrcpy(dest, tmp); } del_estr(tmp); } return (ok); } /* * get_right_estr * * get right part from a expstr; compare BASIC's "RIGHT$()" */ BOOL get_right_estr(EXPSTR * dest, EXPSTR * src, size_t num) { if (num >= src->es_len) num = src->es_len - 1; return (get_mid_estr(dest, src, (src->es_len - num - 1), num)); } /* * get_left_estr * * get left part from a expstr; compare BASIC's "LEFT$()" */ BOOL get_left_estr(EXPSTR * dest, EXPSTR * src, size_t num) { return (get_mid_estr(dest, src, 0, num)); } /* *------------------------------------- * misc. functions *------------------------------------- */ /****** ugly.lib/estr2str() ************************************************* * * NAME * estr2str -- convert expandable string to standard string * * SYNOPSIS * s = estr2str( string ) * * STRPTR estr2str * ( EXPSTR * string ) * * FUNCTION * Copy data from a source string (old) to a destination string (new). * * INPUTS * string - expandable string to convert; if you pass NULL, this * function crashes. * * RESULT * s - pointer to data of string, terminated with a zero-character * ('\0') * * EXAMPLE * EXPSTR * hugo = init_estr(0); * STRPTR data; * ... * data = estr2str( hugo ); * * SEE ALSO * set_estr(), estrlen() * ****************************************************************************** */ STRPTR ugly_estr2str(EXPSTR * es) { return (es->es_data); } /****** ugly.lib/estrlen() ************************************************* * * NAME * estrlen -- dtermines length of an expandable string * * SYNOPSIS * len = estrlen( string ) * * size_t estrlen * ( EXPSTR * string ) * * FUNCTION * This functions determines the number of characters stored in an * expandable string. * * INPUTS * string - expandable string to examine; if you pass NULL, this * function crashes. * * RESULT * len - length of string * * EXAMPLE * EXPSTR * hugo = init_estr(0); * size_t len; * ... * len = estrlen( hugo ); * * NOTES * As expandable strings always keep track of their current length, * this functions always executes in O(1) versus classic strlen(), * which always has to examine the whole string and therefor always * executes in O(n), with n = number of characters stored. * * SEE ALSO * estr2str() * ****************************************************************************** */ size_t ugly_estrlen(EXPSTR * es) { return (es->es_len - 1); } /****** ugly.lib/estrcpy() ************************************************** * * NAME * estrcpy -- copy data of an expandable string * * SYNOPSIS * ok = estrcpy( new, old ) * * BOOL estrcpy * ( EXPSTR * new, EXPPTR * old ) * * FUNCTION * Copy data from a source string (old) to a destination string (new). * * INPUTS * new - destination string * old - source string * * RESULT * ok - TRUE, if string could be updated. If there have not been enough * resources available to allocate a new buffer for the new data, * it will still contain the old data, and FALSE will be returned. * * EXAMPLE * EXPSTR * hugo = init_estr(0); * EXPSTR * sepp = init_estr(0); * BOOL ok; * ... * ok = estrcpy( sepp, hugo ); * * SEE ALSO * estrcat(), set_estr() * ****************************************************************************** */ BOOL estrcpy(EXPSTR * dest, EXPSTR * src) { return (set_estr(dest, estr2str(src))); } /****** ugly.lib/estrcat() ************************************************** * * NAME * estrcat -- concatenate two expandable strings * * SYNOPSIS * ok = estrcat( dest, app ) * * BOOL estrcat * ( EXPSTR * dest, EXPPTR * app ) * * FUNCTION * Append data of an string to another one and store the result in it. * * INPUTS * dest - * app - * * RESULT * ok - TRUE, if string could be updated. If there have not been enough * resources available to allocate a new buffer for the new data, * it will still contain the old data, and FALSE will be returned. * * EXAMPLE * EXPSTR * hugo = init_estr(0); * EXPSTR * sepp = init_estr(0); * BOOL ok; * ... * ok = estrcat( sepp, hugo ); * * SEE ALSO * app_estr(), estrcpy() * ****************************************************************************** */ BOOL estrcat(EXPSTR * dest, EXPSTR * src) { return (app_estr(dest, estr2str(src))); } hsc-0.934.orig/ugly/expstr.h0100600000175000001440000000746307770470741014647 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef UGLY_EXPSTR_H #define UGLY_EXPSTR_H /* * ugly/expstr.h * * self-expanding string functions, header * * (W) by Tommy-Saftwörx in 1995 * */ #include #include "utypes.h" #define EXPSTR_MEMSTEP 96 #define ES_MIN_MEMSTEP 8 /* min. memory step for init( step_size ) */ #ifndef modadj #define modadj(x,by) ((by)*(((x)+(by))/(by))) #endif /* some inline macros used without DEBUG defined */ #define ugly_inline_estr2str(es) ((es)->es_data) #define ugly_inline_estrlen(es) ((es)->es_len - 1) typedef struct { STRPTR es_data; /* ptr to string data */ size_t es_len; /* current len */ size_t es_size; /* current size of mem allocated */ size_t es_step; /* size of memory step */ } EXPSTR; /* * external prototypes */ #ifndef NOEXTERN_UGLY_EXPSTR_H extern EXPSTR *ugly_dbg_init_estr(size_t step_size, STRPTR file, ULONG line); extern EXPSTR *ugly_init_estr(size_t step_size); extern void del_estr(EXPSTR * es); extern BOOL ugly_clr_estr(EXPSTR * es); extern BOOL ugly_dbg_clr_estr(EXPSTR * es, STRPTR file, ULONG line); extern BOOL set_estrn(EXPSTR * es, CONSTRPTR s, size_t n); extern BOOL ugly_set_estr(EXPSTR * es, CONSTRPTR s); extern BOOL ugly_app_estrch(EXPSTR * es, int ch); extern BOOL ugly_app_estr(EXPSTR * es, CONSTRPTR s); extern BOOL ugly_dbg_set_estr(EXPSTR * es, CONSTRPTR s, STRPTR file, ULONG line); extern BOOL ugly_dbg_app_estrch(EXPSTR * es, int ch, STRPTR file, ULONG line); extern BOOL ugly_dbg_app_estr(EXPSTR * es, CONSTRPTR s, STRPTR file, ULONG line); extern STRPTR ugly_estr2str(EXPSTR * es); extern size_t ugly_estrlen(EXPSTR * es); extern BOOL estrcpy(EXPSTR * dest, EXPSTR * src); extern BOOL estrcat(EXPSTR * dest, EXPSTR * src); extern BOOL get_mid_estr(EXPSTR * dest, EXPSTR * src, size_t from, size_t num); extern BOOL get_right_estr(EXPSTR * dest, EXPSTR * src, size_t num); extern BOOL get_left_estr(EXPSTR * dest, EXPSTR * src, size_t num); #endif /* NOEXTERN_UGLY_EXPSTR_H */ /* * debugging prototypes */ #if DEBUG_UGLY_EXPSTR /* full debugging */ #define set_estr_mem( es, size ) ugly_dbg_set_estr_mem( es, size, __FILE__, __LINE__ ) #define set_estr( es, s ) ugly_dbg_set_estr( es, s, __FILE__, __LINE__ ) #define app_estrch( es, ch ) ugly_dbg_app_estrch( es, ch, __FILE__, __LINE__ ) #define app_estr( es, s ) ugly_dbg_app_estr( es, s, __FILE__, __LINE__ ) #define init_estr( s ) ugly_dbg_init_estr( s, __FILE__, __LINE__ ) #define clr_estr( s ) ugly_dbg_clr_estr( s, __FILE__, __LINE__ ) #define estr2str( s ) ugly_estr2str( s ) #define estrlen( s ) ugly_estrlen( s ) #else /* no debugging */ #define set_estr_mem( es, size ) ugly_set_estr_mem( es, size ) #define set_estr( es, s ) ugly_set_estr( es, s ) #define app_estrch( es, ch ) ugly_app_estrch( es, ch ) #define app_estr( es, s ) ugly_app_estr( es, s ) #define init_estr( s ) ugly_init_estr( s ) #define clr_estr( s ) ugly_clr_estr( s ) #define estr2str( s ) ugly_inline_estr2str( s ) #define estrlen( s ) ugly_inline_estrlen( s ) #endif #endif /* UGLY_EXPSTR_H */ hsc-0.934.orig/ugly/fname.c0100600000175000001440000004175510007677502014374 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/fname.c - filename processing functions * * updated: 23-Aug-1998 * created: 24-May-1994 * *------------------------------------------------------------------- * */ #include #include #include #include "utypes.h" #include "umemory.h" #include "ustring.h" #include "expstr.h" #define NOEXTERN_UGLY_FNAME_H #include "fname.h" /* * get_fext * * get filename extension * * params: fn...full filename to examine * result: extension of _fn or NULL, if fn was also NULL * */ BOOL get_fext(EXPSTR * dest, CONSTRPTR fn) { CONSTRPTR fn_ext = fn; /* result var */ /* search for end of string */ while (fn_ext[0]) fn_ext++; /* search string backwards for "." or PATH_SEPARATOR */ do { /* nufin */ ; } while ((fn_ext != fn) /* beginning of name reached? */ && (fn_ext--) /* process next char */ && (fn_ext[0] != '.') && (strchr(PATH_SEPARATOR, fn_ext[0]) == NULL)); /* copy extension to dest */ if (fn_ext[0] == '.') set_estr(dest, ++fn_ext); else clr_estr(dest); return (ok_fnl_fext(dest)); } /* * get_fname * * */ BOOL get_fname(EXPSTR * dest, CONSTRPTR fn) { CONSTRPTR fn_name = fn; fn_name = ustrrpbrk(fn_name, PATH_SEPARATOR); /* copy extension to dest */ if (fn_name) set_estr(dest, ++fn_name); else set_estr(dest, fn); return (ok_fnl_fname(dest)); } /* * get_fpath * * */ BOOL get_fpath(EXPSTR * dest, CONSTRPTR fn) { STRPTR pa_name = ustrrpbrk(fn, PATH_SEPARATOR); if (pa_name) set_estrn(dest, fn, strlen(fn) - strlen(pa_name) + 1); else clr_estr(dest); return (ok_fnl_fpath(dest)); } /* * get_fsdir: get next subdirectory (including separator) * */ BOOL get_fsdir(EXPSTR * dest, CONSTRPTR fn) { STRPTR fn_name = strpbrk(fn, PATH_SEPARATOR); if (fn_name) set_estrn(dest, fn, strlen(fn) - strlen(fn_name) + 1); else clr_estr(dest); return (ok_fnl_fpath(dest)); } /* * get_fdrive * * */ BOOL get_fdrive(EXPSTR * dest, CONSTRPTR fn) { set_estr(dest, fn); /* dummy data */ clr_estr(dest); return (ok_fnl_fpath(dest)); } /* * fextidx: get filename extension index of string * * params: fn...filename to examine * result: index in _fn, where extension starts * * NOTE: if _fn has an extension at all, _fn[i] is equal to '.', else * _fn has no extension (e.g. "TESTFILE") and _fn[i] is equal * to '\0'. * * (internal function) * */ static size_t fextidx(CONSTRPTR fn) { size_t i; /* string index counter */ i = strlen(fn) - 1; /* scan string backwards... */ while ((i) && (fn[i] != '.') && (strchr(PATH_SEPARATOR, fn[i]) == NULL)) i--; if (fn[i] != '.') i = strlen(fn); return i; /* return result */ } /* * clr_fext: clear filename extension * * params: dest...string that contains filename to strip * * EXAMPLE: "testfile.txt" -> "testfile" * */ BOOL clr_fext(EXPSTR * dest) { BOOL ok; size_t extidx = fextidx(estr2str(dest)); /* index, where extension starts */ ok = set_estrn(dest, estr2str(dest), extidx); ok &= ok_fnl_fpath(dest); return (ok); } /* * set_fext: set new (last) extension for filename * * params: dest....string that contains old filename * newext..new extension to set * * EXAMPLE: "testfile.txt", "lha" -> "testfile.lha" * "hugo.tar.gz" , "lha" -> "hugo.tar.lha" */ BOOL set_fext(EXPSTR * dest, CONSTRPTR newext) { BOOL ok; ok = clr_fext(dest); ok &= app_estrch(dest, '.'); ok &= app_estr(dest, newext); ok &= ok_fnl_fpath(dest); return (ok); } /* * app_fext: append extension to filename * * EXAMPLE: ("testfile.txt", "lha") -> "testfile.txt.lha" * -> "testfile.lha" (msdos) */ BOOL app_fext(EXPSTR * dest, CONSTRPTR newext) { BOOL ok = app_estrch(dest, '.'); ok &= app_estr(dest, newext); ok &= ok_fnl_fpath(dest); return (ok); } /* * set_fextIdx: set file name index extension * * params: dest..destination string with new extension * fn....source string with extension to replace * idx...extension index */ BOOL set_fnameIdx(EXPSTR * dest, int idx) { char fn_ext[12]; /* index extension */ sprintf(fn_ext, "%03d", idx); /* create index string */ return (set_fext(dest, fn_ext)); } /* * link_fname: link directory and filename together * * params: dest..where to store result * dir...directoryname * fn....filename to append * * NOTE: a PATHSEPARATOR[0] is append to dir, if none exists */ BOOL link_fname(EXPSTR * dest, STRPTR dir, STRPTR fn) { BOOL anydir; /* TRUE, if any dir passed as arg */ BOOL ok = TRUE; /* was a dir passed? */ anydir = ((dir != NULL) && (strlen(dir) != 0)); if (anydir) { /* clone dir, if any * * NOTE: it's neccesarry to work with a copy do `dir', * because if `dir' is part of `dest', this could lead * to a mungwall hit */ STRPTR dir_clone = strclone(dir); /* clone of `dir' */ set_estr(dest, dir_clone); /* check, if the last char of dir is a path separator */ /* ->if not, append a direcory separator */ if (!strchr(PATH_SEPARATOR, dir_clone[strlen(dir_clone) - 1])) app_estrch(dest, DIR_SEPARATOR); /* free cloned dir */ ufreestr(dir_clone); } else clr_estr(dest); /* append filename */ if (fn) app_estr(dest, fn); ok &= ok_fnl_fpath(dest); return ok; } /* * link_envfname: link content of an environment variable, * directory and filename together * * params: dest..where to store result * env...name of environment variable * dir...directoryname * fn....filename to append * * result: FALSE, if envvar could not be found or * filename got too long */ BOOL link_envfname(EXPSTR * dest, STRPTR envname, STRPTR dir, STRPTR fn) { BOOL ok = FALSE; STRPTR env = getenv(envname); if (env) { STRPTR env1 = strclone(env); /* copy envvar to own memory area */ EXPSTR *tmpstr = init_estr(32); /* strip linefeeds from hscenv */ while (strlen(env1) && (env1[strlen(env1)] == '\n')) env1[strlen(env1)] = '\0'; if (dir) { link_fname(tmpstr, env1, dir); } else { set_estr(tmpstr, env1); } ok = link_fname(dest, estr2str(tmpstr), fn); del_estr(tmpstr); ufreestr(env1); } else { clr_estr(dest); } return ok; } /* * tmpnamstr: alloc & create a string with a temp. filename * * result: string containig filename; * MUST be release using ufreestr() by caller * errors: return NULL; this can be because auf no more * temp. files available or out of mem * * IMPORTANT: you need to copy the filename, if you * call this function frquently */ static size_t adjust_prefix_length(size_t prefix_length) { if (prefix_length > MAX_FNAME - 8) { prefix_length = MAX_FNAME - 8; } return (prefix_length); } STRPTR tmpnamstr(STRPTR suggested_prefix) { static LONG fileidx = 0; static STRARR buf[256 + 32]; STRPTR s = NULL; STRPTR prefix = suggested_prefix; FILE *file = NULL; size_t prefix_length = 0; if (prefix == NULL) { prefix = ""; } /* copy prefix to buffer */ prefix_length = adjust_prefix_length(strlen(prefix)); strncpy(buf, prefix, prefix_length); buf[prefix_length] = '\0'; /* add address of buffer to prefix */ if (MAX_FNAME > 8) { sprintf(&(buf[strlen(buf)]), "%p", (void*)tmpnamstr); } prefix_length = strlen(buf); /* Try to open a file for input until fopen() fails, * which means a file with such a name does not yet exist. * * This still sucks as in multi-tasking systems the file * can be created while this function returns, but already * reduces the likelyhood that a file is reused. */ do { fileidx += 1; #ifdef RISCOS sprintf(&(buf[prefix_length]), "%04lx", fileidx); #else sprintf(&(buf[prefix_length]), "%04lx.tmp", fileidx); #endif file = fopen(buf, "r"); if (file) { fclose(file); if (fileidx == 0xffff) { fileidx = 0; /* ran out of names */ } } } while (fileidx && file); if (fileidx != 0) { s = buf; } return (s); } /* * get_relfname: get relative filename, according to given path * * params: absn..absolute filename * curp..current path * * EXAMPLE: * "image/back.gif" and "image/hugo/" -> "/back.gif" * "image/back.gif" and "" -> "image/back.gif" * "image/back.gif" and "people/" -> "/image/back.gif" */ BOOL get_relfname(EXPSTR * dest, STRPTR absn, STRPTR curp) { EXPSTR *fname = init_estr(32); /* file name only */ EXPSTR *abspa = init_estr(32); /* absolute path only */ EXPSTR *tmpp1 = init_estr(32); /* temp pointer */ EXPSTR *tmpp2 = init_estr(32); STRPTR rest_absp = NULL; /* rest of current path */ STRPTR absp = NULL; /* path processing */ int cmp_result; /* stores result returned by upstrcmp */ /* init string array */ clr_estr(dest); get_fname(fname, absn); get_fpath(abspa, absn); absp = estr2str(abspa); /* * skip all equal subdirs */ do { get_fsdir(tmpp1, absp); get_fsdir(tmpp2, curp); cmp_result = upstrcmp(estr2str(tmpp1), estr2str(tmpp2)); if (!cmp_result) { absp += estrlen(tmpp1); curp += estrlen(tmpp2); } } while (estrlen(tmpp1) && estrlen(tmpp2) && (!cmp_result)); /* remember equal part of path */ rest_absp = absp; /* * for every subdir in absp unequal to * corresponding subdir curp, insert a parent dir */ if (curp[0]) do { get_fsdir(tmpp1, absp); get_fsdir(tmpp2, curp); cmp_result = upstrcmp(estr2str(tmpp1), estr2str(tmpp2)); if (cmp_result) { absp += estrlen(tmpp1); curp += estrlen(tmpp2); app_estr(dest, PARENT_DIR); } } while (strlen(curp) && cmp_result); /* append equal part of path */ app_estr(dest, rest_absp); /* append name of file */ app_estr(dest, estr2str(fname)); /* relaese resources */ del_estr(fname); del_estr(abspa); del_estr(tmpp1); del_estr(tmpp2); return (ok_fnl_fpath(dest)); } BOOL optimize_fname(STRPTR *target_name, STRPTR source_name) { /* Some system dependent defines */ #if defined(AMIGA) || defined(AROS) #define PARENT_DIRECTORY_BEGIN "/" #define PARENT_DIRECTORY_INSIDE "//" #elif defined BEOS || defined NEXTSTEP || defined RISCOS || defined UNIX || defined WINNT #define PARENT_DIRECTORY_BEGIN "../" #define PARENT_DIRECTORY_INSIDE "/../" #else #error "system not supported: parent directory begin/inside" #endif #define mark_for_skip(what) \ { \ STRPTR what2 = (what); \ if (what2[0] != SKIP_CHARACTER) \ { \ what2[0] = SKIP_CHARACTER; \ filename_length -= 1; \ } \ } #define SKIP_CHARACTER '\a' /* Use the invisible bell character */ #define PRINT_FILENAME(heading) /* Do nufin */ STRPTR filename = strclone(source_name); STRPTR filename_fun_start = filename; STRPTR filename_scan = NULL; STRPTR next_parent_inside = NULL; STRPTR previous_directory = NULL; size_t filename_length = strlen(filename); size_t parent_begin_length = strlen(PARENT_DIRECTORY_BEGIN); size_t parent_inside_length = strlen(PARENT_DIRECTORY_BEGIN); size_t parent_inside_index = 0; /* Skip device name */ #if defined(AMIGA) || defined(AROS) STRPTR device_delimiter = strchr(filename_fun_start, ':'); if (device_delimiter != NULL) { filename_fun_start = device_delimiter + 1; PRINT_FILENAME("strip device"); } #elif defined BEOS || defined NEXTSTEP || defined RISCOS || defined UNIX || defined WINNT if (filename_fun_start[0] == '/') { STRPTR next_directory = strchr(filename_fun_start+1, '/'); if (next_directory != NULL) { filename_fun_start = next_directory+1; } else { /* This is a plain device name, simply move to the end of it */ filename_fun_start += strlen(filename_fun_start); } PRINT_FILENAME("strip device"); } #else #error "system not supported: skip device name" #endif /* Skip leading parent directories */ while (!strncmp(filename_fun_start, PARENT_DIRECTORY_BEGIN, parent_begin_length)) { filename_fun_start += parent_begin_length; } /* Now filename_scan points to the first character where "the fun * starts". Everything before it must not be overwritten by * SKIP_CHARACTER */ filename_scan = filename_fun_start; do { /* Find parent directory inside filename starting from current * scan position */ next_parent_inside = strstr(filename_scan, PARENT_DIRECTORY_INSIDE); if (next_parent_inside != NULL) { /* Now we have a situation like this: * * sepp:///hugo/resi//hinz/kunz.txt * ^ ^ ^ * | | | * | | next_parent_inside * | filename_fun_start * filename * * Therefore, we need to scan backwards for the next "/" */ char fun_start_character = filename_fun_start[0]; previous_directory = next_parent_inside - 1; while ((previous_directory > filename_fun_start) && (previous_directory[0] != PATH_SEPARATOR[0])) { previous_directory -= 1; } PRINT_FILENAME(""); /* Overwrite the previous directory, including the "/" */ do { mark_for_skip(previous_directory) previous_directory += 1; } while (previous_directory[0] != PATH_SEPARATOR[0]); PRINT_FILENAME(""); /* Overwrite the parent directory, excluding the "/" */ for (parent_inside_index = 0; parent_inside_index < parent_inside_length; parent_inside_index += 1) { mark_for_skip(&(next_parent_inside[parent_inside_index])); } filename_scan = next_parent_inside + parent_inside_length; PRINT_FILENAME(""); /* If the previous step removed the first directory of the * whole filename, also strip the "/" */ if (filename_fun_start[0] != fun_start_character) { mark_for_skip(filename_scan); filename_scan += 1; PRINT_FILENAME("strip parent inside at start"); } } else { /* Juhuu, the nightmare is over! Copy all characters from * filename to target except those marked as SKIP_CHARACTER */ STRPTR target = (STRPTR) umalloc(filename_length + 1); size_t target_index = 0; *target_name = target; PRINT_FILENAME("finished"); filename_scan = filename; while (filename_scan[0] != '\0') { if (filename_scan[0] != SKIP_CHARACTER) { target[target_index] = filename_scan[0]; target_index += 1; } filename_scan += 1; } /* Mark end of string */ target[target_index] = '\0'; if (target_index != filename_length) { panic("bad target_index"); } } } while (next_parent_inside != NULL); /* Cleanup */ ufree(filename); return TRUE; } hsc-0.934.orig/ugly/fname.h0100600000175000001440000001065310007677402014371 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/fname.h * * header file for filename manipulaton functions * * (W) by Tommy-Saftwörx in 1994-97 * */ #ifndef UGLY_FNAME_H #define UGLY_FNAME_H #include "utypes.h" #include "expstr.h" /* * system depandant defines */ /* * MAX_FPATH max. length of whole path * MAX_FNAME max. length of filename * MAX_FEXT max. length of file extension * PATH_SEPARATOR to separate diretories and devices * DIR_SEPARATOR to separate directories * PARENT_DIR to be inserted to refer to parent directory * FNAME_IGNORE_CASE flag; ignore case within filenames * * CRLF_SHIT 0=OS uses single "\n" for EOL */ #if defined(AMIGA) || defined(AROS) /* AmigaOS */ #define MAX_FPATH 256 #define MAX_FNAME 31 #define MAX_FEXT 30 #define PATH_SEPARATOR "/:" #define DIR_SEPARATOR '/' #define PARENT_DIR "/" #define FNAME_IGNORE_CASE 1 #define SUGGEST_CRLF_SHIT 0 #elif defined RISCOS /* RiscOS */ #define MAX_FPATH 255 #define MAX_FNAME 32 #define MAX_FEXT 32 #define PATH_SEPARATOR "/" #define DIR_SEPARATOR '/' #define PARENT_DIR "../" #define FNAME_IGNORE_CASE 1 #define SUGGEST_CRLF_SHIT 0 #elif defined NEXTSTEP /* NeXTStep */ #define MAX_FPATH 254 #define MAX_FNAME 254 #define MAX_FEXT 253 #define PATH_SEPARATOR "/" #define DIR_SEPARATOR '/' #define PARENT_DIR "../" #define FNAME_IGNORE_CASE 0 #define SUGGEST_CRLF_SHIT 0 #elif defined BEOS /* BeOS */ #define MAX_FPATH 254 #define MAX_FNAME 64 #define MAX_FEXT 63 #define PATH_SEPARATOR "/" #define DIR_SEPARATOR '/' #define PARENT_DIR "../" #define FNAME_IGNORE_CASE 1 #define SUGGEST_CRLF_SHIT 0 #elif defined UNIX /* Weenix */ #define MAX_FPATH 254 #define MAX_FNAME 254 #define MAX_FEXT 253 #define PATH_SEPARATOR "/" #define DIR_SEPARATOR '/' #define PARENT_DIR "../" #define FNAME_IGNORE_CASE 0 #define SUGGEST_CRLF_SHIT 0 #elif defined WINNT /* bullshit 1 */ #define MAX_FPATH 254 #define MAX_FNAME 254 #define MAX_FEXT 253 #define PATH_SEPARATOR "\\:" #define DIR_SEPARATOR '\\' #define PARENT_DIR "..\\" #define FNAME_IGNORE_CASE 1 #define SUGGEST_CRLF_SHIT 0 #else #error "Operating system not supported: filename-functions" #endif /* if CRLF_SHIT has not been set by user, use OS-default */ #ifndef CRLF_SHIT #define CRLF_SHIT SUGGEST_CRLF_SHIT #endif /* strcmp() for filenames: case-sensitive or not */ #if FNAME_IGNORE_CASE #define fnamecmp(a,b) strcmp((a),(b)) #define fnamencmp(a,b,n) strncmp((a),(b),(n)) #else #define fnamecmp(a,b) upstrcmp((a),(b)) #define fnamencmp(a,b,n) upstrncmp((a),(b),(n)) #endif #define ok_fnl_fpath(x) ((BOOL)(estrlen(x)<=MAX_FPATH)) #define ok_fnl_fname(x) ((BOOL)(estrlen(x)<=MAX_FNAME)) #define ok_fnl_fext(x) ((BOOL)(estrlen(x)<=MAX_FEXT)) /* * external function prototypes */ #ifndef NOEXTERN_UGLY_FNAME_H extern BOOL get_fext(EXPSTR * dest, CONSTRPTR fn); extern BOOL get_fname(EXPSTR * dest, CONSTRPTR fn); extern BOOL get_fpath(EXPSTR * dest, CONSTRPTR fn); extern BOOL get_fsdir(EXPSTR * dest, CONSTRPTR fn); extern BOOL get_relfname(EXPSTR * dest, STRPTR absn, STRPTR curp); extern BOOL clr_fext(EXPSTR * dest); extern BOOL set_fext(EXPSTR * dest, CONSTRPTR newext); extern BOOL app_fext(EXPSTR * dest, CONSTRPTR newext); extern BOOL set_fnameIdx(EXPSTR * dest, int idx); extern BOOL link_fname(EXPSTR * dest, STRPTR dir, STRPTR fn); extern BOOL link_envfname(EXPSTR * dest, STRPTR env, STRPTR dir, STRPTR fn); extern STRPTR tmpnamstr(STRPTR prefix); extern BOOL optimize_fname(STRPTR *target_name, STRPTR source_name); #endif #endif hsc-0.934.orig/ugly/infile.c0100600000175000001440000006145307770470775014571 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/infile.c * * ugly input file functions * * updated: 28-Apr-1998 * created: 8-Jul-1995 */ /* * TODO: * * - handle errors within expstr (no mem) * - more elegant handling of inunget( '\n' ); */ /* * includes */ #include #include #include #include #include "utypes.h" #include "expstr.h" #include "ustring.h" #include "fname.h" /* to get define for CRLF_SHIT */ #define NOEXTERN_UGLY_FILE_H #include "infile.h" #include "umemory.h" /* buffer size for fgets() in ugly_infgetc() */ #define INF_FGETS_BUFSIZE 1024 /* * global vars */ STRPTR FNAME_STDIN = "STDIN"; /* filename for stdin (CONSTANT) */ /* * debugging defines */ #define DINF "*infile* " #ifdef D #undef D #endif #if DEBUG_UGLY_INFILE | 0 #define D( x ) x #else #define D( x ) /* nufin */ #endif /* * local vars */ /* forward references */ BOOL infget_skws(INFILE * inpf); static VOID del_infilepos_nddata(APTR data); /* * * local functions (not exported into header) * */ /* * default_whtspc, default_normch * * default methods for infgetw() to determine if * a char is a whitespace or normal char. */ static BOOL default_whtspc(int ch) { if (strchr(" \t", ch) != NULL) { return TRUE; } else { return FALSE; } } static BOOL default_normch(int ch) { if (isalnum(ch) || (ch == '_')) { return TRUE; } else { return FALSE; } } /* * update_wpos * * update word position with the values of the * "normal" position in input file * */ static VOID update_wpos(INFILE * inpf) { inpf->wpos_x = inpf->pos_x; inpf->wpos_y = inpf->pos_y; } /* *------------------------------------- * constructor/destructor *------------------------------------- */ /* * reset_inpf * * reset a INFILE struct (set all items to NULL) * (only called by con/destructor) */ static VOID reset_infile(INFILE * inpf) { inpf->infile = NULL; inpf->filename = NULL; inpf->lnbuf = NULL; inpf->wordbuf = NULL; inpf->wspcbuf = NULL; inpf->filepos = 0; inpf->pos_x = 0; inpf->pos_y = 0; update_wpos(inpf); inpf->base_x = 0; inpf->base_y = 0; inpf->pos_list = NULL; inpf->pos_count = 0; inpf->eof_reached = FALSE; inpf->out_of_mem = FALSE; inpf->skipped_ws = FALSE; inpf->closed = FALSE; inpf->is_nc = NULL; inpf->is_ws = NULL; } /* * remove INFILE structure */ static VOID del_infile(INFILE * inpf) { if (inpf) { D( { fprintf(stderr, DINF "close file"); if (inpf->filename) fprintf(stderr, " \"%s\"", inpf->filename); fprintf(stderr, "\n"); } ); if (inpf->pos_count) { inpf->closed = TRUE; D(fprintf(stderr, DINF " (%lu fpos-req left)\n", inpf->pos_count)); } else { /* close file */ if (inpf->infile) fclose(inpf->infile); /* remove pos-requests */ del_dllist(inpf->pos_list); /* release mem */ ufreestr(inpf->filename); del_estr(inpf->lnbuf); del_estr(inpf->wordbuf); del_estr(inpf->wspcbuf); /* reset all items */ reset_infile(inpf); /* release whole structure */ ufree(inpf); } } } /* * init INFILE structure */ static INFILE *init_infile(CONSTRPTR name, size_t buf_step, size_t word_step) { INFILE *inpf = (INFILE *) umalloc(sizeof(INFILE)); if (inpf) { /* check for buffer-stepsize */ if (!buf_step) buf_step = IF_BUFFER_VALUE; if (!word_step) word_step = IF_BUFFER_VALUE; /* reset all items */ reset_infile(inpf); /* clone filename (NULL=stdin) */ if (name) inpf->filename = strclone(name); /* init wordbuffers */ inpf->lnbuf = init_estr(buf_step); inpf->wordbuf = init_estr(word_step); inpf->wspcbuf = init_estr(word_step); inpf->pos_list = init_dllist(del_infilepos_nddata); inpf->pos_count = 0; /* check if init ok */ if (!((inpf->filename || !(name)) && inpf->lnbuf && inpf->wordbuf && inpf->wspcbuf)) { /* remove infile, */ /* set return value to NULL */ del_infile(inpf); inpf = NULL; } } return (inpf); } /* *===================================== * * exported functions * *===================================== */ /* *------------------------------------- * functions to get info about infile *------------------------------------- */ /* * infget_x * * get colum of current line */ ULONG infget_x(INFILE * inpf) { if (inpf->wpos_y) { return (inpf->pos_x); } else { return (inpf->pos_x + inpf->base_x); } } /* * infget_y * * get current line */ ULONG infget_y(INFILE * inpf) { return (inpf->pos_y + inpf->base_y); } /* * infget_wx * * get colum of current word */ ULONG infget_wx(INFILE * inpf) { if (inpf->wpos_y) { return (inpf->wpos_x); } else { return (inpf->wpos_x + inpf->base_x); } } /* * infget_y * * get line of current word */ ULONG infget_wy(INFILE * inpf) { return (inpf->wpos_y + inpf->base_y); } /* * infget_skws * * get status of skipped_ws */ BOOL infget_skws(INFILE * inpf) { return (inpf->skipped_ws); } /* * infget_fname * * get name of file */ STRPTR infget_fname(INFILE * inpf) { if (inpf->filename) { return (inpf->filename); } else { return (FNAME_STDIN); } } /* * infeof * * check if end of input file reached * * params: inpf...input file to check * result: if end of input file reached, 0 is returned, * else a value < 0 (compare feof() of some * compilers) */ int infeof(INFILE * inpf) { if (inpf->eof_reached == TRUE) { return EOF; } else { return 0; } } /* * infget_cws (get current whites spaces) * * get string that contains all white-spaces * skipped within the last call of infgetw() */ STRPTR infgetcws(INFILE * inpf) { return (estr2str(inpf->wspcbuf)); } /* * infget_cw (get current word) * * get string that contains all chars * read within the last call of infgetw() */ STRPTR infgetcw(INFILE * inpf) { return (estr2str(inpf->wordbuf)); } /* *------------------------------------- * functions to set methods *------------------------------------- */ /* * set_inf_whtspc * * set function to check if a char is a whitespace. * this func is called by infgetw() to determine if * the begining of a word is reached. */ void set_whtspc(INFILE * inpf, BOOL(*iswsfn) (int ch)) { if (inpf) { inpf->is_ws = iswsfn; } } /* * set_inf_normch * * set function to check if a char is a "normal" char. * this function is called by infgetw() to determine if * the end of a word is reached */ void set_normch(INFILE * inpf, BOOL(*isncfn) (int ch)) { if (inpf) { inpf->is_nc = isncfn; } } /* *------------------------------------- * functions for open & close *------------------------------------- */ /* * infclose1 * * close INFILE entry, free all mem allocated by it * * result: always 0 * */ int infclose1(INFILE * inpf) { del_infile(inpf); return (0); } /* * infopen * * params: name.......name of input file to open * step_size..portion of memory buffers should be increased with * result: ptr to INFILE entry or NULL if error; * * NOTE: if result = NULL, but errno=0, too, then there * wasn't enough mem for the line-buffer. in this * case, calling perror() will not produce a proper * error message. * * NOTE: don't forget to set errno=0 before calling infopen(). */ INFILE *infopen(CONSTRPTR name, size_t step_size) { #define FILEMODE "rb" #define INF_DEFAULT_HUNKSIZE (32*1024) INFILE *inpf = NULL; FILE *file = NULL; long int filesize = 0; size_t buf_size = 4096; /* open input file or assign stdin to input file */ if (name) { file = fopen(name, FILEMODE); if (file) { /* evaluate size of file and set * buf_size accroding to it. */ fseek(file, 0, SEEK_END); filesize = ftell(file); if (filesize == -1) buf_size = INF_DEFAULT_HUNKSIZE; else buf_size = filesize + (filesize / 16) + 1; rewind(file); D(fprintf(stderr, "*infile* file=%ld -> bufsz=%lu, wdsz=%lu \n", filesize, buf_size, step_size)); } } else { file = stdin; buf_size = INF_DEFAULT_HUNKSIZE; } /* init infile */ if (file) { inpf = init_infile(name, buf_size, step_size); if (inpf) inpf->infile = file; } /* read whole file into file lnbuf */ if (inpf) { if (file != stdin) { /* read whole file into buffer directly */ /* (perverted and experimental, but faaast) */ D(fprintf(stderr, "*infile* filesize=%ld\n", filesize)); filesize = fread(inpf->lnbuf->es_data, 1, (size_t) filesize, file); inpf->lnbuf->es_len = (size_t) filesize; inpf->lnbuf->es_data[filesize] = 0; } else { /* read stdin, line by line */ STRPTR buf = (STRPTR) umalloc(INF_FGETS_BUFSIZE); /* alloc buffer */ STRPTR restr = buf; /* result of fgets() (dummy init) */ BOOL ok = (buf != NULL); D(fprintf(stderr, "*infile* filesize=STDIN\n")); while (!feof(inpf->infile) && ok) { restr = fgets(buf, INF_FGETS_BUFSIZE, inpf->infile); if (restr) { ok = app_estr(inpf->lnbuf, restr); D( { restr[20] = 0; fprintf(stderr, "*infile* line=`%s'\n", restr); } ); } } ufree(buf); /* free buffer */ } D(fprintf(stderr, "*infile* file read\n")); } return (inpf); /* return input file */ } /* * infopen_str * * open a string as an input file * * params: fname......pseudo filename the string should have * s..........string that should be handled as a file * step_size..portion of memory buffers should be increased with * result: ptr to INFILE entry or NULL if error; * * NOTE: a copy of the passed string is created. so you can * modify or release the string after calling inopen_str() */ INFILE *infopen_str(CONSTRPTR name, CONSTRPTR s, size_t step_size) { /* init file */ INFILE *inpf = init_infile(name, strlen(s) + 1, step_size); if (inpf) { /* copy string to line buffer */ BOOL ok = set_estr(inpf->lnbuf, s); if (!ok) { del_infile(inpf); inpf = NULL; } } return (inpf); /* return input file */ } /* *------------------------------------- * functions to get text from infile *------------------------------------- */ /* * ugly_infgetc * * */ int ugly_infgetc(INFILE * inpf) { int result = EOF; #if 0 fprintf(stderr, "** ingetch( \"%s\" at %p\n", inpf->filename, inpf); #endif if (inpf && (!inpf->eof_reached)) { STRPTR lnbuf_str = estr2str(inpf->lnbuf); /* * if at end of line buffer, scan next line * before proceding */ if (lnbuf_str[inpf->filepos] == 0) { inpf->eof_reached = TRUE; } /* * check wether to return EOF or char from * line buffer */ if (inpf->eof_reached == FALSE) { /* set last char as result */ lnbuf_str = estr2str(inpf->lnbuf); result = (UBYTE) lnbuf_str[inpf->filepos]; if (result) { /* goto next char in buf */ inpf->pos_x++; inpf->filepos++; } } /* update line number */ if (result == '\n') { inpf->pos_y++; inpf->pos_x = 0; } } return (result); } /* * infgetc * * read next char from file, update word-position */ int infgetc(INFILE * inpf) { /* read char */ int ch = ugly_infgetc(inpf); /* update word position */ update_wpos(inpf); #if 0 /* TODO: remove this */ /* TODO: this is shit */ if (ch == '\n') { inpf->wpos_y--; } #endif return (ch); } /* *------------------------------------- * functions to unget text from infile *------------------------------------- */ /* * ugly_inungetc * * write char back to stream; comparable to ansi's ungetc() * * params: inpf...input file * ch.....char to write back * result: ch, if sucessful, else EOF */ static int ugly_inungetc(int ch, INFILE * inpf) { int result = EOF; if (inpf && (inpf->filepos)) { STRPTR lnbuf_str = estr2str(inpf->lnbuf); /* update file position */ inpf->filepos--; /* write back char */ lnbuf_str[inpf->filepos] = ch; result = ch; /* handle LF */ if (ch == '\n') { result = ch; inpf->pos_y--; inpf->pos_x = 0; } else if (inpf->pos_x) inpf->pos_x--; } return (result); } /* * inungetc * * write char back to stream; comparable to ansi's ungetc() * different to ugly_inungetc, this will also update the * word-position of the input file * * params: inpf...input file * ch.....char to write back * result: ch, if sucessful, else EOF */ int inungetc(int ch, INFILE * inpf) { int result = ugly_inungetc(ch, inpf); if (inpf && (inpf->filepos)) { update_wpos(inpf); } return (result); } /* * inungets * write string back to stream * * params: s......string to write back * inpf...input file * result: num of chars written back */ size_t inungets(STRPTR s, INFILE * inpf) { size_t ctr = 0; /* counter, how many chars already written */ size_t slen = strlen(s); STRPTR p = s + (strlen(s) - 1); /* ptr to current char in string */ int ch = 0; /* current char written, dummy init */ if (slen > 0) { ctr = 1; /* unget first char */ ch = ugly_inungetc(p[0], inpf); while ((p != s) && (ch != EOF)) { ctr++; /* inc counter */ p--; /* goto next char */ ch = ugly_inungetc(p[0], inpf); /* unget current char */ } } return (ctr); } /* * inungetcw * write current word back to stream * * params: inpf...input file * result: num of chars written back */ size_t inungetcw(INFILE * inpf) { size_t ctr; /* counter how many chars written */ /* unget word */ ctr = inungets(infgetcw(inpf), inpf); return (ctr); } /* * inungetcwws * write current word & whitespaces back to stream * * params: inpf...input file * result: num of chars written back */ size_t inungetcwws(INFILE * inpf) { size_t ctr; /* counter how many chars written */ /* unget word & white spaces */ ctr = inungets(infgetcw(inpf), inpf); ctr += inungets(infgetcws(inpf), inpf); return (ctr); } /* * inf_isws * * checks if a char is a white space * * params: ch...char to check for white space * result: TRUE if ch was white space */ BOOL inf_isws(char ch, INFILE * inpf) { BOOL(*isws) (int ch) = inpf->is_ws; if (isws == NULL) /* if no func for is_ws, */ isws = default_whtspc; /* set default function */ return ((*isws) (ch)); } /* * infskip_ws * * skip white spaces; update wspbuf; clear wordbuf * * TODO: handle wspcbuf-overflow */ size_t infskip_ws(INFILE * inpf) { char nxtch; /* next char to read */ size_t ctr = 0; /* num of ws skipped */ BOOL ok; /* * set function to determine if a * specified char is a white space */ inpf->skipped_ws = FALSE; /* clear skippe-flag */ /* clear wspcbuf */ ok = clr_estr(inpf->wspcbuf); /* * loop: skip white spaces */ nxtch = ugly_infgetc(inpf); /* read next char */ while ((!infeof(inpf)) /* while not at end of file.. */ && ok && inf_isws(nxtch, inpf)) /* ..and current char is a whtspc */ { ok &= app_estrch(inpf->wspcbuf, nxtch); ctr++; nxtch = ugly_infgetc(inpf); /* read next char */ } if (ctr) /* any whtspcs skipped? */ inpf->skipped_ws = TRUE; /* Y-> set skippe-flag */ #if 0 if (!ok) { /* TODO: error */ ; } #endif /* * write back last char read * (and update word-pos) */ inungetc(nxtch, inpf); return (ctr); } /* * infgetall * * returns whole text */ STRPTR infgetall(INFILE * inpf) { return (estr2str(inpf->lnbuf)); } /* * infgetw * * read word */ STRPTR infgetw(INFILE * inpf) { /* TODO: handle expstr errors */ int ch = EOF; BOOL wordread = FALSE; STRPTR thisword = NULL; BOOL ok = TRUE; /* set function for normal chars */ BOOL(*isnc) (int ch) = inpf->is_nc; if (isnc == NULL) isnc = default_normch; /* skip all white spaces */ infskip_ws(inpf); ok = clr_estr(inpf->wordbuf); /* * read word until non-normal char is reached */ if (!infeof(inpf)) { ch = infgetc(inpf); if (((*isnc) (ch))) { do { ok &= app_estrch(inpf->wordbuf, ch); ch = ugly_infgetc(inpf); /* todo: set out-of-mem-flag */ } while ((ch != EOF) && ok && ((*isnc) (ch))); wordread = TRUE; if (ch != EOF) inungetc(ch, inpf); } else { ok &= app_estrch(inpf->wordbuf, ch); } thisword = estr2str(inpf->wordbuf); } return thisword; } /* * infreadtoeol * * read until CR/LF or EOF and return string */ STRPTR infreadtoeol(INFILE * inpf) { int ch = EOF; BOOL ok; ok = clr_estr(inpf->wordbuf); if (!infeof(inpf)) { /* read all chars until CR appears */ do { ch = ugly_infgetc(inpf); if((ch != '\r') && (ch != '\n')) ok &= app_estrch(inpf->wordbuf, ch); } while (ok && (ch > 0) && (ch != 0x0a)); /* read LF */ if (ch == 0x0a) { ch = ugly_infgetc(inpf); if (ch != 0x0d) inungetc(ch, inpf); } } return strclone(estr2str(inpf->wordbuf)); } /* * infgotoeol * * read all chars until CR or EOF */ int infgotoeol(INFILE * inpf) { int ch = EOF; if (!infeof(inpf)) { /* * read all chars until CR appears */ do { ch = ugly_infgetc(inpf); } while ((ch > 0) && (ch != 0x0a)); /* * read LF */ if (ch == 0x0a) { ch = ugly_infgetc(inpf); if (ch != 0x0d) inungetc(ch, inpf); ch = 0x0a; } } /* return last char read */ return ch; } /* *------------------------------------- * functions for file-positions *------------------------------------- */ /* * del_infilepos_nddata */ static VOID del_infilepos_nddata(APTR data) { INFILEPOS *pos = (INFILEPOS *) data; if (pos) { /* decrese number of pending pos-requests */ (pos->inpf->pos_count)--; D(fprintf(stderr, DINF "del pos-req: \"%s\" (%lu,%lu); %lu left\n", pos->inpf->filename ? pos->inpf->filename : (STRPTR) "STDIN", pos->x, pos->y, pos->inpf->pos_count)); /* free resources alloceted by pos-request */ ufree(pos); } } /* * cmp_posdata */ static int cmp_posdata(APTR data1, APTR data2) { if (data1 == data2) { return -1; } else { return 0; } } /* * del_infilepos */ VOID del_infilepos(INFILEPOS * pos) { if (pos) { INFILE *inpf = pos->inpf; /* remove filename */ ufreestr(pos->fname); /* check, if file has already been closed by user, * but the last pos-requests has just been deleted * now. * if so, really close the file now */ if ((inpf->closed) && (inpf->pos_count == 1) ) { D(fprintf(stderr, DINF " really closing file:\n")); (pos->inpf->pos_count)--; infclose1(inpf); } else { DLNODE *nd = find_dlnode(dll_first(pos->inpf->pos_list), pos, cmp_posdata); del_dlnode(pos->inpf->pos_list, nd); } } } /* * del_all_infilepos */ VOID del_all_infilepos(INFILE * inpf) { del_all_dlnodes(inpf->pos_list); } /* * new_infilepos */ static INFILEPOS *new_infilepos_node(INFILE * inpfile, ULONG x, ULONG y) { INFILEPOS *pos = (INFILEPOS *) umalloc(sizeof(INFILEPOS)); if (pos) { DLNODE *nd = app_dlnode(inpfile->pos_list, pos); pos->inpf = inpfile; pos->fname = strclone(inpfile->filename); pos->x = x; pos->y = y; pos->fpos = inpfile->filepos; if (!nd) { del_infilepos_nddata(pos); pos = NULL; } else { (inpfile->pos_count)++; } } #if DEBUG_UGLY_INFILE { if (pos) { fprintf(stderr, DINF "new pos-req: \"%s\" (%d,%d); #%d\n", (char *) inpfile->filename ? (char *) inpfile->filename : (char *) "STDIN", inpfile->pos_x, inpfile->pos_y, inpfile->pos_count); } else { fprintf(stderr, DINF "new pos-req FAILED\n"); } } #endif return pos; } #if 1 INFILEPOS *new_infilepos(INFILE * inpfile) { INFILEPOS *pos = new_infilepos_node(inpfile, infget_x(inpfile), infget_y(inpfile)); return pos; } INFILEPOS *new_winfilepos(INFILE * inpfile) { INFILEPOS *pos = new_infilepos_node(inpfile, infget_wx(inpfile), infget_wy(inpfile)); return pos; } #else INFILEPOS *new_infilepos(INFILE * inpfile) { INFILEPOS *pos = new_infilepos_node(inpfile, inpfile->pos_x, inpfile->pos_y); return pos; } INFILEPOS *new_winfilepos(INFILE * inpfile) { INFILEPOS *pos = new_infilepos_node(inpfile, inpfile->wpos_x, inpfile->wpos_y); return pos; } #endif INFILEPOS *clone_infilepos(INFILEPOS * ipos) { INFILEPOS *pos = new_infilepos_node(ipos->inpf, ipos->x, ipos->y); return pos; } /* * get methodes for pos-req */ STRPTR ifp_get_fname(INFILEPOS * pos) { return (infget_fname(pos->inpf)); } ULONG ifp_get_x(INFILEPOS * pos) { return (pos->x); } ULONG ifp_get_y(INFILEPOS * pos) { return (pos->y); } BOOL set_infile_base(INFILE * inpf, INFILEPOS * pos) { D(fprintf(stderr, DINF "set base \"%s\" to \"%s\" (%lu,%lu)\n", inpf->filename ? inpf->filename : (STRPTR) "STDIN", pos->inpf->filename ? pos->inpf->filename : (STRPTR) "STDIN", pos->x, pos->y)); reallocstr(&(inpf->filename), pos->fname); inpf->base_x = pos->x; inpf->base_y = pos->y; return TRUE; /* TODO: handle out of mem */ } BOOL set_infilepos(INFILE * inpf, INFILEPOS * pos) { D(fprintf(stderr, DINF "set pos \"%s\" to \"%s\" (%lu,%lu)\n", inpf->filename ? inpf->filename : (STRPTR) "STDIN", pos->inpf->filename ? pos->inpf->filename : (STRPTR) "STDIN", pos->x, pos->y)); reallocstr(&(inpf->filename), pos->fname); inpf->pos_x = pos->x; inpf->pos_y = pos->y; update_wpos(inpf); return TRUE; /* TODO: handle out of mem */ } hsc-0.934.orig/ugly/infile.h0100600000175000001440000001124207770470741014556 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/infile.h * * ugly input file handling functions, header file * */ #ifndef UGLY_INFILE_H /* avoid include twice */ #define UGLY_INFILE_H /* * includes */ #include "utypes.h" #include "expstr.h" #include "dllist.h" /* reasonable value for buffer-step-size */ #define IF_BUFFER_VALUE 128 /* * ugly input file structure (PRIVATE) */ typedef struct infile { STRPTR filename; /* file name */ FILE *infile; /* file opened if fopen() */ EXPSTR *lnbuf; /* buffer for inputline */ EXPSTR *wordbuf; /* word buffer */ EXPSTR *wspcbuf; /* word buffer (white spaces) */ ULONG filepos; /* file position */ ULONG pos_y; /* line number in file */ ULONG pos_x; /* pos. in current line */ ULONG wpos_y; /* line number in file of current word */ ULONG wpos_x; /* pos. in current line of current word */ ULONG base_x; /* base position */ ULONG base_y; DLLIST *pos_list; /* list of pending pos-request */ ULONG pos_count; /* number of entries in poslist */ BOOL(*is_ws) (int ch); /* ptr to func that checks if a char */ /* is a white-space */ BOOL(*is_nc) (int ch); /* deto, but for "normal char" */ BOOL eof_reached; /* flag: TRUE, if end of file */ BOOL out_of_mem; /* flag: TRUE, if ran out of memory */ BOOL skipped_ws; /* flag: TRUE, if last infgetw */ /* skipped a white-space */ BOOL closed; /* flag: TRUE, if closed, but pending */ /* fpos-requested exist */ } INFILE; typedef struct infile_pos { INFILE *inpf; STRPTR fname; /* filename */ ULONG x; /* column */ ULONG y; /* line */ ULONG fpos; /* file position */ } INFILEPOS; /* * global macros */ #define infclose( f ) ((f) ? (infclose1( f ), f=NULL) : (NULL)) /* * global vars */ extern STRPTR FNAME_STDIN; /* * * extern function prototypes & global vars * */ #ifndef NOEXTERN_UGLY_INFILE_H extern INFILE *infopen(CONSTRPTR name, size_t step_size); extern INFILE *infopen_str(CONSTRPTR fname, CONSTRPTR s, size_t step_size); extern int infclose1(INFILE * inpf); /* PRIVATE; use infclose() */ extern int infgetc(INFILE * inpf); extern STRPTR infgetw(INFILE * inpf); extern STRPTR infgetall(INFILE * inpf); extern STRPTR infgetcws(INFILE * inpf); extern STRPTR infgetcw(INFILE * inpf); extern int inungetc(int ch, INFILE * inpf); extern size_t inungets(STRPTR s, INFILE * inpf); extern size_t inungetcwws(INFILE * inpf); extern size_t inungetcw(INFILE * inpf); extern ULONG infget_x(INFILE * inpf); extern ULONG infget_y(INFILE * inpf); extern ULONG infget_wx(INFILE * inpf); extern ULONG infget_wy(INFILE * inpf); extern STRPTR infget_fname(INFILE * inpf); extern BOOL infget_skws(INFILE * inpf); extern BOOL inf_isws(char ch, INFILE * inpf); extern size_t infskip_ws(INFILE * inpf); extern int infeof(INFILE * inpf); extern STRPTR infreadtoeol(INFILE * inpf); extern int infgotoeol(INFILE * inpf); extern VOID del_infilepos(INFILEPOS * pos); extern INFILEPOS *new_infilepos(INFILE * inpfile); extern INFILEPOS *new_winfilepos(INFILE * inpfile); extern INFILEPOS *clone_infilepos(INFILEPOS *ipos); extern STRPTR ifp_get_fname(INFILEPOS * pos); extern ULONG ifp_get_x(INFILEPOS * pos); extern ULONG ifp_get_y(INFILEPOS * pos); extern BOOL set_infilepos(INFILE * inpf, INFILEPOS * pos); extern BOOL set_infile_base(INFILE * inpf, INFILEPOS * pos); #if 0 extern void inflog_enable(INFILE * inpf); extern void inflog_disable(INFILE * inpf); extern BOOL inflog_clear(INFILE * inpf); extern BOOL inflog_app(INFILE * inpf, STRPTR s); extern STRPTR infget_log(INFILE * inpf); #endif #endif /* NOEXTERN_UGLY_INFILE_H */ #endif /* UGLY_INFILE_H */ hsc-0.934.orig/ugly/prginfo.c0100600000175000001440000000767207770470775014772 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/prginfo.c * * ugly program info functions * * updated: 27-Oct-1996 * created: 3-Jul-1994 * *========================================================= * TODO: * - set_prginfo()-macro: replace "name" by "( name ? name : argv[0] )" * */ /* ANSI includes */ #include #include #include #include "utypes.h" #define SIZE_DATESTR 24 #ifdef AMIGA /* system version string on amiga systems */ STRPTR amiga_version = ""; #endif /* * local global vars */ STRPTR pi_progname = NULL; /* exported */ STRPTR pi_authname = NULL; int pi_version = 0; int pi_release = 0; int pi_revision = 0; char pi_rel_date[SIZE_DATESTR]; STRPTR pi_rel_time = NULL; STRPTR pi_descript = NULL; STRPTR pi_copystat = NULL; STRPTR pi_dt_day = NULL; STRPTR pi_dt_month = NULL; STRPTR pi_dt_year = NULL; /* * call_set_prginfo * * set pi_xxx vars; called by macro set_info() * */ void call_set_prginfo(STRPTR name, STRPTR auth, int ver, int rel, int rev, STRPTR rel_date, STRPTR rel_time, STRPTR infostr, STRPTR copystatus) { pi_progname = name; pi_authname = auth; pi_version = ver; pi_release = rel; pi_revision = rev; pi_rel_time = rel_time; pi_descript = infostr; pi_copystat = copystatus; strncpy(pi_rel_date, rel_date, SIZE_DATESTR); pi_rel_date[3] = '\0'; pi_rel_date[6] = '\0'; pi_dt_month = pi_rel_date; pi_dt_day = &(pi_rel_date[4]); if (pi_dt_day[0] == ' ') pi_dt_day++; pi_dt_year = &(pi_rel_date[7]); } /* * call_set_prginfo2 * * set pi_xxx vars; called by macro set_info() * * NOTE: this version expects date "DD.MM.YY" */ void call_set_prginfo2(STRPTR name, STRPTR auth, int ver, int rel, int rev, STRPTR rel_date, STRPTR rel_time, STRPTR infostr, STRPTR copystatus) { STRPTR monthName[] = {"XXX", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; pi_progname = name; pi_authname = auth; pi_version = ver; pi_release = rel; pi_revision = rev; pi_rel_time = rel_time; pi_descript = infostr; pi_copystat = copystatus; strncpy(pi_rel_date, rel_date, SIZE_DATESTR); /* eval day */ pi_dt_day = pi_rel_date; /* eval month */ pi_dt_month = strchr(pi_rel_date, '.'); pi_dt_month[0] = '\0'; pi_dt_month++; /* eval year */ pi_dt_year = strchr(pi_dt_month, '.'); pi_dt_year[0] = '\0'; pi_dt_year++; /* convert numeric month */ pi_dt_month = monthName[strtol(pi_dt_month, NULL, 10)]; } /* * fprintf_prginfo * * display program information * */ int fprintf_prginfo(FILE * stream) { int err = 0; err = fprintf(stream, "%s - %s, v%d.%d", pi_progname, pi_descript, /* name & description */ pi_version, pi_release); /* version */ if (pi_revision) err += fprintf(stream, ".%d", /* revision */ pi_revision); err += fprintf(stream, " (%s-%s-%s)\n", /* date */ pi_dt_day, pi_dt_month, pi_dt_year); err += fprintf(stream, "(C) %s.\n%s\n", /* copyright */ pi_authname, pi_copystat); return (err); } hsc-0.934.orig/ugly/prginfo.h0100600000175000001440000000655307770470741014765 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/prginfo.h * * ugly program info functions, header file * */ #ifndef UGLY_PRGINFO_H /* avoid include twice */ #define UGLY_PRGINFO_H #include /* * Example @ _set_prginfo() * * set_prginfo( "test_prg", "Tommy-Saftwörx", 1, 0, 0, * "a short test program", "This is FreeWare!" ); * * (hope that helps) * * * IMPORTANT: Always use _set_prginfo(), * never use _call_set_prginfo()! * */ /* #if defined (AMIGA) && ( !defined( VERSTAG ) ) #define set_prginfo( name, auth, ver, rev, rel, info, copy ) \ { \ static char amiga_version[50]; \ call_set_prginfo( name, auth, ver, rev, rel, \ __DATE__, __TIME__, info, copy ); \ strcpy(amiga_version, "$VER:"); \ strcat(amiga_version, name); \ strcat(amiga_version, " "); \ strcat(amiga_version, long2str(ver)); \ strcat(amiga_version, "."); \ strcat(amiga_version, long2str(rev)); \ strcat(amiga_version, "."); \ if (rel) \ { \ strcat(amiga_version, long2str(rel)); \ strcat(amiga_version, "."); \ } \ } #else */ #if (defined DATE && defined TIME) #define set_prginfo( name, auth, ver, rev, rel, info, copy ) \ call_set_prginfo2( name, auth, ver, rev, rel, \ DATE, TIME, info, copy ) #else #define set_prginfo( name, auth, ver, rev, rel, info, copy ) \ call_set_prginfo( name, auth, ver, rev, rel, \ __DATE__, __TIME__, info, copy ) #endif #define UGLY_AUTHOR "T.Aglassinger/Tommy-Saftwörx, Matthias Bethke" /* * extern vars & functions */ extern STRPTR pi_progname; extern void call_set_prginfo(STRPTR name, STRPTR auth, int ver, int rel, int rev, STRPTR rel_date, STRPTR rel_time, STRPTR infostr, STRPTR copystatus); extern void call_set_prginfo2(STRPTR name, STRPTR auth, int ver, int rel, int rev, STRPTR rel_date, STRPTR rel_time, STRPTR infostr, STRPTR copystatus); extern int fprintf_prginfo(FILE * stream); #ifdef AMIGA /* system version string on amiga systems */ extern STRPTR amiga_version; #endif #endif /* UGLY_PRGINFO_H */ hsc-0.934.orig/ugly/returncd.h0100600000175000001440000000261310007700076015120 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/returncode.h * * defines for program return codes * */ #ifndef UGLY_RETURNCODE_H /* avoid include twice */ #define UGLY_RETURNCODE_H /* * define values for return code */ #if defined(AMIGA) || defined(AROS) #define RC_OK 0 #define RC_WARN 5 #define RC_ERROR 10 #define RC_FAIL 20 #elif (defined RISCOS) || (defined BEOS) || (defined NEXTSTEP) || (defined UNIX) || (defined WINNT) #define RC_OK 0 #define RC_WARN 0 #define RC_ERROR 1 #define RC_FAIL 2 #else #error "system not supported: return codes" #endif /* return code */ #endif /* UGLY_RETURNCODE_H */ hsc-0.934.orig/ugly/uargs.c0100600000175000001440000000243307770470775014435 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/uargs.c * * ugly argument handling functions * * updated: 30-Jul-1996 * created: 3-Jul-1994 * */ /* * includes */ #include #include #include #include #include #include "utypes.h" #include "umemory.h" #include "ustring.h" #include "dllist.h" #define NOEXTERN_UGLY_UARGS_H #include "uargs.h" /* * * include sub-modules * */ #include "args_fre.c" #include "args_set.c" #include "args_prp.c" #include "args_hlp.c" hsc-0.934.orig/ugly/uargs.h0100600000175000001440000001424307770470741014435 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/uargs.h * * ugly argument handling functions, header file * */ #ifndef UGLY_UARGS_H #define UGLY_UARGS_H /* * includes */ #include #include #include "utypes.h" #include "umemory.h" /* * argument errors (returned by _set_args()) */ #define ASE_NO_MEM 0x01 /* out of memory */ #define ASE_INVALID_NUM 0x02 /* invalid number format */ #define ASE_REQUIRED_MISS 0x03 /* required argument missing */ #define ASE_OUT_OF_RANGE 0x04 /* out of range (LONG, ULONG) */ #define ASE_INVALID_ENUM 0x05 /* invalid enum identifier (ENUM) */ #define ASE_EMPTY_TEMPLATE 0x06 /* empty template (arglist==NULL) */ #define ASE_UNKNOWN_KEYWORD 0x07 /* unknown keyword */ #define ASE_OCCURED_TWICE 0x08 /* arg w/o /O or /M occured twice */ #define ASE_NO_VAL_AFTER_KW 0x09 /* value after keyword missing */ #define ASE_HANDLE_FUNC 0x7f /* error reported by handle func */ /* * argument errors (returned by _prep_args()) */ #define APE_NO_MEM 0x01 /* out of memory */ #define APE_INVALID_TEMPLATE 0x02 /* invalid template */ #define APE_DOUBLE_TEMPLATE 0x03 /* doubel definition of template */ #define APE_EMPTY_TEMPLATE 0x04 /* empty template */ #define APE_ILLEGAL_TYPE 0x05 /* unknown type */ #define APE_ILLEGAL_FLAG 0x06 /* unknown flag */ #define APE_DESTVAR_IS_NULL 0x07 /* destination var is NULL */ #define APE_DOUBLE_MULTIPLE 0x08 /* /M used twice */ #define APE_CONFLICTING_M_O 0x09 /* /M and /O both occured */ /* * argument types */ #define ARG_SWITCH 0x01 /* S */ #define ARG_TEXT 0x02 /* T */ #define ARG_LONG 0x03 /* L */ #define ARG_LONG_RANGE 0x04 /* R */ #define ARG_ENUM 0x05 /* E */ #define ARG_ULONG 0x06 /* U */ /* * argument flags */ #define ARG_KEYWORD ( 1 << 0 ) /* K */ #define ARG_REQUIRED ( 1 << 1 ) /* R */ #define ARG_MULTIPLE ( 1 << 2 ) /* M */ #define ARG_CASESENS ( 1 << 3 ) /* C - case sensitive */ #define ARG_OVERWRITE ( 1 << 4 ) /* O - overwrite old value when */ /* occurend more then once */ #define ARG_HANDLEFUNC ( 1 << 5 ) /* $ */ /* values for arginfo.ai_set */ #define AIS_UNSET 0 /* not set at all */ #define AIS_SET_PREVIOUS 1 /* set by previous set_args() */ #define AIS_SET_LOCAL 2 /* set by current set_args() */ /* * struct arginfo (PRIVATE,DON NOT USE) */ typedef struct arginfo { STRPTR ai_id; /* arg id string */ LONG ai_type; /* arg type */ LONG ai_flags; /* arg flags */ union { STRPTR ai_enum; /* enumerator string */ LONG ai_lolim; /* lower limit for range */ } ai_misc1; /* type depending information */ union { LONG ai_uplim; /* upper limit for range */ } ai_misc2; /* type depending information */ APTR ai_dest; /* ptr to destination var */ STRPTR(*ai_func) (STRPTR); /* additional arg handling function */ STRPTR ai_help; /* help text */ BOOL ai_set; /* handled by _set_args() */ } ARGINFO; typedef struct argfile { int argc; char **argv; } ARGFILE; /* * commments about ARGINFO * * handle function: * the handle function is called by set_arg_value() AFTER the * destination var is updated. the old value is passed as an * APTR to the handle. the handle should return a ptr to a * string that contains an error message or NULL if the new * arg is ok. * * example for a handle function for numeric args * STRPTR handle_func( STRPTR newval ) * { * STRPTR errmsg = NULL; * * printf( "handle_func: set val to %d", newval ); * if ( newval > 3 ) * errmsg = "val to high!\n"; * else if ( newval < 1 ) * errmsg = "val to low!\n"; * * return ( errmsg ); * } */ /* * struct arglist (PRIVATE) */ typedef struct arglist { STRPTR al_name; /* name (only for debugging) */ struct dllist *al_list; /* argument template */ struct arginfo *al_multiple; /* entry with /M flag set */ struct arginfo *al_nokeywd; /* entry w/o /K flag; TODO: remove */ } ARGLIST; /* debuggin define */ #if DEBUG_UGLY_ARG #define DA(x) x #define DUA "*args * " #else #define DA(x) /* nufin */ #define DUA /* nufin */ #endif /* * extern functions & global vars */ #ifndef NOEXTERN_UGLY_UARGS_H extern LONG prep_error_num; extern int prep_error_idx; extern size_t prep_error_pos; extern ARGLIST *prepare_args(STRPTR arglist_name,...); extern BOOL set_args(int argc, char *argv[], ARGLIST *al); extern BOOL set_args_argv(int argc, char *argv[], ARGLIST * al); extern BOOL set_args_file(ARGFILE *argf, ARGLIST *argl); extern VOID free_args(ARGLIST *al); extern BOOL check_args(ARGLIST *al); extern ARGFILE *new_argfile(char *argfname); extern ARGFILE *new_argfilev(STRPTR fname[]); extern VOID del_argfile(ARGFILE *argf); /* display help */ extern int fprintf_arghelp(FILE * stream, ARGLIST *al); extern int fprintf_arghelp_short(FILE * stream, ARGLIST *al); /* error handling */ extern STRPTR strargerr(VOID); extern void pargerr(VOID); #endif /* NOEXTERN_UGLY_UARGS_H */ #endif /* UGLY_UARGS_H */ hsc-0.934.orig/ugly/utypes.h0100600000175000001440000000521710004001627014617 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef UGLY_TYPES_H #define UGLY_TYPES_H /* * ugly/types.h * * ugly data typing. * * NOTE: contains also UGLY_VER and UGLY_REV and * includes debuggin defines * */ /* include debugging defines */ #include "udebug.h" #ifdef AMIGA #include #else typedef void *APTR; /* 32-bit untyped pointer */ typedef long LONG; /* signed 32-bit quantity */ typedef unsigned long ULONG; /* unsigned 32-bit quantity */ typedef short WORD; /* signed 16-bit quantity */ typedef unsigned short UWORD; /* unsigned 16-bit quantity */ #if __STDC__ typedef signed char BYTE; /* signed 8-bit quantity */ #else typedef char BYTE; /* signed 8-bit quantity */ #endif typedef unsigned char UBYTE; /* unsigned 8-bit quantity */ typedef char *STRPTR; /* string pointer (NULL terminated) */ /* Types with specific semantics */ typedef void VOID; #ifndef RISCOS typedef short BOOL; typedef unsigned char TEXT; #else typedef int BOOL; typedef char TEXT; #endif #ifndef TRUE #define TRUE (1) #endif #ifndef FALSE #define FALSE (0) #endif #ifndef NULL #define NULL ((void*)0L) #endif #define BYTEMASK (0xFF) #define WORDMASK (0xFFFF) #endif /* AMIGA */ /* * * global typedefs (on any system) * */ typedef const char *CONSTRPTR; /* string constants */ typedef char STRARR; /* string array */ typedef char CHAR; /* single character */ /* * UPTR as an generic pointer. C-math will not operate on UPTR. * UPTR can be converted to any other pointer and the other way round. * It is used by ugly functions, especially the umx-functions */ typedef void *UPTR; /* generic pointer ( ANSI-def ) */ /* * compare/delete function type */ typedef int cmp_func(UPTR data1, UPTR data2); typedef void del_func(UPTR data); #endif /* UGLY_TYPES_H */ hsc-0.934.orig/ugly/udebug.h0100600000175000001440000000353607770470741014572 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/udebug.h * * basic debugging macro and flags to control debugging output * of ugly.lib */ #ifndef UGLY_DEBUG_H #define UGLY_DEBUG_H #ifdef DEBUG_UGLY /* NOTE: for some defines, a value of "2" enables * extended debuggin information: * * DEBUG_UGLY_EXPSTR=2 display every call to set_estr() * DEBUG_UGLY_MEMORY=2 display every call to umalloc/ufree */ #define DEBUG_UGLY_ARG 0 #define DEBUG_UGLY_EXPSTR 0 #define DEBUG_UGLY_INFILE 0 #define DEBUG_UGLY_MEMORY 1 #define DEBUG_UGLY_TIME 1 #else #define DEBUG_UGLY_ARG 0 #define DEBUG_UGLY_EXPSTR 0 #define DEBUG_UGLY_INFILE 0 #define DEBUG_UGLY_MEMORY 0 #define DEBUG_UGLY_TIME 0 #endif /* DEBUG_UGLY */ /* show panic messages? * * NOTE: display_panic_message() is declared in ugly/umemory.c */ /* this define is named after the marvelous movie directed by * Franz Nowotny starring Hanno Pöschl and Paulus Manker */ #ifndef EXIT_NUR_KEINE_PANIK #define panic(msg) display_panic_message((msg), __FILE__, __LINE__) #else #define panic(msg) /* nufin */ #endif #endif /* UGLY_DEBUG_H */ hsc-0.934.orig/ugly/ufile.c0100600000175000001440000001676107770470775014431 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/ufile.c * * misc. filename functions * * updated: 23-Mar-2003 * created: 14-Oct-1996 * */ #include #include #include #include #include #include #include #include #ifdef AMIGA /* SAS/C's stat handling is weird, so use dos.library :-( */ #include #include #endif #include "utypes.h" #include "umemory.h" #include "ustring.h" #include "expstr.h" #define NOEXTERN_UGLY_UFILE_H #include "ufile.h" /* * fexists * * check if file exists ( = could have been opened for input) * * result: TRUE, if file exists, else FALSE * */ BOOL fexists(STRPTR filename) { FILE *file = fopen(filename, "r"); if (file) { fclose(file); } return ((BOOL) (file != NULL)); } /* * fgetentrytype * * check whether a filesystem object is a file or a directory * * result: see fentrytype_t definition * */ fentrytype_t fgetentrytype(const STRPTR name) { fentrytype_t type = FE_NONE; #ifdef AMIGA struct FileInfoBlock *fib; BPTR lock = Lock(name,ACCESS_READ); if(lock) { if((fib = AllocDosObjectTagList(DOS_FIB,NULL))) { if(Examine(lock,fib)) { /* this will barf on softlinks, but on AmigaOS these suck anyway */ type = (fib->fib_DirEntryType > 0) ? FE_DIR : FE_FILE; } FreeDosObject(DOS_FIB,fib); } UnLock(lock); } #else /* Does this work on RiscOS? Does anyone use HSC on RiscOS? Does anyone use * RiscOS...? */ struct stat sbuf; if(-1 != stat(name,&sbuf)) { if(S_ISDIR(sbuf.st_mode)) type = FE_DIR; else if(S_ISREG(sbuf.st_mode) || S_ISLNK(sbuf.st_mode)) type = FE_FILE; } #endif return type; } /* * fgetmtime * * Get the date/time of last modification from a file and return it as a * pointer to an internal struct tm or NULL on failure. * */ const struct tm *fgetmtime(const STRPTR name) { struct tm *time = NULL; #ifdef AMIGA struct FileInfoBlock *fib; BPTR lock = Lock(name,ACCESS_READ); if(lock) { if((fib = AllocDosObjectTagList(DOS_FIB,NULL))) { if(Examine(lock,fib)) { time_t tt; /* convert struct DateStamp to time_t format */ /* TODO: test this */ tt = 1149112800 + fib->fib_Date.ds_Days * 86400 + fib->fib_Date.ds_Minute * 60 + fib->fib_Date.ds_Tick / 50; time = localtime(&tt); } FreeDosObject(DOS_FIB,fib); } UnLock(lock); } #else /* Does this work on RiscOS? Does anyone use HSC on RiscOS? Does anyone use * RiscOS...? */ struct stat sbuf; if(-1 != stat(name,&sbuf)) { time = localtime(&sbuf.st_mtime); } #endif return time; } /* * getcurrentdir * * Get the current working directory as a string * * result: pointer to the the directory name, free this using ufree() * */ STRPTR getcurrentdir(void) { STRPTR s; int ss=32; errno = 0; while(1) { if(NULL == (s = umalloc(ss))) panic("out of memory"); if(NULL == getcwd(s,ss)) { if(ERANGE != errno) panic(strerror(errno)); ufree(s); ss *= 2; } else break; } return s; } /* * setcurrentdir * * Set the working directory * * result: nothing, side effect only * */ void setcurrentdir(const STRPTR dir) { /* this is just to avoid too much system specific stuff in other modules */ chdir(dir); } /* * getfsize * * get size of file * * params: filename...path and name of file to examine * result: size of file; if file does not exist, result * is 0, and ``errno'' is set */ LONG getfsize(CONSTRPTR filename) { FILE *file = fopen(filename, "rb"); LONG filesize = 0; if (file) { /* retrieve size */ fseek(file, 0L, SEEK_END); filesize = ftell(file); fclose(file); } return (filesize); } /* * fcopy * * copy file (binary) * * params: oldname,newname...filename of input/output files * result: value of type ``fcopy_t'', see "ugly/ufile.h" for details * * NOTE: you can use ``errno'' to obtain details about the error */ fcopy_t fcopy(CONSTRPTR oldname, CONSTRPTR newname) { #define BUFSIZE_FCOPY (16*1024) #define SETERR(code) {err = (code); nowErrno = errno; } fcopy_t err = FC_OK; /* function result */ FILE *inpf = fopen(oldname, "rb"); /* input file */ FILE *outf = fopen(newname, "wb"); /* output file */ char *buf = (char *) umalloc(sizeof(char) * BUFSIZE_FCOPY); /* copy buffer */ int nowErrno = 0; /* check for errors */ if (!buf) { SETERR(FC_ERR_NoMemory); } else if (!inpf) { SETERR(FC_ERR_OpenInput); } else if (!outf) { SETERR(FC_ERR_OpenOutput); } else { /* copy data */ BOOL quit = FALSE; do { size_t byteRead = fread(buf, sizeof(char), BUFSIZE_FCOPY, inpf); if (ferror(inpf)) { SETERR(FC_ERR_Read); } else if (byteRead == 0) { quit = TRUE; } else { fwrite(buf, sizeof(char), byteRead, outf); if (ferror(outf)) { SETERR(FC_ERR_Write); } } } while (!quit && (err == FC_OK)); } /* cleanup */ if (inpf) fclose(outf); if (inpf) fclose(inpf); if (buf) ufree(buf); /* set errno to value where error occured first */ if (nowErrno) errno = nowErrno; return err; } /* * fmove * * rename or move file; act's same as rename(), but is guaranteed * to work accross devices * * params: oldname...source filename * newname...destination filename * result: same as fcopy() */ fcopy_t fmove(CONSTRPTR oldname, CONSTRPTR newname) { fcopy_t ferr = FC_OK; if (rename(oldname, newname)) { int nowErrno = 0; /* rename failed; perform a copy-and-delete */ ferr = fcopy(oldname, newname); nowErrno = errno; /* remember errno */ switch (ferr) { case FC_OK: remove(oldname); /* remove old file */ break; case FC_ERR_Write: remove(newname); /* remove (incomplete) new file */ errno = nowErrno; break; case FC_ERR_NoMemory: case FC_ERR_OpenInput: case FC_ERR_OpenOutput: case FC_ERR_Read: /* do nufin */ break; default: panic("unhandled return value"); break; } } return ferr; } hsc-0.934.orig/ugly/ufile.h0100600000175000001440000000367507770470741014427 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * * ugly/ufile.h * * header file for misc. filename functions * * (W) by Tommy-Saftwörx in 1996 * */ #ifndef UGLY_UFILE_H #define UGLY_UFILE_H #include "utypes.h" #include "expstr.h" enum fcopy_e { FC_OK, /* sucessfull */ FC_ERR_NoMemory, /* out of memory */ FC_ERR_OpenInput, /* can't open input file */ FC_ERR_OpenOutput, /* can't open output file */ FC_ERR_Read, /* error reading input */ FC_ERR_Write /* error writing output */ }; typedef enum fcopy_e fcopy_t; typedef enum { FE_NONE, FE_FILE, FE_DIR /* FE_HARDLINK, FE_SOFTLINK, ... */ } fentrytype_t ; /* * external function prototypes */ #ifndef NOEXTERN_UGLY_UFILE_H extern BOOL fexists(STRPTR filename); extern LONG getfsize(STRPTR filename); extern fentrytype_t fgetentrytype(const STRPTR name); extern const struct tm *fgetmtime(const STRPTR name); extern STRPTR getcurrentdir(void); extern void setcurrentdir(const STRPTR dir); extern fcopy_t fcopy(CONSTRPTR oldname, CONSTRPTR newname); extern fcopy_t fmove(CONSTRPTR oldname, CONSTRPTR newname); #endif #endif hsc-0.934.orig/ugly/umemory.c0100600000175000001440000003644307770470775015021 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/umemory.c * * additional memory manegment functions; * implements some parts of Amiga-developer-tool * "MungWall" at source-level * * updated: 12-May-1997 * created: 29-Mar-1994 * */ /* * * Memory munging: * * Except for ucalloc(), memory is pre-munged on allocation with * $DEADFOOD. When this is used in an Enforcer report, the caller is * allocating memory and doesn't initialize it before using it. * * Memory is filled with $DEADBEEF before it is freed, encouraging * programs reusing free'ed memory to crash. * * Memory watching: * * Null sized malloc()'s are reported. The integrity of the walls will * be tested according to the size specified when free'ed. * */ #include #include #include #include "utypes.h" #define NOEXTERN_UGLY_UMEMORY_H #include "umemory.h" /* * size of wall build around every memory block */ #define UMEM_WALLSIZE 16 /* * blocksize memory allocations are rounded up by OS * (this one's only needed to compute the amount of * slack-memory and won't cause any problems if wrong) */ #if defined(AMIGA) #define UMEM_BLOCKSIZE 8 /* AmigaOS */ #else #define UMEM_BLOCKSIZE 8 #endif #ifndef modfit #define modfit(x,by) ((by)*(((x)+(by-1))/(by))) #endif static UGLYMEM *first = NULL; static UBYTE deadbeef[4] = {0xDE, 0xAD, 0xBE, 0xEF}; /* used to fill mem after free() */ static UBYTE deadfood[4] = {0xDE, 0xAD, 0xF0, 0x0D}; /* used to fill mem after malloc() */ static UBYTE ugly_fillchar = 0x81; static ULONG ugly_umalloc_count = 0; /* num. of calls to umalloc()/ucalloc() */ static ULONG ugly_ufree_count = 0; /* num. of calls to ufree() */ static ULONG ugly_umalloc_count_fail = 0; /* num. of failed calls to umalloc() */ static ULONG ugly_ufree_count_fail = 0; /* num. of failed calls to ufree() */ static ULONG ugly_maxmem_usage = 0; /* maximum memmory used */ static ULONG ugly_curmem_usage = 0; /* current memory used */ static ULONG ugly_real_maxmem_usage = 0; /* maximum memmory used */ static ULONG ugly_real_curmem_usage = 0; /* current memory used */ static ULONG ugly_maxnod_usage = 0; /* maximum num. of memmory nodes used */ static ULONG ugly_curnod_usage = 0; /* current num. of memory nodes used */ /* forward reference */ void *ugly_malloc_notracking(size_t size); static BOOL ugly_walldamaged(UGLYMEM * umem); /* function pointer for nomem-handler */ BOOL(*ugly_nomem_handler) (size_t size) = NULL; /* * send panic message to stderr */ VOID display_panic_message(char *msg, char *file, size_t line) { fprintf(stderr, "\n\n"); fprintf(stderr, " I won't be a monkey in anyone's zoo\n"); fprintf(stderr, " I won't get fazed whatever you do\n"); fprintf(stderr, " (Ride, \"Not Fazed\")\n\n"); fprintf(stderr, "** internal error: \"%s\" (%lu): %s\n", \ file, (unsigned long) line, msg); exit(255); } /* * find_umem */ static UGLYMEM *find_umem(void *mem) { UGLYMEM *nxtum = first; UGLYMEM *found = NULL; while (nxtum && (!found)) { if (nxtum->ptr == mem) { found = nxtum; } nxtum = nxtum->next; } #if DEBUG_UGLY_MEMORY==2 if (!found) { fprintf(stderr, "*memory* FIND_UMEM: couln't find %p\n", mem); } #endif return (found); } /* * find_prev */ static UGLYMEM *find_prev(UGLYMEM * umem) { UGLYMEM *prev = first; UGLYMEM *pprev = NULL; BOOL found = FALSE; while (prev && (!found)) { found = (prev == umem); if (!found) { pprev = prev; prev = prev->next; } } return (pprev); } /* * fill_mem4, fill_mem * * fill memory with value specified */ static void fill_mem4(void *mem, size_t size, UBYTE value[4]) { size_t i; for (i = 0; i < size; i++) { (((UBYTE *) mem)[i]) = value[i % 4]; } } static void fill_mem(void *mem, size_t size, UBYTE value) { size_t i; for (i = 0; i < size; i++) { (((UBYTE *) mem)[i]) = value; } } /* * del_uglymem * * free an uglymem-entry */ static void del_uglymem(UGLYMEM * umem) { UGLYMEM *prev = find_prev(umem); /* unlink from list */ if (prev) prev->next = umem->next; else first = umem->next; /* check for damaged wall */ if (!ugly_walldamaged(umem)) { /* wall ok: * * fill memory with $DEADBEEF, * free memory */ fill_mem4(umem->lower, umem->size + 2 * UMEM_WALLSIZE, deadbeef); free(umem->lower); } /* free memory structure */ umem->lower = NULL; umem->upper = NULL; umem->size = 0; umem->file = NULL; umem->line = 0; free(umem); } /* * new uglymem * * alloc & init a new entry of ugly mem */ static UGLYMEM *new_uglymem(size_t memsize, STRPTR memfile, ULONG memline) { UGLYMEM *newmem = (UGLYMEM *) malloc(sizeof(UGLYMEM)); if (newmem) { newmem->lower = (UBYTE *) ugly_malloc_notracking(memsize + 2 * UMEM_WALLSIZE); if (newmem->lower) { /* compute location of main mem/upper wall */ newmem->ptr = (void *) (newmem->lower + UMEM_WALLSIZE); newmem->upper = (newmem->lower + UMEM_WALLSIZE + memsize); /* link to list */ newmem->next = first; first = newmem; /* init data */ newmem->size = memsize; newmem->file = memfile; newmem->line = memline; newmem->fillchar = ugly_fillchar; /* fill new mem area with $DEADF00D */ fill_mem4(newmem->ptr, memsize, deadfood); /* fill lower/upper wall */ fill_mem(newmem->lower, UMEM_WALLSIZE, ugly_fillchar); fill_mem(newmem->upper, UMEM_WALLSIZE, ugly_fillchar); /* update fillchar */ if (ugly_fillchar == 0xff) { ugly_fillchar = 0x81; } else { ugly_fillchar++; } } else free(newmem); } return (newmem); } static void uglymem_message(STRPTR msg) { fprintf(stderr, "%s\n", msg); } static void ugly_memdump(void *ptr, size_t size) { STRPTR data = (STRPTR) ptr; /* limit size */ if (size > 16) { size = 16; } fprintf(stderr, " %p:", ptr); if (data) { size_t i; /* hex dump */ for (i = 0; i < size; i++) { if (!(i % 4)) { fprintf(stderr, " "); } fprintf(stderr, "%02x", data[i]); } /* fill with blanks */ while (i < 16) { if (!(i % 4)) { fprintf(stderr, " "); } fprintf(stderr, " "); i++; } fprintf(stderr, " \""); /* ascii dump */ for (i = 0; i < size; i++) { if (data[i] < ' ') { fprintf(stderr, "."); } else { fprintf(stderr, "%c", data[i]); } } fprintf(stderr, "\"\n"); } else fprintf(stderr, "NULL\n"); } static void uglymem_meminfo(void *ptr, STRPTR file, ULONG line) { fprintf(stderr, " %p: from \"%s\" (%lu)\n", ptr, file, line); } static void umem_info(UGLYMEM * umem) { fprintf(stderr, " %p: %lu (0x%lx) bytes from \"%s\" (%lu)\n", umem->ptr, (ULONG) umem->size, (ULONG) umem->size, umem->file, umem->line); } /* *------------------------------------- * wall check functions *------------------------------------- */ /* * str_ubyte * * convert a UBYTE-value to hex/dez/char and return * results as a displayable string */ static STRPTR str_ubyte(UBYTE val) { static STRARR strbuf[30]; UBYTE ch = val; if (ch < 32) ch = '.'; sprintf(strbuf, "(0x%02x/#%d/`%c')", val, val, ch); return (strbuf); } /* * ugly_walldamaged * * check memory walls a specifc entry in memory-list, * output message if wall is damaged */ static BOOL ugly_walldamaged(UGLYMEM * umem) { size_t i = 0; BOOL damaged = FALSE; while (!damaged && (i < UMEM_WALLSIZE)) { BOOL lower_damaged = (umem->lower[i] != umem->fillchar); BOOL upper_damaged = (umem->upper[i] != umem->fillchar); damaged = lower_damaged || upper_damaged; if (damaged) { STRPTR wall; UBYTE value; if (lower_damaged) { wall = "LOWER"; value = umem->lower[i]; } else { wall = "UPPER"; value = umem->upper[i]; } fprintf(stderr, "*** MEMORY WALL DAMAGED!!!\n"); fprintf(stderr, "*** %s wall, byte#%lu is %s instead of 0x%02x\n", wall, (ULONG) i, str_ubyte(value), umem->fillchar); umem_info(umem); ugly_memdump(umem->ptr, umem->size); fprintf(stderr, " * lower wall:\n"); ugly_memdump(umem->lower, UMEM_WALLSIZE); fprintf(stderr, " * upper wall:\n"); ugly_memdump(umem->upper, UMEM_WALLSIZE); } else { i++; } } return (damaged); } /* * uglymem_wallcheck * * display a header message and check all walls for consistency */ void uglymem_wallcheck(STRPTR msg, STRPTR file, ULONG line) { UGLYMEM *umem = first; if (umem) { /* report header */ fprintf(stderr, "MEMORY WALL-CHECK (%s)", msg); if (file) fprintf(stderr, " from `%s' (%lu)", file, line); fprintf(stderr, "\n"); /* check all elements */ while (umem) { if (umem->ptr) { ugly_walldamaged(umem); umem = umem->next; } else { umem = NULL; fprintf(stderr, "\n** PANIC: memory list trashed\n"); } } } } /* *------------------------------------- * memory statistics functions *------------------------------------- */ /* * ugly_mem_report * * displaly all memory nodes currently allocated */ void uglymem_report(STRPTR msg, STRPTR file, ULONG line, STRPTR date, STRPTR time) { UGLYMEM *umem = first; if (umem) { /* report header */ fprintf(stderr, "MEMORY REPORT (%s)\n", msg); if (file) { fprintf(stderr, "(\"%s\" (%lu), at %s, %s)\n", file, line, date, time); } /* print all elements */ while (umem) { if (umem->ptr) { umem_info(umem); ugly_memdump(umem->ptr, umem->size); umem = umem->next; } else { umem = NULL; fprintf(stderr, "##\n## panic: memory list trashed\n##\n"); } } } } /* * ugly_mem_stats * * display memory statistics (nodes & size allocated) */ void uglymem_stats(STRPTR msg, STRPTR file, ULONG line, STRPTR date, STRPTR time) { /* statistics header */ fprintf(stderr, "MEMORY STATISTICS (%s)\n", msg); if (file) { fprintf(stderr, "(\"%s\" (%lu), at %s, %s)\n", file, line, date, time); } /* memory statistics */ fprintf(stderr, " bytes used: %lu max: %lu/%lu ", ugly_curmem_usage, ugly_real_maxmem_usage, ugly_maxmem_usage); if (ugly_maxmem_usage) { fprintf(stderr, "slack: %lu%%\n", (100 * (ugly_real_maxmem_usage - ugly_maxmem_usage)) / ugly_maxmem_usage); } else { fprintf(stderr, "no slack\n"); } fprintf(stderr, " nodes used: %lu (max: %lu)\n", ugly_curnod_usage, ugly_maxnod_usage); fprintf(stderr, " calls to: umalloc(%lu) ufree(%lu)\n", ugly_umalloc_count, ugly_ufree_count); } /* *------------------------------------- * atexit functions *------------------------------------- */ /* * atexit_uglymemory_real */ void atexit_uglymemory_real(void) { ULONG mem_lost = ugly_curmem_usage; uglymem_report("at exit: MEMORY LEAK detected!", NULL, 0, NULL, NULL); uglymem_stats("[exit]", NULL, 0, NULL, NULL); /* release all lost mem */ while (first) { del_uglymem(first); } if (mem_lost) { fprintf(stderr, "\n%lu bytes of memory lost!\n", mem_lost); } } /* * atexit_uglymemory_dummy */ void atexit_uglymemory_dummy(void) { /* do nufin */ } /* *------------------------------------- * memory handling functions *------------------------------------- */ /* * ugly_malloc_notracking */ void *ugly_malloc_notracking(size_t size) { void *mem; BOOL retry; do { mem = malloc(size); if (!mem && ugly_nomem_handler) { /* call nomem-handler */ retry = (*ugly_nomem_handler) (size); if (!retry) exit(EXIT_FAILURE); /* abort programm */ } else retry = FALSE; } while (retry); return (mem); } /* * ugly_malloc_tracking */ void *ugly_malloc_tracking(size_t size, STRPTR file, ULONG line) { void *mem = NULL; UGLYMEM *umem = NULL; #if DEBUG_UGLY_MEMORY==2 fprintf(stderr, "*memory* UMALLOC() from `%s' (%lu)\n", file, line); #endif if (size) { /* update num. of calls to umalloc() */ ugly_umalloc_count++; /* alloc new uglymem */ umem = new_uglymem(size, file, line); if (umem) { mem = umem->ptr; /* update memory usage and num of nodes */ ugly_curmem_usage += size; ugly_real_curmem_usage += modfit(size, UMEM_BLOCKSIZE); if (ugly_curmem_usage > ugly_maxmem_usage) ugly_maxmem_usage = ugly_curmem_usage; if (ugly_real_curmem_usage > ugly_real_maxmem_usage) ugly_real_maxmem_usage = ugly_real_curmem_usage; ugly_curnod_usage++; if (ugly_curnod_usage > ugly_maxnod_usage) ugly_maxnod_usage = ugly_curnod_usage; } } else { /* zero-alloc */ /* update num. of failed calls to umalloc() */ ugly_umalloc_count_fail++; uglymem_message("MALLOC: zero-sized allocation"); uglymem_meminfo(NULL, file, line); } return (mem); } /* * ugly_free */ void ugly_free(void *ptr, STRPTR file, ULONG line) { #if DEBUG_UGLY_MEMORY==2 fprintf(stderr, "*memory* UFREE() from `%s' (%lu)\n", file, line); #elif 0 fputc('.', stderr); /* still alive? */ fflush(stderr); #endif if (ptr) { UGLYMEM *umem = find_umem(ptr); if (umem) { /* update num. of calls to ufree() */ ugly_ufree_count++; /* update memory usage */ ugly_curmem_usage -= umem->size; ugly_real_curmem_usage -= modfit(umem->size, UMEM_BLOCKSIZE); /* remove node from mem-list */ del_uglymem(umem); ugly_curnod_usage--; } else { /* ptr has never been allocated */ /* update num. of calls to ufree() */ ugly_ufree_count_fail++; /* -> error message */ uglymem_message("*** FREE: memory never allocated " " or released twice"); uglymem_meminfo(ptr, file, line); } } } /* * ugly_realloc * * replacement of realloc() */ void *ugly_realloc(void *ptr, size_t size, STRPTR file, ULONG line) { void *newptr = ugly_malloc_tracking(size, file, line); UGLYMEM *umem = find_umem(ptr); if (newptr && umem) { /* copy old data */ memcpy(newptr, umem->ptr, umem->size); /* free old memory */ ugly_free(ptr, file, line); } return (newptr); } /* * ugly_calloc * * replacement of calloc() */ void *ugly_calloc(size_t count, size_t size, STRPTR file, ULONG line) { /* alloc new mem */ void *mem = ugly_malloc_tracking(count * size, file, line); /* fill mem with zero */ if (mem) { memset(mem, 0, size * count); } return (mem); } hsc-0.934.orig/ugly/umemory.h0100600000175000001440000000720107770470741015005 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef UGLY_UMEMORY_H #define UGLY_UMEMORY_H /* avoid include twice */ /* * ugly/umemory.h * * additional memory manegment, tracking and debugging functions, header file * */ #include #include "utypes.h" /* * ufree() - macro to free memory and set var * pointing to memory to NULL, * but only if it has been allocated * successfully before */ struct uglymem { struct uglymem *next; void *ptr; /* ptr to mem area allocated before */ UBYTE *lower; /* lower wall */ UBYTE *upper; /* upper wall */ size_t size; /* size of this area */ STRPTR file; /* filename from which call came */ ULONG line; /* line num in this file */ UBYTE fillchar; /* fill character for wall */ }; typedef struct uglymem UGLYMEM; #if DEBUG_UGLY_MEMORY /* ugly function calls with memory tracking ENABLED */ #define umalloc(size) ugly_malloc_tracking( size, __FILE__, __LINE__ ) #define ufree(ptr) if ( ptr ) { ugly_free( ptr, __FILE__, __LINE__ ); ptr = NULL; } #define urealloc(ptr,size) ugly_realloc( ptr, size, __FILE__, __LINE__ ); #define ucalloc(count,size) ugly_calloc( count,size,__FILE__,__LINE__ ); #define umem_report(msg) uglymem_report( msg, __FILE__, __LINE__, __DATE__, __TIME__ ) #define umem_stats(msg) uglymem_stats( msg, __FILE__, __LINE__, __DATE__, __TIME__ ) #define umem_wallcheck(msg) uglymem_wallcheck( msg, __FILE__, __LINE__ ) #define atexit_uglymemory atexit_uglymemory_real #else /* ugly function calls with memory tracking disabled */ #define umalloc(size) ugly_malloc_notracking(size) #define ufree(ptr) if ( ptr ) { free(ptr); ptr=NULL; } /* TODO: use only free() */ #define urealloc(ptr,size) realloc( ptr, size ); #define ucalloc(count,size) calloc( count,size ) #define umem_report(msg) /* nufin */ #define umem_stats(msg) /* nufin */ #define umem_wallcheck(msg) /* nufin */ #define atexit_uglymemory atexit_uglymemory_dummy #endif /* DEBUG_UGLY_MEMORY */ #ifndef NOEXTERN_UGLY_UMEMORY_H extern VOID display_panic_message(char *msg, char *file, size_t line); extern void *ugly_malloc_tracking(size_t size, STRPTR file, ULONG line); extern void *ugly_malloc_notracking(size_t size); extern void ugly_free(void *ptr, STRPTR file, ULONG line); extern void *ugly_realloc(void *ptr, size_t size, STRPTR file, ULONG line); extern void *ugly_calloc(size_t count, size_t size, STRPTR file, ULONG line); extern void uglymem_stats(STRPTR msg, STRPTR file, ULONG line, STRPTR date, STRPTR time); extern void uglymem_report(STRPTR msg, STRPTR file, ULONG line, STRPTR date, STRPTR time); extern void uglymem_wallcheck(STRPTR msg, STRPTR file, ULONG line); extern void atexit_uglymemory(void); extern BOOL(*ugly_nomem_handler) (size_t size); #endif #endif hsc-0.934.orig/ugly/unikot.c0100600000175000001440000001535507770470775014634 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/unikot.c - unicode support functions */ #include "ugly/utypes.h" #include "ugly/unikot.h" /* debuggin define */ #if 0 #define DUC(x) x #else #define DUC(x) #endif #define UNIKOT "*unikot* " /* * display internal error message * * c - condition which causes error * m - message text to discibe error */ #define internal_error(c,m) \ if ((c)) \ { \ unikot_internal_error(__FILE__, __LINE__, m); \ } #if 0 static void unikot_internal_error(char *file, long int line, char *message) { fprintf(stderr, "*** internal error at `%s' (%ld): %s\n", file, line, message); exit(255); } #endif /**** ugly/utf8_to_ucs4 ********************************************* * NAME * uft8_to_ucs4 - convert UTF-8-string to UTF-4-code (32 bit) * SYNOPSIS * skip = utf8_to_ucs4(ucs4 , utf8_t , skip) * int utf8_to_ucs4(ucs4_t *, utf8_t *, size_t *) * FUNCTION * Attempts to convert the beginning of an UTF-8-encoded string to * an UCS-4-code. This will only convert the next character(s) of * the string. The result tell how many characters were needed. * Encoding errors can be handled. * INPUTS * ucs4 - target variable which will hold UCS-4-code * utf8 - start of UTF-8-string to be converted * RESULT * Denotes how many chars of UTF-8-string were used for the * calculation of the UCS-4-code. This can be used to increase the * string pointer and call this routine again. * * If there was an error in the UTF-8 encoding, this value will be * zero or negative. *******************************************************************/ int utf8_to_ucs4(ucs4_t * ucs4, const utf8_t * utf8str) { int skip = 1; if (utf8str[0] >= 192) { /* blimy! This must be an extended char */ char ch_to_read = 0; utf8_t i = utf8str[0]; ucs4_t first_ch_mask = 0x3f; while (i & 0x40) { ch_to_read += 1; i = (i << 1) & 0x7f; first_ch_mask = first_ch_mask >> 1; } *ucs4 = utf8str[0] & first_ch_mask; DUC(fprintf(stderr, "%02x: %d chars, mask=0x%02x\n", utf8str[0], ch_to_read, first_ch_mask)); do { utf8_t ch = 0; /* get next char */ ch = utf8str[skip]; if ((ch & 0xc0) == 0x80) { /* add it to to current ucs4-value */ *ucs4 = (*ucs4 << 6) + (ch & 0x3f); ch_to_read -= 1; skip += 1; } else { /* encoding error */ DUC(fprintf(stderr, UNIKOT "*** encoding error: 0x%02x != 10xxxxxx\n", ch)); skip = ERR_UNIKOT_LATER_CHAR; } } while (ch_to_read && (skip > 0)); } else if (utf8str[0] >= 128) { /* encoding error */ DUC(fprintf(stderr, UNIKOT "*** encoding error: 128 0) { ch = 0x80 + (ucs4 & 0x3f); ucs4 = ucs4 >> 6; utf8str[i] = ch; DUC(fprintf(stderr, UNIKOT " i=%d ch=%02x\n", i, ch)); --i; } DUC(internal_error(first_char & ucs4, "bits overlapping")); /* compute first character */ first_char = first_char | ucs4; utf8str[0] = first_char; } return skip; } hsc-0.934.orig/ugly/unikot.h0100600000175000001440000000277107770470741014630 0ustar loryusers/* * This source code is part of hsc, an html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * Copyright (C) 2001-2003 Matthias Bethke * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/unikot.h - unicode support functions */ #include typedef long int ucs4_t; typedef short int ucs2_t; typedef unsigned char utf8_t; /* * defines */ #define UCS4_TO_UTF8_STR(utf8str,ucs4) \ (utf8str)[ucs4_to_utf8((utf8str),(ucs4))] = '\0' /* * error codes returned by utf8_to_ucs4() */ #define ERR_UNIKOT_FIRST_CHAR (-1) #define ERR_UNIKOT_LATER_CHAR (-2) #ifndef UNIKOT_INLINE #define UNIKOT_INLINE /* nufin */ #endif /* UNIKOT_INLINE */ #ifndef NOEXTERN_UGLY_UNIKOT_H extern int utf8_to_ucs4(ucs4_t * ucs4, const utf8_t * utf8str); extern int ucs4_to_utf8(utf8_t * utf8str, ucs4_t ucs4); #endif /* NOEXTERN_UGLY_UNIKOT_H */ hsc-0.934.orig/ugly/ustring.c0100600000175000001440000002016307770470775015007 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/ustring.c - ugly string functions * * updated: 18-May-1997 * created: 31-Jul-1993 */ #include #include #include #include #include "utypes.h" #include "umemory.h" #define NOEXTERN_UGLY_USTRING_H #include "ustring.h" /* * last_ch * * return last char of a string, or 0 on empty string */ int last_ch(STRPTR s) { size_t len = strlen(s); int ch = 0; if (len) { ch = s[len - 1]; } else { ch = 0; } return ch; } /* * strclone * * create a clone of a string * (copy of string using its own memory area) * * params: *oldstr...ptr to string to clone * result: ptr to copy of string; * errors: out of memory: returns NULL * */ STRPTR ugly_strclone(CONSTRPTR oldstr, STRPTR file, ULONG line) { STRPTR newstr = NULL; if (oldstr) { /* alloc mem for clone */ #if DEBUG_UGLY_MEMORY newstr = (STRPTR) ugly_malloc_tracking(strlen(oldstr) + 1, file, line); #else newstr = (STRPTR) umalloc(strlen(oldstr) + 1); #endif if (newstr) /* alloc sucessful? */ strcpy(newstr, oldstr); /* Y-> copy data */ else panic("out of memory while trying to clone string"); } return (newstr); /* return result */ } /* * lowstr: convert a string to lowercase * * params: *s...string to convert * */ STRPTR lowstr(STRPTR s) { STRPTR s_old = s; if (s) for (; *s != '\0'; s++) *s = tolower(*s); return s_old; } /* * upstr: convert a string to uppercase * * params: *s...string to convert * */ STRPTR upstr(STRPTR s) { STRPTR s_old = s; if (s) for (; *s != '\0'; s++) *s = toupper(*s); return s_old; } /* * upstrcmp * * string compare, ignore case * * params: *s1, *s2...ptr to strings to compare * result: <0: s1 < s2 * 0: s1 = s2 * >0: s1 > s2 * */ int upstrcmp(CONSTRPTR s1, CONSTRPTR s2) { unsigned char c1, c2; /* chars currently comparing */ size_t i = 0; /* string index counter */ do { c1 = toupper(s1[i]); c2 = toupper(s2[i]); ++i; } while (c1 && c2 && (c1 == c2)); return (c2 - c1); } /* * upstrncmp * * string compare, ignore case, max. n chars * * params: *s1, *s2...ptr to strings to compare * n..........max. nr. of chars to compare * result: -1: s1 < s2 * 0: s1 = s2 * 1: s1 > s2 * */ int upstrncmp(CONSTRPTR s1, CONSTRPTR s2, size_t n) { unsigned char c1, c2; /* char of string currently comparing */ size_t i = 0; /* string index counter */ do { c1 = toupper(s1[i]); c2 = toupper(s2[i]); ++i; } while (c1 && c2 && (c1 == c2) && (i < n)); return c2-c1; } /* * upstrstr * * find a sub-string (case insensitive) * */ STRPTR upstrstr(CONSTRPTR s1, CONSTRPTR s2) { const char *c1; const char *c2; do { c1 = s1; c2 = s2; while (*c1 != '\0' && (toupper(c1[0]) == toupper(c2[0]))) { ++c1; ++c2; } if (*c2 == '\0') return (char *) s1; } while (*s1++ != '\0'); return NULL; } /* * freestr * * free memory used by a string * * params: s..string to free * * NOTE: strings created with strclone() or reallocstr * should be freed with this function instead of * ufree(). this will avoid problems when using * the memory-tracking feature of ugly.o */ void ugly_freestr(STRPTR s, STRPTR file, ULONG line) { #if DEBUG_UGLY_MEMORY ugly_free(s, file, line); #else ufree(s); #endif } /* * reallocstr * * free memory used by string, clone new data * * params:oldstr...prt to ptr of old string * *newstr...ptr to new string data * errors: out of mem: returns NULL (old data are lost) * * IMPORTANT: old string has to be initialies like "oldstr = NULL;" before !! * first call like "reallocstr( &oldstr, "" );" */ void ugly_reallocstr(STRPTR * oldstr, CONSTRPTR newstr, STRPTR file, ULONG line) { #if DEBUG_UGLY_MEMORY ugly_freestr(*oldstr, file, line); /* free old string */ *oldstr = ugly_strclone(newstr, file, line); /* clone new string */ #else ufree(*oldstr); /* free old string */ *oldstr = strclone(newstr); /* clone new string */ #endif } /* * ch2str * * convert single char to zero terminated string * * params: ch...char to convert * result: ptr to internal buffer, where a string containning * "\0" is located. * * USAGE : buffer is rewritten at next call of _chstr(), so * be sure to clone string if you need it for a longer * time. * _ch2str() is mostly designed for parameter conversion * on string funtions, e.g s = strclone( ch2str( 'x' ) ); * */ STRPTR ch2str(const char ch) { static char ch2str_buffer[2]; /* internal buffer */ ch2str_buffer[0] = ch; ch2str_buffer[1] = '\0'; return ch2str_buffer; } /* * ustrrpbrk * * searches for last occurence of a char of _set in _str * * params: str...string to examine * set...chars to search for * result: ptr where char of _set occured in _str * or NULL if none occurence found * * NOTE: this is a clone of none-ansi-c function _strrpbrk() * */ STRPTR ustrrpbrk(CONSTRPTR str, CONSTRPTR set) { size_t i; STRPTR result = NULL; if (str && ('\0' != str[0])) { i = strlen(str) - 1; while ((i) && (strchr(set, str[i]) == NULL)) i--; if (strchr(set, str[i])) result = (STRPTR) & (str[i]); } return result; } /* * str2long * * convert string expression to long value * * params: s....string to convert * num..ptr to destination long var * result: TRUE, if sucessful * errors: returen FALSE * */ BOOL str2long(STRPTR s, LONG * num) { BOOL conv_ok = FALSE; if (sscanf(s, "%d", (int *) num)) conv_ok = TRUE; return conv_ok; } /* * long2str * * convert long value to string expresion * * params: num...value to convert * result: ptr to converted string * errors: returns NULL * */ STRPTR long2str(LONG num) { static char num2str_buffer[10]; /* internal buffer */ STRPTR result_str = NULL; if (sprintf(num2str_buffer, "%d", (int) num)) result_str = num2str_buffer; return result_str; } /* * strenum * * find a substring in an enumerator string * * params: str...substring to search for * set...set of legal substrings * sep...substring separator (eg "|") * result: 0..not found * >0..index of substring found * <0..out of mem * errors: out of mem: returns -1 * * example: enumstr( "sepp", "hugo|sepp|resi", '|', STEN_CASE ) -> 2 * * NOTE: calls strtok() */ LONG strenum(CONSTRPTR str, CONSTRPTR set, char sep, BYTE options) { STRPTR s = strclone(set); LONG found = 0; if (s) { STRPTR nxtstr = strtok(s, ch2str(sep)); LONG count = 1; while (!found && nxtstr) { if (options & STEN_NOCASE) { if (!upstrcmp(str, nxtstr)) found = count; } else if (!strcmp(str, nxtstr)) found = count; count++; nxtstr = strtok(NULL, ch2str(sep)); } ufreestr(s); } else found = -1; return (found); } hsc-0.934.orig/ugly/ustring.h0100600000175000001440000000427607770470741015014 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef UGLY_USTRING_H #define UGLY_USTRING_H /* * ugly/string.h * * additional string functions, header * * (W) by Tommy-Saftwörx in 1993,94,95 * */ #include #include "utypes.h" #define freestr( s ) ugly_freestr(s,__FILE__,__LINE__) #define ufreestr( s ) freestr(s),s=NULL #define strclone( s ) ugly_strclone(s,__FILE__,__LINE__) #define reallocstr( o,n ) ugly_reallocstr(o,n,__FILE__,__LINE__) /* options for strenum */ #define STEN_CASE 0 /* case sensitive search */ #define STEN_NOCASE 1 /* case insensitive search */ /* * external prototypes */ #ifndef NOEXTERN_UGLY_USTRING_H extern STRPTR lowstr(STRPTR s); extern STRPTR upstr(STRPTR s); extern int upstrcmp(CONSTRPTR s1, CONSTRPTR s2); extern int upstrncmp(CONSTRPTR s1, CONSTRPTR s2, size_t n); extern STRPTR upstrstr(CONSTRPTR s1, CONSTRPTR s2); extern void ugly_freestr(STRPTR s, STRPTR file, ULONG line); extern STRPTR ugly_strclone(CONSTRPTR oldstr, STRPTR file, ULONG line); extern void ugly_reallocstr(STRPTR * oldstr, CONSTRPTR newstr, STRPTR file, ULONG line); extern STRPTR ustrrpbrk(CONSTRPTR str, CONSTRPTR set); extern LONG strenum(CONSTRPTR str, CONSTRPTR set, char sep, BYTE options); extern int last_ch(STRPTR s); extern STRPTR ch2str(const char ch); extern BOOL str2long(STRPTR s, LONG * num); extern STRPTR long2str(LONG num); #endif /* NOEXTERN_UGLY_USTRING_H */ #endif /* UGLY_USTRING_H */ hsc-0.934.orig/ugly/ustrlist.c0100600000175000001440000000503007770470775015201 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * ugly/ustrlist.c - string list functions * * updated: 9-Mar-1997 * created: 14-Oct-1996 * */ #include #include #include #include "umemory.h" #define NOEXTERN_UGLY_USTRLIST_H #include "ustrlist.h" /* * del_string_node */ VOID del_string_node(APTR data) { STRPTR s = (STRPTR) data; ufreestr(s); } /* * new_string_node */ STRPTR new_string_node(STRPTR data) { #if 0 D(fprintf(stderr, DHL "new string `%s'\n", data)); #endif return (strclone(data)); } /* * cmp_string_node */ int cmp_string_node(APTR cmp_data, APTR lst_data) { STRPTR s1 = (STRPTR) cmp_data; STRPTR s2 = (STRPTR) lst_data; #ifdef DEBUG_UGLY if (!cmp_data) panic("cmp_data = NULL"); if (!lst_data) panic("lst_data = NULL"); #endif if (!strcmp(s1, s2)) return (-1); else return (0); } /* * del_strlist: cleanup whole list of strings */ VOID del_strlist(DLLIST * list) { del_dllist(list); } /* * del_strlist: cleanup whole list of strings */ VOID clr_strlist(DLLIST * list) { del_all_dlnodes(list); } /* * init_strlist: set up new list of strings */ DLLIST *init_strlist(VOID) { return (init_dllist(del_string_node)); } /* * app_strnode * * append new string to string-list (at end) */ DLNODE *app_strnode(DLLIST * list, STRPTR str) { STRPTR scp = new_string_node(str); DLNODE *nd = NULL; if (scp) { nd = app_dlnode(list, (APTR) scp); } return nd; } /* * add_strnode * * add new string to string-list (at begining) */ DLNODE *add_strnode(DLLIST * list, STRPTR str) { STRPTR scp = new_string_node(str); DLNODE *nd = NULL; if (scp) { nd = add_dlnode(list, (APTR) scp); } return nd; } hsc-0.934.orig/ugly/ustrlist.h0100600000175000001440000000304607770470741015204 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * * ugly/ustrlist.h * * header file for string list functions * * (W) by Tommy-Saftwörx in 1996 * */ #ifndef UGLY_USTRLIST_H #define UGLY_USTRLIST_H #include "utypes.h" #include "ustring.h" #include "dllist.h" /* * external function prototypes */ #ifndef NOEXTERN_UGLY_USTRLIST_H #define find_strnode(nd,str) find_dlnode((nd),(APTR)(str), cmp_string_node) extern VOID del_string_node(APTR data); extern STRPTR new_string_node(STRPTR data); extern int cmp_string_node(APTR cmp_data, APTR lst_data); extern VOID clr_strlist(DLLIST *list); extern VOID del_strlist(DLLIST *list); extern DLLIST *init_strlist(VOID); extern DLNODE *app_strnode(DLLIST * list, STRPTR str); extern DLNODE *add_strnode(DLLIST * list, STRPTR str); #endif #endif hsc-0.934.orig/ugly/utime.h0100600000175000001440000000265207772072741014440 0ustar loryusers/* * This source code is part of hsc, a html-preprocessor, * Copyright (C) 1993-1998 Thomas Aglassinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /* * * utime.h * * header file for filename manipulaton functions * * (W) by Tommy-Saftwörx in 1996 * */ #include "utypes.h" #include "expstr.h" /* template used to store time in a string: YYYY/MM/DD HH:MM:SS */ #define UGLY_TIME_TEMPLATE_SSCANF "%04d/%02d/%02d %02d:%02d:%02d" #define UGLY_TIME_TEMPLATE_STRFTIME "%Y/%m/%d %H:%M:%S" #define UGLY_TIMESTR_LEN (strlen(UGLY_TIME_TEMPLATE_SSCANF)) /* * external function prototypes */ #ifndef NOEXTERN_UGLY_UTIME_H extern VOID clrtime(struct tm *time); extern BOOL time2estr(EXPSTR * dest, struct tm *time); extern BOOL str2time(struct tm *time, STRPTR timestr); #endif hsc-0.934.orig/.deps0100600000175000001440000004574107772072752013130 0ustar loryusersamiga/msgbrowser.o: amiga/msgbrowser.c hsc/all_hsc.o: hsc/all_hsc.c hsc/global.c hsclib/hsclib.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/include.h hsclib/linit.h ugly/returncd.h hsc/global.h \ hsc/hdebug.h hsc/status.c hsc/status.h hsc/callback.c hsc/output.h \ hsc/callback.h hsc/args.c ugly/uargs.h ugly/fname.h ugly/prginfo.h \ hscprj/license.h hsc/output.c hsc/hsc.c hsc/hsc_rev.h hsc/args.h hsc/args.o: hsc/args.c hsc/global.h hsclib/hsclib.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/include.h hsclib/linit.h hsc/hdebug.h hsc/status.h \ hsc/callback.h ugly/uargs.h ugly/fname.h ugly/prginfo.h ugly/returncd.h \ hscprj/license.h hsc/callback.o: hsc/callback.c hsc/global.h hsclib/hsclib.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/include.h hsclib/linit.h hsc/hdebug.h hsc/output.h hsc/status.h \ ugly/returncd.h hsc/callback.h hsc/global.o: hsc/global.c hsclib/hsclib.h hsclib/inc_base.h hsclib/ldebug.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/include.h hsclib/linit.h ugly/returncd.h hsc/global.h \ hsc/hdebug.h hsc/hsc.o: hsc/hsc.c hsc/hsc_rev.h hsc/global.h hsclib/hsclib.h \ hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h ugly/udebug.h \ ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h ugly/ustring.h \ ugly/ufile.h hsclib/msgid.h hscprj/document.h hsclib/attrib.h \ hsclib/entity.h hsclib/tag.h hsclib/hscprc.h hscprj/project.h \ hsclib/lmessage.h hsclib/lstatus.h hsclib/include.h hsclib/linit.h \ hsc/hdebug.h ugly/prginfo.h ugly/uargs.h ugly/returncd.h hsc/args.h \ hsc/callback.h hsc/output.h hsc/status.h hsc/output.o: hsc/output.c hsc/global.h hsclib/hsclib.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/include.h hsclib/linit.h hsc/hdebug.h hsc/status.h \ ugly/returncd.h hsc/status.o: hsc/status.c hsc/global.h hsclib/hsclib.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/include.h hsclib/linit.h hsc/hdebug.h hsc/status.h \ ugly/returncd.h hsclib/all_hscl.o: hsclib/all_hscl.c hsclib/ldebug.h hsclib/msgid.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/infile.h ugly/ustring.h hsclib/lmessage.c hsclib/inc_base.h \ ugly/ufile.h hscprj/document.h hsclib/attrib.h hsclib/entity.h \ hsclib/tag.h hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h \ hsclib/lstatus.h ugly/returncd.h hsclib/entity.c hsclib/tag.c \ hsclib/defattr.h hsclib/attrib.c hsclib/eval.h hsclib/uri.h \ hsclib/idref.c ugly/ustrlist.h hsclib/idref.h hsclib/hscprc.c \ ugly/fname.h hsclib/tag_if.h hsclib/css.h hsclib/lstatus.c \ hsclib/input.c hsclib/skip.c hsclib/input.h hsclib/skip.h hsclib/uri.c \ hsclib/tcpip.h hsclib/eval.c hsclib/posteval.c hsclib/defattr.c \ hsclib/deftag.c hsclib/css.c hsclib/parse.c ugly/unikot.h \ hsclib/deftag.h hsclib/include.h hsclib/parse.h hsclib/posteval.h \ hsclib/size.h hsclib/include.c hsclib/linit.c hsclib/tag_a.h \ hsclib/tag_hsc.h hsclib/tag_macro.h hsclib/tag_misc.h hsc/hsc_rev.h \ hsclib/entities.c hsclib/size.c hsclib/tag_misc.c hsclib/tag_a.c \ hsclib/inc_tagcb.h hsclib/tag_hsc.c hsclib/tag_if.c hsclib/tag_macro.c hsclib/attrib.o: hsclib/attrib.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/eval.h \ hsclib/uri.h hsclib/css.o: hsclib/css.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/css.h hsclib/defattr.o: hsclib/defattr.c hsclib/inc_base.h hsclib/ldebug.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/defattr.h hsclib/eval.h hsclib/input.h hsclib/deftag.o: hsclib/deftag.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/defattr.h \ hsclib/eval.h hsclib/input.h hsclib/skip.h hsclib/css.h hsclib/entities.o: hsclib/entities.c hsclib/entity.o: hsclib/entity.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/eval.o: hsclib/eval.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/eval.h \ hsclib/input.h hsclib/skip.h hsclib/uri.h hsclib/gst.o: hsclib/gst.c ugly/dllist.h ugly/utypes.h ugly/udebug.h \ ugly/infile.h ugly/expstr.h ugly/ustrlist.h ugly/ustring.h ugly/uargs.h \ ugly/umemory.h ugly/returncd.h ugly/fname.h ugly/utime.h ugly/prginfo.h \ ugly/ufile.h hsclib/hscprc.o: hsclib/hscprc.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h ugly/fname.h \ ugly/ustrlist.h ugly/returncd.h hsclib/idref.h hsclib/tag_if.h \ hsclib/css.h hsclib/idref.o: hsclib/idref.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h ugly/ustrlist.h \ hsclib/idref.h hsclib/include.o: hsclib/include.c hsclib/inc_base.h hsclib/ldebug.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ ugly/fname.h hsclib/input.h hsclib/parse.h hsclib/include.h hsclib/input.o: hsclib/input.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/linit.o: hsclib/linit.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/defattr.h \ hsclib/deftag.h hsclib/include.h hsclib/parse.h hsclib/tag_a.h \ hsclib/tag_hsc.h hsclib/tag_if.h hsclib/tag_macro.h hsclib/tag_misc.h \ hsc/hsc_rev.h ugly/fname.h hsclib/entities.c hsclib/lmessage.o: hsclib/lmessage.c hsclib/inc_base.h hsclib/ldebug.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ ugly/returncd.h hsclib/lstatus.o: hsclib/lstatus.c hsclib/inc_base.h hsclib/ldebug.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/parse.o: hsclib/parse.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h ugly/unikot.h \ hsclib/defattr.h hsclib/deftag.h hsclib/idref.h hsclib/include.h \ hsclib/input.h hsclib/parse.h hsclib/posteval.h hsclib/skip.h \ hsclib/size.h hsclib/uri.h hsclib/posteval.o: hsclib/posteval.c hsclib/inc_base.h hsclib/ldebug.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/idref.h hsclib/uri.h hsclib/size.o: hsclib/size.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/uri.h \ hsclib/css.h hsclib/skip.o: hsclib/skip.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/input.h \ hsclib/skip.h hsclib/tag.o: hsclib/tag.c hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h ugly/ufile.h hsclib/msgid.h hscprj/document.h \ hsclib/attrib.h hsclib/entity.h hsclib/tag.h hsclib/hscprc.h \ hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h hsclib/defattr.h hsclib/tag_a.o: hsclib/tag_a.c hsclib/inc_tagcb.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/input.h hsclib/skip.h hsclib/tag_hsc.o: hsclib/tag_hsc.c hsclib/inc_tagcb.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/input.h hsclib/skip.h ugly/fname.h hsclib/defattr.h \ hsclib/deftag.h hsclib/eval.h hsclib/include.h hsclib/parse.h \ hsclib/uri.h hsclib/css.h hsclib/tag_macro.h hsclib/tag_if.h hsclib/tag_if.o: hsclib/tag_if.c hsclib/inc_tagcb.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/input.h hsclib/skip.h hsclib/eval.h hsclib/parse.h hsclib/tag_macro.o: hsclib/tag_macro.c hsclib/inc_tagcb.h hsclib/inc_base.h \ hsclib/ldebug.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/input.h hsclib/skip.h hsclib/defattr.h hsclib/deftag.h \ hsclib/include.h hsclib/parse.h ugly/ustrlist.h hsclib/tag_misc.o: hsclib/tag_misc.c hsclib/inc_base.h hsclib/ldebug.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/infile.h ugly/ustring.h ugly/ufile.h hsclib/msgid.h \ hscprj/document.h hsclib/attrib.h hsclib/entity.h hsclib/tag.h \ hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h hsclib/lstatus.h \ hsclib/parse.h hsclib/skip.h hsclib/tcpip.o: hsclib/tcpip.c hsclib/tcpip.h ugly/utypes.h ugly/udebug.h \ ugly/umemory.h ugly/expstr.h hsclib/hscprc.h hsclib/ldebug.h \ hsclib/tag.h ugly/dllist.h hsclib/attrib.h ugly/infile.h \ hscprj/project.h hscprj/document.h ugly/ustring.h hsclib/lmessage.h \ hsclib/msgid.h hsclib/throwback.o: hsclib/throwback.c hsc/global.h hsclib/hsclib.h \ hsclib/inc_base.h hsclib/ldebug.h ugly/utypes.h ugly/udebug.h \ ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h ugly/ustring.h \ ugly/ufile.h hsclib/msgid.h hscprj/document.h hsclib/attrib.h \ hsclib/entity.h hsclib/tag.h hsclib/hscprc.h hscprj/project.h \ hsclib/lmessage.h hsclib/lstatus.h hsclib/include.h hsclib/linit.h \ hsc/hdebug.h hsclib/uri.o: hsclib/uri.c ugly/fname.h ugly/utypes.h ugly/udebug.h \ ugly/expstr.h ugly/ufile.h hsclib/inc_base.h hsclib/ldebug.h \ ugly/dllist.h ugly/umemory.h ugly/infile.h ugly/ustring.h \ hsclib/msgid.h hscprj/document.h hsclib/attrib.h hsclib/entity.h \ hsclib/tag.h hsclib/hscprc.h hscprj/project.h hsclib/lmessage.h \ hsclib/lstatus.h hsclib/idref.h hsclib/uri.h hsclib/tcpip.h hscprj/document.o: hscprj/document.c hscprj/document.h hsclib/ldebug.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h \ ugly/ustring.h ugly/infile.h hscprj/license.o: hscprj/license.c ugly/utypes.h ugly/udebug.h hscprj/project.o: hscprj/project.c hsclib/ldebug.h hscprj/pdebug.h ugly/utypes.h \ ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/umemory.h ugly/infile.h \ ugly/ustring.h hscprj/document.h hscprj/project.h hscprj/readprj.o: hscprj/readprj.c hsclib/ldebug.h hscprj/pdebug.h \ hscprj/pdefs.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h hscprj/document.h \ hscprj/project.h hscprj/writeprj.o: hscprj/writeprj.c hsclib/ldebug.h hscprj/pdebug.h \ hscprj/pdefs.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/umemory.h ugly/infile.h ugly/ustring.h hscprj/document.h \ hscprj/project.h hsctools/all_depp.o: hsctools/all_depp.c hsctools/hscdepp.c hsctools/depp_rev.h \ ugly/ustring.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/infile.h ugly/uargs.h ugly/umemory.h ugly/prginfo.h \ ugly/returncd.h hscprj/document.h hsclib/ldebug.h hscprj/project.h \ hscprj/license.h hsctools/all_pitt.o: hsctools/all_pitt.c hsctools/hscpitt.c hsctools/pitt_rev.h \ ugly/ustring.h ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h \ ugly/infile.h ugly/ufile.h ugly/uargs.h ugly/umemory.h ugly/ustrlist.h \ ugly/prginfo.h ugly/returncd.h hscprj/document.h hsclib/ldebug.h \ hscprj/project.h hscprj/license.h hsctools/hscdepp.o: hsctools/hscdepp.c hsctools/depp_rev.h ugly/ustring.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/infile.h \ ugly/uargs.h ugly/umemory.h ugly/prginfo.h ugly/returncd.h \ hscprj/document.h hsclib/ldebug.h hscprj/project.h hscprj/license.h hsctools/hscpitt.o: hsctools/hscpitt.c hsctools/pitt_rev.h ugly/ustring.h \ ugly/utypes.h ugly/udebug.h ugly/dllist.h ugly/expstr.h ugly/infile.h \ ugly/ufile.h ugly/uargs.h ugly/umemory.h ugly/ustrlist.h ugly/prginfo.h \ ugly/returncd.h hscprj/document.h hsclib/ldebug.h hscprj/project.h \ hscprj/license.h riscos/msgbrowser.o: riscos/msgbrowser.c riscos/throwback.o: riscos/throwback.c riscos/unixname.o: riscos/unixname.c riscos/unixname.h ugly/args_fre.o: ugly/args_fre.c ugly/utypes.h ugly/udebug.h ugly/umemory.h \ ugly/ustring.h ugly/dllist.h ugly/uargs.h ugly/args_hlp.o: ugly/args_hlp.c ugly/utypes.h ugly/udebug.h ugly/umemory.h \ ugly/ustring.h ugly/dllist.h ugly/uargs.h ugly/args_prp.o: ugly/args_prp.c ugly/utypes.h ugly/udebug.h ugly/umemory.h \ ugly/ustring.h ugly/dllist.h ugly/uargs.h ugly/args_set.o: ugly/args_set.c ugly/utypes.h ugly/udebug.h ugly/ufile.h \ ugly/expstr.h ugly/umemory.h ugly/ustring.h ugly/dllist.h ugly/uargs.h ugly/dllist.o: ugly/dllist.c ugly/utypes.h ugly/udebug.h ugly/umemory.h \ ugly/dllist.h ugly/expstr.o: ugly/expstr.c ugly/utypes.h ugly/udebug.h ugly/ustring.h \ ugly/umemory.h ugly/expstr.h ugly/fname.o: ugly/fname.c ugly/utypes.h ugly/udebug.h ugly/umemory.h \ ugly/ustring.h ugly/expstr.h ugly/fname.h ugly/infile.o: ugly/infile.c ugly/utypes.h ugly/udebug.h ugly/expstr.h \ ugly/ustring.h ugly/fname.h ugly/infile.h ugly/dllist.h ugly/umemory.h ugly/prginfo.o: ugly/prginfo.c ugly/utypes.h ugly/udebug.h ugly/uargs.o: ugly/uargs.c ugly/utypes.h ugly/udebug.h ugly/umemory.h \ ugly/ustring.h ugly/dllist.h ugly/uargs.h ugly/args_fre.c \ ugly/args_set.c ugly/ufile.h ugly/expstr.h ugly/args_prp.c \ ugly/args_hlp.c ugly/ufile.o: ugly/ufile.c ugly/utypes.h ugly/udebug.h ugly/umemory.h \ ugly/ustring.h ugly/expstr.h ugly/ufile.h ugly/umemory.o: ugly/umemory.c ugly/utypes.h ugly/udebug.h ugly/umemory.h ugly/unikot.o: ugly/unikot.c ugly/utypes.h ugly/udebug.h ugly/unikot.h ugly/ustring.o: ugly/ustring.c ugly/utypes.h ugly/udebug.h ugly/umemory.h \ ugly/ustring.h ugly/ustrlist.o: ugly/ustrlist.c ugly/umemory.h ugly/utypes.h ugly/udebug.h \ ugly/ustrlist.h ugly/ustring.h ugly/dllist.h hsc-0.934.orig/CHANGES0100600000175000001440000004403510010440004013122 0ustar loryusers CHANGES ======= This file describes improvements and fixes compared to earlier versions of hsc. The current version is mentioned first, for older versions, look below. --------------------------------------------------------------------- Version 0.934, 05-Feb-2004 (fixes, new port) all: - Crosscompiles for AROS now (only tested in hosted mode on Linux/x86 so far), see the Makefile for the set of options hsc: - The JPEG parser that gets the size information from a picture would crash if this information wasn't found within the first 2KB. The fixed version is an order of magnitude or so slower but should handle all JFIF-conforming pictures correctly now, including EXIF. - Error message #8 showed garbage at the end and no filename. Fixed. - The MOD operator was required to be uppercase. Fixed. prefs: - Fixed /MBI spec for the tag in XHTML mode Documentation: - Documented error messages #5 and #8 - HTML files are now created world-readable. This is mainly to support my laziness, but should be fine for installation in system-wide doc directories as well. --------------------------------------------------------------------- Version 0.933, 10-Jan-2004 (fixes) hsc: - Added error message #95 to signal network problems when checking extenal URIs instead of the previous quick-n-dirty perror() - A failed connect() was not considered an error, which of course it should - Added "Host:" line to HTTP request to make querying virtual servers work without a proxy - On systems other than Unices or AmigaOS, the TCP module compiles now but yields error #95 when trying to use it. - Plugged a small memory leak in get_http_hdr() - Cleaned up some embarassing socket mess --------------------------------------------------------------------- Version 0.932, 24-Dec-2003 (The Merry Xmas Release) (fixes, new features) hsc: - Fixed warning when XHTML mode but not QUOTEMODE=double was specified. This quotemode is now the default. - Added HTTP support for online checking of external links. - Compiles with a standard UNIX target on MacOS "Panther" now --------------------------------------------------------------------- Version 0.931, 10-Jul-2003 (fixes, new features) hsc: - Replaced the partial (and partially wrong) compiled-in entity list with the official and complete one from the W3C website. - Activated the ENTITYSTYLE option that had been hidden in there since Agi's times. HSC can now write entities either as found in the source, symbolically (like "ü"), numerically ("ü"), or as UTF-8 ("ü"). The latter is now the default for XHTML documents! - Added a PREFNUM attribute to <$defent>, meaning that the numeric representation should be used if ENTITYSTYLE=replace - Entities with a RPLC character may have arbitrary numeric representations, as long as these are above 160 (positions 128-159 are unused in Latin1 and Unicode!). This allows e.g. to replace the CP-1252 Euro symbol (#128, if your HSC source should be in this charset, which is not recommended) with a proper Unicode Euro (#8364). See the file "defent-cp1252.prefs" for a mapping from Unicode-illegal CP-1252 characters to Unicode. - Removed the undocumented (and fairly dangerous [well, you shouldn't have tried this at home in the first place!] BTW) option JENS/S. all: - Reverted to compilation of individual object files from each source. The significantly smaller executable size should give a bigger speed gain on today's cached memory architectures than a little aid to the global optimizer, which made sense on the virtually cache-less Amiga. documentation: - Updated the Requirements page, documented new features, corrected minor bits. --------------------------------------------------------------------- Version 0.930, 28-Apr-2003 (fixes) hsc: - No idea what broke the tag-nesting checks, but V0.929 silently accepted stuff like "blah" :-( Fixed! - The /AUTOCLOSE stuff was pretty much broken, probably since last century. HSC considered constructions like "
    blah
    foo
    " acceptable, and I'm quite sure has done so ever since. This was completely reworked and should neither let illegal constructions pass now nor moan about correct ones. - STRIPCOMMENTS is more selective now and only strips real SGML comments starting in "")> <$if COND=(set JSX)> <*---------------------------------------------------------------------------*> <* The frames/noframes switching magic :) * To generate the frames version, the symbol USE_FRAMES must be defined. * For the noframes version, the symbol FRAMES_NAVBAR must be set to the * filename of the HTML file that contains the navigation bar (it doesn't * hurt to set it for the frames version, too). The FRAME_MAGIC macro * generates the supposed source name by substituting "hsc" for the suffix * of this file. * The file-global variable FRAMES_NAVSIZE will be set if it isn't defined * already. It contains the percentage of the browser window's width to devote * to the navigation frame. *> <* This macro doesn't generate any text, only warnings *> <$macro _FRAMES_CHECK_NAVSIZE_DEF> <$define _default_navsize:string="15"> <$if COND=(not defined FRAMES_NAVSIZE)> <$message class=warning text=("Warning: FRAMES_NAVSIZE is not defined, using " + _default_navsize)> <$define FRAMES_NAVSIZE:num/GLOBAL/CONST=(_default_navsize)> <* inserts globally defined navigation bar file or an appropriate warning *> <$macro _FRAMES_INSERT_NAVIGATION_BAR> <$if COND=(DEFINED FRAMES_NAVBAR)> <$include FILE=((basename (FRAMES_NAVBAR))+".hsc")> <$else> Warning!FRAMES_NAVBAR was undefined when HSC processed this page. To generate proper noframes-pages, call HSC with DEF "FRAMES_NAVBAR:uri=my_navbar.html"! <$message class=warning text="FRAMES_NAVBAR is undefined - check output!"> <$macro _FRAMES_CHECK_NAVBARPOS_ENUM> <$define _navbarposlist:enum("left|right|top|bottom|l|r|t|b")> <* if you get an error here, your navbar position is not from the above list *> <$if COND=(defined PROJECT_FRAMES_NAVBAR_POS)> <$let _navbarposlist=(PROJECT_FRAMES_NAVBAR_POS)> <$else> <$message class=warning text="PROJECT_FRAMES_NAVBAR_POS is undefined - assuming 'left'!"> <$define PROJECT_FRAMES_NAVBAR_POS:string/GLOBAL/CONST='left'> <* An "intelligent" hyperlink. * This macro emits links to different files depending on whether frames * are in use or not. It tries to figure out what files to treat specially * from their suffix (for now and probably ever: everything that ends in * "html" or "htm" (yuck!)) * HTML files get special treatment in that site-internal links to them * that appear on a frameless page and without a special TARGET get the * "noframes" infix b/w their name and extension. * If you set the global variable DEFAULT_TARGETFRAME to a string, it will be used * as the default frame to open links in. *> <$macro HYPERLINK /CLOSE HREF:uri/R LEAVE:bool NEWWIN:bool TARGET:string REL:enum("contents|chapter|section|subsection|index|glossary|appendix|copyright|next|prev|start|help|bookmark|alternate") REV:enum("contents|chapter|section|subsection|index|glossary|appendix|copyright|next|prev|start|help|bookmark|alternate")> <$define TGT:string> <$define LNK:uri> <$if COND=(set Target)> <$if COND=(set Newwin)> <$message class=warning text="TARGET and NEWWIN are mutually exclusive - ignoring NEWWIN"> <$let TGT=(Target)> <$elseif COND=(set Newwin)> <$let TGT="_blank"> <* independent of frame use *> <$elseif COND=(set Leave)> <$let TGT="_top"> <$elseif COND=(defined DEFAULT_TARGETFRAME)> <$let TGT=(DEFAULT_TARGETFRAME)> <* determine file to link to *> <$if COND=((set TGT) or (defined USE_FRAMES) or ((urikind (HREF)) = "ext") or (not (((extension (HREF)) = "html") or ((extension (HREF)) = "htm" ))))> <* either using frames, or a custom target, or not referencing a local HTML file, so emit the link verbatim *> <$let LNK=(HREF)> <$else> <* not using frames nor a custom target, and referencing a local HTML file, so insert the "noframes" infix. *> <$let LNK=((basename (HREF))+"_nf."+(extension (HREF)))> <$content> <* The following will create a table with the navigation bar from the file * stored in FRAMES_NAVBAR *> <$macro FRAME_MAGIC /CLOSE /ONLYONCE /MBI="html" CLASS:string PAD:num='8'> <$if COND=(defined USE_FRAMES)> <* This page is part of a frameset *> <* Just insert the macro's content into a BODY and be done with it *> <$content> <$else> <* Creating a frameless page *> <_FRAMES_CHECK_NAVBARPOS_ENUM> <_FRAMES_CHECK_NAVSIZE_DEF> <$define _framespacing:num> <$if COND=(defined FRAMES_FRAMESPACING)> <$let _framespacing=(FRAMES_FRAMESPACING)> <* The following depends on the navigation bar's position *> <$if COND=((PROJECT_FRAMES_NAVBAR_POS = "left") or (PROJECT_FRAMES_NAVBAR_POS = "l"))> <_FRAMES_INSERT_NAVIGATION_BAR> <$elseif COND=((PROJECT_FRAMES_NAVBAR_POS = "right") or (PROJECT_FRAMES_NAVBAR_POS = "r"))> <_FRAMES_INSERT_NAVIGATION_BAR> <$elseif COND=((PROJECT_FRAMES_NAVBAR_POS = "top") or (PROJECT_FRAMES_NAVBAR_POS = "t"))> <_FRAMES_INSERT_NAVIGATION_BAR> <$else> <* bottom *> <_FRAMES_INSERT_NAVIGATION_BAR>
    <$content>
    <$content>
    <$content>
    <$content>
    <* Make a navigation frame either into an HTML page or part of a table. * TODO: - allow names other than "main" for the main frame *> <$macro NAVIGATION_FRAME /CLOSE CLASS:string STYLEFILE:uri DEFAULTFRAME:string="main" LANGUAGE:string JAVASCRIPT:string JAVASCRIPT-EXT:uri> <$define _navframecontents:string/CONST=(HSC.Content)> <$if COND=(defined USE_FRAMES)> <* Expand into a full-blown HTML file *> <$define DEFAULT_TARGETFRAME:string=(DEFAULTFRAME)>
    <(_navframecontents)> <$else> <* expand into a mere cell of a table, with much the same properties *> <* first insert javascript stuff that would otherwise be lost *> <_INSERT_JAVASCRIPT JS?=JAVASCRIPT JSX?=JAVASCRIPT-EXT> <(_navframecontents)> <* A little help for creating the frameset page using already defined stuff *> <$macro AUTO_FRAMESET /CLOSE /ONLYONCE /MBI="html" /NAW="body" NAVNAME:string/R MAINNAME:string/R MAINFILE:uri/R NORESIZE:bool> <$define frameborder:num> <$if COND=(defined FRAMES_FRAMEBORDER)> <$let frameborder=(FRAMES_FRAMEBORDER)> <_FRAMES_CHECK_NAVSIZE_DEF> <_FRAMES_CHECK_NAVBARPOS_ENUM> <* The following depends on the navigation bar's position *> <$if COND=((PROJECT_FRAMES_NAVBAR_POS = "left") or (PROJECT_FRAMES_NAVBAR_POS = "l"))> <$elseif COND=((PROJECT_FRAMES_NAVBAR_POS = "right") or (PROJECT_FRAMES_NAVBAR_POS = "r"))> <$elseif COND=((PROJECT_FRAMES_NAVBAR_POS = "top") or (PROJECT_FRAMES_NAVBAR_POS = "t"))> <$else> <* bottom *> <$content> <* The following two macros can help you build a navigation frame, like this: * * Page 1 * Page 2 * Page 3 * * * If you use only text in cells, this will also adapt decently to horizontal * and vertical layouts. * If you set the table's JSCLICKS attribute, the NAVCELLs will try to call * some javascript functions to highlight themselves and respond to clicks * even if you don't hit the link inside. Like these: * function over(cell){cell.style.background='#2AC410';cell.style.cursor='hand';} * function out(cell){cell.style.background='#156208';} * function click(cell){ var t,i,o=cell.childNodes; * for(i=0;o[i].nodeName!="A"&&i <$macro NAVCELL /CLOSE /MBI="navtable" U:uri/R> <$if COND=(defined NAVTABLE_USE_JAVASCRIPT)> <$define _navclickcell:string/C=''> <$else> <$define _navclickcell:string/C=''> <$if COND=((PROJECT_FRAMES_NAVBAR_POS = "top") or (PROJECT_FRAMES_NAVBAR_POS = "t") or (PROJECT_FRAMES_NAVBAR_POS = "bottom") or (PROJECT_FRAMES_NAVBAR_POS = "b"))> <(_navclickcell)><$content> <$else> <(_navclickcell)><$content> <$macro NAVTABLE /MBI="navigation_frame" /CLOSE JSCLICKS:bool> <$if COND=(set JSCLICKS)> <$define NAVTABLE_USE_JAVASCRIPT:bool> <$if COND=((PROJECT_FRAMES_NAVBAR_POS = "top") or (PROJECT_FRAMES_NAVBAR_POS = "t") or (PROJECT_FRAMES_NAVBAR_POS = "bottom") or (PROJECT_FRAMES_NAVBAR_POS = "b"))> <(Hsc.Content)> <$else> <(HSC.Content)> <*-----------------------------------------------------------------------*> <* GRAPHICS *> <*-----------------------------------------------------------------------*> <* This lets you insert a thumbnail picture in the current document, * automagically linked to the full-size picture. Specify the big image's name * as IMG, and the macro will assume the thumbnail has the same name with * "_tnail" added before the extension. NEWWIN opens the picture in a new * window, SIZE lets you add the full picture's size in kilobytes to either the * ALT text or the title. * * TODO: fix problem with absolute URIs *> <$macro THUMBNAIL PIC:uri/R ALT:string/R TITLE:string NEWWIN:bool SIZE:enum("alt|title") [__IAlign]> <$define _tnailname:string/C=((basename (PIC))+"_tnail."+(extension (PIC)))> <$define _tnailpath:string/C=(HSC.DestPath + HSC.Document.Path + _tnailname)> <$define _imgpath:string/C=(HSC.DestPath + HSC.Document.Path + PIC)> <$define _tgt:string> <$define _alttxt:string=(ALT)> <$define _titletxt:string> <$if COND=(set NEWWIN)> <$let _tgt="_blank"> <$if COND=(set SIZE)> <$if COND=(SIZE = "alt")> <$let _alttxt=(_alttxt + " [" + GetFileSize(PIC)+"]")> <$else> <$if COND=(set TITLE)> <$let _titletxt=(TITLE + " [" + GetFileSize(PIC)+"]")> <$else> <$let _titletxt=(GetFileSize(PIC))> <$else> <$if COND=(not (fexists(_tnailpath)))> <$if COND=(not ((defined _AUTOTHUMB-SCALE) and (defined _AUTOTHUMB-MINDIM)))> <$message class=error text="Auto-generated thumbnails need _AUTOTHUMB-SCALE and _AUTOTHUMB-MINDIM set!"> <$message class=note text=("No thumbnail for image " + PIC + ", generating...")> my $pix=""; my ($img,$tnail,$scale,$mindim) = @ARGV; $scale /= 100; my ($picw,$pich) = (`anytopnm $img 2>/dev/null | pnmfile` =~ /(\d+) by (\d+)/); $pix = "-xsize=$mindim",$scale=$mindim/$picw if($mindim > $picw*$scale); $pix = "-ysize=$mindim" if($mindim > $pich*$scale); $scale="" if(length $pix); # TODO: allow for output formats other than JPEG system("anytopnm $img 2>/dev/null | pnmscale 2>/dev/null $scale $pix | ppmtojpeg 2>/dev/null -optimize -quality=60 -dct=float >$tnail"); <$if COND=(defined HSC.Opts.XHTML)> <$if COND=(set NEWWIN)> <$message class=warning text="Sorry, NEWWIN doesn't work in XHTML mode!"> <$else> (_alttxt) <*-----------------------------------------------------------------------*> <* LAYOUT / TeX-ALIKE *> <*-----------------------------------------------------------------------*> <* the following is needed by both the footnote and bibliography macros below. It wraps TEXT in TAG like this: TEXT="foo" TAG="H1" ->

    foo

    *> <$macro _WRAP_STRING_IN_TAGS TEXT:string TAG:string> <$if COND=(set TEXT)> <$if COND=(set TAG)> <('<' + TAG + '>' + TEXT + '<' + '/' + TAG + '>' + HSC.LF)> <$else> <(TEXT + HSC.LF)> <$elseif COND=(set TAG)> <$message class=warning text="TAG is set, but no TEXT - ignored"> <*-------------------------------------*> <* Footnotes LaTeX style! *> <* FOOTNOTE is a container that inserts a superscripted number in place of its * contents, and appends the contents to a global variable (which is * created if nonexistant) instead, marked with a NAMEd anchor. * FOOTNOTES, inserted below in the document, will then interpolate this * variable as a numbered list. *> <$macro FOOTNOTE /CLOSE> <$if COND=(defined the_footnote_counter)><$stripws> <$let the_footnote_counter=(the_footnote_counter & "1")><$stripws> <$else><$stripws> <$define the_footnote_counter:num/GLOBAL=1><$stripws> <$define the_footnote_bucket:string/GLOBAL=''><$stripws> <$stripws> <$define ftnname:string/CONST=('footnote' + the_footnote_counter)><$stripws> <$let the_footnote_bucket = (the_footnote_bucket + '
  • ' + Hsc.Content + '<_FOOTNOTE_BACKLINK NUM=' + the_footnote_counter + '>
  • ' + HSC.LF)><$stripws> <(the_footnote_counter)><$stripws> <*-------------------------------------*> <* this macro inserts all footnotes accumulated during the processing of the current document as an
      . The footnote bucket is emptied, just in case you should want several "foot"note sections in one HTML file See bibliography macro below for TITLE and TC! *> <$macro FOOTNOTES TITLE:string="Footnotes" TC:string="H1" RULERS:bool BACKLINK:bool> <* don't expand to anything if footnotes are not in use *> <$if COND=(defined the_footnote_bucket)> <$if COND=(set BACKLINK)> <$macro _FOOTNOTE_BACKLINK NUM:num/R> [back] <$else> <$macro _FOOTNOTE_BACKLINK NUM:num/R> <* allow special attributes to be set via CSS *>
      <$if COND=(set RULERS)>
      <* either use project-global heading or convert arguments *> <$if COND=(defined PROJECT_FOOTNOTES_CAPTION)> <(PROJECT_FOOTNOTES_CAPTION)> <$else> <_WRAP_STRING_IN_TAGS TEXT?=TITLE TAG?=TC> <* interpolate footnote bucket as entries in a numbered list *>
        <(the_footnote_bucket)>
      <$if COND=(set RULERS)>
      <$let the_footnote_bucket=''> <*-------------------------------------*> <* Some LaTeXish bibliography macros *> <* Mainly a shortcut for some CSS stuff... TITLE is something like "Bibliography". For no title instead of the default (which can be set globally as PROJECT_BIBLIOGRAPHY_CAPTION), use "TITLE=''" TC is the optional "Title Container", i.e. usually some formatting stuff. Use TITLE="foo" TC="H3" for a result of

      foo

      TITLE may contain further tags or macros! *> <$macro THEBIBLIOGRAPHY /CLOSE TITLE:string="Bibliography" TC:string="H1">
      <$if COND=(defined PROJECT_BIBLIOGRAPHY_CAPTION)> <(PROJECT_BIBLIOGRAPHY_CAPTION)> <$else> <_WRAP_STRING_IN_TAGS TEXT?=TITLE TAG?=TC> <$content>
      <*-------------------------------------*> <* This should be fairly self-explanatory. More typing of attribute names than the typical LaTeX bibitem, but with an automagically consistent look! *> <$macro BIBITEM KEY:string/R AUTHOR:string/R DATE:string/R TITLE:string/R PLACE:string PUBLISHER:string TYPE:string EDITION:string> <$define entry:string=(AUTHOR + ': ' + TITLE + '')> <$if COND=(set TYPE)><$let entry=(entry + '. ' + TYPE)> <$if COND=(set EDITION)><$let entry=(entry + ', ' + EDITION)> <$if COND=(set PLACE)><$let entry=(entry + '. ' + PLACE)> <$if COND=(set PUBLISHER)><$let entry=(entry + ', ' + PUBLISHER)> <$let entry=(entry + ': ' + DATE)> [<(KEY)>] <(entry)> <*-------------------------------------*> <* Use this to refer to a citation in the text. SRC must be set to the BIBITEM's KEY value; TEXT is what is to appear as a "link". Leave it unset to get a clickable citation key. If you have a separate bibliography page, put its URI in BIBFILE or the global variable PROJECT_BIBLIOGRAPHY_URI (if both are set, BIBFILE takes precedence!) *> <$macro CITATION SRC:string/R TEXT:string BIBFILE:uri> <$define _linkto:string=''> <$define _linktext:string=''> <$let _linktext?=TEXT> <$if COND=(_linktext = '')><$let _linktext=(SRC)> <$if COND=(defined PROJECT_BIBLIOGRAPHY_URI)> <$let _linkto=(PROJECT_BIBLIOGRAPHY_URI)> <$let _linkto?=BIBFILE> [<(_linktext)>] <*-------------------------------------*> <* Table of contents *> <* The following macros implement LaTeX-like sections. To activate them, call * * somewhere at the start of your document. Depending on , the top-level * element will be either "section" or "chapter". To use special features of the * _TEX-SECTION macro like EXTRA (passes extra attributes to the opening tag of * the container around the section title, like

      ) or HDRLEVEL * (allows you to change the container tag around the title, although this is * not recommended), write your own wrappers like below. * SEPCHAR sets the character to separate section numbers with; NUMSTYLE can be * any one documented below for _CONVERT-NUMBER-SYSTEM's SYS attribute, so you * can number alphabetically, roman, or even hexadecimal :) *> <$macro GIMME-LATEX-SECTIONS /ONLYONCE DOC:enum("book|report|article")/R SEPCHAR:string NUMSTYLE:string BIAS:string> <$if COND=(DOC = "article")> <$macro SECTION TITLE:string/R><_TEX-SECTION LEVEL=1 TITLE=(TITLE)> <$macro SUBSECTION TITLE:string/R><_TEX-SECTION LEVEL=2 TITLE=(TITLE)> <$macro SUBSUBSECTION TITLE:string/R><_TEX-SECTION LEVEL=3 TITLE=(TITLE)> <$macro PARAGRAPH TITLE:string/R><_TEX-SECTION LEVEL=4 TITLE=(TITLE)> <$macro SUBPARAGRAPH TITLE:string/R><_TEX-SECTION LEVEL=5 TITLE=(TITLE)> <$else> <* same for book and report (PART is not supported) *> <$macro CHAPTER TITLE:string/R><_TEX-SECTION LEVEL=1 TITLE=(TITLE)> <$macro SECTION TITLE:string/R><_TEX-SECTION LEVEL=2 TITLE=(TITLE)> <$macro SUBSECTION TITLE:string/R><_TEX-SECTION LEVEL=3 TITLE=(TITLE)> <$macro SUBSUBSECTION TITLE:string/R><_TEX-SECTION LEVEL=4 TITLE=(TITLE)> <$macro PARAGRAPH TITLE:string/R><_TEX-SECTION LEVEL=5 TITLE=(TITLE)> <$macro SUBPARAGRAPH TITLE:string/R><_TEX-SECTION LEVEL=6 TITLE=(TITLE)> <$if COND=(set SEPCHAR)> <$define PROJECT_SECTIONS_SEPCHAR:string/C/G=(SEPCHAR)> <$if COND=(set NUMSTYLE)> <$define PROJECT_SECTIONS_NUMSTYLE:string/C/G=(NUMSTYLE)> <$if COND=(set BIAS)> <$define _bias1:string><$define _bias2:string><$define _bias3:string> <$define _bias4:string><$define _bias5:string><$define _bias6:string> <$define _l:num='0'><$define _m:num='1'> <$let _l = (_l & '1')> <$let {_bias + _l} = (extension BIAS)> <$let BIAS = (basename BIAS)> <$message class=warning text=('XBIAS: _bias' + _l + '=' + {_bias + _l} + ', BIAS=' + BIAS)> <$let {'the_section' + _m + '_counter'} = {_bias + _l}> <$message class=warning text=('BIAS: ' + 'the_section' + _m + '_counter=' + {'the_section' + _m + '_counter'})> <$let _l = (_l - '1')> <$let _m = (_m & '1')> <* This is what the actual section macros are based on. It's a general * sectioning macro with unlimited stacking depth. *> <$macro _TEX-SECTION LEVEL:num TITLE:string EXTRA:string HDRLEVEL:string> <$define sectnum:string=''> <$define ctrname:string=('the_section' + LEVEL + '_counter')> <$define styledctr:string=''> <* this section's number *> <$define hlvl:string> <* headerlevel is either defined explicitely or "Hx" where 1<=x<=6 *> <$if COND=(set HDRLEVEL)> <$let hlvl=(HDRLEVEL)> <$else> <$if COND=((LEVEL < '1') or (LEVEL > "6"))> <$message class=error text="LEVEL must be between 1 and 6 for current HTML versions!"> <$let hlvl=('H' + LEVEL)> <* add extra attributes if there are any defined *> <$if COND=(set EXTRA)> <$define open_hdr:string=("<" + hlvl + ' ' + EXTRA + ">")> <$else> <$define open_hdr:string=("<" + hlvl + ">")> <* simpler: the closing tag *> <$define close_hdr:string=("<" + "/" + hlvl + ">")> <* add to the current counter *> <( "<$if COND=(defined " + ctrname + ")>" + "<$let " + ctrname + "=(" + ctrname + " & '1')>" + "<$else>" + "<$define " + ctrname + ":num/GLOBAL='1'>" + "" )> <* make sure all higher-level counters exist *> <( "<$if COND=(not defined the_section" + i + "_counter)>" + "<$define the_section" + i + "_counter:num/GLOBAL='1'>" + "" )> <* zero all lower-level counters if there are any defined *> <$if COND=(defined {"the_section" + i + "_counter"})> <$let {"the_section" + i + "_counter"}='0'> <* concatenate the actual counters, potentially converted according to the * current NUMSTYLE and separated by periods or SEPCHARs *> <$if COND=(i > "1")> <$if COND=(defined PROJECT_SECTIONS_SEPCHAR)> <$let sectnum = (sectnum + PROJECT_SECTIONS_SEPCHAR)> <$else> <$let sectnum = (sectnum + '.')> <$if COND=(defined PROJECT_SECTIONS_NUMSTYLE)> <_CONVERT-NUMBER-SYSTEM N={"the_section" + i + "_counter"} DEST="styledctr" SYS=(PROJECT_SECTIONS_NUMSTYLE)> <$else> <$let styledctr={"the_section" + i + "_counter"}> <$let sectnum=(sectnum + styledctr)> <* insert the counter string and title at current location *> <( open_hdr + '' + sectnum + " " + TITLE + close_hdr )> <* if we want a table of contents, do this *> <$if COND=(defined PROJECT_GENERATE_TOC)> <* just write a single macro call to the TOC file. this gets expanded when TABLE-OF-CONTENTS reads in the file! *> <$export FILE=(HSC.Source.Path + (basename (HSC.Source.Name)) + ".toc") APPEND DATA=("" + HSC.LF)> <*-------------------------------------*> <* This macro converts a positive numeric value N to one of several numbering * systems SYS and stores the result in DEST: * numeric : no conversion * decimal : same as numeric * loweralpha: lowercase letters; a, b, c, ..., z, aa, ab,... * upperalpha: uppercase letters; A, B, C, ..., Z, AA, AB,... * alpha : same as loweralpha * lowerroman: lowercase roman numerals: i, ii, iii, iv, v, vi, ... * upperroman: uppercase roman numerals: I, II, III, IV, V, VI, ... * roman : same as upperroman * lowerhex : lowercase hexadecimal: 1, 2, 3, ..., a, b, ..., f, 10, 11, ... * upperhex : uppercase hexadecimal: 1, 2, 3, ..., A, B, ..., F, 10, 11, ... * hex : same as lowerhex *> <$macro _CONVERT-NUMBER-SYSTEM SYS:string/R DEST:string/R N:num/R> <$let {DEST} = ''> <$if COND=((SYS = 'numeric') or (SYS = 'decimal'))> <$let {DEST}=(N)> <$elseif COND=((SYS = 'roman') or (SYS = 'lowerroman') or (SYS = 'upperroman'))> <$if COND=(SYS = 'upperroman')> <$define _m:string/C='M'><$define _d:string/C='D'><$define _c:string/C='C'> <$define _l:string/C='L'><$define _x:string/C='X'><$define _v:string/C='V'> <$define _i:string/C='I'> <$else> <$define _m:string/C='m'><$define _d:string/C='d'><$define _c:string/C='c'> <$define _l:string/C='l'><$define _x:string/C='x'><$define _v:string/C='v'> <$define _i:string/C='i'> <$if COND=(N > '0')> <$if COND=(N >= '1000')> <$let {DEST} = ({DEST} + _m)> <$let N = (N - '1000')> <$elseif COND=(N >= '900')> <$let {DEST} = ({DEST} + _c + _m)><$let N = (N - '900')> <$elseif COND=(N >= '500')> <$let {DEST} = ({DEST} + _d)> <$let N = (N - '500')> <$elseif COND=(N >= '400')> <$let {DEST} = ({DEST} + _c + _d)><$let N = (N - '400')> <$elseif COND=(N >= '100')> <$let {DEST} = ({DEST} + _c)> <$let N = (N - '100')> <$elseif COND=(N >= '90')> <$let {DEST} = ({DEST} + _x + _c)><$let N = (N - '90')> <$elseif COND=(N >= '50')> <$let {DEST} = ({DEST} + _l)> <$let N = (N - '50')> <$elseif COND=(N >= '40')> <$let {DEST} = ({DEST} + _x + _l)><$let N = (N - '40')> <$elseif COND=(N >= '10')> <$let {DEST} = ({DEST} + _x)> <$let N = (N - '10')> <$elseif COND=(N >= '9')> <$let {DEST} = ({DEST} + _i + _x)><$let N = (N - '9')> <$elseif COND=(N >= '5')> <$let {DEST} = ({DEST} + _v)> <$let N = (N - '5')> <$elseif COND=(N >= '4')> <$let {DEST} = ({DEST} + _i + _v)><$let N = (N - '4')> <$else> <$let {DEST} = ({DEST} + _i)> <$let N = (N - '1')> <$elseif COND=((SYS = 'hex') or (SYS = 'lowerhex') or (SYS = 'upperhex'))> <$define _q:num> <$define _r:num> <$let _q = (N / '16')> <$let _r = (N - (_q * '16'))> <$if COND=(_r >= '10')> <$if COND=(SYS = 'upperhex')> <$let {DEST}=(chr(ord('A') & _r - '10') + {DEST})> <$else> <* lowerhex or hex *> <$let {DEST}=(chr(ord('a') & _r - '10') + {DEST})> <$else> <$let {DEST}=(_r + {DEST})> <$let N=(_q)> <$elseif COND=((SYS = 'alpha') or (SYS = 'loweralpha') or (SYS = 'upperalpha'))> <$let N=(N - '1')> <$if COND=(SYS = "upperalpha")> <$let {DEST}=((CHR((N MOD '26') & ORD("A"))) + {DEST})> <$else> <* loweralpha or alpha *> <$let {DEST}=((CHR((N MOD '26') & ORD("a"))) + {DEST})> <$let N = (N / '26')> <$else> <$message class=warning text=("Unknown numbering system '" + SYS + "', using 'numeric'!")> <$let {DEST}=(N)> <*-------------------------------------*> <* this macro will only be used in TOC-files written by the above macros * LEVEL: this entry's logical heading level * NUMBER: section number * TITLE: section title * * TODO: extend the whole system to allow for global TOC pages... (numbering?) * TODO: output TOCs for inclusion as navigation menus *> <$macro TABLE-OF-CONTENTS-ENTRY LEVEL:num/R NUMBER:string/R TITLE:string/R> <* Distinguish between the TABLE-OF-CONTENTS environment and TABLE-OF-CONTENTS-LINKS in HEADER *> <$if COND=(defined the_toc)> <* assign a style to the current row if text sizes should be adapted *> <$if COND=(defined _TOC_USE_TEXT_SIZES)> <$if COND=(LEVEL = "1")> <$define _tocentry:string=''> <$elseif COND=(LEVEL = "2")> <$define _tocentry:string=''> <$elseif COND=(LEVEL = "3")> <$define _tocentry:string=''> <$else> <$define _tocentry:string=''> <$else> <$define _tocentry:string=''> <* update max_toc_level (must be defined in TABLE-OF-CONTENTS!) *> <$if COND=(max_toc_level < LEVEL)><$let max_toc_level=(LEVEL)> <* emit an empty cell for indentation according to level *> <$if COND=(LEVEL > "1")> <$let _tocentry = (_tocentry + '')> <* add section number *> <$let _tocentry = (_tocentry + '' + NUMBER + '')> <* make a cell that stretches to the right of the table *> <$let _tocentry = (_tocentry + '')> <* emit a link, add title, close anchor, cell and row *> <$let _tocentry = (_tocentry + '' + TITLE)> <$let _tocentry = (_tocentry + '' + HSC.LF)> <* add _tocentry to the actual TOC string *> <* we have to delay the actual TOC creation until after all * TABLE-OF-CONTENTS-ENTRY macros have been processed, so max_toc_level has * its final value, therefore everything has to go into the_toc first! *> <$let the_toc = (the_toc + _tocentry)> <$else> <$let the_toclinks = (the_toclinks + '' + HSC.LF)> <*-------------------------------------*> <* This emits the actual table of contents in a nice TeXy format :-) * If your TOC-file is neither called .toc nor defined in * PROJECT_TOC_FILE, you may specify it as FILE. "TITLE" should be * self-explanatory. * TEXTSIZE make the TOC use bigger fonts for levels 1 and 2, which is * non-standard but may look nice in places anyway. * If your TOC is above the actual text, you will have to rerun HSC * if you change anything about the sections to see the changes in the TOC. If * the TOC file is missing on the first run, you will get a warning. *> <$macro TABLE-OF-CONTENTS TITLE:string FILE:string TEXTSIZE:bool> <$define max_toc_level:num=1> <$define the_toc:string=''> <$define tocfile:string> <$if COND=(defined PROJECT_GENERATE_TOC)> <$if COND=(set TEXTSIZE)> <$define _TOC_USE_TEXT_SIZES:bool> <$if COND=(set FILE)> <$let tocfile=(FILE)> <$elseif COND=(defined PROJECT_TOC_FILE)> <$let tocfile=(PROJECT_TOC_FILE)> <$else> <$let tocfile=(HSC.Source.Path + (basename (HSC.Source.Name)) + '.toc')> <$if COND=(Exists(tocfile))> <* include file with some TABLE-OF-CONTENTS-ENTRY macros and expand them *> <$include FILE=(tocfile)> <$else> <$define errormsg:string="Missing TOC file - rerun HSC to get it right!"> <$let the_toc=("" + errormsg + "")> <$message class=warning text=(errormsg)> <* now expand the actual TOC in a context where max_toc_level has its final value already *> <$if COND=(set TITLE)> <(the_toc)>
      <(TITLE)>
      <* get rid of the TOC file *> <*-----------------------------------------------------------------------*> <* HIERARCHICAL NAVIGATION MENUS *> <*-----------------------------------------------------------------------*> <* MENUITEMs link to a certain page from a hierarchical menu. The URI to link to * must be given by HREF; TEXT is the text to appear as a link. HREF must * currently be a project-relative URI, i.e. start in ':'. * NOTE: Due to the way TOPMENU works, MENUITEMS must not contain anything but * SUBMENUs! *> <$macro MENUITEM /CLOSE /MBI="topmenu|submenu" HREF:uri/R TEXT:string/R TITLE:string='__HSC_NO_TITLE__'> <$let _menu-rel-uri=(":" + HSC.Document.URI)> <* increment the item counter for the current menu level *> <$let {"_menu-itemctr"+_menu-level} = ({"_menu-itemctr"+_menu-level} & '1')> <$if cond=(_menu-try)> <* just do the checks, don't output any text *> <$if cond=({'_menu-expand' + _menu-level} = '0')> <* if no expansion has been found yet for the current level *> <$if cond=(_menu-rel-uri = HREF)> <* if HREF matches the current document's URI *> <* remember to expand the current level submenu and highlight the current item *> <$let {'_menu-expand' + _menu-level} = {'_menu-itemctr' + _menu-level}> <$let {'_menu-hilite' + _menu-level} = {'_menu-itemctr' + _menu-level}> <(hsc.content)> <* propagate the expansion request upwards *> <$if cond=({'_menu-expand' + _menu-level} = {'_menu-itemctr'+_menu-level})> <$let {'_menu-expand'+(_menu-level - '1')} = {'_menu-itemctr'+(_menu-level - '1')}> <$else> <* this generates the real menu in the second expansion *> <$if cond=({'_menu-hilite'+_menu-level}={"_menu-itemctr"+_menu-level})> <* the current item wants to be highlighted *> <(_activelinktagopen)><$stripws><(TEXT)><$stripws><(_activelinktagclose)> <$else> <* a regular item, visible but not active *> <_MENUITEM-TAG TITLE=(TITLE)><(TEXT)> <$stripws> <$if COND=(MENUKIND = "div")> <*

      ...

      is illegal, so the

      has 2b closed b4 *> <_MENUITEM-TAG CLOSE> <(hsc.content)> <$elseif COND=(MENUKIND = "list")> <* UL may only contain LI, not UL outside of an LI *> <(hsc.content)> <_MENUITEM-TAG CLOSE> <$else> <* must be TABLE menukind *> <(hsc.content)> <_MENUITEM-TAG CLOSE> <* This opens a new menu. The maximum submenu level is given by * MAXNESTDEPTH with a default of 4, which should be plenty for normal * applications. * The attributes: * MENUKIND defines the kind of menu to build. Currently, nested lists and * DIVs are supported. Lists handle the indentation of lower menu * levels automagically, but the style applied to remove annoying * bullet points may give strange results on older browsers such as * Netscape 4.x. Nested DIVs should be combined with AUTOCLASS to * get the appropriate indentation style. You may also want to * reduce the margins for paragraphs in this context. * Note: HTML's MENU tag is deprecated and thus not supported. * Note: TABLE-based menus are possible now, but don't work as they * should yet! * MENUSTYLE gives an extra STYLE attribute to apply to the whole * (top-level, inherited downwards) menu, e.g. to set the font size. * AUTOCLASS gives every menu level its own class, using the prefix specified * here, with a numeric suffix of 1..MAXNESTDEPTH. * MENUCLASS gives a certain CLASS attribute to this menu only * ITEMHLSTYLE specifies a style to apply to menuitems that get highlighted to * show the user the position in the menu hierarchy corresponding * to the current page. "background-color:#fff" or something... * ITEMHLEXTRA holds extra attributes to be added to items that should be * highlighted. * HILITELINK gives the ITEMHLSTYLE only to the link tag, not to the entire * menuitem * NOLINKCURRENT (set by default!) makes the entry for the current page a simple * text instead of an anchor. * JSCLICKS makes enclosed MENUITEMs add an 'onClick="menuclick(this)"' * attribute * * TOPMENUs may only contain MENUITEMs, which in turn may contain further * SUBMENUs. *> <$macro TOPMENU /CLOSE /MBI="body" /NAW="topmenu" MAXNESTDEPTH:num='4' MENUKIND:enum("list|div|table")="div" MENUSTYLE:string='' ITEMHLSTYLE:string ITEMHLEXTRA:string="" HILITELINK:bool AUTOCLASS:string MENUCLASS:string='' NOLINKCURRENT:bool='1' JSCLICKS:bool> <$define _menu-try:bool='1'> <$define _menu-level:num='1'> <$define _menu-rel-uri:uri> <$define _activelinktagopen:string> <$define _activelinktagclose:string> <$let MAXNESTDEPTH=(MAXNESTDEPTH & '1')> <* define arrays for item counters, menu expansion and highlighting *> <$define _arraycode:string> <_MAKE_ARRAYCODE N=(MAXNESTDEPTH) P=_menu-itemctr TYPE=num VAR=_arraycode DEFAULT='0'> <(_arraycode)> <_MAKE_ARRAYCODE N=(MAXNESTDEPTH) P=_menu-expand TYPE=num VAR=_arraycode DEFAULT='0'> <(_arraycode)> <_MAKE_ARRAYCODE N=(MAXNESTDEPTH) P=_menu-hilite TYPE=num VAR=_arraycode DEFAULT='0'> <(_arraycode)> <$if COND=(NOLINKCURRENT)> <$if COND=(set HILITELINK)> <$let _activelinktagopen='<("<_MENUITEM-TAG TITLE=(TITLE)>")>'> <$let _activelinktagclose = ''> <$else> <$let _activelinktagopen=('<("<_MENUITEM-TAG TITLE=(TITLE) STYLE?=ITEMHLSTYLE EXTRA=' + "'" + '" + ITEMHLEXTRA + "' + "'" + '>")>')> <$let _activelinktagclose = ''> <$else> <$if COND=(set HILITELINK)> <$let _activelinktagopen='<("<_MENUITEM-TAG TITLE=(TITLE)>")>'> <$else> <$let _activelinktagopen=('<("<_MENUITEM-TAG TITLE=(TITLE) STYLE?=ITEMHLSTYLE EXTRA=' + "'" + '" + ITEMHLEXTRA + "' + "'" + '>")>')> <$let _activelinktagclose = '' <* expand content once with _menu-try set *> <(hsc.content)> <* reset some variables *> <$let _menu-try=''> <$let _menu-level='1'> <$let {"_menu-itemctr" + i}='0'> <* open a new menu and expand everything anew, with _menu-try reset *> <_SUBMENU-TAG> <(hsc.content)> <_SUBMENU-TAG CLOSE> <* A SUBMENU may occur inside a MENUITEM and contain more MENUITEMs. See * TOPMENU for a description of MENUSTYLE/MENUCLASS *> <$macro SUBMENU /CLOSE /MBI="menuitem" MENUSTYLE:string='' MENUCLASS:string=''> <* increase the current menu level for per-level counter etc. *> <$let _menu-level=(_menu-level & '1')> <* if we're just trying, simply expand all contents *> <$if cond=(_menu-try)> <(hsc.content)> <$else> <* only expand contents if _menu-expand is our parent item's number *> <$if cond=({"_menu-expand" + (_menu-level - '1') } = {"_menu-itemctr" + (_menu-level - '1')})> <* put everything into an unsorted list *> <_SUBMENU-TAG> <(hsc.content)> <_SUBMENU-TAG CLOSE> <* zero the item counter for further submenus on the same level *> <$let {"_menu-itemctr" + _menu-level}='0'> <$let _menu-level=(_menu-level - '1')> <* Helper macros: generate submenu/item tags. They could be containers but * rather provide CLOSE attributes to avoid excessively deep container macro * nesting and consequent debugging problems. *> <$macro _SUBMENU-TAG CLOSE:bool> <* set the tag according to the desired MENUKIND *> <$if COND=(MENUKIND = "list")> <$define _tag:string="ul"> <$elseif COND=(MENUKIND = "div")> <$define _tag:string="div"> <$else> <$define _tag:string="table"> <* add appropriate closing slash or STYLE/CLASS attributes *> <$if COND=(set CLOSE)> <$let _tag = ("<" + "/" + _tag)> <$else> <$let _tag = ("<" + _tag)> <* MENUSTYLE has an empty default to allow for nesting SUBMENU macros *> <$if COND=(not (MENUSTYLE = ''))> <$let _tag=(_tag + ' STYLE="' + MENUSTYLE + '"')> <$if COND=((not (MENUCLASS = '')) or (set AUTOCLASS))> <$if COND=(not (MENUCLASS = ''))> <$let _tag=(_tag + ' CLASS="' + MENUCLASS + '"')> <$else> <$let _tag=(_tag + ' CLASS="' + AUTOCLASS + _menu-level + '"')> <* this actually yields the tag :) *> <(_tag + ">")> <$macro _MENUITEM-TAG CLOSE:bool STYLE:string TITLE:string='__HSC_NO_TITLE__' EXTRA:string=''> <$define _menuitem_tag:string> <$define _menuitem_tagopen:string> <$define _menuitem_attrs:string=""> <$if COND=(set CLOSE)> <$let _menuitem_tagopen=" <$if COND=(MENUKIND = "table")> <* table cells need special treatment as they need more than one tag *> <$let _menuitem_tag=("<" + "/td><" + "/tr")> <$else> <$let _menuitem_tagopen="<"> <$if COND=(set STYLE)> <$let _menuitem_attrs=(' STYLE="' + STYLE + '"' + EXTRA)> <$if COND=(not (TITLE = '__HSC_NO_TITLE__'))> <$let _menuitem_attrs=(_menuitem_attrs + ' TITLE="' + TITLE + '"')> <$if COND=(set JSCLICKS)> <$let _menuitem_attrs=(_menuitem_attrs + ' onClick="menuclick(this)"')> <$if COND=(MENUKIND = "table")> <$let _menuitem_tag=" <* list-kind menus get LI items, DIVs get Ps, TABLEs are treated above *> <$if COND=(MENUKIND = "list")> <$let _menuitem_tag=(_menuitem_tagopen + "li")> <$elseif COND=(MENUKIND = "div")> <$let _menuitem_tag=(_menuitem_tagopen + "p")> <* expand to tag *> <(_menuitem_tag + _menuitem_attrs + ">")> <*-----------------------------------------------------------------------*> <* DYNAMIC LAYOUT: COLUMNS AND GROUPS *> <*-----------------------------------------------------------------------*> <*-------------------------------------*> <* Dynamic layout with tables: use ROWGROUP or COLUMNGROUP to layout * arbitrarily many HTML objects of any kind in a regular grid: * * * * * * * * yields this layout: * i1 i4 * i2 i5 * i3 * while COLUMNGROUP would put them like this: * i1 i2 i3 * i4 i5 * * To start a new row/column respectively, use the COLUMNGROUP-NEWROW * and ROWGROUP-NEWCOLUMN macros. *> <$macro ROWGROUP /CLOSE NELEMS:num/R PAD:num BORDER:num STYLE:string CLASS:string> <$if COND=(NELEMS = '0')><$message class=fatal text="NELEMS must not be zero!"> <* the group level will be used in GROUPENTRY to deal with nested groups *> <$if COND=(not (defined _the_group_level))> <$define _the_group_level:string='1'> <$define _the_group_nelems:num=(NELEMS)> <$define _the_group_counter:num=(NELEMS)> <$define _the_group_columnwise:bool=''> <$define _the_group_arrayprefix:string=''> <$define _the_group_newrow:bool=''> <* only for nested COLUMNGROUPs *> <$define _groupentry_celltype:string=''> <* used in GROUPENTRYs *> <$else> <$let _the_group_level=(_the_group_level & '1')> <("<$define _the_group_nelems" + _the_group_level + ":num=(_the_group_nelems)>")> <("<$define _the_group_counter" + _the_group_level + ":num=(_the_group_counter)>")> <("<$define _the_group_columnwise" + _the_group_level + ":bool=(_the_group_columnwise)>")> <("<$define _the_group_arrayprefix" + _the_group_level + ":string=(_the_group_arrayprefix)>")> <("<$define _groupentry_celltype" + _the_group_level + ":string=(_groupentry_celltype)>")> <$let _the_group_nelems=(NELEMS)> <$let _the_group_counter=(NELEMS)> <$let _the_group_columnwise=''> <* construct prefix for the row array according to level *> <$let _the_group_arrayprefix=("_rowgroup_l" + _the_group_level + "r")> <* create variables 0 .. *> <(DEFARRAY_PRE)> <(DEFARRAY_POST)> <* insert all GROUPENTRYs, which will only add text to array vars! *> <(HSC.Content)> <* start the layout table *> <* now emit all rows previously accumulated in the array *> <({_the_group_arrayprefix + {"_rowgrp_emitctr" + _the_group_level}})>
      <$if COND=(_the_group_level > '1')> <$let _the_group_nelems={"_the_group_nelems" + _the_group_level}> <$let _the_group_counter={"_the_group_counter" + _the_group_level}> <$let _the_group_columnwise={"_the_group_columnwise" + _the_group_level}> <$let _the_group_arrayprefix={"_the_group_arrayprefix" + _the_group_level}> <$let _groupentry_celltype={"_groupentry_celltype" + _the_group_level}> <$let _the_group_level=(_the_group_level - '1')> <*-------------------------------------*> <$macro COLUMNGROUP /CLOSE NELEMS:num/R PAD:num BORDER:num CLASS:string> <$if COND=(NELEMS = '0')> <$message class=fatal text="NELEMS must not be zero!"> <$if COND=(not (defined _the_group_level))> <$define _the_group_level:string='1'> <$define _the_group_nelems:num=(NELEMS)> <$define _the_group_counter:num=(NELEMS)> <$define _the_group_columnwise:bool='1'> <$define _the_group_newrow:bool='1'> <* force new row on 1st element *> <$define _the_group_arrayprefix:string=''> <* only for nested ROWGROUPs *> <$define _groupentry_celltype:string=''> <* used in GROUPENTRYs *> <$else> <$let _the_group_level=(_the_group_level & '1')> <("<$define _the_group_nelems" + _the_group_level + ":num=(_the_group_nelems)>")> <("<$define _the_group_counter" + _the_group_level + ":num=(_the_group_counter)>")> <("<$define _the_group_columnwise" + _the_group_level + ":bool=(_the_group_columnwise)>")> <("<$define _the_group_newrow" + _the_group_level + ":bool=(_the_group_newrow)>")> <("<$define _groupentry_celltype" + _the_group_level + ":string=(_groupentry_celltype)>")> <$let _the_group_nelems=(NELEMS)> <$let _the_group_counter=(NELEMS)> <$let _the_group_columnwise='1'> <$let _the_group_newrow='1'> <(HSC.Content + "<$if COND=(_the_group_counter <> _the_group_nelems)>")>
      <$if COND=(_the_group_level > '1')> <$let _the_group_nelems={"_the_group_nelems" + _the_group_level}> <$let _the_group_counter={"_the_group_counter" + _the_group_level}> <$let _the_group_columnwise={"_the_group_columnwise" + _the_group_level}> <$let _the_group_newrow={"_the_group_newrow" + _the_group_level}> <$let _groupentry_celltype={"_groupentry_celltype" + _the_group_level}> <$let _the_group_level=(_the_group_level - '1')> <*-------------------------------------*> <$macro GROUPENTRY /CLOSE /MBI="rowgroup|columngroup" HEAD:bool> <* decide whether we want data cells or table headers *> <$if COND=(HEAD)> <$let _groupentry_celltype="TH"> <$else> <$let _groupentry_celltype="TD"> <* distinguish between row and column layouts *> <$if COND=(_the_group_columnwise)> <* if a new row has to be started, emit and reset flag *> <$if COND=(_the_group_newrow)> <$let _the_group_newrow=''> <* simply put the contents into a table cell or header *> <_WRAP_STRING_IN_TAGS TAG=(_groupentry_celltype) TEXT=(Hsc.Content)> <* decrement element counter *> <$let _the_group_counter=(_the_group_counter - '1')> <* check for end of row *> <_COLUMNGROUP_CHECKENDROW> <$else> <* if the element counter has expired, just reset it *> <$if COND=(_the_group_counter = '0')> <$let _the_group_counter=(_the_group_nelems)> <* decrement element counter *> <$let _the_group_counter=(_the_group_counter - '1')> <* add macro contents to current row's array variable *> <$let {_the_group_arrayprefix + ((_the_group_nelems - _the_group_counter) - '1')} = ({_the_group_arrayprefix + ((_the_group_nelems - _the_group_counter) - '1')} + "<" + _groupentry_celltype + ">" + HSC.Content + "<" + "/" + _groupentry_celltype + ">")> <* This is highly experimental... *> <$macro COLUMNGROUP-NG /CLOSE NELEMS:num/R CLASS:string> <$if COND=(NELEMS = '0')> <$message class=fatal text="NELEMS must not be zero!"> <$if COND=(not (defined _the_group_level))> <$define _the_group_level:string='1'> <$define _the_group_nelems:num=(NELEMS)> <$define _the_group_counter:num=(NELEMS)> <$define _the_group_columnwise:bool='1'> <$define _the_group_newrow:bool='1'> <* force new row on 1st element *> <$define _the_group_arrayprefix:string=''> <* only for nested ROWGROUPs *> <$else> <$let _the_group_level=(_the_group_level & '1')> <("<$define _the_group_nelems" + _the_group_level + ":num=(_the_group_nelems)>")> <("<$define _the_group_counter" + _the_group_level + ":num=(_the_group_counter)>")> <("<$define _the_group_columnwise" + _the_group_level + ":bool=(_the_group_columnwise)>")> <("<$define _the_group_newrow" + _the_group_level + ":bool=(_the_group_newrow)>")> <$let _the_group_nelems=(NELEMS)> <$let _the_group_counter='0'> <$let _the_group_columnwise='1'> <$let _the_group_newrow='1'> <_GROUPING-TABLE CLASS?=CLASS> <(HSC.Content + "<$if COND=(_the_group_counter <> _the_group_nelems)><_GROUPING-TABLE-ROW CLOSE>")> <_GROUPING-TABLE CLOSE> <$if COND=(_the_group_level > '1')> <$let _the_group_nelems={"_the_group_nelems" + _the_group_level}> <$let _the_group_counter={"_the_group_counter" + _the_group_level}> <$let _the_group_columnwise={"_the_group_columnwise" + _the_group_level}> <$let _the_group_newrow={"_the_group_newrow" + _the_group_level}> <$let _the_group_level=(_the_group_level - '1')> <$macro GROUPENTRY-NG /CLOSE /MBI="rowgroup-ng|columngroup-ng"> <* distinguish between row and column layouts *> <$if COND=(_the_group_columnwise)> <* if a new row has to be started, emit and reset flag *> <$if COND=(_the_group_newrow)> <_GROUPING-TABLE-ROW><$let _the_group_newrow=''> <* simply put the contents into a table cell or header *> <_GROUPING-TABLE-CELL> <(Hsc.Content + "<$if COND=(_the_group_counter <> _the_group_nelems)><_GROUPING-TABLE-ROW CLOSE>")> <_GROUPING-TABLE-CELL CLOSE> <* decrement element counter *> <$let _the_group_counter=(_the_group_counter - '1')> <* check for end of row *> <_COLUMNGROUP-NG_CHECKENDROW> <$else> <* if the element counter has expired, just reset it *> <$if COND=(_the_group_counter = '0')> <$let _the_group_counter=(_the_group_nelems)> <* decrement element counter *> <$let _the_group_counter=(_the_group_counter - '1')> <* add macro contents to current row's array variable *> <$let {_the_group_arrayprefix + ((_the_group_nelems - _the_group_counter) - '1')} = ({_the_group_arrayprefix + ((_the_group_nelems - _the_group_counter) - '1')} + "<_GROUPING-TABLE-ROW>" + HSC.Content + "<_GROUPING-TABLE-ROW CLOSE>")> <$macro _COLUMNGROUP-NG_CHECKENDROW> <* close row if element counter has reached zero *> <$if COND=(_the_group_counter = '0')> <_GROUPING-TABLE-ROW CLOSE> <* reset counter and set flag for new row on next groupentry *> <$let _the_group_counter=(_the_group_nelems)> <$let _the_group_newrow='1'> <$macro _GROUPING-TABLE CLOSE:bool CLASS:string PAD:string BORDER:num> <$if COND=(set CLOSE)> <$if COND=(defined HSC.Opts.XHTML)> <$else> <$else> <$if COND=(defined HSC.Opts.XHTML)> <$if COND=(set CLASS)>

      <$else>
      <$else> <$macro _GROUPING-TABLE-ROW CLOSE:bool CLASS:string> <$message class=warning text="New row"> <$if COND=(set CLOSE)> <$if COND=(defined HSC.Opts.XHTML)><$else> <$else> <$if COND=(defined HSC.Opts.XHTML)> <$if COND=(set CLASS)>
      <$else>
      <$else>
      <$macro _GROUPING-TABLE-CELL CLOSE:bool CLASS:string> <$if COND=(set CLOSE)> <$if COND=(defined HSC.Opts.XHTML)><$else> <$else> <$if COND=(defined HSC.Opts.XHTML)> <$if COND=(set CLASS)>
      <$else>
      <$else>
      "> <$else> <$define _newcolumn_fillcell:string/C=""> <$let {_the_group_arrayprefix + ((_the_group_nelems - i) - '1')} = ({_the_group_arrayprefix + ((_the_group_nelems - i) - '1')} + _newcolumn_fillcell)> <$let _the_group_counter=0> <*-------------------------------------*> <$macro COLUMNGROUP-NEWROW /MBI="columngroup" CELLS:bool> <$if COND=(HEAD)> <$define _newrow_fillcell:string/C=""> <$else> <$define _newrow_fillcell:string/C=""> <$if COND=(set CELLS)> <$let _the_group_counter=(_the_group_counter - '1')> <(_newrow_fillcell)> <$else> <$let _the_group_counter='0'> <_COLUMNGROUP_CHECKENDROW> <*-------------------------------------*> <$macro _COLUMNGROUP_CHECKENDROW> <* close row if element counter has reached zero *> <$if COND=(_the_group_counter = '0')> <* reset counter and set flag for new row on next groupentry *> <$let _the_group_counter=(_the_group_nelems)> <$let _the_group_newrow='1'> <*-------------------------------------*> <* This adds the string ":" to DEST, possibly separated with a * semicolon if DEST was defined before. If ATTR is undefined, does nothing, * so it is safe to use it like this: * <$macro FOO SOME:string PARAMETER:num> * <$define styleattr:string> * <_MAKE-CSS-STYLE ATTR?=SOME NAME=some DEST=styleattr> * <_MAKE-CSS-STYLE ATTR?=PARAMETER NAME=other DEST=styleattr> * *> <$macro _MAKE-CSS-STYLE ATTR:string NAME:string/R DEST:string/R> <$if COND=(set ATTR)> <$if COND=(set {DEST})> <$let {DEST}=({DEST} + ';' + NAME + ':' + ATTR)> <$else> <$let {DEST}=(NAME + ':' + ATTR)> <*-----------------------------------------------------------------------*> <* * $Log: macros.hsc,v $ * Revision 1.68 2004/02/05 09:43:23 mb * Added TITLE attribute to MENUITEM * Added (experimental) BIAS to GIMME-LATEX-SECTIONS * * Revision 1.67 2004/01/21 07:49:02 mb * Added NOLINKCURRENT attribute to TOPMENU, hopefully aiding usability * * Revision 1.66 2004/01/19 12:06:23 mb * Simplified BREAK a little, added ORDINAL, improved BIBITEM * * Revision 1.65 2003/12/23 16:59:06 mb * Rewrote experimental (and still broken) grouping macros * * Revision 1.64 2003/12/20 11:36:46 mb * Bugfix: added EXTRA attribute to _MENUITEM-TAG helper macro * Reduced default menu's MAXNESTDEPTH to 4 * * Revision 1.63 2003/11/06 11:17:32 mb * Added BACKLINK attribute to FOOTNOTES * * Revision 1.62 2003/11/06 10:49:28 mb * Added MENUCLASS to TOPMENU and SUBMENU macros * Removed automatic "list-style-type: none" from list-style menus. If you want * this look, enable it yourself in a class definition; I use: * .menu a[href] { display: block; } * .menu ul { padding-left: 0em; font-size: 120%; list-style-type: none; line-height: 140%; } * .menu ul ul { padding-left: 1em; font-size: 68%; } * .menu ul ul ul { font-size: 75%; } *> <* vi: set tabstop=2 expandtab nowrap: *> hsc-0.934.orig/macros.readme0100600000175000001440000000750407772072345014630 0ustar loryusersThe following is a more or less complete list of macros distributed with HSC, grouped by function. The "$macro" tag has been omitted, otherwise the definition is identical to the one in macros.hsc. A more detailed documentation can be found in macros.hsc itself. GENERAL UTILITY =============== <_CONVERT-NUMBER-SYSTEM SYS:string/R DEST:string/R N:num/R> <_MAKE-CSS-STYLE ATTR:string NAME:string/R DEST:string/R> LOOPS ===== ARRAYS ====== <_MAKE_ARRAYCODE N:num/R P:string/R VAR:string/R TYPE:string='string's DEFAULT:string GLOBAL:bool> <(DEFARRAY_PRE)> <(DEFARRAY_POST)> SCRIPTING ========= PAGES AND FRAMES ================
      GRAPHICS ======== LAYOUT / TEX ============ provides the following macros
      MENUS ===== DYNAMIC LAYOUT ============== hsc-0.934.orig/smakefile0100600000175000001440000000521607770472430014043 0ustar loryusers# # Makefile for hsc ("html sucks completely") # # Copyright (C) 2002 Matthias Bethke # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # # Now that HSC development has continued on Linux for a while, it seems time for # a "backport" to AmigaOS. # /me digs for smakefile syntax under the new heaps of GNUwledge... # NOTE: this smakefile is *not* "standalone. It requires dependencies generated # only by the GNU Makefile, and it can't do any of the things that require # sh/bash functionality CFLAGS=OPT OPTSCHED ANSI CPU=68020 DEF AMIGA IGN=304 IGN=315 COMP=sc $(CFLAGS) .c.o: $(COMP) $*.c # # symbols for objects and executables # OBJ_TOOLS = ugly/umemory.o ugly/ustring.o ugly/unikot.o ugly/expstr.o \ ugly/fname.o ugly/dllist.o ugly/ufile.o ugly/uargs.o \ ugly/ustrlist.o ugly/infile.o ugly/prginfo.o \ hscprj/document.o hscprj/license.o hscprj/project.o \ hscprj/readprj.o hscprj/writeprj.o OBJ_HSC = $(OBJ_TOOLS) \ hsclib/lmessage.o hsclib/entity.o hsclib/tag.o hsclib/attrib.o \ hsclib/idref.o hsclib/hscprc.o hsclib/lstatus.o hsclib/input.o \ hsclib/skip.o hsclib/uri.o hsclib/eval.o hsclib/posteval.o \ hsclib/defattr.o hsclib/deftag.o hsclib/css.o hsclib/parse.o \ hsclib/include.o hsclib/linit.o hsclib/size.o hsclib/tag_misc.o \ hsclib/tag_a.o hsclib/tag_hsc.o hsclib/tag_if.o \ hsclib/tag_macro.o \ hsc/global.o hsc/status.o hsc/callback.o hsc/args.o \ hsc/output.o hsc/hsc.o OBJ_DEPP = hsctools/hscdepp.o OBJ_PITT = hsctools/hscpitt.o OBJ_ALL = $(OBJ_HSC) EXE_ALL = hsc/hsc hsctools/hscdepp hsctools/hscpitt # # compile all tools # all : $(EXE_ALL) hsc/hsc : $(OBJ_HSC) slink
      <*-------------------------------------*> <$macro ROWGROUP-NEWCOLUMN /MBI="rowgroup" HEAD:bool> <$if COND=(_the_group_counter)> <$if COND=(HEAD)> <$define _newcolumn_fillcell:string/C="