source: trunk/monitas/structs.h @ 387

Last change on this file since 387 was 353, checked in by bcornec, 14 years ago

monitas latest version

File size: 3.9 KB
Line 
1/* structs.h
2
307/17
4- add central global struct
5
606/16
7- added CLIENT_RCFILE [moved to common.c on 07/17]
8- added .bodyAux to msg record structure
9
1006/14
11- added SERVER_COMDEV and CLIENT_COMDEV [moved to common.c on 07/17]
12
1306/11
14- added busy to s_registered_client_record structure
15- added compare_ok, compare_fail
16
1705/27
18- added pthread.h
19
2005/11
21- added file transfer flags to type t_msg
22
23*/
24
25
26
27#include <pthread.h>
28#include <stdio.h>
29#include <string.h>
30#include <errno.h>
31#include <pthread.h>
32#include <sys/file.h>
33#include <sys/types.h>
34#include <sys/stat.h>
35#include <signal.h>
36#include <sys/socket.h>
37#include <unistd.h>
38#include <netdb.h>
39#include <stdlib.h>
40#include <sys/time.h>
41#include <sys/wait.h>
42#include <sys/poll.h>
43#include <time.h>
44#include <ctype.h>
45#include <unistd.h>
46#include <fcntl.h>
47
48
49/* moved to common.c :
50#define CLIENT_RCFILE "/root/.monitas-client.rc"
51#define CLIENT_COMDEV "/var/spool/monitas/client-input.dev"
52#define SERVER_COMDEV "/var/spool/monitas/server-input.dev"
53#define SERVER_STATUS_FILE "/var/spool/monitas/server-status.txt"
54*/
55#define MAX_STR_LEN 510
56#define MAX_PENDING 8 /* silently limited to 5 by BSD, says a Linux manual */
57#define MAX_CLIENTS 100
58#define MSG_BODY_SIZE 200 /* 512 doesn't work; don't ask me why */
59#define XFER_BUF_SIZE 16384 /* for sending archives between client and server */
60                            /* NB: 32768 doesn't work; don't ask me why */
61
62typedef enum { false=0, true=1} bool;
63typedef enum { unused=0, login, logout, ping, pong, login_ok, logout_ok, 
64                login_fail, logout_fail, backup_ok, backup_fail,
65                restore_ok, restore_fail, compare_ok, compare_fail,
66        trigger_backup, trigger_restore, trigger_compare,
67                begin_stream, end_stream, user_req, progress_rpt } t_msg;
68typedef enum { debug, info, warn, error, fatal } t_loglevel;
69
70
71//#define log_it(x,y) { log_it_SUB(g_logfile,x,y); }
72#ifndef __XSTR
73#   define __XSTR(x) _XSTR(x)
74#   define _XSTR(x) #x
75#endif
76#define log_it(lvl,msg,args...) { logToFile(g->logfile,lvl,__FILE__,__XSTR(__LINE__),__FUNCTION__,msg , ## args); }
77extern void logToFile(char *logfile, t_loglevel level, char *filename, char *lineno, char *funcname, char *sz_message, ...);
78
79
80/*
81 * Global structure for all data that doesn't change at runtime.
82 * The data may be modified at program start via command line options,
83 * or -not implemented yet- via environment variables or server-client
84 * communication.
85 */
86struct s_globaldata
87{
88    char *client_rcfile;        // path+name of client's rc file
89    char *client_comdev;        // path+name of client's
90    char *server_comdev;        // path+name of server's
91    char *server_status_file;   // path+name of server's
92
93    char *logfile;              // path+name of logfile
94    t_loglevel loglevel;        // lowest level of msg written in the logfile
95};
96/*
97 * there is one (1) global instance of above struct [defined in common.c] and
98 * one global pointer [also in common.c] to address the struct inside all functions.
99 * The pointer is declared here as external to permit the global access.
100 */
101extern struct s_globaldata *g;
102
103
104
105
106struct s_client2server_msg_record /* msg from client to server */
107{
108  t_msg msg_type;
109  long magic;
110  int port; /* which port to contact client on */ 
111  char body[MSG_BODY_SIZE];
112  char bodyAux[MSG_BODY_SIZE];
113};
114
115
116
117struct s_server2client_msg_record /* msg from client */
118{
119  t_msg msg_type;
120  long magic; /* if pong/ack then it equals the magic# of the packet to which it's replying; else, 0 */
121  int dummy;
122  char body[MSG_BODY_SIZE];
123  char bodyAux[MSG_BODY_SIZE];
124};
125
126
127
128struct s_registered_client_record
129{
130  char hostname_pretty[128]; /* specified by client in login packet */
131  char ipaddr[20]; /* xxx.yyy.zzz.nnn of client */
132  int port;
133  bool busy; /* backing up / restoring / comparing */
134  char last_progress_rpt[MAX_STR_LEN+1];
135};
136
137
138
139struct s_clientlist
140{
141  int items;
142  struct s_registered_client_record el[MAX_CLIENTS];
143};
144
145
Note: See TracBrowser for help on using the repository browser.