瀏覽代碼

move flow/error.h to FlowError

ambrop7 15 年之前
父節點
當前提交
8e969cfc58

+ 1 - 0
flow/CMakeLists.txt

@@ -32,5 +32,6 @@ add_library(flow
     PacketRecvInterface.c
     StreamPassInterface.c
     StreamRecvInterface.c
+    FlowError.c
 )
 target_link_libraries(flow system security)

+ 1 - 1
flow/DatagramSocketSink.h

@@ -32,7 +32,7 @@
 #include <system/DebugObject.h>
 #include <system/BSocket.h>
 #include <flow/PacketPassInterface.h>
-#include <flow/error.h>
+#include <flow/FlowError.h>
 
 #define DATAGRAMSOCKETSINK_ERROR_BSOCKET 1
 #define DATAGRAMSOCKETSINK_ERROR_WRONGSIZE 2

+ 1 - 1
flow/DatagramSocketSource.h

@@ -33,7 +33,7 @@
 #include <system/BSocket.h>
 #include <system/BPending.h>
 #include <flow/PacketRecvInterface.h>
-#include <flow/error.h>
+#include <flow/FlowError.h>
 
 #define DATAGRAMSOCKETSOURCE_ERROR_BSOCKET 1
 

+ 42 - 0
flow/FlowError.c

@@ -0,0 +1,42 @@
+/**
+ * @file FlowError.c
+ * @author Ambroz Bizjak <ambrop7@gmail.com>
+ * 
+ * @section LICENSE
+ * 
+ * This file is part of BadVPN.
+ * 
+ * BadVPN is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ * 
+ * BadVPN 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.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <flow/FlowError.h>
+
+void FlowErrorDomain_Init (FlowErrorDomain *d, FlowErrorDomain_handler handler, void *user)
+{
+    d->handler = handler;
+    d->user = user;
+}
+
+FlowErrorReporter FlowErrorReporter_Create (FlowErrorDomain *domain, int component)
+{
+    FlowErrorReporter r;
+    r.domain = domain;
+    r.component = component;
+    return r;
+}
+
+void FlowErrorReporter_ReportError (FlowErrorReporter *reporter, const void *data)
+{
+    reporter->domain->handler(reporter->domain->user, reporter->component, data);
+}

+ 6 - 25
flow/error.h → flow/FlowError.h

@@ -1,5 +1,5 @@
 /**
- * @file error.h
+ * @file FlowError.h
  * @author Ambroz Bizjak <ambrop7@gmail.com>
  * 
  * @section LICENSE
@@ -24,8 +24,8 @@
  * Flow error handling.
  */
 
-#ifndef BADVPN_FLOW_ERROR_H
-#define BADVPN_FLOW_ERROR_H
+#ifndef BADVPN_FLOW_FLOWERROR_H
+#define BADVPN_FLOW_FLOWERROR_H
 
 #include <stdint.h>
 
@@ -54,7 +54,7 @@ typedef struct {
  * @param handler callback function invoked when {@link FlowErrorReporter_ReportError} is called
  * @param user value passed to callback functions
  */
-static void FlowErrorDomain_Init (FlowErrorDomain *d, FlowErrorDomain_handler handler, void *user);
+void FlowErrorDomain_Init (FlowErrorDomain *d, FlowErrorDomain_handler handler, void *user);
 
 /**
  * Structure that can be passed to flow components to ease error reporting.
@@ -71,7 +71,7 @@ typedef struct {
  * @param component component identifier
  * @return a {@link FlowErrorReporter} structure with the specifed error domain and component.
  */
-static FlowErrorReporter FlowErrorReporter_Create (FlowErrorDomain *domain, int component);
+FlowErrorReporter FlowErrorReporter_Create (FlowErrorDomain *domain, int component);
 
 /**
  * Reports an error.
@@ -80,25 +80,6 @@ static FlowErrorReporter FlowErrorReporter_Create (FlowErrorDomain *domain, int
  *                 component identifier user to report the error
  * @param data component-specific error data
  */
-static void FlowErrorReporter_ReportError (FlowErrorReporter *reporter, const void *data);
-
-void FlowErrorDomain_Init (FlowErrorDomain *d, FlowErrorDomain_handler handler, void *user)
-{
-    d->handler = handler;
-    d->user = user;
-}
-
-FlowErrorReporter FlowErrorReporter_Create (FlowErrorDomain *domain, int component)
-{
-    FlowErrorReporter r;
-    r.domain = domain;
-    r.component = component;
-    return r;
-}
-
-void FlowErrorReporter_ReportError (FlowErrorReporter *reporter, const void *data)
-{
-    reporter->domain->handler(reporter->domain->user, reporter->component, data);
-}
+void FlowErrorReporter_ReportError (FlowErrorReporter *reporter, const void *data);
 
 #endif

+ 1 - 1
flow/PacketProtoDecoder.h

@@ -35,7 +35,7 @@
 #include <system/DebugObject.h>
 #include <flow/StreamRecvInterface.h>
 #include <flow/PacketPassInterface.h>
-#include <flow/error.h>
+#include <flow/FlowError.h>
 
 #define PACKETPROTODECODER_ERROR_TOOLONG 1
 

+ 1 - 1
flow/StreamSocketSink.h

@@ -33,7 +33,7 @@
 #include <system/DebugObject.h>
 #include <system/BSocket.h>
 #include <flow/StreamPassInterface.h>
-#include <flow/error.h>
+#include <flow/FlowError.h>
 
 #define STREAMSOCKETSINK_ERROR_BSOCKET 1
 

+ 1 - 1
flow/StreamSocketSource.h

@@ -33,7 +33,7 @@
 #include <system/DebugObject.h>
 #include <system/BSocket.h>
 #include <flow/StreamRecvInterface.h>
-#include <flow/error.h>
+#include <flow/FlowError.h>
 
 #define STREAMSOCKETSOURCE_ERROR_CLOSED 0
 #define STREAMSOCKETSOURCE_ERROR_BSOCKET 1

+ 1 - 1
nspr_support/PRStreamSink.h

@@ -32,7 +32,7 @@
 #include <misc/dead.h>
 #include <system/DebugObject.h>
 #include <flow/StreamPassInterface.h>
-#include <flow/error.h>
+#include <flow/FlowError.h>
 #include <nspr_support/BPRFileDesc.h>
 
 #define PRSTREAMSINK_ERROR_NSPR 1

+ 1 - 1
nspr_support/PRStreamSource.h

@@ -32,7 +32,7 @@
 #include <misc/dead.h>
 #include <system/DebugObject.h>
 #include <flow/StreamRecvInterface.h>
-#include <flow/error.h>
+#include <flow/FlowError.h>
 #include <nspr_support/BPRFileDesc.h>
 
 #define PRSTREAMSOURCE_ERROR_CLOSED 0

+ 1 - 1
server_connection/ServerConnection.h

@@ -45,7 +45,7 @@
 #include <protocol/msgproto.h>
 #include <system/DebugObject.h>
 #include <system/BSocket.h>
-#include <flow/error.h>
+#include <flow/FlowError.h>
 #include <flow/SCKeepaliveSource.h>
 #include <flow/PacketProtoEncoder.h>
 #include <flow/KeepaliveIO.h>