
#ifdef TPLTER

Tackon = {

    SHORT = {{ join path, filename and suffix }};

    DESCRIPTION = {{
	Tackon gets a filename and perhaps a pathname and a
	suffix and creates a new filename out of them.

	To add correctly filename to pathname we use AmigaDOS.

	If the suffix starts with a "." or "_" (any non
	alnum character), it is directly appended to the
	full filename;
	if suffix starts with an alphanumeric char,
	a "." is prepended.

	The resulting string is sent to STDOUT

     RESULT
	a filename created with the inputs.
    }};

    BUGS = {{
	* there is no check (yet), if suffix is itself a path
	* the resulting filename must not be bigger than 256 chars
	there is a strange behaviour if compiled w/ DICE;
	* I cannot say why, but If You do not specify
	each input-slot, You will get a Enforcer-Hits;
	for that reason, I'll distribute Chris' SAS-executable
    }};

    EXAMPLES = {{
	>Tackon x: a:b _c
	a:b_c

	>Tackon x:a b c
	x:a/b.c

	> tackon xx yy zz
	xx/yy.zz

	> tackon xx :yy -zz
	:yy-zz
    }};

    SEEALSO = {{
	dos.library/AddPart
	Suffix, PathPart, FilePart
    }};

    HISTORY = {{
	01-08-93 b_noll created
	20-02-95 b_noll restructured source, removed mstrcpy
	21-02-95 b_noll added version/format-prefix/offset
	27-02-95 b_noll removed an Enforcer Hit (huch!)
	20-03-95 b_noll added args diagnostics
	20-03-95 b_noll fixed crash, if resultstring was too large,
			always returned RETURN_WARN
	19-08-95 b_noll created .data file
    }};



    includes = { "<strings.h>" };



Template = "PATH,NAME/A,SUFFIX";
Arguments = {{
    STRPTR path;
    STRPTR name;
    STRPTR suffix;

#define isalnum(x) ((((x) <= '9') && ((x >= '0'))) || (((x) <= 'Z') && ((x >= 'A'))) || (((x) <= 'z') && ((x >= 'a'))))
#define BODY(x)      do{ x }while(0)
#define findlast(s)  BODY(char*td=(s);while(*td) ++td; (s)=td;)
}};

    version = "1.2";

    body = {{
	    char* b2;
	    char* buffer;
	    if (buffer = AllocMem(MAXPATHLEN, 0)) {

		retval	= RETURN_WARN;
		*buffer = 0;

		strcpy (buffer, argv->path);

		if (AddPart (buffer, argv->name, MAXPATHLEN-1)) {

		    b2 = buffer;
		    while (*b2) ++b2;
		    if (argv->suffix) {
			if (isalnum(*argv->suffix)) {
			    *b2   = '.';
			    ++b2;
			    *b2 = 0;
			} /* if */
		    } /* if */

		    if (!PutStr (buffer)) retval = RETURN_OK;
		    if (argv->suffix)
			PutStr (argv->suffix);

		    PutStr ("\n");
		} else {
		    //SetIoErr(ERROR_OBJECT_TOO_LARGE);
		} /* addpart */
		FreeMem (buffer, MAXPATHLEN);
	    } /* if */

    }};

};

#endif

