Subversion Repositories IRCServ

Rev

Rev 6 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

/* $Id: check.c 7 2024-08-25 20:49:55Z 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_ircd(void) {
        int count = 0;
        const char* name = "";
#ifdef USE_BAHAMUT_IRCD
        name = "Bahamut";
        count++;
#endif
        if(count == 0) {
                fprintf(stderr, "Select an IRCd\n");
                return 1;
        } else if(count > 1) {
                fprintf(stderr, "Too many IRCds\n");
                return 1;
        } else {
                printf("Using %s for IRCd\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
#ifndef IRC_SERVICE_DESCRIPTION
        fprintf(stderr, "Set a service description\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;
                st = check_ircd();
                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(" ");
#if defined(USE_BAHAMUT_IRCD)
                printf("ircd/bahamut.o");
#endif

                printf(" ");
#ifdef USE_NICKSERV
                printf("service/nickserv.o");
#endif

                printf(" ");
#ifdef USE_CHANSERV
                printf("service/chanserv.o");
#endif

                printf(" ");
#ifdef USE_MEMOSERV
                printf("service/memoserv.o");
#endif

                printf(" ");
#ifdef USE_OPERSERV
                printf("service/operserv.o");
#endif
                printf("\n");
        }
}