#include <zephyr/zephyr.h>
#include <stdio.h>
#include <string.h>

extern int errno;
extern Code_t ZHackSetLocation();
extern Code_t ZHackUnsetLocation();
extern Code_t ZHackFlushMyLocations();

main(argc, argv)
    int argc;
    char *argv[];
{
    int retval;
    char *host = NULL, *disp = NULL;
    
    if ((retval = ZInitialize())) {
	com_err(argv[0], retval, "while initializing");
	exit(1);
    }
    if (argc < 2) {
	fprintf(stderr, "must have at least one arg!\n");
	exit(1);
    }
    if (argc >= 3)
	host = *argv[2] == '\0' ? NULL : argv[2];
    if (argc >= 4)
	disp = *argv[3] == '\0' ? NULL : argv[3];
    if (strlen(argv[1]) == 3 && !strcmp(argv[1], "-rv")) {
	ZHackSetLocation(EXPOSE_REALMVIS, host, disp);
	exit(0);
    } else if (strlen(argv[1]) == 3 && !strcmp(argv[1], "-ra")) {
	ZHackSetLocation(EXPOSE_REALMANN, host, disp);
	exit(0);
    } else if (strlen(argv[1]) == 3 && !strcmp(argv[1], "-nv")) {
	ZHackSetLocation(EXPOSE_NETVIS, host, disp);
	exit(0);
    } else if (strlen(argv[1]) == 3 && !strcmp(argv[1], "-na")) {
	ZHackSetLocation(EXPOSE_NETANN, host, disp);
	exit(0);
    } else if (strlen(argv[1]) == 3 && !strcmp(argv[1], "-op")) {
	ZHackSetLocation(EXPOSE_OPSTAFF, host, disp);
	exit(0);
    } else if (strlen(argv[1]) == 3 && !strcmp(argv[1], "-lo")) {
	ZHackUnsetLocation(host, disp);
	exit(0);
    } else if (strlen(argv[1]) == 3 && !strcmp(argv[1], "-fl")) {
	ZHackFlushMyLocations();
	exit(0);
    } else {
	fprintf(stderr, "invalid args\n");
	exit(1);
    }
}
