~ knotless Search/
↑↓ move↵ open⇧↵ all results

spaces.cameron.stream/hello

Hello.

0
1
main
47 lines · 1.5 KB Raw History
/* The post: postboxes, van rounds and the sorting office. */

#ifndef POST_H
#define POST_H

#include "census.h"
#include "history.h"
#include "records.h"

#define OFFICE "Sorting Office"
#define STOP 1 /* Minutes a van stands at each box. */
#define MAX_DAILY 16 /* Boxes the van can empty in a day. */
#define MAX_VISITS MAX_DAILY

struct visit {
	char round[FIELD];
	char box[FIELD];
	int left; /* When the van left the office. */
	int at;   /* When the van empties the box. */
	int back; /* When the van is back at the office. */
};

struct letter {
	struct sender sender;
	int posted;
	struct visit visit;
};

/* Every box emptied on a day, by every round that runs.
 * A round leaves the office, drives to each of its boxes in turn, and comes back.
 * The sorting office clock is set by the bell every first of the month. */
int visits(struct day day, struct visit out[]);

/* Walk a letter to the nearest box and wait for a van. 0 if no van comes. */
int post(const struct sender *sender, struct day day, struct letter *letter);

/* Everything addressed to the World, in the order the dead letter office opens it.
 *
 * Nobody has an address for the World, so it all comes here. Vans are unloaded in
 * the order they come back. The last bag put in a van is on top, and the last
 * letter put in a box is on top of its bag. */
int dead_letters(struct day day, struct letter out[]);

/* The same, for a town as it is, on the first of the month it is in. */
int letters_from(const struct town *town, struct day day, struct letter out[]);

#endif