1 #ifndef DPID_COMMON_H
2 #define DPID_COMMON_H
3 
4 /*! \file
5  * Declares common functions, global variables, and types.
6  *
7  * \todo
8  * The dpid error codes will be used in
9  * the next patch
10  */
11 
12 #include <dirent.h>
13 
14 #include "../dlib/dlib.h"
15 
16 /*
17  * Debugging macros
18  */
19 #define _MSG(...)
20 #define MSG(...)  printf("[dpid]: " __VA_ARGS__)
21 #define _MSG_ERR(...)
22 #define MSG_ERR(...)  fprintf(stderr, "[dpid]: " __VA_ARGS__)
23 
24 #define dotDILLO_DPI ".dillo/dpi"
25 #define dotDILLO_DPIDRC ".dillo/dpidrc"
26 #define dotDILLO_DPID_COMM_KEYS ".dillo/dpid_comm_keys"
27 
28 #define ERRMSG(CALLER, CALLED, ERR)\
29  errmsg(CALLER, CALLED, ERR, __FILE__, __LINE__)
30 #define _ERRMSG(CALLER, CALLED, ERR)
31 
32 
33 /*!
34  * Macros for calling ckd_write and ckd_close functions
35  */
36 #define CKD_WRITE(fd, msg) ckd_write(fd, msg, __FILE__, __LINE__)
37 #define CKD_CLOSE(fd)      ckd_close(fd, __FILE__, __LINE__)
38 
39 
40 /*! Error codes for dpid */
41 enum {
42    no_errors,
43    dpid_srs_addrinuse /* dpid service request socket address already in use */
44 } dpi_errno;
45 
46 /*! Intended for identifying dillo plugins
47  * and related files
48  */
49 enum file_type {
50    DPI_FILE,                     /*! Any file name containing .dpi */
51    UNKNOWN_FILE
52 };
53 
54 
55 void errmsg(char *caller, char *called, int errornum, char *file, int line);
56 
57 ssize_t ckd_write(int fd, char *msg, char *file, int line);
58 ssize_t ckd_close(int fd, char *file, int line);
59 
60 #endif
61