source: trunk/athena/etc/larvnetd/larvnetd.h @ 12057

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