1 /***************************************************************************
2 kdbos.h - operating system specific workarounds
4 begin : Mon Dec 29 2003
5 copyright : (C) 2003 by Avi Alkalay
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the BSD License (revised). *
14 ***************************************************************************/
16 /* This header purpose is that afterwards following types are defined:
17 * .. means don't care, just enough for your system
18 * For more information on that types read POSIX documentation.
21 * size_t size of array or string 0, SIZE_MAX
22 * ssize_t size with error cond. -1, SSIZE_MAX(<SIZE_MAX)
23 * time_t Seconds since 1970 0,.. recommended: 64 bit
25 * Integer Types must be at least 32bit:
27 * int Integral Fast Type INT_MIN, INT_MAX
28 * uid_t User identification 0,..
29 * gid_t Group identification 0,..
30 * type_t Typing information -1,..
31 * keyswitch_t For keyNew
32 * option_t For kdbGet, kdbSet and ksLookup*
35 * Following elektra specific types are defined:
38 * cursor_t stores information to find a position in a keyset
40 * Following constants must be defined:
42 * KEY_SEPARATOR how to delimit keynames
43 * PATH_SEPARATOR how to delimit pathnames
44 * KEY_DEF_MODE the standard mode for keys
45 * KEY_DIR_MODE the mode to add (|=) for key directories
47 * Following limits must be defined (in addition to limits mentioned
50 * MAX_UCHAR the maximum for unsigned char
51 * MAX_KEY_LENGTH the maximum length for a keyname
52 * MAX_PATH_LENGTH the maximum length for a pathname
54 * In addition to the types the ... or va_list must be supported,
55 * this is ISO C and should happen by including <stdarg.h>.
57 * Go ahead and write a #ifdef block for your operating system
58 * when the POSIX defaults are not ok.
66 /* Include essential headers used in kdb.h */
71 /***************************************************
73 ***************************************************/
80 /* Conforming C++ programs are not allowed to
81 * include inttypes.h*/
83 #include <sys/types.h>
85 /**Separator for Path names*/
86 #define PATH_SEPARATOR '/'
89 /**MAX_PATH_LENGTH will be the value for longest
90 * possible filenames on the system.*/
92 /*Some systems have even longer pathnames*/
94 #define MAX_PATH_LENGTH PATH_MAX
95 /*This value is garanteed on any Posixsystem*/
96 #elif defined __USE_POSIX
97 #define MAX_PATH_LENGTH _POSIX_PATH_MAX
99 #define MAX_PATH_LENGTH 4096
102 /*Type to point to every position within the keyset*/
103 typedef ssize_t cursor_t;
107 typedef int keyswitch_t;
108 typedef int option_t;
110 /**Separator for key names.
111 * This character will be used to separate key names*/
112 #define KEY_SEPARATOR '/'
114 * This mode will be used for fresh keys*/
115 #define KEY_DEF_MODE 0664
116 /**Default directory mode.
117 * This mode will be ORed to have a directory key*/
118 #define KEY_DEF_DIR 0111
120 /**Lets assume that the namespace + relative path is shorter then the absolute path.
121 * So the maximum length of key is what the system allows for the path.*/
122 #define MAX_KEY_LENGTH MAX_PATH_LENGTH
129 /***************************************************
131 ***************************************************/
132 # include <windows.h>
135 # define usleep(x) Sleep(x)
138 # define snprintf _snprintf
140 /**Separator for Path names*/
141 #define PATH_SEPARATOR '\\'
143 #define MAX_PATH_LENGTH 4096
145 /*Type to point to every position within the keyset*/
146 typedef ssize_t cursor_t;
150 typedef int keyswitch_t;
151 typedef int option_t;
153 /**Separator for key names.
154 * This character will be used to separate key names*/
155 #define KEY_SEPARATOR '/'
157 * This mode will be used for fresh keys*/
158 #define KEY_DEF_MODE 0664
159 /**Default directory mode.
160 * This mode will be ORed to have a directory key*/
161 #define KEY_DEF_DIR 0111
163 /**Lets assume that the namespace + relative path is shorter then the absolute path.
164 * So the maximum length of key is what the system allows for the path.*/
165 #define MAX_KEY_LENGTH MAX_PATH_LENGTH