environ.h


Headers Index Help      Within this page: Functions Constants Variables


Overview

The environ library

- written by Martin Gregorie, June, 2005.

This library was initially developed to allow me to write C code that could be ported between the OS-9 and MS-DOS environments with minimal code changes and, so far as possible, to restrict machine-dependent code to functions within this library. It was later extended for portability to Linux as well.

A major part of this library's development involved implementing, e.g., library functions peculiar to MS-DOS, which has a lot of library functions that are not part of the standard C libraries, within the OS-9 and Linux environments. As a result of this philosophy, the package exists in three distinct forms because functions provided by each native C library are omitted from the version of this package for that environment.

On top of this, the library has been extended to incorporate a number of generally useful functions that are used in many programs, such as the error trapping and tracing functions and the improved command line parsing functions.

As a result of both the portability and convenience functions, almost every program I write uses part of this library, so it is documented and distributed with all such open source programs.

The library contents fall into a number of categories:

This collection of functions is compiled to form part of the libenviron.a library, which must be linked if any of of its constituent functions are called.

Running the environ utility will display the version and release date of the library.

Compilation

The calling programs should include environ.h and must be linked using -lenviron.

environ - C programming support functions
Copyright (C) 2005 Martin C Gregorie

This program is free software; you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License.

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 Lesser GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Contact Martin Gregorie at martin@gregorie.org

Functions

Include files defined in the header, environ.h, are shown in italics.


argval

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int argval(char *s, int d);

Convert a string to an integer, using the second parameter as the default if the string is empty. This is intended to be used in conjunction with getopt() to handle options with optional integer values which default to zero if the option is omitted or to some known value if the option is present in the command line but without a specified value:

See also: getopt(), getarg()

In: argval.c

Return to the top

autodate

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

CHARDATE autodate(struct tm *tbp, int fmt, int code);

Formats dates to a display layout, taking national preferences into account where necessary. tm is the standard UNIX time structure, holding the components of a date and time. This contains the date that is to be formatted for display. fmt is one of:

Returns CHARDATE, which points to a static string containing the formatted date.

The default country is defined in /usr/local/etc/country and retrieved by a call to country().

See also country()

In: autodate.c

Return to the top

autotime

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

CHARTIME autotime(struct tm *tbp);

Returns CHARTIME, which points to a string containing the time formatted for a 12 hour or 24 hour clock to suit the default country.

The default country is defined in /usr/local/etc/country and retrieved by a call to country().

See also country()

In: autodate.c

Return to the top

bitsout

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *bitsout(int v, int n);

Display the last n bits of the integer value v. Returns a string containing the value as a list of 0 and 1 characters.

In: bitsout.c

Return to the top

buff_add_one

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int buff_add_one(CIRC_BUFF *b, char c);

Add a byte c into the circular buffer b. Returns 1 if a byte was added. If the buffer is full zero is returned.

In: buffer.c

Return to the top

buff_add_string

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void buff_add_string(CIRC_BUFF *b, char *s, int n);

Move n characters from s into a circular buffer, b. You should call buff_freespace() first to check that there is enough space in the buffer to hold the string.

In: buffer.c

Return to the top

buff_create

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

CIRC_BUFF *buff_create(int size);

Create and initialise a circular buffer. The size of the buffer is set by the size argument and, once set, cannot be changed without recreating the buffer.

In: buffer.c

Return to the top

buff_delete

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

CIRC_BUFF *buff_delete(CIRC_BUFF *b);

Release the space occupied by a circular buffer. Returns NULL.

In: buffer.c

Return to the top

buff_extract_one

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int buff_extract_one(CIRC_BUFF *b);

Return the next byte from the circular buffer b. Returns zero if the buffer is empty and -1 for errors.

In: buffer.c

Return to the top

buff_extract_string

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int buff_extract_string(CIRC_BUFF *b,
                        char *s,
                        int  n,
                        int  sep_active,
                        int  sep_extern,
                        char sep_marker);

Pull up to n characters out of a circular buffer, b, and put them in the reply area, s. Use the separator in sep_marker, if sep_active is true, as the string terminator. Separators are discarded (sep_extern is true) or included in the string (sep_extern is false). Returns the number of bytes extracted.

In: buffer.c

Return to the top

buff_freespace

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int buff_freespace(CIRC_BUFF *b);

Returns the available space in the circular buffer

In: buffer.c

Return to the top

buff_reset

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void buff_reset(CIRC_BUFF *b);

Initialise (reset) a circular buffer.

In: buffer.c

Return to the top

buff_size

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int buff_size(CIRC_BUFF *b);

Return the size of a circular buffer

In: buffer.c

Return to the top

buff_usedspace

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int buff_usedspace(CIRC_BUFF *b);

Returns the occupied space in the circular buffer.

In: buffer.c

Return to the top

byteout

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *byteout(char c);

Returns a pointer to an internal static string containing the byte c or its hexadecimal equivalent formatted as "<hh>". The string contains the unmodified byte provided it is an ASCII character, is printable and is not a control character.

This function should not appear more than once in a formatted print statement because all such calls be evaluated before the formatted output is generated. By this time the internal static string will contain the result of the final call and all such byte decodings will apparently result in the same (final) value.

If this is necessary, capture each decoded value in a separate string and print from these:

      char trap[5];
      strcpy(trap, byteout(cval));
      fprint("Caught %s\n", trap);
   

This function is primarily intended as a debugging aid.

In: byteout.c

Return to the top

capitalise

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *capitalise(char *s);

Convert the first character of a string to upper case and the remainder to lower case.

In: capitalise.c

Return to the top

check_range

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void check_range(int val, int low, int high, char *desc);

Range_check the value val. It it is outside the range low - high the program is terminated by calling error() to output the error message:

program: desc must be in range low - high

It is intended for use during run-time parameter checking.

In: check_range.c

Return to the top

chopinsert

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int chopinsert(void **Table,
               int *Items,
               int Tablimit,
               void *NewItem,
               int InsertPoint);

chopinsert() is called to add a missing item into the array. Table is the array into which the item must be inserted. Items contains the number of items in the array. It is incremented to reflect the new number of items in the array after a successful insertion. Tablimit contains the maximum number of items that can be held in the array. Newitem is a pointer to the item to be added to the array. InsertPoint is the subscript of the correct insertion place in the array. It is returned by chopsearch().

See also: chopsearch().

In: chopinsert.c

Return to the top

chopsearch

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void *chopsearch(void *Target,
                 void **Table,
                 int Items,
                 int *InsertHere,
                 int (*Compare)(const void*, const void*));

chopsearch() is an enhanced binary chop array search for use when the array must grow during use. It is implemented using the binary chop algorithm from Sedgwick : Algorithms. The array to be searched is a list of pointers to objects in heap storage. Each object must contain a key value and may also contain other values, hence the pointer ordering defines the key sequence within the array. If the search succeeds it returns a pointer to the object. A failed search is signalled by returning NULL.

If the search fails chopsearch() returns information to allow chopinsert() to efficiently insert the missing entry in the correct position, thus maintaining the array in key sequence.

chopsearch() is called with Target pointing to an object containing the key value to be found. Table points to the array to be searched. Items holds the number of items in the array. If the search fails InsertHere is used to return the subscript of the array element where the missing item should be added. If the search is successful it holds the subscript of the array containing the pointer that chopsearch() returned. Compare is a user-written function that compares Target with an array entry. The object pointed to by Target must be identical to the objects pointed to by items in the array.

Compare must be declared as:

int function(void* target, void* elem);

where target is an object containing the search key and elem is an object pointed to by an item in the array being searched. Compare() should return a negative value if the first argument is less than the second argument, zero if they are the same and a positive value if the first argument is larger than the second.

See also: chopinsert().

In: chopsearch.c

Return to the top

config_close

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void config_close(FILE *cf);

Close the configuration file cf.

In: config_handler.c

Return to the top

config_getline

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int config_getline(FILE *cf, char *line, int lth);

Read the next non-blank, non-comment line from the config file cf into the line buffer. lth contains the maximum length of line. Lines that are too long for the buffer are returned with truncation warnings.

Comment lines start with #. Trailing comments and blanks are stripped from the remaining lines.

config_getline returns TRUE if a line with data was returned and FALSE when end of file is found. I/O errors are trapped and the run abandoned.

In: config_handler.c

Return to the top

config_open

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

FILE *config_open(char *prog, char *name, int d);

Open the configuration file. Search the current directory, /usr/local/etc and /etc in that order. prog is the name of the calling program, name is the basename of the configuration file and d is the debugging level. A value of 1 causes the name of the configuration file, significant configuration lines and configuration file closure to be traced. A value of 2 or greater will additionally cause the search for the configuration file to be traced. The debug level also applies to config_close() and config_getline().

config_open returns the FILE* pointer on success and null on failure.

In: config_handler.c

Return to the top

country

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

struct COUNTRY *country(int xcode, struct COUNTRY *cp);

The country() function

country() provides a degree of international independance to a program. It started as an attempt to implement the Borland DOS country() function for OS/9. The result was subsequently ported to Linux. This explains the interface and omissions from the information returned, as these exactly match the Borland definition. The implementation is derived from the termcap system.

If country() is called with xcode=0 the default country will be processed. If it is called with cp set to -1 the contents of xcode becomes the default for the rest of the program run. Calls with a pointer to the struct and a non-zero country code access details for the requested country.

Information from the database is returned in the following structure:

   struct  COUNTRY {
      int  co_date;         0 - US format: MM.DD.CCYY
                            1 - European:  DD.MM.CCYY
                            2 - Japanese:  CCYY.MM.DD 
      char co_curr[5];      The currency symbol. Up to 4 characters. 
      char co_thsep[2];     The symbol used to delimit thousands. 
      char co_desep[2];     The symbol used for a decimal point. 
      char co_dtsep[2];     The separator used within dates. 
      char co_tmsep[2];     The separator used within times. 
      char co_currstyle;    0 - symbol preceeds value w/o gap.
                            1 - symbol follows value w/o gap.
                            2 - symbol preceeds value w/space between.
                            3 - symbol follows value w/space between. 
      char co_digits;       1-3        Number of decimal places 
      char co_time;         0 = 12 hour time format: HH.MM.SS am
                            1 = 24 hour time format: HH.MM.SS 
      long co_case;         not used - conformity with Borland C 
      char co_dasep[2];     The character used in delimited data files
                            to separate fields. Usually a comma. 
      char co_fill[10];
   };
   

The country database

National information is held in a database file. This is /dd/sys/country in the OS-9 implementation and /usr/local/etc/country in the Linux implementation.

If the database cannot be found country() returns values for the UK and will do so regardless of the country code input.

If the database file does exist it must be correctly formatted and the first line in the file that is not blank or a comment must be the default country definition, e.g.

default=44

Any line starting with an asterisk is treated as a comment.

The order of other entries is not important; a country data definition block must be correctly formatted. A missed default definition, a reference to a missing country, or a malformed country definition block will all cause errors. A country data block has the following format:

dialcode:[keyword=value:]...

where dialcode is the international dialing code for the country. Each data block must be contiguous, must not contain comments or blank lines, and must be separated from the next data block by at least one blank line or comment. The minimum UK/US database is:

   default=44
   *UK
   44:datefmt=1:datesep=/:currsym=x9c:currdec=2:currsty=0:thousep=,:\
      decpt=.:timefmt=1:timesep=::casemap=18222325:datasep=,:
   *USA
   01:datefmt=0:datesep=/:currsym=$:currdec=2:currsty=0:thousep=,:\
      decpt=.:timefmt=0:timesep=::datasep=,:
   
The parameters describing the country are all of the form

keyword=value

and may not contain spaces. If necessary, values may be supplied as hexadecimal strings, which will be converted to the equivalent character string before validation and length checking. A hex string is made of the repeating group 'xhh', e.g. x30x31x32 is '012'.

The parameters are:

   casemap - Exists for conformity with DOS. Not used by OS/9.
   currdec - 1 - 3 Number of decimal places in the currency.
   currsty - 0 - Currency symbol preceeds value without a gap.
             1 - Currency symbol follows value without a gap.
             2 - Currency symbol preceeds value with a space between.
             3 - Currency symbol follows value with a space between.
   currsym - The currency symbol. Up to 4 characters.
   datasep - The character used in delimited data files to separate
             fields. Usually a comma.
   datefmt - 0 - US format: MM.DD.CCYY
             1 - European:  DD.MM.CCYY
             2 - Japanese:  CCYY.MM.DD
   datesep - The separator used within dates (shown above as '.').
   decpt   - The symbol used for a decimal point
   thousep - The symbol used to delimit thousands.
   timefmt - 0 - 12 hour time format: HH.MM.SS xx (xx = am or pm))
             1 - 24 hour time format: HH.MM.SS
   timesep - The separator used within times (shown above as '.'). 
   

Files

OS9: /dd/sys/country
Linux: /usr/local/etc/country

In: country.c

Return to the top

dirclose

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int dirclose(DIRPATH *dp);

Close the directory, release the DIRPATH control block memory and return the result code from closing the directory. Zero is returned if the close was successful.

In: diracc.c

Return to the top

diropen

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

DIRPATH *diropen(char *p);

Open the directory p for reading. Returns a DIRPATH* pointer to the directory control block on success and null if an error ocurred.

In: diracc.c

Return to the top

dirread

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int dirread(DIRPATH *dp, char *name);

Read the next filename from the directory referred to by the DIRPATH pointer dp. The absolute filename is placed in the name buffer. Returns:

In: diracc.c

Return to the top

dumphex

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void dumphex(FILE *f, char *buff, int lth);

Write a hex and ASCII dump of lth bytes from *buff to the FILE f. Each line of the output displays the content of 16 bytes of data. The line format is:

   111 aaaaaaaaaaaaaaa : hh hh hh hh hh hh hh hh hh hh hh hh hh hh hh hh :
   
where 111 is the offset of the start of the line from the start of buff. 'a' is the characters in ASCII. These must be valid printable ASCII characters that are not control characters. Those that do not meet this criterion are repaced with a full stop (.). hh is the same character represented as hexadecimal. If the final line would extend past the end of buff the overflow characters are left blank in both representations. The output line is 72 characters wide.

dumphex() does not output any form of heading line. It is intended for diagnostic displays.

In: dumphex.c

Return to the top

error

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void error(char *f, char *e, char *p);

Ends the process with the current errno value as the return code after outputting an error message of the form

fffff: eeeee ppppp

f is normally the program name, e is a short description of the reason for abandoning the program and p is either blank or an extension of the reason, e.g.

error(progname, "can't open", filename);

would output: progname: can't open filename

In: error.c

Return to the top

expand_space

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void *expand_space(void *pp, size_t n);

This is a convenience wrapper for realloc(). It expands the area pointed to by pp to n bytes and returns a pointer to the new area. If it fails to get the requested space it abandons with a suitable error message by calling error().

In: get_space.c

Return to the top

filesize

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

long filesize(char *name);

Return the size of the file name in bytes or -1 if the file is inaccessable.

In: filesize.c

Return to the top

fixext

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char* fixext(char *name, char *ext);

Set the filename extension to that provided. If name is "." or ".." it is returned unchanged. If name has no extension a dot and ext are appended to it. If the file already has an extension it is replaced with ext. The revised name is in a hidden place; a pointer to it is returned. If fixext() is called repeatedly this space should be released as soon as possible by calling free().

The function returns the modified filename on success and null on failure.

In: fixext.c

Return to the top

fixname

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *fixname(char *name, char *ext, char *type);

Force a string to conform to current operating system conventions as regards length, default extension, and numbers of dots. name is the file name to be fixed, ext is the default extension and type is the file type, which must be "f" for a regular file and "d" for a directory. There are specific rules for each operating system:

MS-DOS: name processing:

  1. loose any leading dot (DOS hates them)
  2. change all but the last dot into underscores (DOS can't handle multiple dots in a filename)
  3. Leave the last dot intact and treat it as the start of the extension.
  4. Names consisting entirely of dots ( . and .. ) are valid directory references and are left alone.
  5. Limit the filename size to MAXFILE characters.
OS/9 and Linux: Dot processing:
  1. Copy to last dot (or end)
  2. Limit filename to MAXFILE characters
Extension processing. This applies to OS/9, MS-DOS and Linux:
  1. If there is an extension (either in the filename or the default parameter) append a dot to the filename.
  2. If the filename contains an extension (all chars after the last dot) it is copied onto the end of the (truncated) filename.
  3. Copy the default extension if there isn't one in the file name (i.e., no dots other than a leading dot).
  4. Truncate the extension so that:
Now apply operating system-specific rules to capitalisation:

NOTE: The function allocates storage for the modified name in a safe place. If it is called repeatedly this space should be released as soon as possible by calling free().

The function returns the modified filename on success and null on failure.

In: fixname.c

Return to the top

fixpath

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *fixpath(char *path, char *ext, char *type);

Force the pathname in path to conform to a correct local pathname. The default extension is in ext. type sets the file type. It is "f" for a regular file or "d" for a directory.

If the pathname is a local name this is equivalent to calling fixname(). If there is more than one term all except the last will be treated as directories. The last term will be treated as directory or file depending on the type parameter. To process a path:

  1. copy separators unchanged
  2. extract terms and pass them through fixname()
  3. terms followed by a separator are treated as directories
  4. the final term, if null-terminated, is treated as requested in the type parameter.

NOTE: The function allocates storage for the modified name in a safe place. If it is called repeatedly this space should be released as soon as possible by calling free().

The function returns the modified pathname on success and null on failure.

In: fixpath.c

Return to the top

get_sigtrap_name

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *get_sigtrap_name(int e);

Translate a signal type into a string. This function is intended for diagnostic and debugging use. It returns a pointer to a string containing the name of the signal type e.

See also: sighandler(), set_sigtrap_debug(), set_sigtraps(), get_sigtrap_type().

In: sigtrap.c

Return to the top

get_sigtrap_type

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int get_sigtrap_type();

Retrieves the last signal type trapped by sighandler(). It is used in conjunction with poll(). When a signal is detected poll() exits with a return value of -1 and errno set to EINTR. When this occurs get_sigtrap_type() is used to retrieve the signal type before taking the appropriate action.

It returns the type of signal that caused poll() to exit.

See also: sighandler(), set_sigtrap_debug(), set_sigtraps(), get_sigtrap_name().

In: sigtrap.c

Return to the top

get_space

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void *get_space(size_t n);

This is a convenience wrapper for malloc(). It allocates n bytes and returns a pointer to it. If this fails to get the requested space it abandons with a suitable error message by calling error().

In: get_space.c

Return to the top

getarg

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int getarg(int nargc, char **nargv);

getarg

Original version:
Martin Gregorie
Harlow,
U.K.
getarg returns command line parameters ignored by getopt(). It must only be called after getopt() has completely scanned the command parameters. optind should be reset to 1 before the first call.

getarg Should be called repeatedly until it returne EOF. Each call returns one of the following values:

NOTE: This version can ONLY be compiled under Linux, as the _tell() function uses writeln() to force a newline onto the terminal; writeln() is not a standard UNIX function.

See also: getopt(), argval()

In: argparse.c

Return to the top

getdelcode

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char getdelcode(void);

Retrieves the current delete code (usually ^H or DEL) from the terminal control block.

In: getdelcode.c

Return to the top

getkey

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char getkey(void);

Get a single keystroke from stdin.

This is a raw, unbuffered keyboard single key terminal read operation.

In: getkey.c

Return to the top

getopt

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int getopt(int nargc, char * const nargv[], const char *ostr);

getopt - extended version.

Original version:
Keith Bostic

Extended version:
Lloyd Zusman
Masterbyte Software
Los Gatos, CA

Adapted to OS9/68K standard:
Martin Gregorie
Harlow,
U.K.
getopt is used to parse options on the command line. The extension to OS/9 standards adds these facilities:
  1. Arguments and options may be freely mixed on the command line.
  2. Argument options must meet one of the following standards:
  3. The entire option or just the value may be enclosed in quotes
  4. Options not taking values can be concatenated
  5. Added the optcase global; Defaults to case sensitive.
  6. Causes getarg() to ignore parameters that have already been processed as options and/or option values
  7. Returns:

getopt is called repeatedly with the same parameters to process all the arguments on the command line. Each call returns NULL if the command line argument is not an option: it should be called again to skip this argument. It returns EOF when all arguments have been processed. It returns each option character as it is found: if the option has an associated value then optarg points to a string containing the option value.

After getopt has completely processed the command line getarg() should be used to retrieve the other argument(s).

NOTE: This version can ONLY be compiled under Linux, as the _tell() function uses writeln() to force a newline onto the terminal; writeln() is not a standard UNIX function.

See also: getarg(), argval()

In: argparse.c

Return to the top

getpath

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char* getpath(int argc, char *argv[], FILE *pathlist, int listflag);

A general purpose file name handler. It retrieves filenames from the command line arguments argc and argv if listflag is FALSE. The filenames are read from the pathlist file if listflag is TRUE. getpath() is used in conjunction with the command line parsing functions getopt() and getarg().

getpath() is called repeatedly until it returns null. Each call returns a pointer to the next filename or null when the end of the list is reached.

Assumptions are that when it is called:

A convention observed by all OS-9 command line utilities is the use of the -z option to provide an alternative to passing filenames as command line arguments. If the option is absent the filename(s) are passed as command line arguments. If the -z option is present they will be taken from a file. If the option takes the form -z=filename then the list of filenames will be read from from the filename supplied as the option value. If option takes the form -z then the list of files is read from stdin.

getpath() was originally written to implement this convention. When getopt() encounters a -z option, listflag is set TRUE. If optarg contains a filename this is opened for reading. If optarg is blank stdin is cloned. The result is passed to getpath() as pathlist.

In: getpath.c

Return to the top

itoa

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *itoa(int i, char *a, int r);

Transform the integer i into an ASCII string and store the result in the buffer a, which must be long enough to hold the resulting string. The numeric string is encoded in the base given in r. The base must be in the range 2 to 36. If it is outside this range it is defaulted to base 10. This is a recursive function that occupies a stack level for every digit in the output string.

The function returns a pointer to a.

- written by Lew Pitcher

In: itoa.c

Return to the top

logdump

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void logdump(void);

Print the circular buffer filled by logmsg().

If the operational mode is DIRECT_LOG this function does nothing. If it is INDIRECT_LOG all unprinted messages in the circular buffer are printed and the circular buffer is cleared. The output format is controlled by logtime(). If logtime(TRUE) was called each message will be preceeded by the time when logmsg() wrote it into the circular buffer. If logtime() was never called or if it was last called with the FALSE argument, the timestamp is not shown.

This is one of a set of functions that provide a means of reducing tracing output being used to diagnose problems in an operational program. Tracing information is written to a circular buffer, overwriting old information, until an error condition is discovered At this point the contents of the circular buffer is dumped to show the events leading up to the error. This would typically be followed a diagnostic message to describe the error. After this the program can continue to run, refilling the circular buffer, or it can terminate.

See also: logmsg(), logsetup(), logtime()

In: logmsg.c

Return to the top

logmsg

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void logmsg(char* fmt, ...);

If the operational mode is DIRECT_LOG and the output file is STDERR_LOG, this call is equivalent to fprintf(stderr, format, ....); except that, because logmsg() always adds a newline to the message, the message format defined by fmt should not end with one unless the message is to be followed by a blank line.

If the operational mode is INDIRECT_LOG, each message is timestamped and written to a circular buffer from where it is printed by logdump().

This is one of a set of functions that provide a means of reducing tracing output being used to diagnose problems in an operational program. Tracing information is written to a circular buffer, overwriting old information, until an error condition is discovered At this point the contents of the circular buffer is dumped to show the events leading up to the error. This would typically be followed a diagnostic message to describe the error. After this the program can continue to run, refilling the circular buffer, or it can terminate.

See also: logdump(), logsetup(), logtime()

In: logmsg.c

Return to the top

logsetup

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void logsetup(int r, int f, int s);

Select the operational mode, circular buffer size, and output file for logging.

r is DIRECT_LOG if all tracing output is to be sent straight to the file and INDIRECT_LOG if it is to be written to the circular buffer for later output.

f is the output file. It must be STDOUT_LOG or STDERR_LOG.

s is the circular buffer size. Its default size is 20 log messages.

If this function is not called, default run conditions will be used. This is equivalent to the call logsetup(DIRECT_LOG, STDERR_LOG, 20);

This is one of a set of functions that provide a means of reducing tracing output being used to diagnose problems in an operational program. Tracing information is written to a circular buffer, overwriting old information, until an error condition is discovered At this point the contents of the circular buffer is dumped to show the events leading up to the error. This would typically be followed a diagnostic message to describe the error. After this the program can continue to run, refilling the circular buffer, or it can terminate.

See also: logdump(), logmsg(), logtime()

In: logmsg.c

Return to the top

logtime

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void logtime(int t);

Determines whether logdump() preceeds each message with a timestamp showing when it was written to the circular buffer by logmsg().

t is TRUE if a timestamp is to preceed each message and FALSE no timestamp is shown.

If this function is not called, default run conditions will be used. This is equivalent to the call logtime(FALSE);

This is one of a set of functions that provide a means of reducing tracing output being used to diagnose problems in an operational program. Tracing information is written to a circular buffer, overwriting old information, until an error condition is discovered At this point the contents of the circular buffer is dumped to show the events leading up to the error. This would typically be followed a diagnostic message to describe the error. After this the program can continue to run, refilling the circular buffer, or it can terminate.

See also: logdump(), logmsg(), logsetup()

In: logmsg.c

Return to the top

ltoa

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *ltoa(long i, char *a, int r);

Transform the long integer i into an ASCII string and store the result in the buffer a, which must be long enough to hold the resulting string. The numeric string is encoded in the base given in r. The base must be in the range 2 to 36. If it is outside this range it is defaulted to base 10. This is a recursive function that occupies a stack level for every digit in the output string.

The function returns a pointer to a.

- written by Lew Pitcher

In: ltoa.c

Return to the top

numconv

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int numconv(char *s);

Accepts a string containing an unsigned integer value representing an address or a character in a number of formats. It returns an integer value. Acceptable input formats are:

An empty string returns zero.

In: numconv.c

Return to the top

numdisp

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *numdisp(int n, char* units);

Return a string containing an positive integer value as a decimal, hex, kilobyte or megabyte representation. Note that if kilobytes or megabytes are specified, the value will be rounded down to the nearest whole unit.

Valid units are:

Hexadecimal values are always shown in upper case. If the hexadecimal units are followed by a number, it gives the minimum number of digits to be output. Shorter strings are zero padded on the left, so a value of 1 with a unit code of "$2" will be output as $01 and a value of 255 with a code of "0x4" will be output as 0X00FE.

Invalid units are treated as requests for decimal output.

numdisp() output is accepted as valid input by numconv().

In: numconv.c

Return to the top

plugin_getref

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void *plugin_getref(void *handle, char *name);

Return a pointer to a plugin from the library pointed to by *handle.

If the plugin can't be found, save the error text for retrieval by pluginlib_error and return NULL.

In: pluginlib.c

Return to the top

pluginlib_close

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void pluginlib_close(void *handle);

Close the plugin library if it was open.

In: pluginlib.c

Return to the top

pluginlib_error

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char* pluginlib_error();

Return a pointer to the error text if an error has ocurred and NULL otherwise.

In: pluginlib.c

Return to the top

pluginlib_open

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void *pluginlib_open(char *libname);

Open the dynamic loader library libname. On success, return a handle for the library. On error, save the error text for retrieval by pluginlib_error() and return NULL.

In: pluginlib.c

Return to the top

progname

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *progname(void);

Retrieve the program name stored by setprog(). If it wasn't called "UNSET" is retrieved by default. This is a means of passing the program name to diagnostic, warning and error mesages without having to pass them down a function stack.

See also: setprog()

In: progname.c

Return to the top

prstat

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *prstat(int status);

Decode a waitpid() reply. This decodes the value in status and returns a string containing the decoded reply.

In: prstat.c

Return to the top

question

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int question(char *prompt);

Outputs prompt on stdout as "prompt (y/n) ? " and accepts the reply. If the answer is not one of 'YyNn' it emits a beep and a backspace and accepts input until the result is y,n,Y or N. It returns the validated input as an upper case letter (Y or N).

In: question.c

Return to the top

release_space

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void *release_space(void *p);

This is a convenience wrapper for free(). It releases the space pointed to by p and returns null. If p is null it abandons with a suitable error message by calling error().

In: get_space.c

Return to the top

searchpath

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

FILE* searchpath(char *list, char *name, char *mode1, char *mode2, int debug);

Search for and open a file within a predefined search path.

An attempt to open a file whose local name is name, trying mode1 then mode2. The modes are the normal ones used with the FILE* buffered i/o system.

This is tried first in the current directory and then in each directory in turn in the list specified by the list environment variable. The list must the normal searchpath ($PATH) format using the system default directory separators.

In: searchpath.c

Return to the top

set_sigtrap_debug

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void set_sigtrap_debug(int d);

Set the signal handling debug level. Level 1 traces calls on all signal trap functions except sighandler(), which is never traced, and get_sigtrap_type() and get_sigtrap_name(), which are traced at debug level 2.

See also: sighandler(), set_sigtraps(), get_sigtrap_type(), get_sigtrap_name().

In: sigtrap.c

Return to the top

set_sigtraps

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int set_sigtraps();

Sets up signal trap handling by installing sighandler() as the signal handler for SIGHUP, SIGINT, SIGQUIT, SIGTERM, SIGPOLL, SIGUSR1 and SIGUSR2. It returns zero on success and the signal type that caused an error if one ocurred.

See also: sighandler(), set_sigtrap_debug(), get_sigtrap_type(), get_sigtrap_name().

In: sigtrap.c

Return to the top

setpause

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int setpause(int action, int pathno);

This is machine-dependent code to handle paging terminal output.

In the OS-9 environment, where the terminal drivers will handle display pagination if so requested, this function sets the terminal to the pagination method requested in action for the requested pathno. It returns -1 if it failed to retrieve or modify the i/o manager options, E_BTYP if the path is not connected to an SCF (terminal) device and E_ILLARG if the value of action is invalid. Zero is returned if the request was successfully actioned. Valid values for action are:

The function does nothing in a Linux or MS-DOS environment because neither operating system's terminal device drivers support output pagination. These versions only exist to ensure program portability.

In: setpause.c

Return to the top

setprog

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void setprog(char *name);

Set the program name retrieved by progname(). This is a means of passing the program name to diagnostic, warning and error mesages without having to pass them down a function stack.

See also: setprog()

In: progname.c

Return to the top

sighandler

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

static void sighandler(int sig);

Signal handler used to trap shutdowns. This is designed for use with programs using poll() for asynchronous i/o and to detect signals. It is installed as the signal handler for all signals by set_sigtraps(). When a signal is detected it stores the signal internally before poll() exits with a return value of -1 and errno set to EINTR. When this occurs get_sigtrap_type() is used to retrieve the signal type before taking the appropriate action.

See also: set_sigtrap_debug(), set_sigtraps(), get_sigtrap_type(), get_sigtrap_name().

In: sigtrap.c

Return to the top

strhex

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *strhex(char *s);

Returns a pointer to an internal static string containing the converted string. Each byte that is printable and not a control character is unmodified, but the rest are replaced the hexadecimal equivalent formatted as "<hh>".

This function should not appear more than once in a formatted print statement because all such calls be evaluated before the formatted output is generated. By this time the internal static string will contain the result of the final call and all such byte decodings will apparently result in the same (final) value.

If this is necessary, capture each decoded value in a separate string and print from these:

      char buff[80];
      strcpy(buff, strhex(s));
      fprint("Read '%s'\n", buff);
   

This function is primarily intended as a debugging aid.

In: strhex.c

Return to the top

strlwr

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *strlwr(char *s);

Convert the string in s to lower case and return a pointer to s.

In: strlwr.c

Return to the top

strmfe

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *strmfe(char *fullname, char *name, char *ext);

Complete a filename by adding a default extension if needed.

If name doesn't have an extension, append a '.' followed by ext, putting the result in fullname, which must be large enough to contain the completed name plus the string terminator. A pointer to fullname is returned.

In: strmfe.c

Return to the top

strupr

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

char *strupr(char *s);

Convert the string in s to upper case and return a pointer to s.

In: strupr.c

Return to the top

swapdir

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int swapdir(char *path);

Switch the program's current directory to path. Return zero on success and an error indication if the operation failed.

The OS9/68K and Linux versions of this function are identical to chdir(). The MS-DOS version has some extra work to do to switch drives as well and to clean up in a tidy fashion if the combination of switching drive and directory does not work.

In: swapdir.c

Return to the top

tabclear

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void tabclear(char *tabstops);

Clear all tabs from the tabstops list.

See also: tabexpand(), tabdefault(), tabnormal(), tabout(), tabpos(), tabset(), tabspread()

In: tabclear.c

Return to the top

tabdefault

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int tabdefault();

Returns the default tab spacing for this system. Standard tab spacing is defined by:

  1. the value in the stdout path descriptor if it points to an SCF device (OS/9 only).
  2. the environmental variable TABSPACE, if it is defined.
  3. TABSPACE in environ.h
These possibilities are inspected in sequence until a value is found.

See also: tabclear(), tabexpand(), tabnormal(), tabout(), tabpos(), tabset(), tabspread()

In: tabdefault.c

Return to the top

tabexpand

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int tabexpand(char dest[], int i, char *tabstops, char fill);

Expand a tab in the output string dest by appending the fill character from i (normally the end of the string that's being built) until the next tab is reached in tabstops. The end position is returned.

See also: tabclear(), tabout(), tabset(), tabdefault(), tabnormal(), tabpos(), tabspread()

In: tabexpand.c

Return to the top

tabnormal

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void tabnormal(char *tabstops);

Set standard tabs for the system in the tab stop list tabstops. This is a convenience function. It calls tabdefault() to get the standard tab spacing, tabclear() to clear the tabs list and then tabspread() to set the tabs at the standard spacing.

See also: tabclear(), tabexpand(), tabout(), tabset(), tabdefault(), tabpos(), tabspread()

In: tabnormal.c

Return to the top

tabout

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int tabout(FILE *fn, int i, char *tabstops);

Expand a tab stop by sending spaces to the output FILE* fn until the next tab stop in tabstops is reached. i is the current position on the line. Returns the new end position.

See also: tabclear(), tabexpand(), tabset(), tabdefault(), tabnormal(), tabpos(), tabspread()

In: tabout.c

Return to the top

tabpos

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int tabpos(int col, char *tabstops);

Return TRUE if col is a tab in the tab list, tabstops.

See also: tabclear(), tabexpand(), tabout(), tabset(), tabdefault(), tabnormal(), tabspread()

In: tabpos.c

Return to the top

tabset

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void tabset(int col, char state, char *tabstops);

Set or clear a tab in the tabs list, tabstops at col. The tab is set if state is TRUE and cleared if it is FALSE.

See also: tabclear(), tabexpand(), tabout(), tabdefault(), tabnormal(), tabpos(), tabspread()

In: tabset.c

Return to the top

tabspread

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void tabspread(int gap, char *tabstops);

Set a tab every gap characters in the tabs list tabstops.

See also: tabclear(), tabexpand(), tabout(), tabset(), tabdefault(), tabnormal(), tabpos()

In: tabspread.c

Return to the top

trim

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void trim(char *trimmed, char *s);

Trims any whitespace from the beginning and end of s and leaves the cleaned up string in trimmed, which must be at least as long as s.

It is the caller's responsibility to make sure that trimmed is big enough to contain the trimmed string.

In: trim.c

Return to the top

trimchars

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void trimchars(char *trimmed, char *s, char *u);

Trims any characters in the u string from the beginning and end of s and leaves the cleaned up string in trimmed, which must be at least as long as s.

It is the caller's responsibility to make sure that trimmed is big enough to contain the trimmed string.

In: trim.c

Return to the top

tsclose

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

tempstore* tsclose(tempstore *ptr);

Close the storage system referenced by the tempstore pointer ptr, release the storage and return NULL.

This function is part of the Temporary storage buffer package. It allows charactetrs and strings to be written to and read from a block of memory. This is held in memory unless it is bigger than a predefined limit TSLIM, when it is put in a temporary file, whose name is system dependent but conforms the the pattern TZXXXXXX. The Xs are replaced by a system-supplied value which is guaranteed to be unique.

NOTE: If the constant TSLIM is changed the temporary storage package should be recompiled because the constant is used internally.

See also: tsgetc(), tsgetstr(), tsopen(), tsputc(), tsputstr()

In: tempstore.c

Return to the top

tsgetc

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int tsgetc(tempstore *ptr);

Read the next character from the tempstore ptr. The next character is returned if the operation was successful and EOF if it failed.

This function is part of the Temporary storage buffer package. It allows charactetrs and strings to be written to and read from a block of memory. This is held in memory unless it is bigger than a predefined limit TSLIM, when it is put in a temporary file, whose name is system dependent but conforms the the pattern TZXXXXXX. The Xs are replaced by a system-supplied value which is guaranteed to be unique.

NOTE: If the constant TSLIM is changed the temporary storage package should be recompiled because the constant is used internally.

See also: tsclose(), tsgetstr(), tsopen(), tsputc(), tsputstr()

In: tempstore.c

Return to the top

tsgetstr

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int tsgetstr(tempstore *ptr, char *str, int n);

Read the next string from the tempstore ptr into str. Up to n characters will be read unless the string termination character (null) or the end of the temporary storage is encountered first. It returns TRUE if the string was read successfully or FALSE if the end of the storage was reached or an error ocurred. Reading n characters before reaching the string terminator is NOT an error.

This function is part of the Temporary storage buffer package. It allows charactetrs and strings to be written to and read from a block of memory. This is held in memory unless it is bigger than a predefined limit TSLIM, when it is put in a temporary file, whose name is system dependent but conforms the the pattern TZXXXXXX. The Xs are replaced by a system-supplied value which is guaranteed to be unique.

NOTE: If the constant TSLIM is changed the temporary storage package should be recompiled because the constant is used internally.

See also: tsclose(), tsgetc(), tsopen(), tsputc(), tsputstr()

In: tempstore.c

Return to the top

tsopen

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

tempstore* tsopen(long s, int d);

Initialise the storage system to hold s bytes and set the debugging level to d.

A pointer to a tempstore control block is returned if the temporary storage was successfully initialised and null if an error ocurred.

This function is part of the Temporary storage buffer package. It allows charactetrs and strings to be written to and read from a block of memory. This is held in memory unless it is bigger than a predefined limit TSLIM, when it is put in a temporary file, whose name is system dependent but conforms the the pattern TZXXXXXX. The Xs are replaced by a system-supplied value which is guaranteed to be unique.

NOTE: If the constant TSLIM is changed the temporary storage package should be recompiled because the constant is used internally.

See also: tsclose(), tsgetc(), tsgetstr(), tsputc(), tsputstr()

In: tempstore.c

Return to the top

tsputc

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int tsputc(tempstore *ptr, int c);

Append a character c to the tempstore referenced by ptr. Returns TRUE on success and FALSE if an error ocurred or the temporary store is full.

This function is part of the Temporary storage buffer package. It allows charactetrs and strings to be written to and read from a block of memory. This is held in memory unless it is bigger than a predefined limit TSLIM, when it is put in a temporary file, whose name is system dependent but conforms the the pattern TZXXXXXX. The Xs are replaced by a system-supplied value which is guaranteed to be unique.

NOTE: If the constant TSLIM is changed the temporary storage package should be recompiled because the constant is used internally.

See also: tsclose(), tsgetc(), tsgetstr(), tsopen(), tsputstr()

In: tempstore.c

Return to the top

tsputstr

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

int tsputstr(tempstore *ptr, char *str);

Append the string str to the tempstore ptr followed by a string delimiter (NULL). Returns TRUE if the string was successfully stored and FALSE if errors were encountered.

This function is part of the Temporary storage buffer package. It allows charactetrs and strings to be written to and read from a block of memory. This is held in memory unless it is bigger than a predefined limit TSLIM, when it is put in a temporary file, whose name is system dependent but conforms the the pattern TZXXXXXX. The Xs are replaced by a system-supplied value which is guaranteed to be unique.

NOTE: If the constant TSLIM is changed the temporary storage package should be recompiled because the constant is used internally.

See also: tsclose(), tsgetc(), tsgetstr(), tsopen(), tsputc()

In: tempstore.c

Return to the top

warn

#include <stdio.h>
#include <dirent.h>
#include <time.h>
#include <environ.h>

void warn(char *f, char *e, char *p);

Outputs an error message of the form:

fffff: eeeee ppppp

f is normally the program name, e is a short description of the reason for showing the warning and p is either blank or an extension of the reason, e.g.

warn(progname, "now reading", filename);

would output: progname: now reading filename

In: warn.c

Return to the top

Constants

AUTOFMT
#define AUTOFMT       0
BLANK
#define BLANK         ' '
DDMMMYY
#define DDMMMYY       1
DIRECT_LOG
#define DIRECT_LOG    1
DIR_EOF
#define DIR_EOF       0
DIR_FILE
#define DIR_FILE      2
DIR_NULL
#define DIR_NULL      1
DIR_SUBDIR
#define DIR_SUBDIR    3
DOT
#define DOT           '.'
EOF
#define EOF    (-1)
FALSE
#define     FALSE     0
FIRSTCALL
#define FIRSTCALL     1
FORM_FEED
#define FORM_FEED     0x0c
FOUND
#define FOUND         1
INDIRECT_LOG
#define INDIRECT_LOG  0
LINUX
#define LINUX         "Linux"
MANUAL
#define MANUAL        2
MAXEXT
#define MAXEXT        256
MAXFILE
#define MAXFILE       256
MAXLINE
#define MAXLINE       161
MAXNAME
#define MAXNAME       512
MAXPATH
#define MAXPATH       1024
NAMELTH
#define NAMELTH       256
NAMESIZE
#define NAMESIZE      1024
NEXTCALL
#define NEXTCALL      2
NOTHING
#define NOTHING       0
NULL
#define NULL   (0)
PATHSEP
#define PATHSEP       "/"
PRINTER
#define PRINTER       "/dev/printer"
P_NOPAUSE
#define P_NOPAUSE     3
P_PAUSE
#define P_PAUSE       2
P_RECORD
#define P_RECORD      1
P_RESTORE
#define P_RESTORE     4
SEARCHSEP
#define SEARCHSEP     ':'
SEPARATOR
#define SEPARATOR     '/'
SEPCHAR
#define SEPCHAR       '/'
STDERR_LOG
#define STDERR_LOG    2
STDOUT_LOG
#define STDOUT_LOG    1
TABSPACE
#define TABSPACE      8
TRUE
#define     TRUE      1
TSLIM
#define TSLIM 16384
UNDERSCORE
#define UNDERSCORE    '_'
max
#define max(a,b) ( a>b ? a : b )
min
#define min(a,b) ( a<b ? a : b )

Return to the top

Variable type definitions

BYTE
typedef unsigned char BYTE;
CHARDATE
typedef char* CHARDATE;
CHARTIME
typedef char* CHARTIME;
CIRC_BUFF
typedef struct {
   int   size;
   char  *buff;
   int   read_ptr;
   int   write_ptr;
} CIRC_BUFF;
COUNTRY
struct  COUNTRY {
                    int  co_date;
                    char co_curr[5];
                    char co_thsep[2];
                    char co_desep[2];
                    char co_dtsep[2];
                    char co_tmsep[2];
                    char co_currstyle;
                    char co_digits;
                    char co_time;
                    long co_case;
                    char co_dasep[2];
                    char co_fill[10];
                };
DIRPATH
typedef struct {
                    DIR    *p;
                    char   path[NAMESIZE];
               }
                    DIRPATH;
tempstore
typedef struct {
                    char  *buffer;
                    int   fileused;
                    char  *filename;
                    FILE* fil;
                    int   inptr;
                    int   outptr;
                    int   size;
               }
                    tempstore;

Return to the top

Global Variable definitions

optarg
extern char *optarg;
optbad
extern int  optbad;
optcase
extern int  optcase;
optchar
extern int  optchar;
opterr
extern int  opterr;
opterrfd
extern int  opterrfd;
optind
extern int  optind;
optmaybe
extern int  optmaybe;
optneed
extern int  optneed;
optopt
extern int  optopt;
optstart
extern char *optstart;

Return to the top