From bf009b43856f0922f312598590269c2e309bae1b Mon Sep 17 00:00:00 2001 From: dcp1990 Date: Mon, 27 Jun 2005 21:19:30 +0000 Subject: [PATCH] Why are these here? --- cnd/Makefile | 13 ------ cnd/cnd.c | 116 --------------------------------------------------- 2 files changed, 129 deletions(-) delete mode 100644 cnd/Makefile delete mode 100644 cnd/cnd.c diff --git a/cnd/Makefile b/cnd/Makefile deleted file mode 100644 index c99cfb5..0000000 --- a/cnd/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -# cnd Makefile -# $Amigan: phoned/cnd/Makefile,v 1.2 2005/06/01 00:43:07 dcp1990 Exp $ -# (C)2005, Dan Ponte -include ../global.mk -# basic stuff. we append for a reason. -CPPFLAGS=-I../include -CFLAGS+=-g -Wall -W -ansi ${CPPFLAGS} -LDFLAGS= -# keep these up to date. -MAINBIN=cnd -SRCS=cnd.c -OBJS=cnd.o -include ../main.mk diff --git a/cnd/cnd.c b/cnd/cnd.c deleted file mode 100644 index 4ec09c6..0000000 --- a/cnd/cnd.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Caller ID Server mgetty support - * (C)2004, Dan Ponte - * Licensed under the BSD license, with advertising clause. - * Excerpted from the original cidserv distribution. Modified to work - * with phoned. - */ -/* $Amigan: phoned/cnd/cnd.c,v 1.2 2005/06/01 00:43:07 dcp1990 Exp $ */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#define VERSION "0.1" -#define ADDRS "/usr/local/etc/cidserv.conf" -int nhosts = 0; -char hosts[10][18]; -static const char rcsid[] = "$Amigan: phoned/cnd/cnd.c,v 1.2 2005/06/01 00:43:07 dcp1990 Exp $"; -void send_dgram(char* address, char* datar); -void load_addrs(const char* fl); -int parse_cid(char* tty, char* phone, char* name, int dist_r, char* called); -int main(int argc, char* argv[]) -{ - if(argc < 6) { - fprintf(stderr, "Needs 5 args:\n" - " \n"); - exit(-2); - } - load_addrs(ADDRS); - parse_cid(argv[1], argv[2], argv[3], atoi(argv[4]), argv[5]); - return 0; -} -int parse_cid(tty, phone, name, dist_r, called) - char* tty __unused; - char* phone; - char* name; - int dist_r __unused; - char* called __unused; -{ - int i = 0; - char msg[512]; - char fdate[25]; - time_t rnow; - struct tm *ctm; - memset(msg, 0, sizeof msg); - memset(fdate, 0, sizeof fdate); - rnow = time(NULL); - ctm = localtime(&rnow); - strftime(fdate, sizeof(fdate) * sizeof(char), - "%m%d:%H%M", ctm); - sprintf(msg, "%s:0:%s:%s", fdate, name, phone); - for(i = 0; i <= nhosts; i++) { - send_dgram(hosts[i], msg); - } - return 0; -} -void send_dgram(char* address, char* datar) -{ - char msg[212]; - int s; - int on = 1; - struct sockaddr_in sin; - if(strlen(address) < 3) return; -#ifdef DEBUG - printf("send_dgram(%s) %p\n", address, address); -#endif - strcpy(msg, datar); - s = socket(PF_INET, SOCK_DGRAM, 0); - bzero(&sin, sizeof sin); - sin.sin_family = AF_INET; - sin.sin_addr.s_addr = inet_addr(address); - sin.sin_port = htons(3890); - if(setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char*) &on, sizeof(on)) < 0) { - perror("setsockopt"); - exit(-1); - } - if (connect(s, (struct sockaddr *)&sin, sizeof sin) < 0) { - perror("connect"); - close(s); - return; - } - write(s, msg, strlen(msg) + 1); - close(s); - return; -} -void load_addrs(const char* fl) -{ - FILE* tfl; - char fbuf[128]; - if(!(tfl = fopen(fl, "r"))) { - perror("fopen"); - exit(-1); - } - while(!feof(tfl)) { - fgets(fbuf, 126, tfl); - if(fbuf[strlen(fbuf)] == '\n') fbuf[strlen(fbuf)] = 0; - if(strlen(fbuf) > 4 && fbuf[0] != '#') strcpy(hosts[nhosts++], fbuf); - memset(fbuf, 0, sizeof fbuf); - } - fclose(tfl); -}