diff options
author | dos-reis <gdr@axiomatics.org> | 2010-11-28 18:27:48 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2010-11-28 18:27:48 +0000 |
commit | a53a740a2a1cb6cbfa58cc79caedd4e947ff1ca0 (patch) | |
tree | 457424993ac0beaa92f79d5304570d9c6f88edfc /src/include | |
parent | bbb5a69f0f2348adbbb8db960e5e45306b865683 (diff) | |
download | open-axiom-a53a740a2a1cb6cbfa58cc79caedd4e947ff1ca0.tar.gz |
* clef/: Add using directive at toplevel.
* etc/: Likewise.
* graph/: Likewise.
* hyper/: Likewise.
* lib/: Likewise.
* sman/: Likewise.
* Makefile.am (OA_SMAN_TARGETS): New.
(OA_GRAPHICS_TARGETS): Likewise.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/cfuns.h | 14 | ||||
-rw-r--r-- | src/include/open-axiom.h | 72 | ||||
-rw-r--r-- | src/include/sockio.h | 32 |
3 files changed, 67 insertions, 51 deletions
diff --git a/src/include/cfuns.h b/src/include/cfuns.h index 28e89d85..9697cf06 100644 --- a/src/include/cfuns.h +++ b/src/include/cfuns.h @@ -1,6 +1,3 @@ -#ifndef OPENAXIOM_CFUNS_included -#define OPENAXIOM_CFUNS_included - /* Copyright (C) 1991-2002, The Numerical ALgorithms Group Ltd. All rights reserved. @@ -36,8 +33,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef OPENAXIOM_CFUNS_included +#define OPENAXIOM_CFUNS_included + #include "open-axiom.h" +namespace OpenAxiom { + OPENAXIOM_C_EXPORT int addtopath(char*); OPENAXIOM_C_EXPORT int directoryp(char*); OPENAXIOM_C_EXPORT int make_path_from_file(char*, char*); @@ -62,11 +64,13 @@ OPENAXIOM_C_EXPORT int oa_copy_file(const char*, const char*); OPENAXIOM_C_EXPORT double plus_infinity(void); OPENAXIOM_C_EXPORT double minus_infinity(void); OPENAXIOM_C_EXPORT double quiet_double_NaN(void); -OPENAXIOM_C_EXPORT openaxiom_byteorder oa_get_host_byteorder(void); +OPENAXIOM_C_EXPORT Byteorder oa_get_host_byteorder(void); OPENAXIOM_C_EXPORT const char* oa_concatenate_string(const char*, const char*); OPENAXIOM_C_EXPORT const char* oa_strcat(const char*, const char*); OPENAXIOM_C_EXPORT char* oa_substr(const char*, const size_t, const size_t); OPENAXIOM_C_EXPORT char** oa_split(const char*, const char*, int*); - + +} + #endif /* OPENAXIOM_CFUNS_included */ diff --git a/src/include/open-axiom.h b/src/include/open-axiom.h index 30cb3fd3..33be7e97 100644 --- a/src/include/open-axiom.h +++ b/src/include/open-axiom.h @@ -65,14 +65,10 @@ #elif defined (HAVE_INTTYPES_H) # include <inttypes.h> #endif -typedef uint8_t openaxiom_byte; /* The opaque datatype. */ #ifdef __WIN32__ -#include <windows.h> -typedef HANDLE openaxiom_handle; -#else -typedef void* openaxiom_handle; +# include <windows.h> #endif #include <unistd.h> @@ -84,27 +80,40 @@ typedef void* openaxiom_handle; # define OPENAXIOM_HAVE_GRAPHICS 1 #endif -/* Byte order enumeration. */ -enum openaxiom_byteorder { - oa_unknown_endian, oa_little_endian, oa_big_endian -}; - +namespace OpenAxiom { + // A name for the byte datatype. + typedef uint8_t Byte; -/* Datatype for packaging information necessary tolaunch a process. */ -struct openaxiom_process { - int argc; - char** argv; - int id; -}; + // An opaque datatype +#ifdef __WIN32__ + typedef HANDLE Handle; +#else + typedef void* Handle; +#endif -enum openaxiom_spawn_flags { - openaxiom_spawn_search_path = 0x01, - openaxiom_spawn_replace = 0x02, -}; + // Byte order of machine word data. + enum Byteorder { + unknown_endian, little_endian, big_endian + }; + + // Datatype for packaging information necessary tolaunch a process. + struct Process { + int argc; + char** argv; + int id; + }; + + enum SpawnFlags { + spawn_search_path = 0x01, + spawn_replace = 0x02, + }; -/* Return the address of the data buffer `BUF'. */ -#define oa_buffer_address(BUF) ((openaxiom_byte*)&BUF[0]) + // Return the address of the byte array object representation of `t'. + template<typename T> + inline Byte* byte_address(T& t) { + return reinterpret_cast<Byte*>(&t); + } /* Internal field separator character. */ #ifdef __WIN32__ @@ -124,19 +133,20 @@ enum openaxiom_spawn_flags { of magnitude of difference when compared to the Unix world. We abstract over that difference here. */ -static inline void -openaxiom_sleep(int n) -{ + static inline void + openaxiom_sleep(int n) + { #ifdef __WIN32__ - Sleep(n * 1000); + Sleep(n * 1000); #else - sleep(n); + sleep(n); #endif -} + } + OPENAXIOM_C_EXPORT void oa_allocate_process_argv(Process*, int); + OPENAXIOM_C_EXPORT int oa_spawn(Process*, SpawnFlags); + OPENAXIOM_C_EXPORT const char* oa_concatenate_string(const char*, const char*); -OPENAXIOM_C_EXPORT void oa_allocate_process_argv(openaxiom_process*, int); -OPENAXIOM_C_EXPORT int oa_spawn(openaxiom_process*, openaxiom_spawn_flags); -OPENAXIOM_C_EXPORT const char* oa_concatenate_string(const char*, const char*); +} #endif /* OPENAXIOM_included */ diff --git a/src/include/sockio.h b/src/include/sockio.h index 03893967..c848c434 100644 --- a/src/include/sockio.h +++ b/src/include/sockio.h @@ -53,6 +53,8 @@ #include "openaxiom-c-macros.h" #include "open-axiom.h" +namespace OpenAxiom { + /* On Windows, a socket identifier is not a file descriptor. It is represented by an integer type, but that integer type is not just plain int as in the Unix world. It is an unsigned integer. @@ -87,36 +89,34 @@ struct openaxiom_sio { OPENAXIOM_C_EXPORT openaxiom_filedesc oa_open_local_client_stream_socket(const char*); -OPENAXIOM_C_EXPORT int oa_inet_pton(const char*, int, openaxiom_byte*); -OPENAXIOM_C_EXPORT int oa_get_host_address(const char*, int, openaxiom_byte*); +OPENAXIOM_C_EXPORT int oa_inet_pton(const char*, int, Byte*); +OPENAXIOM_C_EXPORT int oa_get_host_address(const char*, int, Byte*); OPENAXIOM_C_EXPORT int oa_open_local_server_stream_socket(const char*); OPENAXIOM_C_EXPORT openaxiom_socket - oa_connect_ip_port_stream(const openaxiom_byte*, int, openaxiom_port); + oa_connect_ip_port_stream(const Byte*, int, openaxiom_port); -OPENAXIOM_C_EXPORT int oa_socket_write(openaxiom_socket, - const openaxiom_byte*, int); -OPENAXIOM_C_EXPORT int oa_socket_write_byte(openaxiom_socket, openaxiom_byte); +OPENAXIOM_C_EXPORT int oa_socket_write(openaxiom_socket, const Byte*, int); +OPENAXIOM_C_EXPORT int oa_socket_write_byte(openaxiom_socket, Byte); -OPENAXIOM_C_EXPORT int oa_socket_read(openaxiom_socket, - openaxiom_byte*, int); +OPENAXIOM_C_EXPORT int oa_socket_read(openaxiom_socket, Byte*, int); OPENAXIOM_C_EXPORT int oa_socket_read_byte(openaxiom_socket); OPENAXIOM_C_EXPORT void oa_close_socket(openaxiom_socket); OPENAXIOM_C_EXPORT int -oa_filedesc_write(openaxiom_filedesc, const openaxiom_byte*, int); +oa_filedesc_write(openaxiom_filedesc, const Byte*, int); OPENAXIOM_C_EXPORT int -oa_filedesc_read(openaxiom_filedesc, openaxiom_byte*, int); +oa_filedesc_read(openaxiom_filedesc, Byte*, int); OPENAXIOM_C_EXPORT int oa_filedesc_close(openaxiom_filedesc); -OPENAXIOM_C_EXPORT int sread(openaxiom_sio*, openaxiom_byte*, int, const char*); -OPENAXIOM_C_EXPORT int swrite(openaxiom_sio*, const openaxiom_byte*, int, +OPENAXIOM_C_EXPORT int sread(openaxiom_sio*, Byte*, int, const char*); +OPENAXIOM_C_EXPORT int swrite(openaxiom_sio*, const Byte*, int, const char*); -OPENAXIOM_C_EXPORT int wait_for_client_read(openaxiom_sio*, openaxiom_byte*, +OPENAXIOM_C_EXPORT int wait_for_client_read(openaxiom_sio*, Byte*, int, const char*); OPENAXIOM_C_EXPORT int wait_for_client_write(openaxiom_sio*, - const openaxiom_byte*, int, + const Byte*, int, const char*); OPENAXIOM_C_EXPORT int make_server_name(char*, const char*); @@ -133,7 +133,7 @@ OPENAXIOM_C_EXPORT double sock_get_float(int); OPENAXIOM_C_EXPORT int get_sfloats(openaxiom_sio*, float*, int); OPENAXIOM_C_EXPORT char* get_string(openaxiom_sio*); OPENAXIOM_C_EXPORT void sigpipe_handler(int); -OPENAXIOM_C_EXPORT int fill_buf(openaxiom_sio*, openaxiom_byte*, int, +OPENAXIOM_C_EXPORT int fill_buf(openaxiom_sio*, Byte*, int, const char*); OPENAXIOM_C_EXPORT int sock_get_int(int); OPENAXIOM_C_EXPORT int get_ints(openaxiom_sio*, int*, int); @@ -219,4 +219,6 @@ OPENAXIOM_C_EXPORT openaxiom_sio clients[]; OPENAXIOM_C_EXPORT fd_set socket_mask; OPENAXIOM_C_EXPORT fd_set server_mask; +} + #endif /* OPENAXIOM_SOCKIO_included */ |