daybodep / daybodep.h

    Daybo Logic Dependency tool
    Copyright (C) 2001-2003  David Duncan Ross Palmer, Daybo Logic.

    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
    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Daybo Logic
  57 Alderwood Parc,
  United Kingdom.

  TR10 8RL

#ifndef __INC_DAYBODEP_H
#define __INC_DAYBODEP_H
  First we need to define a boolean type so we can compile on older
  C compilers (from 1989), "bool" is illegal to define on C++, so avoid
  doing that.
#ifndef __cplusplus /* Begin C++ exclusion zone */

typedef enum {
  false = 0,
  true = 1
} bool;

/* Must be available as macros also */
#define false false
#define true true

#define __bool_true_false_are_defined 1 /* Ala GNU? */

#endif /*!__cplusplus*/ /* End C++ exclusion zone */
/* The platform object suffix */
#ifdef __UNIX__
# define OBJ_SUFFIX ".o"
# define OBJ_SUFFIX ".obj"
#endif /*__UNIX__*/

/* The name of this program */
#define PROGRAM_NAME "daybodep"

/* Return values for shell scripts/batch files */
#define RET_SUCCESS    (0)
#define RET_BADPARAMS  (1)
#define RET_INITFAILED (2) /* Not used but kept for backward compat. */
#define RET_DEPGENFAIL (3)

/* Version information */
#define VER_MAJ   (0)
#define VER_MIN   (4)
#define VER_PATCH (3)
#define VER_STAMP (20030914) /* Keep this up to date with releases, it's format should be obvious, YYYYMMDD */

/* Maximum size of a buffer for reading from a file line by line */
#define MAX_LINE_BUFF (1024)

/* Time and date the program was built */
#ifdef __DATE__
# define BUILD_DATE __DATE__
# define BUILD_DATE "1st Jan 1970 (you believe that?)"
#endif /*__DATE__*/
#ifdef __TIME__
# define BUILD_TIME __TIME__
# define BUILD_TIME "00:00"
#endif /*__TIME__*/

/* Macros */
#define SAFESTRCOMP(s1, s2) \
          ( s1 && s2 && strcmp(s1, s2) == 0 )

#define TESTARG(otable, index, arg) \
          ( SAFESTRCOMP(otable[index].longOptStr, arg) || \
            SAFESTRCOMP(otable[index].shortOptStr, arg) )
  Simple checksum functions, should be the same on all platforms,
  16-bits.  Shields the user from the actual information so we can
  make it a structure or something later on.  Not that we ever will
  but I'm as mad as a hatter.
typedef unsigned short int CHECKSUM;

enum checksumDiff {
  chkdLesser = -1, /* Right hand checksum is lesser */
  chkdEqual = 0, /* Checksums are the same */
  chkdGreater = 1 /* Right hand checksum is greater */

enum checksumDiff ChecksumCompare(const CHECKSUM* PChecksumLeft, const CHECKSUM* PChecksumRight);
void ChecksumAssign(CHECKSUM* PChecksumTarget, const CHECKSUM* PChecksumSource); /* PChecksumSource may be NULL */
CHECKSUM ChecksumCalculate(const char* PCString);
  String list
/* This is how nodes are stored internally */
struct string_list_node {
  char* dynamicString; /* The string we have stored in this node */
  CHECKSUM checkSum; /* Checksum of the string */
  struct string_list_node* next; /* Link to next node */

/* The "class" */
struct string_list {
  /* private - touch nothing from outside in this section please */
  struct string_list_node* base; /* Free list of nodes */
  unsigned int count; /* Number of nodes, prevents counting crawls */
  /* public */
  bool (*Add)(struct string_list* Obj, const char* NewString);
  unsigned int (*Count)(const struct string_list* Obj);
  void (*Clear)(struct string_list* Obj); /* Delete all strings */
  const char* (*GetString)(const struct string_list* Obj, const unsigned int Pos);
  bool (*DelByPos)(struct string_list* Obj, const unsigned int Pos);
  bool (*StringExists)(struct string_list* Obj, const char* S);

void S_StringList_Construct(struct string_list* Obj); /* Object constructor */
void S_StringList_Destruct(struct string_list* Obj); /* Object destructor */
  Simple string functions which make the code a little bit more
char* Copy(const char* SourceString); /* Makes and returns a copy of the string */
char* CopyAndAppend(const char* SS1, const char* SS2); /* Makes a new string of the two parameters suppied */
extern const char LicenseData[]; /* Text of the GNU GPL (license), in daybodep_license.c */
  Function to set the standard error stream.  The old version is returned.
  Passing NULL will reset the value to 'stderr', the default.
FILE* SetStandardError(FILE* NewStandardError);

  Function to get the standard error, use this in calls to fprintf() and
  friends.  It never returns NULL, so no need for any annoying tests.
FILE* GetStandardError(void);
#endif /*!__INC_DAYBODEP_H*/