summaryrefslogtreecommitdiffstats
path: root/innbbsd/pmain.c
blob: 5236244e9cf37aa99caa934b08ccfe24ca6f2bcb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "bbs.h"
#include "innbbsconf.h"
#include "daemon.h"
#include "externs.h"

/* char *AccessFile=ACCESSFILE; */
#define INNBBSDPORT1 "1904"
#define INNBBSDPORT2 "1234"
#define INNBBSDPATH1  ".innbbsd1"
#define INNBBSDPATH2  ".innbbsd2"

int
pmain(port)
    char           *port;
{
    if (port == NULL) {
    int             rel;
    /* installbbstalkd(); */
    fprintf(stderr, "Trying to listen in port %s\n", INNBBSDPORT1);
    rel = open_listen(INNBBSDPORT1, "tcp", NULL);
#ifdef DEBUG
    printf("port fd %d allocated\n", rel);
#endif
    if (rel < 0) {
        fprintf(stderr, "Trying to listen in port %s\n", INNBBSDPORT2);
        return open_listen(INNBBSDPORT2, "tcp", NULL);
    }
    return rel;
    } else {
#ifdef DEBUG
    printf("start to allocate port\n");
#endif
    return open_listen(port, "tcp", NULL);
    }
}

int
p_unix_main(path)
    char           *path;
{
    if (path == NULL) {
    int             rel;
    /* installbbstalkd(); */
    fprintf(stderr, "Trying to listen in port %s\n", INNBBSDPATH1);
    rel = open_unix_listen(INNBBSDPATH1, "tcp", NULL);
#ifdef DEBUG
    printf("port fd %d allocated\n", rel);
#endif
    if (rel < 0) {
        fprintf(stderr, "Trying to listen in port %s\n", INNBBSDPATH2);
        return open_listen(INNBBSDPATH2, "tcp", NULL);
    }
    return rel;
    } else {
#ifdef DEBUG
    printf("start to allocate path %s\n", path);
#endif
    int             fd = toconnect(path);
    if (fd < 0)
        unlink(path);
    else
        close(fd);
    return open_unix_listen(path, "tcp", NULL);
    }
}