libdlog: extract declarations into a header 79/198879/2
authorMichal Bloch <m.bloch@samsung.com>
Wed, 30 Jan 2019 13:48:46 +0000 (14:48 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Mon, 4 Feb 2019 11:50:02 +0000 (11:50 +0000)
Change-Id: Ia2c892765322b4b147dd2f4c9720d607bdabb023
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
include/libdlog.h [new file with mode: 0644]
src/libdlog/dynamic_config.c
src/libdlog/log.c
src/libdlog/log_android.c
src/libdlog/log_pipe.c
src/tests/libdlog_base.c

diff --git a/include/libdlog.h b/include/libdlog.h
new file mode 100644 (file)
index 0000000..6e62899
--- /dev/null
@@ -0,0 +1,23 @@
+#pragma once
+
+// C
+#include <stdbool.h>
+
+// POSIX
+#include <pthread.h>
+
+// DLog
+#include <dlog.h>
+
+struct log_config;
+
+extern int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg);
+extern pthread_mutex_t log_init_lock;
+extern bool limiter;
+
+void __update_plog(const struct log_config *conf);
+
+#ifdef UNIT_TEST
+void __dlog_fini(void);
+void __configure(void);
+#endif
index c947ff5..18ef467 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+// C
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
+// POSIX
 #include <limits.h>
 #include <pthread.h>
 #include <unistd.h>
 #include <sys/inotify.h>
 
+// DLog
 #include <dynamic_config.h>
+#include <libdlog.h>
 #include <logcommon.h>
 #include <logconfig.h>
 #include <loglimiter.h>
@@ -31,10 +36,6 @@ static int inotify_fd = -1;
 static typeof(((struct inotify_event *)0)->wd) inotify_wd = -1;
 static char *inotify_path;
 
-extern pthread_mutex_t log_init_lock;
-extern bool limiter;
-extern void __update_plog(const struct log_config *conf);
-
 static bool __setup_runtime_watch(char const *path)
 {
        assert(path);
index 37a47c7..08aaebf 100644 (file)
  * limitations under the License.
  */
 
-#include <pthread.h>
-#include <stdlib.h>
+// C
+#include <assert.h>
 #include <stdbool.h>
 #include <stdio.h>
+#include <stdlib.h>
+
+// POSIX
+#include <pthread.h>
+#include <unistd.h>
 
+// DLog
 #include <dynamic_config.h>
+#include <libdlog.h>
 #include <logcommon.h>
-#include "loglimiter.h"
 #include "logconfig.h"
-#include <assert.h>
-#include <unistd.h>
+#include "loglimiter.h"
 
 #define DEFAULT_CONFIG_LIMITER false
 #define DEFAULT_CONFIG_PLOG true
@@ -53,8 +58,6 @@ bool dynamic_config;
 bool plog[LOG_ID_MAX];
 bool plog_default_values[LOG_ID_MAX];
 
-void __update_plog(const struct log_config *conf);
-
 static int debugmode;
 static int fatal_assert;
 static int limiter_apply_to_all_buffers;
index 5f7a030..5cff87e 100644 (file)
@@ -1,13 +1,16 @@
+// C
 #include <stdio.h>
+
+// POSIX
 #include <fcntl.h>
 #include <time.h>
 #include <sys/socket.h>
 
+// DLog
+#include <libdlog.h>
 #include <logcommon.h>
 #include <logconfig.h>
 
-extern int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg);
-
 /* TODO: initialize in for loop to be sure of initializing all items */
 static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1, -1, -1 };
 
index 2f27b94..428fad6 100644 (file)
@@ -1,16 +1,19 @@
-#include <sys/socket.h>
-#include <signal.h>
+// C
+#include <assert.h>
 #include <stdio.h>
+
+// POSIX
+#include <signal.h>
 #include <linux/limits.h>
+#include <sys/socket.h>
 #include <sys/un.h>
+
+// DLog
+#include <libdlog.h>
+#include <logconfig.h>
 #include <logpipe.h>
 #include <logprint.h>
-#include <logconfig.h>
-#include <assert.h>
-
 
-extern int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg);
-extern pthread_mutex_t log_init_lock;
 /* TODO: initialize in for loop to be sure of initializing all items */
 static int pipe_fd[LOG_ID_MAX] = {-1, -1, -1, -1, -1, -1};
 static char log_pipe_path[LOG_ID_MAX][PATH_MAX];
index 4cbea4a..b4f1dbb 100644 (file)
@@ -6,12 +6,9 @@
 
 // DLog
 #include <dlog.h>
+#include <libdlog.h>
 #include <logconfig.h>
 
-extern int (*write_to_log)(log_id_t, log_priority, const char *tag, const char *msg);
-void __dlog_fini(void);
-void __configure(void);
-
 void __log_limiter_update(struct log_config *config) { }
 void __log_limiter_destroy(void) { }
 void __dynamic_config_destroy() { }