Subversion Repositories IRCServ

Rev

Rev 3 | Rev 6 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/* $Id: check.c 5 2024-08-25 11:58:10Z nishi $ */

#include "config.h"

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

int check_log(void) {
        int count = 0;
        const char* name = "";
#ifdef USE_SYSLOG
        name = "Syslog";
        count++;
#endif
#ifdef USE_STDERR
        name = "stderr";
        count++;
#endif
        if(count == 0) {
                fprintf(stderr, "Select a logger\n");
                return 1;
        } else if(count > 1) {
                fprintf(stderr, "Too many loggers\n");
                return 1;
        } else {
                printf("Using %s for logging\n", name);
                return 0;
        }
}

int check_irc(void) {
        int st = 0;
#ifndef IRC_SERVER
        fprintf(stderr, "Set a server IP\n");
        st = 1;
#endif
#ifndef IRC_PORT
        fprintf(stderr, "Set a server port\n");
        st = 1;
#endif
#ifndef IRC_SECRET
        fprintf(stderr, "Set a service password\n");
        st = 1;
#endif
#ifndef IRC_SERVICE
        fprintf(stderr, "Set a service name\n");
        st = 1;
#endif
        return st;
}

int main(int argc, char** argv) {
        if(argc == 1) {
                int st = 0;
                st = check_log();
                if(st != 0) goto cleanup;
                st = check_irc();
                if(st != 0) goto cleanup;
        cleanup:
                return st;
        } else if(strcmp(argv[1], "objs") == 0) {
#if defined(USE_SYSLOG)
                printf("log/syslog.o");
#elif defined(USE_STDERR)
                printf("log/stderr.o");
#endif
                printf("\n");
        }
}