- code cleaned up

This commit is contained in:
Jan Hutter
2005-12-06 13:07:06 +00:00
parent f1802881f6
commit b23b556ae7
2 changed files with 83 additions and 10 deletions
+7 -2
View File
@@ -1,7 +1,7 @@
/** /**
* @file types.c * @file types.c
* *
* @brief Generic type definitions * @brief Generic types.
* *
*/ */
@@ -23,7 +23,9 @@
#include "types.h" #include "types.h"
/**
* String mappings for type status_t.
*/
mapping_t status_m[] = { mapping_t status_m[] = {
{SUCCESS, "SUCCESS"}, {SUCCESS, "SUCCESS"},
{FAILED, "FAILED"}, {FAILED, "FAILED"},
@@ -40,4 +42,7 @@ mapping_t status_m[] = {
{MAPPING_END, NULL} {MAPPING_END, NULL}
}; };
/**
* Empty chunk.
*/
chunk_t CHUNK_INITIALIZER = {NULL,0}; chunk_t CHUNK_INITIALIZER = {NULL,0};
+76 -8
View File
@@ -1,7 +1,7 @@
/** /**
* @file types.h * @file types.h
* *
* @brief Generic type definitions * @brief Generic types.
* *
*/ */
@@ -30,42 +30,112 @@
#include <definitions.h> #include <definitions.h>
typedef enum status_t status_t; typedef enum status_t status_t;
/** /**
* return status for function calls * Return values of function calls.
*/ */
enum status_t { enum status_t {
/**
* Call succeeded.
*/
SUCCESS, SUCCESS,
/**
* Call failed.
*/
FAILED, FAILED,
/**
* Out of ressources.
*/
OUT_OF_RES, OUT_OF_RES,
/**
* Already done.
*/
ALREADY_DONE, ALREADY_DONE,
/**
* Not supported.
*/
NOT_SUPPORTED, NOT_SUPPORTED,
/**
* One of the arguments is invalid.
*/
INVALID_ARG, INVALID_ARG,
/**
* Something could not be found.
*/
NOT_FOUND, NOT_FOUND,
/**
* Error while parsing.
*/
PARSE_ERROR, PARSE_ERROR,
/**
* Error while verifying.
*/
VERIFY_ERROR, VERIFY_ERROR,
/**
* Object in invalid state.
*/
INVALID_STATE, INVALID_STATE,
/**
* Delete object which function belongs to.
*/
DELETE_ME, DELETE_ME,
/**
* An object got created.
*/
CREATED, CREATED,
}; };
/**
* String mappings for type status_t.
*/
extern mapping_t status_m[]; extern mapping_t status_m[];
/**
* Handle struct timeval like an own type.
*/
typedef struct timeval timeval_t; typedef struct timeval timeval_t;
/**
* Handle struct timespec like an own type.
*/
typedef struct timespec timespec_t; typedef struct timespec timespec_t;
/**
* Handle struct chunk_t like an own type.
*/
typedef struct sockaddr sockaddr_t; typedef struct sockaddr sockaddr_t;
/**
* Use struct chunk_t as chunk_t.
*/
typedef struct chunk_t chunk_t; typedef struct chunk_t chunk_t;
/** /**
* General purpose pointer/length abstraction * General purpose pointer/length abstraction.
*/ */
struct chunk_t { struct chunk_t {
/**
* Pointer to start of data
*/
u_char *ptr; u_char *ptr;
/**
* Length of data in bytes
*/
size_t len; size_t len;
}; };
@@ -76,12 +146,10 @@ struct chunk_t {
extern chunk_t CHUNK_INITIALIZER; extern chunk_t CHUNK_INITIALIZER;
/** /**
* General purpose boolean type * General purpose boolean type.
*/ */
typedef int bool; typedef int bool;
#define FALSE 0 #define FALSE 0
#define TRUE 1 #define TRUE 1
#endif /*TYPES_H_*/ #endif /*TYPES_H_*/