pmain.c
上传用户:minyiyu
上传日期:2018-12-24
资源大小:864k
文件大小:1k
- #include "innbbsconf.h"
- #include "daemon.h"
- /*char *AccessFile=ACCESSFILE;*/
- #define INNBBSDPORT1 "1904"
- #define INNBBSDPORT2 "1234"
- #define INNBBSDPATH1 ".innbbsd1"
- #define INNBBSDPATH2 ".innbbsd2"
- pmain(port)
- char *port;
- {
- if (port == NULL) {
- int rel;
- /* installbbstalkd(); */
- fprintf(stderr, "Trying to listen in port %sn", INNBBSDPORT1);
- rel = open_listen(INNBBSDPORT1, "tcp", NULL);
- #ifdef DEBUG
- printf("port fd %d allocatedn", rel);
- #endif
- if (rel < 0) {
- fprintf(stderr, "Trying to listen in port %sn", INNBBSDPORT2);
- return open_listen(INNBBSDPORT2, "tcp", NULL);
- }
- return rel;
- } else {
- #ifdef DEBUG
- printf("start to allocate portn");
- #endif
- return open_listen(port, "tcp", NULL);
- }
- }
- p_unix_main(path)
- char *path;
- {
- if (path == NULL) {
- int rel;
- /* installbbstalkd(); */
- fprintf(stderr, "Trying to listen in port %sn", INNBBSDPATH1);
- rel = open_unix_listen(INNBBSDPATH1, "tcp", NULL);
- #ifdef DEBUG
- printf("port fd %d allocatedn", rel);
- #endif
- if (rel < 0) {
- fprintf(stderr, "Trying to listen in port %sn", INNBBSDPATH2);
- return open_listen(INNBBSDPATH2, "tcp", NULL);
- }
- return rel;
- } else {
- #ifdef DEBUG
- printf("start to allocate path %sn", path);
- #endif
- int fd = unixclient(path, "tcp");
- if (fd < 0)
- unlink(path);
- else
- close(fd);
- return open_unix_listen(path, "tcp", NULL);
- }
- }