From b43e8cd0f0858e78486752007c3640b70bf44c8d Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 13 Apr 2017 12:00:09 +0200 Subject: include, lib: Rename ap_init/ap_fini Fixes #35 --- doc/man/CMakeLists.txt | 4 +-- doc/man/ap_fini.3 | 1 - doc/man/ap_init.3 | 67 ------------------------------------------ doc/man/flow_alloc.3 | 3 +- doc/man/ouroboros_fini.3 | 1 + doc/man/ouroboros_init.3 | 69 ++++++++++++++++++++++++++++++++++++++++++++ include/ouroboros/dev.h | 4 +-- src/ipcpd/ipcp.c | 8 ++--- src/irmd/main.c | 2 +- src/lib/dev.c | 4 +-- src/tools/cbr/cbr.c | 6 ++-- src/tools/echo/echo.c | 6 ++-- src/tools/echo/echo_server.c | 2 +- src/tools/operf/operf.c | 6 ++-- src/tools/oping/oping.c | 6 ++-- 15 files changed, 96 insertions(+), 93 deletions(-) delete mode 100644 doc/man/ap_fini.3 delete mode 100644 doc/man/ap_init.3 create mode 100644 doc/man/ouroboros_fini.3 create mode 100644 doc/man/ouroboros_init.3 diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index c864d756..f0ce5df4 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -1,7 +1,7 @@ set(MAN_NAMES # Add man page sources here - ap_init.3 - ap_fini.3 + ouroboros_init.3 + ouroboros_fini.3 flow_accept.3 flow_alloc.3 flow_dealloc.3 diff --git a/doc/man/ap_fini.3 b/doc/man/ap_fini.3 deleted file mode 100644 index 4aaa723b..00000000 --- a/doc/man/ap_fini.3 +++ /dev/null @@ -1 +0,0 @@ -.so ap_init.3 diff --git a/doc/man/ap_init.3 b/doc/man/ap_init.3 deleted file mode 100644 index c5b93764..00000000 --- a/doc/man/ap_init.3 +++ /dev/null @@ -1,67 +0,0 @@ -.\" Ouroboros man pages (C) 2017 -.\" Dimitri Staessens -.\" Sander Vrijders - -.TH AP_INIT 3 2017-04-10 GNU "Ouroboros Programmer's Manual" - -.SH NAME - -ap_init, ap_fini \- initialize and finalize an application for using -Ouroboros - -.SH SYNOPSIS - -.B #include - -\fBint ap_init(char * \fIapn\fB);\fR - -\fBvoid ap_fini(void);\fR - -Compile and link with \fI-louroboros\fR. - -.SH DESCRIPTION - -The \fBap_init\fR() call initializes an application process instance -for using the Ouroboros IPC infrastructure. If the application is a -server or peer, a \fBchar * \fIapn\fR has to be provided indicating the -application process that this instance belongs to. This is usually -argv[0]. A client application may pass NULL. The \fBap_fini\fR() call -will release all resources allocated by \fBap_fini\fR(). - -\fBap_init\fR() and \fBap_fini\fR() should be called only once in the -application. - -.SH RETURN VALUE - -On success, \fBap_init\fR() returns 0. On failure, a negative value -indicating the error will be returned. The \fBap_fini\fR() function -has no return value. - -.SH ERRORS - -\fBap_init\fR() can return the following errors: - -.B -EIRMD -Failed to contact an IRMd instance. - -.B -ENOMEM -Insufficient system resources to intialize the application. - -.SH ATTRIBUTES - -For an explanation of the terms used in this section, see \fBattributes\fR(7). - -.TS -box, tab(&); -LB|LB|LB -L|L|L. -Interface & Attribute & Value -_ -\fBap_init\fR() & Thread safety & MT-Safe -_ -\fBap_fini\fR() & Thread safety & MT-Safe -.TE - -.SH COLOPHON -This page is part of the Ouroboros project, found at -https://bitbucket.org/ouroboros-rina/ouroboros diff --git a/doc/man/flow_alloc.3 b/doc/man/flow_alloc.3 index 84dd5f57..dd0fe7ea 100644 --- a/doc/man/flow_alloc.3 +++ b/doc/man/flow_alloc.3 @@ -109,7 +109,8 @@ _ .SH SEE ALSO -.BR ap_init "(3), " ap_fini "(3), " flow_read "(3), " flow_write (3) +.BR ouroboros_init "(3), " ouroboros_fini "(3), " \ +flow_read "(3), " flow_write (3) .SH COLOPHON This page is part of the Ouroboros project, found at diff --git a/doc/man/ouroboros_fini.3 b/doc/man/ouroboros_fini.3 new file mode 100644 index 00000000..d525d287 --- /dev/null +++ b/doc/man/ouroboros_fini.3 @@ -0,0 +1 @@ +.so ouroboros_init.3 diff --git a/doc/man/ouroboros_init.3 b/doc/man/ouroboros_init.3 new file mode 100644 index 00000000..c74bea5e --- /dev/null +++ b/doc/man/ouroboros_init.3 @@ -0,0 +1,69 @@ +.\" Ouroboros man pages (C) 2017 +.\" Dimitri Staessens +.\" Sander Vrijders + +.TH OUROBOROS_INIT 3 2017-04-10 GNU "Ouroboros Programmer's Manual" + +.SH NAME + +ouroboros_init, ouroboros_fini \- initialize and finalize an +application for using Ouroboros + +.SH SYNOPSIS + +.B #include + +\fBint ouroboros_init(char * \fIapn\fB);\fR + +\fBvoid ouroboros_fini(void);\fR + +Compile and link with \fI-louroboros\fR. + +.SH DESCRIPTION + +The \fBouroboros_init\fR() call initializes an application process +instance for using the Ouroboros IPC infrastructure. If the +application is a server or peer, a \fBchar * \fIapn\fR has to be +provided indicating the application process that this instance belongs +to. This is usually argv[0]. A client application may pass NULL. The +\fBouroboros_fini\fR() call will release all resources allocated by +\fBouroboros_fini\fR(). + +\fBouroboros_init\fR() and \fBouroboros_fini\fR() should be called +only once in the application. + +.SH RETURN VALUE + +On success, \fBouroboros_init\fR() returns 0. On failure, a negative +value indicating the error will be returned. The +\fBouroboros_fini\fR() function has no return value. + +.SH ERRORS + +\fBouroboros_init\fR() can return the following errors: + +.B -EIRMD +Failed to contact an IRMd instance. + +.B -ENOMEM +Insufficient system resources to intialize the application. + +.SH ATTRIBUTES + +For an explanation of the terms used in this section, see +\fBattributes\fR(7). + +.TS +box, tab(&); +LB|LB|LB +L|L|L. +Interface & Attribute & Value +_ +\fBouroboros_init\fR() & Thread safety & MT-Safe +_ +\fBouroboros_fini\fR() & Thread safety & MT-Safe +.TE + +.SH COLOPHON +This page is part of the Ouroboros project, found at +https://bitbucket.org/ouroboros-rina/ouroboros diff --git a/include/ouroboros/dev.h b/include/ouroboros/dev.h index 31c681db..396f2ae3 100644 --- a/include/ouroboros/dev.h +++ b/include/ouroboros/dev.h @@ -30,9 +30,9 @@ #define OUROBOROS_DEV_H /* These calls should be removed once we write the ouroboros OS. */ -int ap_init(const char * ap_name); +int ouroboros_init(const char * ap_name); -void ap_fini(void); +void ouroboros_fini(void); /* Returns flow descriptor, qs updates to supplied QoS. */ int flow_alloc(const char * dst_name, diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c index 795ce42c..47c951f1 100644 --- a/src/ipcpd/ipcp.c +++ b/src/ipcpd/ipcp.c @@ -476,12 +476,12 @@ int ipcp_init(int argc, log_init(log); if (type == IPCP_NORMAL) { - if (ap_init(argv[0])) { + if (ouroboros_init(argv[0])) { log_err("Failed to init normal IPCPI."); return -1; } } else { - if (ap_init(NULL)) { + if (ouroboros_init(NULL)) { log_err("Failed to init shim IPCPI."); return -1; } @@ -600,7 +600,7 @@ int ipcp_init(int argc, fail_sock_path: free(ipcpi.threadpool); fail_thr: - ap_fini(); + ouroboros_fini(); return ret; } @@ -732,7 +732,7 @@ void ipcp_fini() log_fini(); - ap_fini(); + ouroboros_fini(); log_info("IPCP %d out.", getpid()); } diff --git a/src/irmd/main.c b/src/irmd/main.c index d24c0ba1..bdc03ef8 100644 --- a/src/irmd/main.c +++ b/src/irmd/main.c @@ -931,7 +931,7 @@ static int flow_accept(pid_t api, e = api_table_get(&irmd.api_table, api); if (e == NULL) { - /* Can only happen if server called ap_init(NULL); */ + /* Can only happen if server called ouroboros_init(NULL); */ pthread_rwlock_unlock(&irmd.reg_lock); log_err("Unknown instance %d calling accept.", api); return -EINVAL; diff --git a/src/lib/dev.c b/src/lib/dev.c index d68fb471..757f26a8 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -245,7 +245,7 @@ static void reset_flow(int fd) init_flow(fd); } -int ap_init(const char * ap_name) +int ouroboros_init(const char * ap_name) { int i = 0; @@ -335,7 +335,7 @@ int ap_init(const char * ap_name) return 0; } -void ap_fini() +void ouroboros_fini() { int i = 0; diff --git a/src/tools/cbr/cbr.c b/src/tools/cbr/cbr.c index cd29c9ad..597ae8a6 100644 --- a/src/tools/cbr/cbr.c +++ b/src/tools/cbr/cbr.c @@ -129,14 +129,14 @@ int main(int argc, char ** argv) } if (server) { - if (ap_init(argv_dup[0]) < 0) { + if (ouroboros_init(argv_dup[0]) < 0) { printf("Failed to init.\n"); exit(EXIT_FAILURE); } ret = server_main(); } else { - if (ap_init(NULL) < 0) { + if (ouroboros_init(NULL) < 0) { printf("Failed to init.\n"); exit(EXIT_FAILURE); } @@ -150,7 +150,7 @@ int main(int argc, char ** argv) ret = client_main(s_apn, duration, size, rate, flood, sleep); } - ap_fini(); + ouroboros_fini(); return ret; } diff --git a/src/tools/echo/echo.c b/src/tools/echo/echo.c index 051a16c3..b68e8c02 100644 --- a/src/tools/echo/echo.c +++ b/src/tools/echo/echo.c @@ -59,20 +59,20 @@ int main(int argc, char ** argv) } if (server) { - if (ap_init(argv_dup[0])) { + if (ouroboros_init(argv_dup[0])) { printf("Failed to init AP.\n"); return -1; } ret = server_main(); } else { - if (ap_init(NULL)) { + if (ouroboros_init(NULL)) { printf("Failed to init AP.\n"); return -1; } ret = client_main(); } - ap_fini(); + ouroboros_fini(); return ret; } diff --git a/src/tools/echo/echo_server.c b/src/tools/echo/echo_server.c index 771155f4..22175a65 100644 --- a/src/tools/echo/echo_server.c +++ b/src/tools/echo/echo_server.c @@ -31,7 +31,7 @@ void shutdown_server(int signo) { (void) signo; - ap_fini(); + ouroboros_fini(); exit(EXIT_SUCCESS); } diff --git a/src/tools/operf/operf.c b/src/tools/operf/operf.c index 7935d12c..5e7f2f37 100644 --- a/src/tools/operf/operf.c +++ b/src/tools/operf/operf.c @@ -140,14 +140,14 @@ int main(int argc, char ** argv) } if (serv) { - if (ap_init(argv_dup[0])) { + if (ouroboros_init(argv_dup[0])) { printf("Failed to init AP.\n"); exit(EXIT_FAILURE); } ret = server_main(); } else { - if (ap_init(NULL)) { + if (ouroboros_init(NULL)) { printf("Failed to init AP.\n"); exit(EXIT_FAILURE); } @@ -171,7 +171,7 @@ int main(int argc, char ** argv) ret = client_main(); } - ap_fini(); + ouroboros_fini(); if (ret < 0) exit(EXIT_FAILURE); diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c index 7c9c108c..a88e06e5 100644 --- a/src/tools/oping/oping.c +++ b/src/tools/oping/oping.c @@ -139,14 +139,14 @@ int main(int argc, char ** argv) } if (serv) { - if (ap_init(argv_dup[0])) { + if (ouroboros_init(argv_dup[0])) { printf("Failed to init AP.\n"); exit(EXIT_FAILURE); } ret = server_main(); } else { - if (ap_init(NULL)) { + if (ouroboros_init(NULL)) { printf("Failed to init AP.\n"); exit(EXIT_FAILURE); } @@ -179,7 +179,7 @@ int main(int argc, char ** argv) ret = client_main(); } - ap_fini(); + ouroboros_fini(); if (ret < 0) exit(EXIT_FAILURE); -- cgit v1.2.3 From 21187cdf04f6b6697064430aac68dcf795923943 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 13 Apr 2017 12:09:14 +0200 Subject: include: Add C++ directives in headers Fixes #34 --- include/ouroboros/CMakeLists.txt | 1 + include/ouroboros/cacep.h | 6 ++++++ include/ouroboros/cdap.h | 6 ++++++ include/ouroboros/cdefs.h | 35 +++++++++++++++++++++++++++++++++++ include/ouroboros/dev.h | 9 +++++++-- include/ouroboros/fcntl.h | 6 ++++++ include/ouroboros/fqueue.h | 6 ++++++ include/ouroboros/irm.h | 5 +++++ include/ouroboros/nsm.h | 7 +++++++ 9 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 include/ouroboros/cdefs.h diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index 748d5e2d..b07568e3 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -5,6 +5,7 @@ configure_file( set(HEADER_FILES cacep.h cdap.h + cdefs.h dev.h errno.h fcntl.h diff --git a/include/ouroboros/cacep.h b/include/ouroboros/cacep.h index 950f3cf7..967151de 100644 --- a/include/ouroboros/cacep.h +++ b/include/ouroboros/cacep.h @@ -24,6 +24,8 @@ #ifndef OUROBOROS_CACEP_H #define OUROBOROS_CACEP_H +#include + #include enum proto_concrete_syntax { @@ -40,10 +42,14 @@ struct conn_info { uint64_t addr; }; +__BEGIN_DECLS + int cacep_snd(int fd, const struct conn_info * in); int cacep_rcv(int fd, struct conn_info * out); +__END_DECLS + #endif /* OUROBOROS_CACEP_H */ diff --git a/include/ouroboros/cdap.h b/include/ouroboros/cdap.h index 32edb51c..fe16a9c9 100644 --- a/include/ouroboros/cdap.h +++ b/include/ouroboros/cdap.h @@ -24,6 +24,8 @@ #ifndef OUROBOROS_CDAP_H #define OUROBOROS_CDAP_H +#include + #include #include #include @@ -46,6 +48,8 @@ struct cdap; typedef int32_t cdap_key_t; +__BEGIN_DECLS + struct cdap * cdap_create(void); int cdap_destroy(struct cdap * instance); @@ -81,4 +85,6 @@ int cdap_reply_send(struct cdap * instance, const void * data, size_t len); +__END_DECLS + #endif /* OUROBOROS_CDAP_H */ diff --git a/include/ouroboros/cdefs.h b/include/ouroboros/cdefs.h new file mode 100644 index 00000000..da7c4732 --- /dev/null +++ b/include/ouroboros/cdefs.h @@ -0,0 +1,35 @@ +/* + * Ouroboros - Copyright (C) 2016 - 2017 + * + * C Definitions + * + * Dimitri Staessens + * Sander Vrijders + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * version 2.1 as published by the Free Software Foundation. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef OUROBOROS_CDEFS_H +#define OUROBOROS_CDEFS_H + +#ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +#else +# define __BEGIN_DECLS +# define __END_DECLS +#endif + +#endif /* OUROBOROS_CDEFS_H */ diff --git a/include/ouroboros/dev.h b/include/ouroboros/dev.h index 396f2ae3..73d2d7b6 100644 --- a/include/ouroboros/dev.h +++ b/include/ouroboros/dev.h @@ -21,13 +21,16 @@ * 02110-1301 USA */ +#ifndef OUROBOROS_DEV_H +#define OUROBOROS_DEV_H + +#include #include #include #include -#ifndef OUROBOROS_DEV_H -#define OUROBOROS_DEV_H +__BEGIN_DECLS /* These calls should be removed once we write the ouroboros OS. */ int ouroboros_init(const char * ap_name); @@ -53,4 +56,6 @@ ssize_t flow_read(int fd, void * buf, size_t count); +__END_DECLS + #endif /* OUROBOROS_DEV_H */ diff --git a/include/ouroboros/fcntl.h b/include/ouroboros/fcntl.h index 65e8c378..489fff15 100644 --- a/include/ouroboros/fcntl.h +++ b/include/ouroboros/fcntl.h @@ -24,6 +24,8 @@ #ifndef OUROBOROS_FCNTL_H #define OUROBOROS_FCNTL_H +#include + #include /* same values as fcntl.h */ @@ -37,6 +39,8 @@ #define FLOW_O_INVALID (FLOW_O_WRONLY | FLOW_O_RDWR) +__BEGIN_DECLS + int flow_set_flags(int fd, int flags); @@ -51,4 +55,6 @@ int flow_get_timeout(int fd, int flow_get_qosspec(int fd, qosspec_t * qs); +__END_DECLS + #endif /* OUROBOROS_FCNTL_H */ diff --git a/include/ouroboros/fqueue.h b/include/ouroboros/fqueue.h index fc7dc303..604fabf7 100644 --- a/include/ouroboros/fqueue.h +++ b/include/ouroboros/fqueue.h @@ -24,6 +24,8 @@ #ifndef OUROBOROS_FQUEUE_H #define OUROBOROS_FQUEUE_H +#include + #include #include @@ -34,6 +36,8 @@ struct fqueue; typedef struct flow_set flow_set_t; typedef struct fqueue fqueue_t; +__BEGIN_DECLS + flow_set_t * flow_set_create(void); void flow_set_destroy(flow_set_t * set); @@ -59,4 +63,6 @@ int flow_event_wait(flow_set_t * set, fqueue_t * fq, const struct timespec * timeout); +__END_DECLS + #endif /* OUROBOROS_FQUEUE_H */ diff --git a/include/ouroboros/irm.h b/include/ouroboros/irm.h index d1aa5230..61b2fd87 100644 --- a/include/ouroboros/irm.h +++ b/include/ouroboros/irm.h @@ -24,6 +24,7 @@ #ifndef OUROBOROS_IRM_H #define OUROBOROS_IRM_H +#include #include #include @@ -33,6 +34,8 @@ #define BIND_AP_AUTO 0x01 #define BIND_AP_UNIQUE 0x02 +__BEGIN_DECLS + pid_t irm_create_ipcp(const char * name, enum ipcp_type ipcp_type); @@ -71,4 +74,6 @@ int irm_unreg(const char * name, char ** difs, size_t len); +__END_DECLS + #endif /* OUROBOROS_IRM_H */ diff --git a/include/ouroboros/nsm.h b/include/ouroboros/nsm.h index 22a2a593..45adfed3 100644 --- a/include/ouroboros/nsm.h +++ b/include/ouroboros/nsm.h @@ -24,9 +24,13 @@ #ifndef OUROBOROS_NSM_H #define OUROBOROS_NSM_H +#include + #include #include +__BEGIN_DECLS + int nsm_reg(char * name, char ** dafs, size_t dafs_size); @@ -41,4 +45,7 @@ int nsm_unreg(char * name, */ ssize_t nsm_resolve(char * name, char ** dafs); + +__END_DECLS + #endif -- cgit v1.2.3