From a53a740a2a1cb6cbfa58cc79caedd4e947ff1ca0 Mon Sep 17 00:00:00 2001
From: dos-reis <gdr@axiomatics.org>
Date: Sun, 28 Nov 2010 18:27:48 +0000
Subject: 	* 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.

---
 src/ChangeLog                   | 11 +++++
 src/Makefile.am                 |  7 ++-
 src/Makefile.in                 |  7 ++-
 src/clef/edible.c               |  2 +
 src/driver/main.c               | 33 +++++++-------
 src/driver/utils.c              | 97 +++++++++++++++++++++--------------------
 src/driver/utils.h              | 52 +++++++++++-----------
 src/etc/asq.c.pamphlet          |  1 +
 src/graph/Gdraws/Gfun.c         |  2 +
 src/graph/include/sselect.H1    |  2 +-
 src/graph/view2D/main2d.c       |  2 +
 src/graph/view2D/process2d.c    |  4 +-
 src/graph/view2D/viewport2D.c   |  2 +
 src/graph/view3D/main3d.c       |  2 +
 src/graph/view3D/process3d.c    |  2 +-
 src/graph/viewAlone/spoon2D.c   |  2 +
 src/graph/viewAlone/spoonComp.c |  2 +
 src/graph/viewman/fun2D.c       |  2 +
 src/graph/viewman/fun3D.c       |  2 +
 src/graph/viewman/globalsM.h    |  2 +-
 src/graph/viewman/sselect.c     |  6 +--
 src/graph/viewman/viewman.c     |  6 ++-
 src/hyper/addfile.c             |  2 +
 src/hyper/ex2ht.c               |  2 +
 src/hyper/extent2.c             |  2 +
 src/hyper/htadd.c               |  3 ++
 src/hyper/htinp.c               |  2 +
 src/hyper/htsearch.cc           |  3 ++
 src/hyper/hyper.c               |  2 +
 src/hyper/hyper.h               |  6 +--
 src/hyper/initx.c               |  2 +
 src/hyper/lex.c                 |  8 +++-
 src/hyper/node.h                |  2 +-
 src/hyper/parse-types.c         |  2 +
 src/hyper/parse.c               |  2 +
 src/hyper/spadbuf.c             |  4 +-
 src/hyper/spadint.c             |  2 +
 src/hyper/titlebar.c            |  2 +
 src/include/cfuns.h             | 14 +++---
 src/include/open-axiom.h        | 72 +++++++++++++++++-------------
 src/include/sockio.h            | 32 +++++++-------
 src/lib/cfuns-c.c               | 19 ++++----
 src/lib/fnct_key.c              |  2 +
 src/lib/sockio-c.c              | 58 ++++++++++++------------
 src/lib/util.c                  |  2 +
 src/sman/session.c              | 12 ++---
 src/sman/sman.c                 | 31 ++++++-------
 src/sman/spadclient.c           |  2 +
 48 files changed, 318 insertions(+), 220 deletions(-)

(limited to 'src')

diff --git a/src/ChangeLog b/src/ChangeLog
index f342236d..3b34f6b2 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
+2010-11-28  Gabriel Dos Reis  <gdr@cs.tamu.edu>
+
+	* 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.
+
 2010-11-27  Gabriel Dos Reis  <gdr@cs.tamu.edu>
 
 	* lib/Makefile.in: Build libopen-axiom-core and libspad with a C++
diff --git a/src/Makefile.am b/src/Makefile.am
index 60024a43..680b71a1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -39,13 +39,12 @@ DIST_SUBDIRS = \
 
 oa_targetdir = $(top_builddir)/$(target)
 
-OA_OPTIONAL_TARGETS=
 if OA_BUILD_SMAN
-OA_OPTIONAL_TARGETS += all-sman all-clef
+OA_SMAN_TARGETS = all-sman all-clef
 endif
 
 if OA_BUILD_GRAPHICS
-OA_OPTIONAL_TARGETS += all-graph
+OA_GRAPHICS_TARGETS = all-graph
 endif
 
 
@@ -54,7 +53,7 @@ all-local: all-src
 .PHONY: all-src
 all-src: all-lib all-utils all-driver all-lisp all-boot \
 	all-interpsys all-algebra all-axiomsys all-share \
-	all-asq all-input all-doc $(OA_OPTIONAL_TARGETS)
+	all-asq all-input all-doc $(OA_SMAN_TARGETS) $(OA_GRAPHICS_TARGETS)
 
 stamp-subdirs:
 	rm -f stamp-subdirs
diff --git a/src/Makefile.in b/src/Makefile.in
index 0d210a20..6e980cb1 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -66,8 +66,6 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@OA_BUILD_SMAN_TRUE@am__append_1 = all-sman all-clef
-@OA_BUILD_GRAPHICS_TRUE@am__append_2 = all-graph
 subdir = src
 SUBDIRS =
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog
@@ -301,7 +299,8 @@ DIST_SUBDIRS = \
 	testsuite utils
 
 oa_targetdir = $(top_builddir)/$(target)
-OA_OPTIONAL_TARGETS = $(am__append_1) $(am__append_2)
+@OA_BUILD_SMAN_TRUE@OA_SMAN_TARGETS = all-sman all-clef
+@OA_BUILD_GRAPHICS_TRUE@OA_GRAPHICS_TARGETS = all-graph
 all: all-recursive
 
 .SUFFIXES:
@@ -652,7 +651,7 @@ all-local: all-src
 .PHONY: all-src
 all-src: all-lib all-utils all-driver all-lisp all-boot \
 	all-interpsys all-algebra all-axiomsys all-share \
-	all-asq all-input all-doc $(OA_OPTIONAL_TARGETS)
+	all-asq all-input all-doc $(OA_SMAN_TARGETS) $(OA_GRAPHICS_TARGETS)
 
 stamp-subdirs:
 	rm -f stamp-subdirs
diff --git a/src/clef/edible.c b/src/clef/edible.c
index 918d354b..f4116f3d 100644
--- a/src/clef/edible.c
+++ b/src/clef/edible.c
@@ -58,6 +58,8 @@
 #include "fnct_key.h"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 #ifdef AXIOM_UNLIKELY
 #define log 1
 #define logterm 1
diff --git a/src/driver/main.c b/src/driver/main.c
index 7a7bc161..002ccef8 100644
--- a/src/driver/main.c
+++ b/src/driver/main.c
@@ -48,6 +48,8 @@
 
 #define OPENAXIOM_GLOBAL_ENV   "AXIOM"
 
+namespace OpenAxiom {
+
 /* Publish the system exec prefix for use by sub-processes.  */
 static void
 publish_systemdir(const char* dir)
@@ -87,7 +89,7 @@ upgrade_environment(const char* sysdir) {
 
 /* Print configuration info. */
 static int
-print_configuration_info(openaxiom_command* command) {
+print_configuration_info(Command* command) {
    int i;
    for (i = 1; i < command->core.argc; ++i) {
       if (strcmp(command->core.argv[i], "include") == 0)
@@ -104,35 +106,35 @@ print_configuration_info(openaxiom_command* command) {
    return 0;
 }
 
+}
 
 int
 main(int argc, char* argv[])
 {
-   openaxiom_command command = { };
-   openaxiom_driver driver =
-      openaxiom_preprocess_arguments(&command, argc, argv);
+   using namespace OpenAxiom;
+   Command command = { };
+   Driver driver = preprocess_arguments(&command, argc, argv);
    upgrade_environment(command.root_dir);
 
    switch (driver) {
-   case openaxiom_null_driver:
+   case null_driver:
       return 0;                 /* Bye.  */
 
-   case openaxiom_config_driver:
+   case config_driver:
       return print_configuration_info(&command);
 
-   case openaxiom_core_driver:
-   case openaxiom_script_driver:
-   case openaxiom_compiler_driver:
+   case core_driver:
+   case script_driver:
+   case compiler_driver:
       putenv("LC_ALL=C");
       setlocale(LC_ALL, "");
-      return openaxiom_execute_core(&command, driver);
+      return execute_core(&command, driver);
 
-   case openaxiom_execute_driver:
+   case execute_driver:
       return oa_spawn(&command.core,
-                      openaxiom_spawn_flags
-                      (openaxiom_spawn_search_path | openaxiom_spawn_replace));
+                      SpawnFlags(spawn_search_path | spawn_replace));
 
-   case openaxiom_sman_driver:
+   case sman_driver:
       break;
 
    default:
@@ -143,8 +145,7 @@ main(int argc, char* argv[])
    /* Should not happen on MS platforms.  */
    abort();
 #else  /* __WIN32__ */
-   execv(openaxiom_make_path_for(command.root_dir, openaxiom_sman_driver),
-         argv);
+   execv(make_path_for(command.root_dir, sman_driver), argv);
    perror(strerror(errno));
    return -1;
 #endif /* __WIN32__ */
diff --git a/src/driver/utils.c b/src/driver/utils.c
index 6914c5ac..5122ca9b 100644
--- a/src/driver/utils.c
+++ b/src/driver/utils.c
@@ -37,6 +37,8 @@
 #include <stdio.h>
 #include "utils.h"
 
+namespace OpenAxiom {
+
 /* The basename of the file holding the OpenAxiom core executable.  */
 #define OPENAXIOM_CORE_EXECUTABLE \
    "AXIOMsys" OPENAXIOM_EXEEXT
@@ -64,7 +66,7 @@
 /* Return a path to the running system, either as specified on command
    line through --system=, or as specified at configuration time.  */
 const char*
-openaxiom_get_systemdir(int argc, char* argv[])
+get_systemdir(int argc, char* argv[])
 {
    int i;
 
@@ -84,15 +86,15 @@ openaxiom_get_systemdir(int argc, char* argv[])
 
 /* Return the path to `driver'. */
 static const char*
-get_driver_name(openaxiom_driver driver)
+get_driver_name(Driver driver)
 {
    switch (driver) {
-   case openaxiom_sman_driver:
+   case sman_driver:
       return OPENAXIOM_SMAN_PATH;
 
-   case openaxiom_script_driver:
-   case openaxiom_compiler_driver:
-   case openaxiom_core_driver:
+   case script_driver:
+   case compiler_driver:
+   case core_driver:
       return OPENAXIOM_CORE_PATH;
 
    default:
@@ -103,7 +105,7 @@ get_driver_name(openaxiom_driver driver)
 
 /* Return a path for PROG specified as a relative path to PREFIX.  */
 const char*
-openaxiom_make_path_for(const char* prefix, openaxiom_driver driver)
+make_path_for(const char* prefix, Driver driver)
 {
    const int prefix_length = strlen(prefix);
    const char* prog = get_driver_name(driver);
@@ -116,7 +118,7 @@ openaxiom_make_path_for(const char* prefix, openaxiom_driver driver)
 /* Allocate a nul-terminated vector for holding pointers to arguments
    for the base Lisp runtime.   */
 static void
-openaxiom_allocate_argv(openaxiom_command* command, int n) {
+openaxiom_allocate_argv(Command* command, int n) {
    command->rt_argc = n;
    command->rt_argv = (char**) malloc((n + 1) * sizeof(char*));
    command->rt_argv[n] = 0;
@@ -125,23 +127,22 @@ openaxiom_allocate_argv(openaxiom_command* command, int n) {
 /* Build arguments, if any, to be supplied to the runtime system
    of `driver'.  */
 void
-openaxiom_build_rts_options(openaxiom_command* command,
-                            openaxiom_driver driver)
+build_rts_options(Command* command, Driver driver)
 {
    switch (driver) {
-   case openaxiom_config_driver:
-   case openaxiom_sman_driver:
-   case openaxiom_execute_driver:
-   case openaxiom_unknown_driver:
+   case config_driver:
+   case sman_driver:
+   case execute_driver:
+   case unknown_driver:
       break;
 
-   case openaxiom_core_driver:
+   case core_driver:
       break;
 
-   case openaxiom_compiler_driver:
-   case openaxiom_script_driver:
+   case compiler_driver:
+   case script_driver:
       switch (OPENAXIOM_BASE_RTS) {
-      case openaxiom_gcl_runtime:
+      case gcl_runtime:
          openaxiom_allocate_argv(command, 3);
          command->rt_argv[0] = (char*) "-batch";
          command->rt_argv[1] = (char*) "-eval";
@@ -149,7 +150,7 @@ openaxiom_build_rts_options(openaxiom_command* command,
             (char*) ("(" OPENAXIOM_LISP_CORE_ENTRY_POINT ")");
          break;
 
-      case openaxiom_sbcl_runtime:
+      case sbcl_runtime:
          openaxiom_allocate_argv(command, 4);
          command->rt_argv[0] = (char*) "--noinform";
          command->rt_argv[1] = (char*) "--end-runtime-options";
@@ -157,13 +158,13 @@ openaxiom_build_rts_options(openaxiom_command* command,
          command->rt_argv[3] = (char*) "--end-toplevel-options";
          break;
 
-      case openaxiom_clozure_runtime:
+      case clozure_runtime:
          openaxiom_allocate_argv(command, 2);
          command->rt_argv[0] = (char*) "--quiet";
          command->rt_argv[1] = (char*) "--batch";
          break;
 
-      case openaxiom_clisp_runtime:
+      case clisp_runtime:
          openaxiom_allocate_argv(command, 2);
          command->rt_argv[0] = (char*) "--quiet";
          command->rt_argv[1] = (char*) "-norc";
@@ -180,9 +181,9 @@ openaxiom_build_rts_options(openaxiom_command* command,
 }
 
 #if OPENAXIOM_USE_SMAN
-#  define OPENAXIOM_DEFAULT_DRIVER openaxiom_sman_driver
+#  define OPENAXIOM_DEFAULT_DRIVER sman_driver
 #else
-#  define OPENAXIOM_DEFAULT_DRIVER openaxiom_core_driver
+#  define OPENAXIOM_DEFAULT_DRIVER core_driver
 #endif
 
 
@@ -235,44 +236,43 @@ static void print_usage(void) {
 }
 
 /* Determine driver to be used for executing `command'.  */
-openaxiom_driver
-openaxiom_preprocess_arguments(openaxiom_command* command,
-                               int argc, char** argv)
+Driver
+preprocess_arguments(Command* command, int argc, char** argv)
 {
    int i;
    int other = 1;
    int files = 0;
-   openaxiom_driver driver = openaxiom_unknown_driver;
+   Driver driver = unknown_driver;
 
-   command->root_dir = openaxiom_get_systemdir(argc, argv);
+   command->root_dir = get_systemdir(argc, argv);
    for (i = 1; i < argc; ++i)
       if(strcmp(argv[i], "--no-server") == 0)
-         driver = openaxiom_core_driver;
+         driver = core_driver;
       else if (strcmp(argv[i], "--server") == 0)
-         driver = openaxiom_sman_driver;
+         driver = sman_driver;
       else if (strcmp(argv[i], "--config") == 0)
-         driver = openaxiom_config_driver;
+         driver = config_driver;
       else if (strcmp(argv[i], "--execute") == 0) {
-         driver = openaxiom_execute_driver;
+         driver = execute_driver;
          break;
       }
       else if (strcmp(argv[i], "--help") == 0) {
          print_usage();
-         driver = openaxiom_null_driver;
+         driver = null_driver;
          break;
       }
       else if (strcmp(argv[i], "--version") == 0) {
          print_version();
-         driver = openaxiom_null_driver;
+         driver = null_driver;
          break;
       }
       else {
          /* Apparently we will invoke the Core system; we need to
             pass on this option.  */
          if (strcmp(argv[i], "--script") == 0)
-            driver = openaxiom_script_driver;
+            driver = script_driver;
          else if(strcmp(argv[i], "--compile") == 0)
-            driver = openaxiom_compiler_driver;
+            driver = compiler_driver;
          else {
             if (argv[i][0] == '-')
                /* Maybe option for the driver.  */
@@ -289,7 +289,7 @@ openaxiom_preprocess_arguments(openaxiom_command* command,
       }
 
    /* Determine argument vector.  */
-   if (driver == openaxiom_execute_driver) {
+   if (driver == execute_driver) {
       command->core.argc = argc - i - 1;
       command->core.argv = argv + i + 1;
    }
@@ -298,13 +298,13 @@ openaxiom_preprocess_arguments(openaxiom_command* command,
       command->core.argv = argv;
    }
 
-   if (driver != openaxiom_null_driver) {
+   if (driver != null_driver) {
       /* If we have a file but not instructed to compile, assume
          we are asked to interpret a script.  */
       if (files > 0)
          switch (driver) {
-         case openaxiom_unknown_driver:
-         case openaxiom_sman_driver:
+         case unknown_driver:
+         case sman_driver:
             command->core.argc += 1;
             command->core.argv =
                (char**) malloc((other + 2) * sizeof(char*));
@@ -312,17 +312,17 @@ openaxiom_preprocess_arguments(openaxiom_command* command,
             command->core.argv[1] = (char*) "--script";
             for (i = 0; i < other; ++i)
                command->core.argv[2 + i] = argv[1 + i];
-            driver = openaxiom_script_driver;
+            driver = script_driver;
             break;
          default:
             /* Driver specified by user.  */
             break;
          }
-      else if (driver == openaxiom_unknown_driver)
+      else if (driver == unknown_driver)
          driver = OPENAXIOM_DEFAULT_DRIVER;
       command->core.argv[command->core.argc] = NULL;
       
-      openaxiom_build_rts_options(command, driver);
+      build_rts_options(command, driver);
    }
    return driver;
 }
@@ -334,10 +334,9 @@ openaxiom_preprocess_arguments(openaxiom_command* command,
    POSIX systems, this is a non-return function on success.
    See execv().  */
 int
-openaxiom_execute_core(const openaxiom_command* command,
-                       openaxiom_driver driver)
+execute_core(const Command* command, Driver driver)
 {
-   char* execpath = (char*) openaxiom_make_path_for(command->root_dir, driver);
+   char* execpath = (char*) make_path_for(command->root_dir, driver);
 #ifdef __WIN32__
    char* command_line;
    int cur = strlen(command->core.argv[0]);
@@ -410,11 +409,11 @@ openaxiom_execute_core(const openaxiom_command* command,
       malloc(sizeof (char*) * (command->rt_argc + command->core.argc + 2));
    /* GCL has this oddity that it wants to believe that argv[0] has
       something to tell about what GCL's own runtime is.  Silly.  */
-   if (OPENAXIOM_BASE_RTS == openaxiom_gcl_runtime)
+   if (OPENAXIOM_BASE_RTS == gcl_runtime)
       args[0] = (char*) "";
    /* And CLISP wants to believe that argv[0] is where it hides stuff
       from the saved image.  */
-   else if (OPENAXIOM_BASE_RTS == openaxiom_clisp_runtime)
+   else if (OPENAXIOM_BASE_RTS == clisp_runtime)
       args[0] = execpath;
    else
       args[0] = command->core.argv[0];
@@ -442,3 +441,5 @@ openaxiom_execute_core(const openaxiom_command* command,
    return -1;
 #endif /* __WIN32__ */
 }
+
+}
diff --git a/src/driver/utils.h b/src/driver/utils.h
index 8f56ba45..4f973973 100644
--- a/src/driver/utils.h
+++ b/src/driver/utils.h
@@ -42,45 +42,47 @@
 #  include <windows.h>
 #endif
 
+namespace OpenAxiom {
+
 /* A list of drivers for OpenAxiom.  */
-enum openaxiom_driver {
-   openaxiom_unknown_driver,    /* unknown driver */
-   openaxiom_null_driver,       /* do nothing */
-   openaxiom_config_driver,     /* print out configuration information */
-   openaxiom_sman_driver,       /* start Superman as master process */
-   openaxiom_core_driver,       /* start the core system as master process */
-   openaxiom_script_driver,     /* start the core system in script mode. */
-   openaxiom_compiler_driver,   /* start the core system in compiler mode. */
-   openaxiom_execute_driver     /* Execute a command.  */
+enum Driver {
+   unknown_driver,    /* unknown driver */
+   null_driver,       /* do nothing */
+   config_driver,     /* print out configuration information */
+   sman_driver,       /* start Superman as master process */
+   core_driver,       /* start the core system as master process */
+   script_driver,     /* start the core system in script mode. */
+   compiler_driver,   /* start the core system in compiler mode. */
+   execute_driver     /* Execute a command.  */
 };
 
 /* A list of runtime support systems for OpenAxiom. */
-enum openaxiom_runtime {
-   openaxiom_unknown_runtime,
-   openaxiom_gcl_runtime,       /* GCL-based runtime  */
-   openaxiom_sbcl_runtime,      /* SBCL-based runtime */
-   openaxiom_clisp_runtime,     /* CLISP-based runtime */
-   openaxiom_ecl_runtime,       /* ECL-based runtime */
-   openaxiom_clozure_runtime,   /* Clozure CL-based runtime */
-   openaxiom_bemol_runtime      /* Bemol-based runtime */
+enum Runtime {
+   unknown_runtime,
+   gcl_runtime,       /* GCL-based runtime  */
+   sbcl_runtime,      /* SBCL-based runtime */
+   clisp_runtime,     /* CLISP-based runtime */
+   ecl_runtime,       /* ECL-based runtime */
+   clozure_runtime,   /* Clozure CL-based runtime */
+   bemol_runtime      /* Bemol-based runtime */
 };
 
 /* A description of external command to be executed.  */
-struct openaxiom_command {
-   openaxiom_process core;      /* arguments for actual executable.  */
+struct Command {
+   Process core;      /* arguments for actual executable.  */
    char** rt_argv;              /* arguments to the base RT, if any.  */
    int rt_argc;                 /* number of such arguments.  */
    const char* root_dir;        /* path to the OpenAxiom system. */
 };
 
-const char* openaxiom_get_systemdir(int argc, char*[]);
-const char* openaxiom_make_path_for(const char*, openaxiom_driver);
+const char* get_systemdir(int argc, char*[]);
+const char* make_path_for(const char*, Driver);
 
-int openaxiom_execute_core(const openaxiom_command*, openaxiom_driver);
-void openaxiom_build_rts_options(openaxiom_command*, openaxiom_driver);
+int execute_core(const Command*, Driver);
+void build_rts_options(Command*, Driver);
 
-openaxiom_driver
-  openaxiom_preprocess_arguments(openaxiom_command*, int, char**);
+Driver preprocess_arguments(Command*, int, char**);
 
+}
 
 #endif /* OPENAXIOM_UTILS_INCLUDED */
diff --git a/src/etc/asq.c.pamphlet b/src/etc/asq.c.pamphlet
index a5f37be0..f5c0c8b1 100644
--- a/src/etc/asq.c.pamphlet
+++ b/src/etc/asq.c.pamphlet
@@ -533,6 +533,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <string.h>
 
 #include "cfuns.h"
+using namespace OpenAxiom;
 
 /* we need to predeclare some functions so their signatures are known */
 int printandor(char *list);
diff --git a/src/graph/Gdraws/Gfun.c b/src/graph/Gdraws/Gfun.c
index 7052256b..07237838 100644
--- a/src/graph/Gdraws/Gfun.c
+++ b/src/graph/Gdraws/Gfun.c
@@ -48,6 +48,8 @@
 #include "Gfun.H1"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 
 /*
  * Given 2 file pointers, this function copies file ifp to file ofp
diff --git a/src/graph/include/sselect.H1 b/src/graph/include/sselect.H1
index 9dc75670..46645e0e 100644
--- a/src/graph/include/sselect.H1
+++ b/src/graph/include/sselect.H1
@@ -1,2 +1,2 @@
-extern int superSelect(int n , int * rd , int * wr , int * ex , char * timeout);
+extern int superSelect(int n , fd_set * rd , fd_set * wr , fd_set * ex , timeval * timeout);
 
diff --git a/src/graph/view2D/main2d.c b/src/graph/view2D/main2d.c
index 5df59398..5642c7ae 100644
--- a/src/graph/view2D/main2d.c
+++ b/src/graph/view2D/main2d.c
@@ -51,6 +51,8 @@
 #include "XSpadFill.h"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 
 /**********************/
 /** global variables **/
diff --git a/src/graph/view2D/process2d.c b/src/graph/view2D/process2d.c
index eb711bc9..803a2822 100644
--- a/src/graph/view2D/process2d.c
+++ b/src/graph/view2D/process2d.c
@@ -54,6 +54,8 @@
 #include "XSpadFill.h"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 
 static int doit=0;  /* globish variable for picking/dropping/clearing - all sorts of
                 2 button sequence events (command & graph #). */
@@ -533,7 +535,7 @@ processEvents(void)
         break;
       }
       if (!followMouse) 
-        len=select(FD_SETSIZE,(void *) &rd,0,0,0); 
+        len=select(FD_SETSIZE, &rd,0,0,0); 
       else 
         len=1;
     }
diff --git a/src/graph/view2D/viewport2D.c b/src/graph/view2D/viewport2D.c
index ec1f7083..0d5aaf30 100644
--- a/src/graph/view2D/viewport2D.c
+++ b/src/graph/view2D/viewport2D.c
@@ -60,6 +60,8 @@
 #include "spadBitmap.bitmap"
 #include "spadMask.mask"
 
+using namespace OpenAxiom;
+
 #define rint(z) ((int)(z))
 
 Atom    wm_delete_window;               
diff --git a/src/graph/view3D/main3d.c b/src/graph/view3D/main3d.c
index 60593094..b00d2b87 100644
--- a/src/graph/view3D/main3d.c
+++ b/src/graph/view3D/main3d.c
@@ -54,6 +54,8 @@
 #include "all_3d.H1"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
                                  /**********************/
                                  /** global variables **/
                                  /**********************/
diff --git a/src/graph/view3D/process3d.c b/src/graph/view3D/process3d.c
index 5e56825d..dc8540b0 100644
--- a/src/graph/view3D/process3d.c
+++ b/src/graph/view3D/process3d.c
@@ -913,7 +913,7 @@ processEvents(void)
         break;
       }
       if (!followMouse) 
-        len=select(FD_SETSIZE,(void *)&rd,0,0,0); 
+        len=select(FD_SETSIZE, &rd,0,0,0); 
       else 
         len=1;
     }
diff --git a/src/graph/viewAlone/spoon2D.c b/src/graph/viewAlone/spoon2D.c
index d19b008f..2765ce56 100644
--- a/src/graph/viewAlone/spoon2D.c
+++ b/src/graph/viewAlone/spoon2D.c
@@ -47,6 +47,8 @@
 #include "cfuns.h"
 #include "all_alone.H1"
 
+using namespace OpenAxiom;
+
 /* #define huhDEBUG */
 
 /* #define spoonDEBUG  */
diff --git a/src/graph/viewAlone/spoonComp.c b/src/graph/viewAlone/spoonComp.c
index 8c8dcd0e..b708eed3 100644
--- a/src/graph/viewAlone/spoonComp.c
+++ b/src/graph/viewAlone/spoonComp.c
@@ -47,6 +47,8 @@
 #include "cfuns.h"
 #include "all_alone.H1"
 
+using namespace OpenAxiom;
+
 
 
 /* This file forks a child process and exits the parent. It 
diff --git a/src/graph/viewman/fun2D.c b/src/graph/viewman/fun2D.c
index 7027a40b..02810ffe 100644
--- a/src/graph/viewman/fun2D.c
+++ b/src/graph/viewman/fun2D.c
@@ -52,6 +52,8 @@
 #include "make2D.H1"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 #define writeEach
 
 void 
diff --git a/src/graph/viewman/fun3D.c b/src/graph/viewman/fun3D.c
index f277a442..a0ced1b6 100644
--- a/src/graph/viewman/fun3D.c
+++ b/src/graph/viewman/fun3D.c
@@ -52,6 +52,8 @@
 #include "readView.H1"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 void 
 funView3D(int viewCommand)
 {
diff --git a/src/graph/viewman/globalsM.h b/src/graph/viewman/globalsM.h
index cce83265..0dd1690b 100644
--- a/src/graph/viewman/globalsM.h
+++ b/src/graph/viewman/globalsM.h
@@ -34,7 +34,7 @@
 */
 
 extern viewManager *viewports,*slot,*stepSlot;
-extern openaxiom_sio* spadSock;
+extern OpenAxiom::openaxiom_sio* spadSock;
 extern int         viewType, viewCommand; 
 extern fd_set         filedes;
 extern int             acknow;
diff --git a/src/graph/viewman/sselect.c b/src/graph/viewman/sselect.c
index 0e56e9a7..68a3f869 100644
--- a/src/graph/viewman/sselect.c
+++ b/src/graph/viewman/sselect.c
@@ -60,14 +60,14 @@
  *******************************************/
  
 int 
-superSelect(int n, int *rd, int *wr, int *ex, char *timeout)
+superSelect(int n, fd_set *rd, fd_set *wr, fd_set *ex, timeval *timeout)
 {
   
   int waiting;
   viewManager *viewport;
   int ret_val;
   
-  ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (void *)timeout);
+  ret_val = select(n, rd, wr, ex, timeout);
   while (ret_val == -1 && errno == EINTR) {
     /* checkClosedChild gets set by the SIGCHLD handler */
     if (checkClosedChild) {
@@ -84,7 +84,7 @@ superSelect(int n, int *rd, int *wr, int *ex, char *timeout)
         bsdSignal(OPENAXIOM_SIGCHLD,endChild,DontRestartSystemCalls);
       }
     }
-    ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (void *)timeout);
+    ret_val = select(n, rd, wr, ex, timeout);
   }
   return ret_val;
 }
diff --git a/src/graph/viewman/viewman.c b/src/graph/viewman/viewman.c
index a8dd4777..5085a3e9 100644
--- a/src/graph/viewman/viewman.c
+++ b/src/graph/viewman/viewman.c
@@ -57,6 +57,8 @@
 #include "cleanup.H1"
 #include "sselect.H1"
 
+using namespace OpenAxiom;
+
 /************* global variables **************/
 
 Display *dsply;
@@ -125,9 +127,9 @@ main (void)
 #ifdef DEBUG
     fprintf(stderr,"Selection for filedes of %x \n",filedes);
 #endif
-    code = check(superSelect(FD_SETSIZE,(void *) &filedes,0,0,0));
+    code = check(superSelect(FD_SETSIZE, &filedes,0,0,0));
     for (;code<=0;) 
-      code = check(superSelect(FD_SETSIZE,(void *)&filedes,0,0,0));
+      code = check(superSelect(FD_SETSIZE, &filedes,0,0,0));
     
     slot = viewports;
     keepLooking = 1;
diff --git a/src/hyper/addfile.c b/src/hyper/addfile.c
index 1e6c6b9b..3671b2a5 100644
--- a/src/hyper/addfile.c
+++ b/src/hyper/addfile.c
@@ -46,6 +46,8 @@
 #include "sockio.h"
 #include "addfile.h"
 
+/* FIXME: Remove this kludge */
+using namespace OpenAxiom;
 
 
 static int build_ht_filename(char*, char*, char*);
diff --git a/src/hyper/ex2ht.c b/src/hyper/ex2ht.c
index a109339a..bbb1db14 100644
--- a/src/hyper/ex2ht.c
+++ b/src/hyper/ex2ht.c
@@ -50,6 +50,8 @@
 #include "cfuns.h"
 
 
+using namespace OpenAxiom;
+
 #define MaxLineLength 512
 #define MaxFiles      100
 
diff --git a/src/hyper/extent2.c b/src/hyper/extent2.c
index 56c37777..8a57cd0b 100644
--- a/src/hyper/extent2.c
+++ b/src/hyper/extent2.c
@@ -50,6 +50,8 @@
 #include "titlebar.h"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 static void center_nodes(TextNode * begin_node , TextNode * end_node);
 static int input_string_width(TextNode * node);
 static int punctuation_width(TextNode * node);
diff --git a/src/hyper/htadd.c b/src/hyper/htadd.c
index b4dc6121..89d8626a 100644
--- a/src/hyper/htadd.c
+++ b/src/hyper/htadd.c
@@ -52,6 +52,9 @@
 #include "addfile.h"
 #include "node.h"
 
+/* FIXME: Remove this kludge */
+using namespace OpenAxiom;
+
 static void add_file(char*, char*, int);
 static void add_new_pages(FILE*, FILE*, char*, char*);
 static int build_db_filename(short, char*, char*);
diff --git a/src/hyper/htinp.c b/src/hyper/htinp.c
index b2065b8e..12964bc4 100644
--- a/src/hyper/htinp.c
+++ b/src/hyper/htinp.c
@@ -48,6 +48,8 @@
 #include "cfuns.h"
 #include "sockio.h"
 
+using namespace OpenAxiom;
+
 extern char **input_file_list;
 extern int input_file_count;
 extern int make_patch_files;
diff --git a/src/hyper/htsearch.cc b/src/hyper/htsearch.cc
index d67c6074..ef89a298 100644
--- a/src/hyper/htsearch.cc
+++ b/src/hyper/htsearch.cc
@@ -50,6 +50,9 @@
 #include <iostream>
 #include "cfuns.h"
 
+// FIXME: Remove kludge
+using namespace OpenAxiom;
+
  // Path to the directory containing the hyperdoc pages.
 static std::string htpagedir;
 
diff --git a/src/hyper/hyper.c b/src/hyper/hyper.c
index 969a9a03..e88f63f0 100644
--- a/src/hyper/hyper.c
+++ b/src/hyper/hyper.c
@@ -63,6 +63,8 @@
 #include "sockio.h"
 #include "parse.h"
 
+using namespace OpenAxiom;
+
 static void init_hash(void);
 static void make_server_connections(void);
 static void check_arguments(void);
diff --git a/src/hyper/hyper.h b/src/hyper/hyper.h
index 2abecbaf..c4956a5f 100644
--- a/src/hyper/hyper.h
+++ b/src/hyper/hyper.h
@@ -114,7 +114,7 @@ extern HyperDocPage * issue_server_command(HyperLink * link);
 extern HyperDocPage * issue_unixlink(TextNode * node);
 extern char * print_to_string(TextNode * command);
 extern void issue_spadcommand(HyperDocPage * page , TextNode * command , int immediate , int type);
-extern openaxiom_sio * accept_menu_connection(openaxiom_sio * server_sock);
+extern OpenAxiom::openaxiom_sio * accept_menu_connection(OpenAxiom::openaxiom_sio * server_sock);
 extern char * print_to_string1(TextNode * command , int * sizeBuf);
 extern int issue_serverpaste(TextNode * command);
 extern void issue_unixcommand(TextNode * node);
@@ -173,8 +173,8 @@ extern int gSwitch_to_mono;
 extern unsigned long * spadColors;
 extern int gIsEndOfOutput;
 extern HDWindow *gWindow;
-extern openaxiom_sio *session_server;
-extern openaxiom_sio *spad_socket;
+extern OpenAxiom::openaxiom_sio *session_server;
+extern OpenAxiom::openaxiom_sio *spad_socket;
 extern HashTable gFileHashTable;
 extern HashTable gImageHashTable;           /* A global hash table for images */
 extern openaxiom_cursor gNormalCursor; /* The normal mouse cursor. */
diff --git a/src/hyper/initx.c b/src/hyper/initx.c
index c4d212dd..8f072dbd 100644
--- a/src/hyper/initx.c
+++ b/src/hyper/initx.c
@@ -73,6 +73,8 @@ extern int gethostname(char *, int );
 #include "mouse11.bitmap"
 #include "mouse11.mask"
 
+using namespace OpenAxiom;
+
 static void get_GCs(HDWindow * window);
 static int get_border_properties(void);
 static int get_color(const char* , const char* , int, Colormap*);
diff --git a/src/hyper/lex.c b/src/hyper/lex.c
index 1b828a08..aa3e4c91 100644
--- a/src/hyper/lex.c
+++ b/src/hyper/lex.c
@@ -66,8 +66,6 @@
 #include "debug.h"
 #include "sockio.h"
 
-int useAscii;
-
 #define PARSER 1
 
 #include "halloc.h"
@@ -75,10 +73,16 @@ int useAscii;
 #include "node.h"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 static int get_char1(void );
 static void spad_error_handler(void );
 static int keyword_type(void );
 
+
+
+int useAscii;
+
 extern int gTtFontIs850;
 extern HDWindow *gWindow;
 
diff --git a/src/hyper/node.h b/src/hyper/node.h
index 38204487..575d4229 100644
--- a/src/hyper/node.h
+++ b/src/hyper/node.h
@@ -265,7 +265,7 @@ typedef struct HyperDocPage {
    TextNode *header;             /* formatted version of page               */
    TextNode *scrolling;          /* Top of scrolling region                 */
    TextNode *footer;             /* top of non-scrolling region at bottom   */
-   openaxiom_sio *sock;          /* socket connection for spad buffer       */
+   OpenAxiom::openaxiom_sio *sock;          /* socket connection for spad buffer       */
    HashTable *fLinkHashTable;         /* active link hash table                  */
    ButtonList *s_button_list;    /* active buttons on page                  */
    ButtonList *button_list;      /* active buttons on page                  */
diff --git a/src/hyper/parse-types.c b/src/hyper/parse-types.c
index 9f0ddeaf..a548347a 100644
--- a/src/hyper/parse-types.c
+++ b/src/hyper/parse-types.c
@@ -52,6 +52,8 @@
 #include "extent.h"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 static void parse_condnode(void );
 static void parse_hasreturnto(void );
 
diff --git a/src/hyper/parse.c b/src/hyper/parse.c
index 5ef50baf..69527334 100644
--- a/src/hyper/parse.c
+++ b/src/hyper/parse.c
@@ -48,6 +48,8 @@
 #include "scrollbar.h"
 #include "titlebar.h"
 
+using namespace OpenAxiom;
+
 static void end_a_page(void );
 static HyperDocPage * format_page(UnloadedPage * ulpage);
 static void parse_page(HyperDocPage * page);
diff --git a/src/hyper/spadbuf.c b/src/hyper/spadbuf.c
index 02f0ebad..e173b86f 100644
--- a/src/hyper/spadbuf.c
+++ b/src/hyper/spadbuf.c
@@ -60,6 +60,8 @@
 #include "cursor.h"
 #include "fnct_key.h"
 
+using namespace OpenAxiom;
+
 static void spadbuf_inter_handler(int);
 static void spadbuf_function_chars(void);
 static void interp_io(void);
@@ -137,7 +139,7 @@ interp_io(void)
             return;
         }
         if (FD_ISSET(session_sock->socket, &rd)) {
-            len = sread(session_sock, (openaxiom_byte*) buf, 1024, "stdio");
+           len = sread(session_sock, byte_address(buf), 1024, "stdio");
             if (len == -1)
                 return;
             else {
diff --git a/src/hyper/spadint.c b/src/hyper/spadint.c
index f872baf8..20d1b2a2 100644
--- a/src/hyper/spadint.c
+++ b/src/hyper/spadint.c
@@ -48,6 +48,8 @@
 #include "sockio.h"
 #include "cfuns.h"
 
+using namespace OpenAxiom;
+
 static void start_user_buffer(HyperDocPage * page);
 static void clear_execution_marks(HashTable * depend_hash);
 static void issue_dependent_commands(HyperDocPage * page , TextNode * command , int type);
diff --git a/src/hyper/titlebar.c b/src/hyper/titlebar.c
index 90dfabf4..6cf37472 100644
--- a/src/hyper/titlebar.c
+++ b/src/hyper/titlebar.c
@@ -54,6 +54,8 @@
 #include "cfuns.h"
 #include "parse-types.h"
 
+using namespace OpenAxiom;
+
 static void readTitleBarImages(void);
 
 extern int y_off;               /* y offset for scrolling regions */
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 */
diff --git a/src/lib/cfuns-c.c b/src/lib/cfuns-c.c
index d32c584f..572b7835 100644
--- a/src/lib/cfuns-c.c
+++ b/src/lib/cfuns-c.c
@@ -77,6 +77,8 @@
 #  define getegid() getgid()
 #endif
 
+namespace OpenAxiom {
+
 OPENAXIOM_C_EXPORT int
 addtopath(char *dir)
 {
@@ -741,19 +743,19 @@ quiet_double_NaN(void)
 }
 
 
-OPENAXIOM_C_EXPORT openaxiom_byteorder
+OPENAXIOM_C_EXPORT Byteorder
 oa_get_host_byteorder(void)
 {
 #ifdef WORDS_BIGENDIAN
-   return oa_big_endian;
+   return big_endian;
 #else
-   return oa_little_endian;
+   return little_endian;
 #endif   
 }
 
 
 OPENAXIOM_C_EXPORT void
-oa_allocate_process_argv(openaxiom_process* proc, int argc)
+oa_allocate_process_argv(Process* proc, int argc)
 {
    proc->argc = argc;
    proc->argv = (char**) malloc((1 + argc) * sizeof (char*));
@@ -761,7 +763,7 @@ oa_allocate_process_argv(openaxiom_process* proc, int argc)
 }
 
 OPENAXIOM_C_EXPORT int
-oa_spawn(openaxiom_process* proc, openaxiom_spawn_flags flags)
+oa_spawn(Process* proc, SpawnFlags flags)
 {
 #ifdef __WIN32__
    const char* path = NULL;
@@ -812,16 +814,16 @@ oa_spawn(openaxiom_process* proc, openaxiom_spawn_flags flags)
 
 #else
    proc->id = 0;
-   if ((flags & openaxiom_spawn_replace) == 0)
+   if ((flags & spawn_replace) == 0)
       proc->id = fork();
    if (proc->id == 0) {
-      if (flags & openaxiom_spawn_search_path)
+      if (flags & spawn_search_path)
          execvp(proc->argv[0], proc->argv);
       else
          execv(proc->argv[0], proc->argv);
       perror(strerror(errno));
       /* Don't keep useless clones around.  */
-      if ((flags & openaxiom_spawn_replace) == 0)
+      if ((flags & spawn_replace) == 0)
          exit(-1);
    }
    return proc->id;
@@ -874,3 +876,4 @@ oa_split(const char* sequence, const char* delimiter, int* size)
    return tokens; 
 }
 
+}
diff --git a/src/lib/fnct_key.c b/src/lib/fnct_key.c
index 3c36df2a..bac0fdb5 100644
--- a/src/lib/fnct_key.c
+++ b/src/lib/fnct_key.c
@@ -52,6 +52,8 @@
 #include "prt.h"
 #include "edin.h"
 
+/* FIXME: Remove this in complete rewrite */
+using namespace OpenAxiom;
 
 /** Some constants for functio key defs ****/
 #define DELAYED 0
diff --git a/src/lib/sockio-c.c b/src/lib/sockio-c.c
index 19bfc085..09b41a8d 100644
--- a/src/lib/sockio-c.c
+++ b/src/lib/sockio-c.c
@@ -58,6 +58,9 @@
 #include "sockio.h"
 #include "com.h"
 #include "bsdsignal.h"
+#include "sockio.h"
+
+namespace OpenAxiom {
 
 #define TotalMaxPurposes 50
 #define MaxServerNumbers 100
@@ -98,8 +101,6 @@ int socket_closed;
 int spad_server_number = -1;    
 
 
-#include "sockio.h"
-
 /* Non zero if the host system module support for socket is activated.
    This is needed only for MS platforms.  */
 static int openaxiom_socket_module_loaded = 0;
@@ -145,7 +146,7 @@ openaxiom_load_socket_module(void)
    to numeric form.  The result is stored in the last argument.
    Success is indicated by a return value 0; failure is -1.  */
 OPENAXIOM_C_EXPORT int
-oa_inet_pton(const char* addr, int prot, openaxiom_byte* bytes)
+oa_inet_pton(const char* addr, int prot, Byte* bytes)
 {
    openaxiom_load_socket_module();
    switch (prot) {
@@ -173,7 +174,7 @@ oa_inet_pton(const char* addr, int prot, openaxiom_byte* bytes)
 /* Resolve a hostname to its IP address.  On success return 0,
    otherwise -1.  */
 OPENAXIOM_C_EXPORT int
-oa_get_host_address(const char* n, int prot, openaxiom_byte* bytes)
+oa_get_host_address(const char* n, int prot, Byte* bytes)
 {
    struct hostent* h;
    openaxiom_load_socket_module();
@@ -304,7 +305,7 @@ oa_open_local_client_stream_socket(const char* path)
 }
 
 OPENAXIOM_C_EXPORT int
-oa_filedesc_read(openaxiom_filedesc desc, openaxiom_byte* buf, int size)
+oa_filedesc_read(openaxiom_filedesc desc, Byte* buf, int size)
 {
 #ifdef __WIN32__
    DWORD count = -1;
@@ -321,7 +322,7 @@ oa_filedesc_read(openaxiom_filedesc desc, openaxiom_byte* buf, int size)
 }
 
 OPENAXIOM_C_EXPORT int
-oa_filedesc_write(openaxiom_filedesc desc, const openaxiom_byte* buf, int size)
+oa_filedesc_write(openaxiom_filedesc desc, const Byte* buf, int size)
 {
 #ifdef __WIN32__
    DWORD count = -1;
@@ -351,8 +352,7 @@ oa_filedesc_close(openaxiom_filedesc desc)
 */
 
 OPENAXIOM_C_EXPORT openaxiom_socket
-oa_connect_ip_port_stream(const openaxiom_byte* addr, int prot,
-                          openaxiom_port port)
+oa_connect_ip_port_stream(const Byte* addr, int prot, openaxiom_port port)
 {
    struct sockaddr_in server;
    openaxiom_socket sock;
@@ -387,7 +387,7 @@ oa_connect_ip_port_stream(const openaxiom_byte* addr, int prot,
    actually read.  */
 
 OPENAXIOM_C_EXPORT int
-oa_socket_read(openaxiom_socket sock, openaxiom_byte* buf, int size)
+oa_socket_read(openaxiom_socket sock, Byte* buf, int size)
 {
    return recv(sock, (char*) buf, size, 0);
 }
@@ -398,7 +398,7 @@ oa_socket_read(openaxiom_socket sock, openaxiom_byte* buf, int size)
 OPENAXIOM_C_EXPORT int
 oa_socket_read_byte(openaxiom_socket sock)
 {
-   openaxiom_byte byte;
+   Byte byte;
    if(oa_socket_read(sock, &byte, 1) < 1)
       return -1;
    return byte;
@@ -409,14 +409,14 @@ oa_socket_read_byte(openaxiom_socket sock)
    Return -1 on failured; the number of actualy write bytes on success.  */
 
 OPENAXIOM_C_EXPORT int
-oa_socket_write(openaxiom_socket sock, const openaxiom_byte* buf, int size)
+oa_socket_write(openaxiom_socket sock, const Byte* buf, int size)
 {
    return send(sock, (const char*) buf, size, 0);
 }
 
 /* Send one byte to socket `sock'.  */
 OPENAXIOM_C_EXPORT int
-oa_socket_write_byte(openaxiom_socket sock, openaxiom_byte byte)
+oa_socket_write_byte(openaxiom_socket sock, Byte byte)
 {
    return oa_socket_write(sock, &byte, 1) < 1 ? -1 : byte;
 }
@@ -454,7 +454,7 @@ sigpipe_handler(int sig)
 }
 
 OPENAXIOM_C_EXPORT int 
-wait_for_client_read(openaxiom_sio *sock, openaxiom_byte* buf, int buf_size,
+wait_for_client_read(openaxiom_sio *sock, Byte* buf, int buf_size,
                      const char* msg)
 {
   int ret_val;
@@ -472,7 +472,7 @@ wait_for_client_read(openaxiom_sio *sock, openaxiom_byte* buf, int buf_size,
 }
 
 OPENAXIOM_C_EXPORT int 
-wait_for_client_write(openaxiom_sio* sock, const openaxiom_byte* buf,
+wait_for_client_write(openaxiom_sio* sock, const Byte* buf,
                       int buf_size, const char* msg)
 {
   int ret_val;
@@ -490,7 +490,7 @@ wait_for_client_write(openaxiom_sio* sock, const openaxiom_byte* buf,
 }
 
 OPENAXIOM_C_EXPORT int 
-sread(openaxiom_sio* sock, openaxiom_byte* buf, int buf_size, const char *msg)
+sread(openaxiom_sio* sock, Byte* buf, int buf_size, const char *msg)
 {
   int ret_val;
   char err_msg[256];
@@ -515,7 +515,7 @@ sread(openaxiom_sio* sock, openaxiom_byte* buf, int buf_size, const char *msg)
 }
 
 OPENAXIOM_C_EXPORT int 
-swrite(openaxiom_sio* sock, const openaxiom_byte* buf, int buf_size,
+swrite(openaxiom_sio* sock, const Byte* buf, int buf_size,
        const char* msg)
 {
   int ret_val;
@@ -552,7 +552,7 @@ sselect(int n,fd_set  *rd, fd_set  *wr, fd_set *ex, void *timeout)
 }
 
 OPENAXIOM_C_EXPORT int 
-fill_buf(openaxiom_sio *sock, openaxiom_byte* buf, int len, const char* msg)
+fill_buf(openaxiom_sio *sock, Byte* buf, int len, const char* msg)
 {
   int bytes =  0, ret_val;
   while(bytes < len) {
@@ -567,7 +567,7 @@ OPENAXIOM_C_EXPORT int
 get_int(openaxiom_sio *sock)
 {
   int val = -1, len;
-  len = fill_buf(sock, (openaxiom_byte*)&val, sizeof(int), "get_int");
+  len = fill_buf(sock, byte_address(val), sizeof(int), "get_int");
   if (len != sizeof(int)) {
 #ifdef DEBUG
   fprintf(stderr,"get_int: caught error\n",val);
@@ -609,7 +609,7 @@ OPENAXIOM_C_EXPORT int
 send_int(openaxiom_sio *sock,int val)
 {
   int ret_val;
-  ret_val = swrite(sock, (const openaxiom_byte*)&val, sizeof(int), "send_int");
+  ret_val = swrite(sock, byte_address(val), sizeof(int), "send_int");
   if (ret_val == -1) {
     return -1;
   }
@@ -652,14 +652,14 @@ send_string_len(openaxiom_sio *sock, const char *str,int len)
     strncpy(buf,str,len);
     buf[len]='\0';
     send_int(sock,len+1);
-    val = swrite(sock, (const openaxiom_byte*) buf, len+1, "send_string_len");
+    val = swrite(sock, (const Byte*) buf, len+1, "send_string_len");
     free(buf);
   } else {
     static char buf[1024];
     strncpy(buf, str, len);
     buf[len] = '\0';
     send_int(sock, len+1);
-    val = swrite(sock, (const openaxiom_byte*) buf, len+1, "send_string_len");
+    val = swrite(sock, (const Byte*) buf, len+1, "send_string_len");
   }
   if (val == -1) {
     return -1;
@@ -672,7 +672,7 @@ send_string(openaxiom_sio* sock, const char* str)
 {
   int val, len = strlen(str);
   send_int(sock, len+1);
-  val = swrite(sock, (const openaxiom_byte*) str, len+1, "send_string");
+  val = swrite(sock, (const Byte*) str, len+1, "send_string");
   if (val == -1) {
     return -1;
   }
@@ -722,7 +722,7 @@ get_string(openaxiom_sio *sock)
   len = get_int(sock);
   if (len <0) return NULL;
   buf = (char*) malloc(len*sizeof(char));
-  val = fill_buf(sock, (openaxiom_byte*) buf, len, "get_string");
+  val = fill_buf(sock, (Byte*) buf, len, "get_string");
   if (val == -1){
         free(buf);
         return NULL;
@@ -752,7 +752,7 @@ get_string_buf(openaxiom_sio *sock, char *buf, int buf_len)
    nbytes_to_read = sock->nbytes_pending > buf_len
       ? buf_len
       : sock->nbytes_pending;
-   nbytes_read = fill_buf(sock, (openaxiom_byte*)buf, nbytes_to_read,
+   nbytes_read = fill_buf(sock, (Byte*)buf, nbytes_to_read,
                           "get_string_buf");
    if (nbytes_read == -1) {
       sock->nbytes_pending = 0;
@@ -791,7 +791,7 @@ OPENAXIOM_C_EXPORT int
 send_float(openaxiom_sio *sock, double num)
 {
   int val;
-  val = swrite(sock, (const openaxiom_byte*)&num, sizeof(double),"send_float");
+  val = swrite(sock, byte_address(num), sizeof(double),"send_float");
   if (val == -1) {
     return -1;
   }
@@ -847,7 +847,7 @@ get_float(openaxiom_sio *sock)
 {
   int val;
   double num = -1.0;
-  val = fill_buf(sock, (openaxiom_byte*)&num, sizeof(double), "get_float");
+  val = fill_buf(sock, byte_address(num), sizeof(double), "get_float");
 #ifdef DEBUG
   fprintf(stderr,"get_float: received %f\n",num);
 #endif
@@ -1094,10 +1094,10 @@ remote_stdio(openaxiom_sio *sock)
     if (FD_ISSET(0, &rd)) {
       fgets(buf,1024,stdin);
       len = strlen(buf);
-      swrite(sock, (const openaxiom_byte*)buf, len, "remote_stdio::write");
+      swrite(sock, byte_address(buf), len, "remote_stdio::write");
     }
     if (FD_ISSET(sock->socket, &rd)) {
-      len = sread(sock, (openaxiom_byte*)buf, 1024, "remote_stdio::read");
+       len = sread(sock, byte_address(buf), 1024, "remote_stdio::read");
       if (len == -1)
         return;
       else {
@@ -1386,3 +1386,5 @@ print_line(const char* s)
 {
   printf("%s\n", s);
 }
+
+}
diff --git a/src/lib/util.c b/src/lib/util.c
index 01681611..c82358c5 100644
--- a/src/lib/util.c
+++ b/src/lib/util.c
@@ -47,6 +47,8 @@
 #include "util.H1"
 
 
+/* FIXME: Remove this kludge */
+using namespace OpenAxiom;
 
 
 int
diff --git a/src/sman/session.c b/src/sman/session.c
index 999dc367..2a64dbc2 100644
--- a/src/sman/session.c
+++ b/src/sman/session.c
@@ -50,6 +50,8 @@
 #include "bsdsignal.h"
 #include "sockio.h"
 
+using namespace OpenAxiom;
+
 static void usr1_handler(int);
 static void usr2_handler(int);
 static void term_handler(int);
@@ -276,11 +278,11 @@ static void
 read_from_spad_io(void)
 {
   int ret_code;
-  ret_code = sread(spad_io, oa_buffer_address(big_bad_buf), BufSize,
+  ret_code = sread(spad_io, byte_address(big_bad_buf), BufSize,
                    "session: stdout socket");
   if (ret_code == -1) return;
   if(active_session != (openaxiom_sio *) 0) {
-    ret_code = swrite(active_session, oa_buffer_address(big_bad_buf),
+    ret_code = swrite(active_session, byte_address(big_bad_buf),
                       ret_code, NULL);
   }
 }
@@ -354,7 +356,7 @@ accept_session_connection(openaxiom_sio *server_sock)
       active_session = (openaxiom_sio *)plSock;
       get_string_buf(spad_server, big_bad_buf, BufSize);
       ret_code = swrite((openaxiom_sio *)plSock,
-                        oa_buffer_address(big_bad_buf),
+                        byte_address(big_bad_buf),
                         strlen(big_bad_buf)+1,
                         "session: writing to InterpWindow");
       if (ret_code == -1) 
@@ -377,14 +379,14 @@ read_from_session(openaxiom_sio *sock)
     send_int(spad_server, sock->frame);
   }
   active_session = sock;
-  ret_code = sread(sock, oa_buffer_address(big_bad_buf), BufSize, 
+  ret_code = sread(sock, byte_address(big_bad_buf), BufSize, 
                    "session: reading InterpWindow");
   if (ret_code == -1) {
     active_session = (openaxiom_sio *) 0;
     reading_output = 0;
     return;
   }
-  ret_code = swrite(spad_io, oa_buffer_address(big_bad_buf), ret_code,
+  ret_code = swrite(spad_io, byte_address(big_bad_buf), ret_code,
                     "session: writing SessionIO");
   if (ret_code == -1) {
     active_session = (openaxiom_sio *)0 ;
diff --git a/src/sman/sman.c b/src/sman/sman.c
index e0ba9deb..b6e6dbb5 100644
--- a/src/sman/sman.c
+++ b/src/sman/sman.c
@@ -57,10 +57,12 @@
 #include "cfuns.h"
 #include "utils.h"
 
-static void process_arguments(openaxiom_command*, int, char**);
+using namespace OpenAxiom;
+
+static void process_arguments(Command*, int, char**);
 static int in_X(void);
 static void set_up_defaults(void);
-static void process_options(openaxiom_command*, int, char**);
+static void process_options(Command*, int, char**);
 static void death_handler(int);
 static void sman_catch_signals(void);
 static void fix_env(int);
@@ -76,8 +78,8 @@ static void start_the_local_spadclient(void);
 static void start_the_session_manager(void);
 static void start_the_hypertex(void);
 static void start_the_graphics(void);
-static void fork_Axiom(openaxiom_command*);
-static void start_the_Axiom(openaxiom_command*);
+static void fork_Axiom(Command*);
+static void start_the_Axiom(Command*);
 static void clean_up_sockets(void);
 static void clean_hypertex_socket(void);
 static void read_from_spad_io(int);
@@ -149,7 +151,7 @@ struct termios childbuf;         /* terminal structure for user i/o */
 int death_signal = 0;
 
 static void
-process_arguments(openaxiom_command* command, int argc,char ** argv)
+process_arguments(Command* command, int argc,char ** argv)
 {
   int arg;
   int other = 0;
@@ -246,7 +248,7 @@ set_up_defaults(void)
 }
 
 static void
-process_options(openaxiom_command* command, int argc, char **argv)
+process_options(Command* command, int argc, char **argv)
 {
   set_up_defaults();
   process_arguments(command, argc, argv);
@@ -472,7 +474,7 @@ start_the_graphics(void)
 /* Start the core executable session in a separate process, */
 /* using a pseudo-terminal to catch all input and output */
 static void 
-fork_Axiom(openaxiom_command* cmd)
+fork_Axiom(Command* cmd)
 {
   SpadProcess *proc;
 
@@ -528,15 +530,14 @@ fork_Axiom(openaxiom_command* cmd)
 
     /* Tell the Core that it is being invoked in server mode.   */
     oa_allocate_process_argv(&cmd->core, 2);
-    cmd->core.argv[0] =
-       (char*) openaxiom_make_path_for(cmd->root_dir, openaxiom_core_driver);
+    cmd->core.argv[0] = (char*) make_path_for(cmd->root_dir, core_driver);
     cmd->core.argv[1] = (char*) "--role=server";
-    openaxiom_execute_core(cmd, openaxiom_core_driver);
+    execute_core(cmd, core_driver);
   }
 }
 
 static void
-start_the_Axiom(openaxiom_command* cmd)
+start_the_Axiom(Command* cmd)
 {
   server_num = make_server_number();
   clean_up_old_sockets();
@@ -598,7 +599,7 @@ read_from_spad_io(int ptcNum)
     }
   }
   else
-    ret_code = swrite(session_io, oa_buffer_address(big_bad_buf), ret_code,
+    ret_code = swrite(session_io, byte_address(big_bad_buf), ret_code,
                       "writing to session man");
   if (ret_code == -1) {
     perror("writing output to session manager");
@@ -611,7 +612,7 @@ static void
 read_from_manager(int ptcNum)
 {
   int ret_code;
-  ret_code = sread(session_io, oa_buffer_address(big_bad_buf), BufSize,
+  ret_code = sread(session_io, byte_address(big_bad_buf), BufSize,
                    "reading session io");
   if (ret_code == -1) {
     return;
@@ -758,8 +759,8 @@ monitor_children(void)
 int
 main(int argc, char *argv[])
 {
-   openaxiom_command command = { };
-   command.root_dir = openaxiom_get_systemdir(argc, argv);
+   Command command = { };
+   command.root_dir = get_systemdir(argc, argv);
    process_options(&command, argc, argv);
 
   putenv((char*) "LC_ALL=C");
diff --git a/src/sman/spadclient.c b/src/sman/spadclient.c
index 7d61a296..dd1d6722 100644
--- a/src/sman/spadclient.c
+++ b/src/sman/spadclient.c
@@ -48,6 +48,8 @@
 
 #include "sockio.h"
 
+using namespace OpenAxiom;
+
 openaxiom_sio* sock;
 
 static void 
-- 
cgit v1.2.3