-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlarvnetd.h
129 lines (110 loc) · 3.4 KB
/
larvnetd.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* $Id: larvnetd.h,v 1.3 1998-10-21 20:02:06 ghudson Exp $ */
/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#ifndef LARVNETD__H
#define LARVNETD__H
#include <sys/types.h>
#include <netinet/in.h>
#include <stdio.h>
#include <time.h>
#include <ares.h>
#include "timer.h"
enum busystate { BUSY, FREE, UNKNOWN_BUSYSTATE };
struct cluster {
char *name;
char *phone;
int cgroup; /* Index into config.cgroups, or -1 */
};
struct archname {
char *reportname;
char **netnames;
int nnetnames;
};
struct machine {
/* Configuration data */
char *name;
int cluster; /* Index into config.clusters */
/* State information */
enum busystate busy;
char *arch; /* Architecture name reported in status */
time_t laststatus; /* Time of last status report */
time_t lastpoll; /* Time of last poll we sent */
int numpolls; /* Number of polls since laststatus */
};
struct printer {
/* Configuration data */
char *name;
char *location;
int cluster; /* Index into config.clusters */
/* State information */
int up;
int jobs;
int s; /* Communications socket for polling */
int to_send; /* Non-zero if we want to send data */
char buf[BUFSIZ]; /* Data to send or data received */
int buflen; /* Amount of data in buf */
int jobs_counted; /* Jobs counted from data received so far */
int up_so_far; /* 1 until we find out the printer is down */
Timer *timer; /* Timer for next poll (when s == -1) */
};
struct cgroup {
char *name;
int x;
int y;
};
struct config {
struct cluster *clusters;
int nclusters;
struct archname *arches;
int narch;
struct machine *machines; /* Sorted by name */
int nmachines;
struct printer *printers;
int nprinters;
struct cgroup *cgroups;
int ncgroups;
char *report_other;
char *report_unknown;
};
struct serverstate {
struct config config;
ares_channel channel;
void *hescontext;
int server_socket;
unsigned short poll_port;
int startmachine;
const char *configfile;
};
/* config.c */
void read_initial_config(struct serverstate *state);
void reread_config(struct serverstate *state);
/* printer.c */
void printer_start_polls(struct serverstate *state);
void printer_handle_output(struct serverstate *state, struct printer *printer);
void printer_handle_input(struct serverstate *state, struct printer *printer);
/* report.c */
void report(void *arg);
/* util.c */
void *emalloc(size_t size);
void *erealloc(void *ptr, size_t size);
char *estrdup(const char *s);
char *estrndup(const char *s, size_t n);
int read_line(FILE *fp, char **buf, int *bufsize);
/* ws.c */
void ws_poll(void *arg);
void ws_handle_status(int s, struct config *config);
struct machine *ws_find(struct config *config, const char *name);
void ws_sort(struct config *config);
#endif /* LARVNETD__H */