/*
    ####             #    #     # #
    #   #            #    #       #          The FreeWare C library for 
    #   #  ##   ###  #  # #     # ###             RISC OS machines
    #   # #  # #     # #  #     # #  #   ___________________________________
    #   # ####  ###  ##   #     # #  #                                      
    #   # #        # # #  #     # #  #    Please refer to the accompanying
    ####   ### ####  #  # ##### # ###    documentation for conditions of use
    ________________________________________________________________________

    File:    TextFile.h
    Author:  Copyright  1992 Jason Williams
    Version: 1.00 (07 Apr 1992)
    Purpose: Generic textfile-handling routines
*/


#ifndef __dl_textfile_h
#define __dl_textfile_h

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>

#define TextFile_Lowercase(x) (((x)>='A' && (x)<='Z') ? (x)+32 : (x))


extern void TextFile_SkipBlanks(FILE *infile);
/*  reads characters from the given file until eof or until a non-blank
 *  (space or tab character) is found.
 */


extern void TextFile_GetToken(FILE *infile, char delimiter,
                              char *token,  BOOL lowercase);
/*  Read in a token from a file. A token is defined as:
 *    A sequence of up to 32 characters, delimited by a specific character
 *    or a newline. Leading spaces/tabs are ignored.
 *
 *  This is generally used to read a word from a textfile (delimiter = ' ')
 *  or to read tags from a msgtrans style file (delimiter = ":")
 */


extern void TextFile_ReadToDelimiter(FILE *infile, char delimiter,
                                     char *line, int maxlength);
/*  Reads characters from the given file until eof or delimiter character
 *  Delimiter is typically a newline character, which gives read-to-eol
 *  Leading spaces/tabs are ignored
 *  Won't read more than "maxlength" characters (maxlength *includes* 0
 *  string-terminating character)
 */

#ifdef __cplusplus
}
#endif

#endif
