Files
Datakomm_1/udefs.h
2026-03-05 13:37:25 +01:00

237 lines
6.0 KiB
C

/******************************************************************************
*
* (c) Copyright 1998, University of Karlstad.
*
* 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 1, 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Please report any bugs you find in this code or any improvements to:
*
* Hans Hedbom, Dept. of Computer Science,
* University of Karlstad, Sweden.
*
* Phone: +46 54 838157
* E-mail: Hans.Hedbom@hks.se
*
* ============================================================================
*
* FILE:
*
* udefs.h [ the Data Communication I course programming project ]
*
* AUTHORS:
*
* Jonny Wiederholm
* E-mail: fr7wied@cse.hks.se
*
* Per-Ola Gustafsson
* E-mail: fr7gust@cse.hks.se
*
* CREATION DATE:
*
* Jan, 06, 1998
*
* DESCRIPTION:
*
* Includes constants used in the example implementation of the Data
* Communication I course programming project.
*
* MODIFICATIONS: Date Changes
* ----------------------------------------------------------------------------
*
*/
#ifndef _UDEFS_H /* Avoid multiple copies of this file. */
#define _UDEFS_H
#ifdef __cplusplus /* Make this file possible to use in C++ code. */
extern "C" {
#endif
/******************************************************************************
* INCLUDE FILES
*/
#include "systems.h"
/******************************************************************************
* DEFINE CONSTANTS
*/
/* Null pointer value. */
#ifndef NULL /* Avoid type redeclaration. */
#if !defined( __cplusplus) && !defined (sun)
#define NULL ((void *) 0)
#else /* !defined( __cplusplus) && !defined (sun) */
#define NULL 0 /* C++ definition of NULL. */
#endif /* ifndef __cplusplus */
#endif /* ifndef NULL */
/* Normal exit value. */
#define NORMAL_EXIT 1
/* Non normal exit value. */
#define NON_NORMAL_EXIT -1
/* End of string. */
#define EOS '\0'
/* Value returned on the occurence of a system failure. */
#ifndef SYSTEM_FAILURE /* Avoid type redeclaration. */
#define SYSTEM_FAILURE (-1)
#endif
/* Value returned on a successful operation. */
#ifndef SUCCESS /* Avoid type redeclaration. */
#define SUCCESS 0
#endif
/* Allow ANSI C keywords if ANSI C or C++. */
#if defined (__STDC__) || defined (__cplusplus)
#define const__ const
#define volatile__ volatile
/* Pointer to void is defined as pointer to char on non ANSI C systems. */
#define void_ptr_ void *
#else /* defined (__STDC__) || defined (__cplusplus) */
#define const__ /* No ANSI C keywords. */
#define volatile__
#define void_ptr_ char *
#endif /* defined (__STDC__) || defined (__cplusplus) */
/******************************************************************************
* DEFINE TYPES
*/
/*
`c_buf_ptr_' is used by functions which take a pointer to a character
buffer as parameter and does not change the contents of the buffer.
*/
#ifndef C_BUF_PTR_ /* Avoid type redeclaration. */
#define C_BUF_PTR_
#if defined (__linux__)
typedef const__ char * c_buf_ptr_;
#else /* defined (__linux__) */
typedef char * c_buf_ptr_;
#endif /* defined (__linux__) */
#endif
/*
`buf_ptr' is used by functions which take a pointer to a character
buffer and does change the value of the buffer.
*/
#ifndef BUF_PTR_ /* Avoid type redeclaration. */
#define BUF_PTR_
typedef char * buf_ptr_;
#endif
/*
`string_ptr_' is used by functions which take a pointer to a character
string as parameter and does not change the contents of the string.
*/
#ifndef STRING_PTR_ /* Avoid type redeclaration. */
#define STRING_PTR_
typedef c_buf_ptr_ string_ptr_;
#endif
/*
`byte_ptr_' is used by functions which takes a pointer to a character-buffer
which only needs to store one character, or byte.
*/
#ifndef BYTE_PTR_
#define BYTE_PTR_
typedef char * byte_ptr_;
#endif
/* `size_t_' is used as a length parameter for string functions. */
#ifndef SIZE_T_ /* Avoid type redeclaration. */
#define SIZE_T_
typedef unsigned int size_t_;
#endif
/*
`ssize_t_' is used by functions which return a count of bytes or an error
indication.
*/
#ifndef SSIZE_T_ /* Avoid type redeclaration. */
#define SSIZE_T_
typedef signed int ssize_t_;
#endif
/*
`u_int_' is used by functions which take or return an unsigned int that
is not indicating a length.
*/
#ifndef U_INT_ /* Avoid type redeclaration. */
#define U_INT_
typedef unsigned int u_int_;
#endif
/*
`ul_int_' is used by functions which take or return an unsigned long int
that is not indicating a length.
*/
#ifndef UL_INT_ /* Avoid type redeclaration. */
#define UL_INT_
typedef unsigned long int ul_int_;
#endif
/******************************************************************************
* DEFINE MACROS
*/
/* Allow function prototypes. */
#if defined (__STDC__) || defined (__cplusplus)
#ifndef __P /* Avoid type redeclaration. */
#define __P(args) args
#endif
#else /* defined (__STDC__) || defined (__cplusplus) */
#ifndef __P /* Avoid type redeclaration. */
#define __P(args) () /* No prototypes. */
#endif
#endif /* defined (__STDC__) || defined (__cplusplus) */
/******************************************************************************
* END
*/
#ifdef __cplusplus
}
#endif
#endif /* _UDEFS_H */