view util.h @ 29:4d455c29bfd1 noffle

[svn] Send MODE READER for INN
author enz
date Sun, 30 Apr 2000 12:17:40 +0100
parents 526a4c34ee2e
children 8e972daaeab9
line wrap: on
line source

/*
  util.h

  Miscellaneous helper functions.

  $Id: util.h 32 2000-04-29 14:45:56Z enz $
*/

#ifndef UTL_H
#define UTL_H

#include <time.h>
#include "common.h"

/*
  Find first non-whitespace character after <token> tokens in string <line>.
  Return pointer to end of string, if parsing failed.
*/
const char *
Utl_restOfLn( const char *line, unsigned int token );

void
Utl_toLower( Str line );

/*
  Read a line from string.
  Return NULL if pos == NULL or no more line to read
*/
const char *
Utl_getLn( Str result, const char *p );

/*
  Go back to last line.
*/
const char *
Utl_ungetLn( const char *str, const char *p );

/*
  Read a header line from string. Reads continuation lines if
  necessary. Return NULL if pos == NULL or no more line to read
*/
const char *
Utl_getHeaderLn( Str result, const char *p );

/*
  Strip white spaces from left and right side.
  Return pointer to new start. This is within line.
*/
char *
Utl_stripWhiteSpace( char *line );

/* Write timestamp into <file>. */
void
Utl_stamp( Str file );

/* Get time stamp from <file> */
Bool
Utl_getStamp( time_t *result, Str file );

void
Utl_cpyStr( Str dst, const char *src );

void
Utl_cpyStrN( Str dst, const char *src, size_t n );

void
Utl_catStr( Str dst, const char *src );

void
Utl_catStrN( Str dst, const char *src, size_t n );

/* String allocation and copying. */
void
Utl_allocAndCpy( char **dst, const char *src );

/*
  Do shell-style pattern matching for ?, \, [], and * characters.
*/
Bool
Utl_matchPattern( const char *text, const char *pattern );

#endif