Subversion Repositories Okuu

Rev

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

Rev Author Line No. Line
2 nishi 1
/* $Id: main.c 5 2024-09-11 00:26:25Z nishi $ */
2
 
3 nishi 3
#include "ok_bot.h"
4
 
5
#include "ok_news.h"
6
 
2 nishi 7
#include <stdio.h>
8
#include <stdlib.h>
9
#include <stdbool.h>
10
 
11
char* nntpserver;
12
char* nntpuser;
13
char* nntppass;
3 nishi 14
char* nntppath;
5 nishi 15
char* nntpgroup;
16
char* nntpfrom;
3 nishi 17
char* nntpcount;
2 nishi 18
int nntpport = 119;
19
 
20
char* ircserver;
3 nishi 21
char* ircchan;
22
char* ircuser;
23
char* ircnick;
24
char* ircreal;
25
char* ircpass;
26
int ircport = 6667;
2 nishi 27
 
28
int main(){
29
	printf("Okuu starting up\n");
30
 
31
	nntpserver = getenv("NNTPSERVER");
32
	nntpuser = getenv("NNTPUSER");
33
	nntppass = getenv("NNTPPASS");
3 nishi 34
	nntppath = getenv("NNTPPATH");
5 nishi 35
	nntpgroup = getenv("NNTPGROUP");
3 nishi 36
	nntpcount = getenv("NNTPCOUNT");
5 nishi 37
	nntpfrom = getenv("NNTPFROM");
2 nishi 38
	ircserver = getenv("IRCSERVER");
3 nishi 39
	ircchan = getenv("IRCCHAN");
40
	ircuser = getenv("IRCUSER");
41
	ircnick = getenv("IRCNICK");
42
	ircreal = getenv("IRCREAL");
43
	ircpass = getenv("IRCPASS");
2 nishi 44
	if(getenv("NNTPPORT") != NULL){
45
		nntpport = atoi(getenv("NNTPPORT"));
46
	}
47
	if(getenv("IRCPORT") != NULL){
48
		ircport = atoi(getenv("IRCPORT"));
49
	}
50
	bool bad = false;
51
	if(nntpserver == NULL){
52
		fprintf(stderr, "Set NNTPSERVER\n");
53
		bad = true;
54
	}
3 nishi 55
	if(nntppath == NULL){
56
		fprintf(stderr, "Set NNTPPATH\n");
57
		bad = true;
58
	}
59
	if(nntpcount == NULL){
60
		fprintf(stderr, "Set NNTPCOUNT\n");
61
		bad = true;
62
	}
5 nishi 63
	if(nntpfrom == NULL){
64
		fprintf(stderr, "Set NNTPFROM\n");
65
		bad = true;
66
	}
67
	if(nntpgroup == NULL){
68
		fprintf(stderr, "Set NNTPGROUP\n");
69
		bad = true;
70
	}
2 nishi 71
	if(ircserver == NULL){
72
		fprintf(stderr, "Set IRCSERVER\n");
73
		bad = true;
74
	}
3 nishi 75
	if(ircchan == NULL){
76
		fprintf(stderr, "Set IRCCHAN\n");
77
		bad = true;
78
	}
79
	if(ircuser == NULL){
80
		fprintf(stderr, "Set IRCUSER\n");
81
		bad = true;
82
	}
83
	if(ircnick == NULL) ircnick = ircuser;
84
	if(ircreal == NULL) ircreal = ircuser;
2 nishi 85
	if(bad){
86
		return 1;
87
	}
3 nishi 88
	ok_news_init();
89
	ok_bot();
2 nishi 90
}