/ src / libnml / rcs / rcs_print.hh
rcs_print.hh
  1  /********************************************************************
  2  * Description: rcs_print.hh
  3  *
  4  *   Derived from a work by Fred Proctor & Will Shackleford
  5  *
  6  * Author:
  7  * License: LGPL Version 2
  8  * System: Linux
  9  *    
 10  * Copyright (c) 2004 All rights reserved.
 11  *
 12  * Last change: 
 13  ********************************************************************/
 14  #ifndef RCS_PRNT_HH
 15  #define RCS_PRNT_HH
 16  
 17  
 18  #ifdef __cplusplus
 19  extern "C" {
 20  #endif
 21  
 22  #include <stdarg.h>		/* va_list */
 23  
 24  #ifdef __cplusplus
 25  }
 26  #endif
 27  #ifdef __cplusplus
 28  class LinkedList;
 29  
 30  extern LinkedList *get_rcs_print_list();
 31    /* Returns the address of the linked list where messages may have been
 32       stored. */
 33  #endif
 34  
 35  #ifdef __cplusplus
 36  extern "C" {
 37  #endif
 38  
 39      extern void clean_print_list(void);
 40      /* Deletes the linked list where messages may have been stored. */
 41  
 42      extern void output_print_list(int output_func(const char *));
 43      extern int count_characters_in_print_list(void);
 44      extern int count_lines_in_print_list(void);
 45      extern void convert_print_list_to_lines(void);
 46      extern void update_lines_table(void);
 47      extern int rcs_vprint(const char *_fmt, va_list va_args, int save_string);
 48      /* Prints a message using the _fmt format string and the _va_args using
 49         the vprintf conventions. */
 50  
 51      extern int rcs_print(const char *_fmt, ...) __attribute__((format(printf,1,2)));
 52      /* 
 53         Prints a message using the _fmt format string and optional additional
 54         arguments using the printf conventions. */
 55  
 56      extern int rcs_print_debug(long, const char *_fmt, ...) __attribute__((format(printf,2,3)));
 57      /* 
 58         Prints a message using the _fmt format string and optional additional
 59         arguments using the printf conventions if the corresponding flag to
 60         _flag_to_check is set. (See set_rcs_print_flag().) */
 61  #ifdef DO_NOT_USE_RCS_PRINT_ERROR_NEW
 62      extern int rcs_print_error(const char *_fmt, ...) __attribute__((format(printf,1,2)));
 63  #else
 64      extern int set_print_rcs_error_info(const char *file, int line);
 65      extern int print_rcs_error_new(const char *_fmt, ...) __attribute__((format(printf,1,2)));
 66  #define rcs_print_error set_print_rcs_error_info( __FILE__, __LINE__); print_rcs_error_new
 67  #endif
 68  
 69      extern void set_rcs_print_flag(long flags_to_set);
 70      /* An internal 32 bit integer contains a set of flags that are checked
 71         whenever an rcs_print_debug or rcs_print_error occurs to determine if
 72         the message should be printed or not. Programmers can define their own 
 73         flags in the most significant byte or turn on or off several NODE or
 74         CMS/NML debug messages.
 75  
 76         See the Print MODE flags defined below for messages that can be turned 
 77         on or off. */
 78  
 79      extern void clear_rcs_print_flag(long flags_to_set);
 80      /* Clears a flag set with set_rcs_print_flag. */
 81  
 82      extern char *strip_control_characters(char *_dest, char *_src);
 83      /* Removes new lines, carriage returns and tabs from the _src string and
 84         stores the result in the _dest string if the _dest pointer does not
 85         equal NULL. If the _dest pointer equals NULL the new string is stored
 86         in an internal array.
 87  
 88         Returns the dest pointer or the address of the internal array where
 89         the new string was stored. */
 90  
 91      extern int separate_words(char **_dest, int _max, char *_src);
 92      extern int rcs_puts(const char *);
 93      /* Prints the string _str and adds a new line character at the end
 94         following the puts convention. */
 95  
 96      extern int rcs_fputs(const char *);
 97      extern char **get_rcs_lines_table(void);
 98      extern int get_rcs_print_list_size(void);
 99      typedef void (*RCS_PRINT_NOTIFY_FUNC_PTR) (void);
100      extern void set_rcs_print_notify(RCS_PRINT_NOTIFY_FUNC_PTR);
101      extern int set_rcs_print_file(const char *_file_name);
102      extern void close_rcs_printing(void);
103  
104  #ifdef __cplusplus
105  }
106  #endif
107  /* Print MODE flags. */
108  #define PRINT_RCS_ERRORS                0x00000001	/* 1 */
109  #define PRINT_NODE_CONSTRUCTORS         0x00000002	/* 2 */
110  #define PRINT_NODE_DESTRUCTORS          0x00000004	/* 4 */
111  #define PRINT_CMS_CONSTRUCTORS          0x00000008	/* 8 */
112  #define PRINT_CMS_DESTRUCTORS           0x00000010	/* 16 */
113  #define PRINT_NML_CONSTRUCTORS          0x00000020	/* 32 */
114  #define PRINT_NML_DESTRUCTORS           0x00000040	/* 64 */
115  #define PRINT_COMMANDS_RECIEVED         0x00000100	/* 256 */
116  #define PRINT_COMMANDS_SENT             0x00000200	/* 512 */
117  #define PRINT_STATUS_RECIEVED           0x00000400	/* 1024 */
118  #define PRINT_STATUS_SENT               0x00000800	/* 2048 */
119  #define PRINT_NODE_CYCLES               0x00001000	/* 4096 */
120  #define PRINT_NODE_MISSED_CYCLES        0x00002000	/* 8192 */
121  #define PRINT_NODE_CYCLE_TIMES          0x00004000	/* 16384 */
122  #define PRINT_NODE_PROCESS_TIMES        0x00008000	/* 32768 */
123  #define PRINT_NEW_WM                    0x00010000	/* 65536 */
124  #define PRINT_NODE_ABORT                0x00020000	/* 131072 */
125  #define PRINT_CMS_CONFIG_INFO           0x00040000	/* 262144 */
126  #define PRINT_SOCKET_READ_SIZE          0x00080000	/* 524288 */
127  #define PRINT_SOCKET_WRITE_SIZE         0x00100000	/* 1048576 */
128  #define PRINT_INTERFACE_LOADING         0x00200000	/* 2097152 */
129  #define PRINT_RPC_SERVER_CALL           0x00400000	/* 4194304 */
130  #define PRINT_SEMAPHORE_ACTIVITY        0x00800000	/* 8388608 */
131  #define PRINT_SOCKET_CONNECT            0x01000000	/* 16777216 */
132  #define PRINT_SERVER_THREAD_ACTIVITY    0x02000000	// 33554432
133  #define PRINT_SERVER_SUBSCRIPTION_ACTIVITY    0x04000000	// 67108864
134  #define PRINT_SHARED_MEMORY_ACTIVITY    0x08000000
135  #define PRINT_ALL_SOCKET_REQUESTS       0x10000000
136  #define PRINT_EVERYTHING                0xFFFFFFFF	/* 4294967295 */
137  #ifdef __cplusplus
138  enum RCS_PRINT_DESTINATION_TYPE {
139  #else
140  typedef enum {
141  #endif
142      RCS_PRINT_TO_STDOUT,
143      RCS_PRINT_TO_STDERR,
144      RCS_PRINT_TO_NULL,
145      RCS_PRINT_TO_LIST,
146      RCS_PRINT_TO_FILE,
147      RCS_PRINT_TO_MESSAGE_BOX,	/* Only available for Windows */
148      RCS_PRINT_TO_LOGGER		/* Only available for VXWORKS */
149  #ifdef __cplusplus
150  };
151  #else
152  } RCS_PRINT_DESTINATION_TYPE;
153  #endif
154  
155  #ifdef __cplusplus
156  extern "C" {
157  #endif
158  
159      extern void set_rcs_print_destination(RCS_PRINT_DESTINATION_TYPE);
160      /* Changes where the output of the rcs_print functions is directed. The
161         following choices are available:
162  
163         RCS_PRINT_TO_STDOUT Print to stdout.
164  
165         RCS_PRINT_TO_LOGGER Currently prints to stdout, except under VxWorks
166         where it uses the logMsg function, which is non-blocking.
167  
168         RCS_PRINT_TO_STDERR Print to stderr
169  
170         RCS_PRINT_TO_NULL Make all rcs_print functions return without doing
171         anything.
172  
173         RCS_PRINT_TO_LIST Store all rcs_print messages in a linked list, so
174         that later they can be displayed in a separate window, or used in some 
175         other way. The current list sizing mode defaults to a maximum size of
176         256 with excess nodes being deleted from the head. */
177  
178      extern RCS_PRINT_DESTINATION_TYPE get_rcs_print_destination(void);
179      extern int rcs_print_sys_error(int error_source, const char *_fmt, ...) __attribute__((format(printf,2,3)));
180  
181  #ifdef __cplusplus
182      enum RCS_PRINT_ERROR_SOURCE_TYPE {
183  #else
184      typedef enum {
185  #endif
186  	ERRNO_ERROR_SOURCE = 1,
187  	GETLASTERROR_ERROR_SOURCE,
188  	WSAGETLASTERROR_ERROR_SOURCE
189  #ifdef __cplusplus
190      };
191  #else
192      } RCS_PRINT_ERROR_SOURCE_TYPE;
193  #endif
194  
195  #ifdef __cplusplus
196  };
197  #endif
198  
199  extern int max_rcs_errors_to_print;
200  extern int rcs_errors_printed;
201  
202  extern char last_error_bufs[4][100];
203  extern int last_error_buf_filled;
204  
205  #endif