status: Move status_t type and functions to separate files
authorMartin Willi <martin@revosec.ch>
Wed, 15 Apr 2015 14:34:23 +0000 (16:34 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 16 Apr 2015 12:50:05 +0000 (14:50 +0200)
src/libstrongswan/Android.mk
src/libstrongswan/Makefile.am
src/libstrongswan/utils/utils.c
src/libstrongswan/utils/utils.h
src/libstrongswan/utils/utils/status.c [new file with mode: 0644]
src/libstrongswan/utils/utils/status.h [new file with mode: 0644]

index 4772997..afd2f4a 100644 (file)
@@ -41,7 +41,7 @@ utils/utils.c utils/chunk.c utils/debug.c utils/enum.c utils/identification.c \
 utils/lexparser.c utils/optionsfrom.c utils/capabilities.c utils/backtrace.c \
 utils/parser_helper.c utils/test.c utils/process.c utils/utils/strerror.c \
 utils/utils/atomics.c utils/utils/string.c utils/utils/memory.c \
-utils/utils/tty.c utils/utils/path.c
+utils/utils/tty.c utils/utils/path.c utils/utils/status.c
 
 libstrongswan_la_SOURCES += \
     threading/thread.c \
index b0ecf6b..6ef6dd6 100644 (file)
@@ -39,7 +39,7 @@ utils/utils.c utils/chunk.c utils/debug.c utils/enum.c utils/identification.c \
 utils/lexparser.c utils/optionsfrom.c utils/capabilities.c utils/backtrace.c \
 utils/parser_helper.c utils/test.c utils/process.c utils/utils/strerror.c \
 utils/utils/atomics.c utils/utils/string.c utils/utils/memory.c \
-utils/utils/tty.c utils/utils/path.c
+utils/utils/tty.c utils/utils/path.c utils/utils/status.c
 
 if !USE_WINDOWS
   libstrongswan_la_SOURCES += \
@@ -110,7 +110,8 @@ utils/printf_hook/printf_hook_vstr.h utils/printf_hook/printf_hook_builtin.h \
 utils/parser_helper.h utils/test.h utils/integrity_checker.h utils/process.h \
 utils/utils/strerror.h utils/compat/windows.h utils/compat/apple.h \
 utils/utils/atomics.h utils/utils/types.h utils/utils/byteorder.h \
-utils/utils/string.h utils/utils/memory.h utils/utils/tty.h utils/utils/path.h
+utils/utils/string.h utils/utils/memory.h utils/utils/tty.h utils/utils/path.h \
+utils/utils/status.h
 endif
 
 library.lo :   $(top_builddir)/config.status
index 5ff1b0b..399b915 100644 (file)
 #include <threading/mutex.h>
 #include <threading/condvar.h>
 
-ENUM(status_names, SUCCESS, NEED_MORE,
-       "SUCCESS",
-       "FAILED",
-       "OUT_OF_RES",
-       "ALREADY_DONE",
-       "NOT_SUPPORTED",
-       "INVALID_ARG",
-       "NOT_FOUND",
-       "PARSE_ERROR",
-       "VERIFY_ERROR",
-       "INVALID_STATE",
-       "DESTROY_ME",
-       "NEED_MORE",
-);
-
 /**
  * Described in header.
  */
@@ -300,22 +285,6 @@ bool return_false()
 }
 
 /**
- * returns FAILED
- */
-status_t return_failed()
-{
-       return FAILED;
-}
-
-/**
- * returns SUCCESS
- */
-status_t return_success()
-{
-       return SUCCESS;
-}
-
-/**
  * nop operation
  */
 void nop()
index 7ecc42c..7e25567 100644 (file)
@@ -81,6 +81,7 @@
 #include "utils/string.h"
 #include "utils/memory.h"
 #include "utils/strerror.h"
+#include "utils/status.h"
 #include "utils/path.h"
 #include "utils/tty.h"
 #ifdef __APPLE__
@@ -276,78 +277,6 @@ void utils_deinit();
  */
 #define TIME_32_BIT_SIGNED_MAX 0x7fffffff
 
-typedef enum status_t status_t;
-
-/**
- * Return values of function calls.
- */
-enum status_t {
-       /**
-        * Call succeeded.
-        */
-       SUCCESS,
-
-       /**
-        * Call failed.
-        */
-       FAILED,
-
-       /**
-        * Out of resources.
-        */
-       OUT_OF_RES,
-
-       /**
-        * The suggested operation is already done
-        */
-       ALREADY_DONE,
-
-       /**
-        * Not supported.
-        */
-       NOT_SUPPORTED,
-
-       /**
-        * One of the arguments is invalid.
-        */
-       INVALID_ARG,
-
-       /**
-        * Something could not be found.
-        */
-       NOT_FOUND,
-
-       /**
-        * Error while parsing.
-        */
-       PARSE_ERROR,
-
-       /**
-        * Error while verifying.
-        */
-       VERIFY_ERROR,
-
-       /**
-        * Object in invalid state.
-        */
-       INVALID_STATE,
-
-       /**
-        * Destroy object which called method belongs to.
-        */
-       DESTROY_ME,
-
-       /**
-        * Another call to the method is required.
-        */
-       NEED_MORE,
-};
-
-/**
- * enum_names for type status_t.
- */
-extern enum_name_t *status_names;
-
 /**
  * Handle struct timeval like an own type.
  */
@@ -439,16 +368,6 @@ bool return_true();
 bool return_false();
 
 /**
- * returns FAILED
- */
-status_t return_failed();
-
-/**
- * returns SUCCESS
- */
-status_t return_success();
-
-/**
  * Get the padding required to make size a multiple of alignment
  */
 static inline size_t pad_len(size_t size, size_t alignment)
diff --git a/src/libstrongswan/utils/utils/status.c b/src/libstrongswan/utils/utils/status.c
new file mode 100644 (file)
index 0000000..4a97d84
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2008-2014 Tobias Brunner
+ * Copyright (C) 2005-2008 Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * 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 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * 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.
+ */
+
+#include <utils/utils.h>
+
+ENUM(status_names, SUCCESS, NEED_MORE,
+       "SUCCESS",
+       "FAILED",
+       "OUT_OF_RES",
+       "ALREADY_DONE",
+       "NOT_SUPPORTED",
+       "INVALID_ARG",
+       "NOT_FOUND",
+       "PARSE_ERROR",
+       "VERIFY_ERROR",
+       "INVALID_STATE",
+       "DESTROY_ME",
+       "NEED_MORE",
+);
+
+/**
+ * returns FAILED
+ */
+status_t return_failed()
+{
+       return FAILED;
+}
+
+/**
+ * returns SUCCESS
+ */
+status_t return_success()
+{
+       return SUCCESS;
+}
diff --git a/src/libstrongswan/utils/utils/status.h b/src/libstrongswan/utils/utils/status.h
new file mode 100644 (file)
index 0000000..c96eebd
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2008-2014 Tobias Brunner
+ * Copyright (C) 2008 Martin Willi
+ * Hochschule fuer Technik Rapperswil
+ *
+ * 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 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * 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.
+ */
+
+/**
+ * @defgroup status_i status
+ * @{ @ingroup utils_i
+ */
+
+#ifndef STATUS_H_
+#define STATUS_H_
+
+typedef enum status_t status_t;
+
+/**
+ * Return values of function calls.
+ */
+enum status_t {
+       /** Call succeeded */
+       SUCCESS,
+       /** Call failed */
+       FAILED,
+       /** Out of resources */
+       OUT_OF_RES,
+       /** The suggested operation is already done */
+       ALREADY_DONE,
+       /** Not supported */
+       NOT_SUPPORTED,
+       /** One of the arguments is invalid */
+       INVALID_ARG,
+       /** Something could not be found */
+       NOT_FOUND,
+       /** Error while parsing */
+       PARSE_ERROR,
+       /** Error while verifying */
+       VERIFY_ERROR,
+       /** Object in invalid state */
+       INVALID_STATE,
+       /** Destroy object which called method belongs to */
+       DESTROY_ME,
+       /** Another call to the method is required */
+       NEED_MORE,
+};
+
+/**
+ * enum_names for type status_t.
+ */
+extern enum_name_t *status_names;
+
+/**
+ * returns FAILED
+ */
+status_t return_failed();
+
+/**
+ * returns SUCCESS
+ */
+status_t return_success();
+
+#endif /** STATUS_H_ @} */