diff --git a/AUTHORS b/AUTHORS index dce5d09..0741aac 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,8 @@ -* Andrew Williams (nik_doof@users.sourceforge.net) -* Lee Robinson (boxy@users.sourceforge.net) -* Mark Harrison (qwaszx@users.sourceforge.net) +Programmers: + + * Andrew Williams (nik_doof@users.sourceforge.net) + +Testing: + + * Lee Robinson (boxy@users.sourceforge.net) + * Mark Harrison (qwaszx@users.sourceforge.net) diff --git a/ChangeLog b/ChangeLog index d0e6a23..f637021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,3 +6,20 @@ Version 0.02 * New makefile compile/install system * Now uses a config file + +Version 0.02-1 + + * Fatal problems in the packaging, problems with the makefiles + * Few minor bugfixes + +Version 0.03 + + * Error checking code for HTTP returns + * Fixed problem with devcheck() not returning properly on ip changes + total re-write of the checking methods. + * Multiple host support capable of handling upto 10 hosts. + * Various speed improvements and bugfixes. + +Version 0.04 + + * \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index 125454b..5aff916 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,4 @@ EXTRA_DIST = TODO ChangeLog SUBDIRS = src scripts - + +TAR = tar diff --git a/Makefile.in b/Makefile.in index 6a1549d..7e378fe 100644 --- a/Makefile.in +++ b/Makefile.in @@ -64,6 +64,8 @@ VERSION = @VERSION@ EXTRA_DIST = TODO ChangeLog SUBDIRS = src scripts + +TAR = tar ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ./src/config.h @@ -75,7 +77,6 @@ missing mkinstalldirs src/config.h.in src/stamp-h.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = gtar GZIP_ENV = --best all: all-redirect .SUFFIXES: diff --git a/README b/README index 0d7531d..a02fc4d 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -DHSD v0.01 Beta +DHSD v0.03 Beta --------------- DHSD is a dynamic update engine for the dhs.org dynamic dns service. @@ -13,5 +13,8 @@ Thanks go to: * Sourceforge for hosting my project * Dyfet for his pdetach() code - * DFX for his dprintf() code * Peter Mac Millan for his base64.c + * #linpeople on OpenProjects for various linux ioctl help + * #c on efnet for various c coding help + * Boxy & Qwaz for the odd testing and bitching + diff --git a/TODO b/TODO index 747019c..9060d83 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,8 @@ -* Multiple Device/Host config -* Setuid/Setgid for daemon -* More information in Syslog -* .pid file output and more daemon config options -* Error checking on http returns +* Multiple Device/Host config (99%) +* Setuid/Setgid for daemon (needed?) (0%) +* More information in Syslog (50%) +* .pid file output and more daemon config options (0%) +* Error checking on http returns (99%) Possible features: diff --git a/configure b/configure index d007661..5f550d8 100755 --- a/configure +++ b/configure @@ -693,7 +693,7 @@ fi PACKAGE=dhsd -VERSION=0.02 +VERSION=0.03 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff --git a/configure.in b/configure.in index 1d1ef57..2e446fe 100644 --- a/configure.in +++ b/configure.in @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(src/main.c) -AM_INIT_AUTOMAKE(dhsd, 0.02) +AM_INIT_AUTOMAKE(dhsd, 0.03) AC_PROG_MAKE_SET dnl Checks for programs. diff --git a/scripts/Makefile.am b/scripts/Makefile.am index f54a981..135e6c8 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = dhsd dhsd.conf +EXTRA_DIST = dhsd-rh dhsd-deb dhsd.conf sysconfdir = /etc sysconf_DATA = dhsd.conf diff --git a/scripts/Makefile.in b/scripts/Makefile.in index 488dde9..09bc4a3 100644 --- a/scripts/Makefile.in +++ b/scripts/Makefile.in @@ -61,7 +61,7 @@ MAKEINFO = @MAKEINFO@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ -EXTRA_DIST = dhsd dhsd.conf +EXTRA_DIST = dhsd-rh dhsd-deb dhsd.conf sysconfdir = /etc sysconf_DATA = dhsd.conf @@ -75,7 +75,7 @@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = gtar +TAR = tar GZIP_ENV = --best all: all-redirect .SUFFIXES: diff --git a/scripts/dhsd-deb b/scripts/dhsd-deb new file mode 100755 index 0000000..408e5de --- /dev/null +++ b/scripts/dhsd-deb @@ -0,0 +1,23 @@ +#!/bin/sh +# Start/stop the dhsd daemon by Boxy. + +test -f /usr/sbin/dhsd || exit 0 + +case "$1" in +start) echo -n "Starting dhsd ... " + start-stop-daemon --start --quiet --exec /usr/sbin/dhsd + echo "done" + ;; +stop) echo -n "Stopping dhsd ... " + start-stop-daemon --stop --quiet --exec /usr/sbin/dhsd + echo "done" + ;; +restart) echo -n "Re-starting dhsd ... " + start-stop-daemon --stop --quiet --exec /usr/sbin/dhsd + start-stop-daemon --start --quiet --exec /usr/sbin/dhsd + echo "done" + ;; +*) echo "Usage: /etc/init.d/dhsd start|stop|restart"; exit 1 + ;; +esac +exit 0 diff --git a/scripts/dhsd b/scripts/dhsd-rh similarity index 100% rename from scripts/dhsd rename to scripts/dhsd-rh diff --git a/scripts/dhsd.conf b/scripts/dhsd.conf index a9a8012..681035d 100644 --- a/scripts/dhsd.conf +++ b/scripts/dhsd.conf @@ -1,8 +1,9 @@ # DHSD configure script # Please note that CASE MATTERS! -username=usernamehere -passwd=passwdhere -host=hosthere -domain=domainhere -device=ppp0 +USER=usernamehere +PASS=passwdhere +DEV=ppp0 + +HOST=example1.2y.net +HOST=example2.2y.net diff --git a/src/Makefile.am b/src/Makefile.am index eeddd1b..42f535b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,7 +3,7 @@ prefix = /usr EXTRA_DIST = config.h.in stamp-h.in sbin_PROGRAMS = dhsd -dhsd_SOURCES = main.c dhsd.h rconfig.c pdetach.c dprintf.c updateip.c devcheck.c base64.c debug.c +dhsd_SOURCES = main.c dhsd.h rconfig.c pdetach.c updateip.c devcheck.c base64.c debug.c utils.c if DEBUG DBG = -DDEBUG=1 diff --git a/src/Makefile.in b/src/Makefile.in index 0f11885..69fbbbe 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -66,7 +66,7 @@ prefix = /usr EXTRA_DIST = config.h.in stamp-h.in sbin_PROGRAMS = dhsd -dhsd_SOURCES = main.c dhsd.h rconfig.c pdetach.c dprintf.c updateip.c devcheck.c base64.c debug.c +dhsd_SOURCES = main.c dhsd.h rconfig.c pdetach.c updateip.c devcheck.c base64.c debug.c utils.c mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../src/config.h CONFIG_CLEAN_FILES = @@ -77,8 +77,8 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I../src CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ -dhsd_OBJECTS = main.o rconfig.o pdetach.o dprintf.o updateip.o \ -devcheck.o base64.o debug.o +dhsd_OBJECTS = main.o rconfig.o pdetach.o updateip.o devcheck.o \ +base64.o debug.o utils.o dhsd_LDADD = $(LDADD) dhsd_DEPENDENCIES = dhsd_LDFLAGS = @@ -91,7 +91,7 @@ DIST_COMMON = Makefile.am Makefile.in DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) -TAR = gtar +TAR = tar GZIP_ENV = --best SOURCES = $(dhsd_SOURCES) OBJECTS = $(dhsd_OBJECTS) diff --git a/src/base64.c b/src/base64.c index bed251e..e35698b 100644 --- a/src/base64.c +++ b/src/base64.c @@ -49,7 +49,7 @@ void benc( unsigned char *dst, unsigned char *s ) void encbasic( char *d, const char *u, const char *p ) { - char _buf[4*1024]; + char _buf[1024]; sprintf( _buf, "%s:%s", u, p); benc( d, _buf); diff --git a/src/debug.c b/src/debug.c index 891dca9..8288266 100644 --- a/src/debug.c +++ b/src/debug.c @@ -21,22 +21,33 @@ #include "dhsd.h" #include #include +#include void han_segv() { + + /* TODO: add a method of debugging...dunno how! */ + #ifdef HAVE_SYSLOG_H + syslog(LOG_NOTICE,"Segmentation fault...exiting safely..."); closelog(); #endif close(sockfd); pdebug("SegFault in DHSD...exiting safely..."); - //return 1; - exit(0); + + signal(SIGSEGV,SIG_DFL); } void pdebug(char *dmsg) { #ifdef DEBUG - printf("DhsD Debug: %s\n",dmsg); + +#ifndef HAVE_SYSLOG_H +printf("DHSD Debug: %s\n",dmsg); +#else +syslog(LOG_DEBUG,"DHSD Debug: %s",dmsg); +#endif + #endif } diff --git a/src/devcheck.c b/src/devcheck.c index 1ac8b5e..50f2e21 100644 --- a/src/devcheck.c +++ b/src/devcheck.c @@ -32,14 +32,11 @@ int devcheck(char *dev) { int fd; + int strl; struct sockaddr *sa; struct sockaddr_in *sin; struct ifreq ifr; - char *toldaddr; - - toldaddr = oldaddr; - fd = socket(PF_INET,SOCK_STREAM,0); if (fd == -1) { pdebug("socket() failed"); @@ -49,17 +46,19 @@ int devcheck(char *dev) /* Copy the interface name into the buffer */ strncpy(ifr.ifr_name,dev,IFNAMSIZ); - if (ioctl(fd,SIOCGIFADDR,&ifr) == -1) { + if (ioctl(fd,SIOCGIFADDR,&ifr)) { pdebug("device ioctl failed"); - oldaddr = '\0'; // Hackaratus? + //oldaddr = 0; // Hackaratus? return -1; } /* Now the buffer will contain the information we requested */ sa = (struct sockaddr *)&(ifr.ifr_addr); if (sa->sa_family == AF_INET) { sin = (struct sockaddr_in*) sa; - if (inet_ntoa(sin->sin_addr) != toldaddr) { - oldaddr = inet_ntoa(sin->sin_addr); + if (inet_addr(inet_ntoa(sin->sin_addr)) != oldaddr) { + oldaddr = inet_addr(inet_ntoa(sin->sin_addr)); + strl = strlen(inet_ntoa(sin->sin_addr)); + strncpy(coldaddr,inet_ntoa(sin->sin_addr),strl); close(fd); return 1; } else { @@ -67,7 +66,7 @@ int devcheck(char *dev) return 0; } } else { - printf(": Unknown Address Family (%d)\n",sa->sa_family); + pdebug("Unknown Address Family"); } close(fd); diff --git a/src/dhsd.h b/src/dhsd.h index d72667b..7cfc90c 100644 --- a/src/dhsd.h +++ b/src/dhsd.h @@ -25,7 +25,7 @@ #include "config.h" #endif -#define DHSD_CONFIG "/etc/dhsd.conf" +#define DHSD_DEF_CONFIG "/etc/dhsd.conf" #define DHS_IP "209.249.50.99" #define DHS_PORT 80 @@ -40,16 +40,14 @@ // pdetach.c - by dyfet@sourceforge.net void pdetach(void); -// dprintf.c - by dfx@sourceforge.net -void dprintf(int fd, char *format, ...); - // devcheck.c -char *oldaddr; +unsigned long int oldaddr; +char coldaddr[32]; int devcheck(char *dev); // updateip.c int sockfd; -int updateip(char *ipaddr, char *dhsdom, char *dhshost); +int updateip(char *ipaddr, char *host); // debug.c void han_segv(); @@ -59,11 +57,23 @@ void pdebug(char *dmsg); void encbasic( char *d, const char *u, const char *p ); // rconfig.c -char dhs_username[10]; -char dhs_passwd[10]; -char dhs_host[10]; -char dhs_domain[10]; -char conf_dev[10]; +struct cdata config; +char dhsd_config[255]; int rconfig(char *filename); +struct cdata +{ + char username[32]; + char passwd[32]; + char host[10][32]; + char device[10]; + int noofhosts; +}; + +// utils.c +void splitstr(char *src, char delim, char *dest1, char *dest2); + +// UNTESTED BETA +void filtercr(char *str); + #endif diff --git a/src/dprintf.c b/src/dprintf.c deleted file mode 100644 index dc64483..0000000 --- a/src/dprintf.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#include -#include - -#define BUFLEN 4096 - -void dprintf(int fd, char *format, ...) -{ - va_list arglist; - char buffer[BUFLEN]; - - va_start(arglist, format); - vsnprintf(buffer, BUFLEN, format, arglist); - va_end(arglist); - - write(fd, buffer, strlen(buffer)); -} diff --git a/src/main.c b/src/main.c index 7f00f3b..4804143 100644 --- a/src/main.c +++ b/src/main.c @@ -34,58 +34,72 @@ void cleanup() exit(0); } - -int main(void) +void sig_hup() { - int doext; - char verstring[255]; - int res; +#ifdef USE_SYSLOG + syslog(LOG_NOTICE,"HUP recived, reloading config"); +#endif + pdebug("Reloading config"); + if (rconfig(dhsd_config)) { +#ifdef USE_SYSLOG + syslog(LOG_NOTICE,"Config file cant be found, or invalid...exiting"); +#endif + pdebug("Config not found!"); + exit(0); + } +} + +int main(int argc, char **argv) +{ + int i, res, doext; - printf("DhsD %s\n\n",VERSION); - printf("Detaching to daemon...\n"); #ifndef DEBUG pdetach(); + signal(SIGSEGV,han_segv); #endif signal(SIGINT,cleanup); signal(SIGKILL,cleanup); -#ifndef DEBUG - signal(SIGSEGV,han_segv); -#endif + signal(SIGHUP,sig_hup); #ifdef HAVE_SYSLOG_H - verstring[0] = '\0'; openlog("dhsd",LOG_PID,LOG_DAEMON); - sprintf(verstring, "DhsD %s loaded...",VERSION); - syslog(LOG_NOTICE,verstring); + syslog(LOG_NOTICE,"DHSD %s loaded...",VERSION); #endif - res = rconfig(DHSD_CONFIG); - if (res == -1) { + /* Loop here for multiple argvs */ + + if(argv[1]) { + strncpy(dhsd_config,argv[1],strlen(argv[1])); + } else { + strncpy(dhsd_config,DHSD_DEF_CONFIG,strlen(DHSD_DEF_CONFIG)); + } + if (rconfig(dhsd_config)) { #ifdef USE_SYSLOG - syslog(LOG_ERR,"Config file cant be found, or invalid...exiting"); + syslog(LOG_NOTICE,"Config file cant be found, or invalid...exiting"); #endif pdebug("Config not found!"); exit(0); } do { - if (devcheck(conf_dev) == 1) { + if (devcheck(config.device)) { #ifdef HAVE_SYSLOG_H syslog(LOG_NOTICE,"device ip has changed, update initiated..."); #endif + + i = 0; + do { - res = updateip(oldaddr,dhs_domain,dhs_host); - if (res != 0) { + while(updateip(coldaddr,config.host[i])) {; sleep(SLEEP_TIME); - } - } while(res != 0); -#ifdef HAVE_SYSLOG_H - syslog(LOG_NOTICE,"update complete"); -#endif + }; + i++; + } while(i != config.noofhosts); + } doext = 0; sleep(SLEEP_TIME); - } while(doext == 0); + } while(!doext); cleanup(); return 0; diff --git a/src/rconfig.c b/src/rconfig.c index 191f51c..11b3626 100644 --- a/src/rconfig.c +++ b/src/rconfig.c @@ -22,40 +22,47 @@ #include #include #include +#include #include #include "dhsd.h" +void addhost (char *hostname) +{ + strncat(config.host[config.noofhosts], hostname, strlen(hostname)); + pdebug(hostname); + config.noofhosts++; +} + void parseline(char *strbuf) { int strl; int i = 0; - char cmd[10]; - char arg[10]; + char cmd[20]; + char arg[20]; - bzero(cmd,10); - bzero(arg,10); + bzero(cmd,sizeof(cmd)); + bzero(arg,sizeof(arg)); - strl = strlen(strbuf); + //filtercr(strbuf); + strbuf[strlen(strbuf)-1] = '\0'; - if (strl > 0) { - if (strbuf[0] == '#') return; - if (strbuf[0] == '\n') return; - while (i < strl) { - if (strbuf[i] == '=') { - strncpy(cmd, &strbuf[0], i); - strncpy(arg, &strbuf[i+1], strlen(strbuf)-i-1); - cmd[strlen(cmd)] = '\0'; - arg[strlen(arg)-1] = '\0'; - break; - } - i++; - }; + splitstr(strbuf, '=', cmd, arg); - if(strcmp("username",cmd) == 0) { strncat(dhs_username, arg, strlen(arg)); return; } - if(strcmp("passwd",cmd) == 0) { strncat(dhs_passwd, arg, strlen(arg)); return; } - if(strcmp("host",cmd) == 0) { strncat(dhs_host, arg, strlen(arg)); return; } - if(strcmp("domain",cmd) == 0) { strncat(dhs_domain, arg, strlen(arg)); return; } - if(strcmp("device",cmd) == 0) { strncat(conf_dev, arg, strlen(arg)); return; } + if(!strcasecmp("USER",cmd)) { + strncat(config.username, arg, strlen(arg)); + return; + } + if(!strcasecmp("PASS",cmd)) { + strncat(config.passwd, arg, strlen(arg)); + return; + } + if(!strcasecmp("HOST",cmd)) { + addhost(arg); + return; + } + if(!strcasecmp("DEV",cmd)) { + strncat(config.device, arg, strlen(arg)); + return; } } @@ -68,21 +75,21 @@ int rconfig(char *filename) { filefd = fopen(filename,"r"); } else { - filefd = fopen(DHSD_CONFIG,"r"); + filefd = fopen(DHSD_DEF_CONFIG,"r"); } - if (filefd == 0) { + if (!filefd) { return -1; } /* Zero the strings */ - bzero(dhs_username,10); - bzero(dhs_passwd,10); - bzero(dhs_host,10); - bzero(dhs_domain,10); - bzero(conf_dev,4); + bzero(config.username,sizeof(config.username)); + bzero(config.passwd,sizeof(config.passwd)); + bzero(config.host,sizeof(config.host)); + bzero(config.device,sizeof(config.device)); + config.noofhosts = 0; /* Start parsing the file */ - while (fgets(strbuf, 255, filefd)) { + while (fgets(strbuf, 255, filefd) != NULL) { if (strbuf) { parseline(strbuf); } @@ -90,6 +97,11 @@ int rconfig(char *filename) fclose(filefd); - return 0; + if(config.username && config.passwd && config.device && config.noofhosts) { + return 0; + } else { + return -1; + } + } diff --git a/src/updateip.c b/src/updateip.c index bb5e937..217ca93 100644 --- a/src/updateip.c +++ b/src/updateip.c @@ -48,7 +48,7 @@ int sconnect(char *ip) return isock; } -int updateip(char *ipaddr, char *dhsdom, char *dhshost) +int updateip(char *ipaddr, char *host) { char post_data[128]; char post_head[128]; @@ -60,14 +60,23 @@ int updateip(char *ipaddr, char *dhsdom, char *dhshost) char b64str[64]; int ibytes; - encbasic(b64str,dhs_username,dhs_passwd); - sprintf(chostname,"%s.%s",dhshost,dhsdom); + char hostn[32]; + char domn[32]; + + bzero(hostn,32); + bzero(domn,32); + + splitstr(host, '.', hostn, domn); + + encbasic(b64str,config.username,config.passwd); sprintf(auth_head,"Authorization: Basic %s\r\n",b64str); - - sprintf(post_data,"%stype=4&updatetype=Online&hostscmd=edit&hostscmdstage=2&ip=%s&mx=%s&domain=%s&hostname=%s",DHS_ADDR,ipaddr,chostname,dhsdom,dhshost); + + sprintf(post_data,"%stype=4&updatetype=Online&hostscmd=edit&hostscmdstage=2&ip=%s&mx=%s&domain=%s&hostname=%s",DHS_ADDR,ipaddr,host,domn,hostn); sprintf(post_head,"GET %s HTTP/1.0\r\n",post_data); + pdebug(post_head); + sockfd = sconnect(DHS_IP); if (sockfd == -1) { pdebug("sconnect() failed"); @@ -76,8 +85,6 @@ int updateip(char *ipaddr, char *dhsdom, char *dhshost) sprintf(outbuf,"%s%s\r\n\r\n",post_head,auth_head); - //pdebug(outbuf); - send(sockfd,outbuf,strlen(outbuf),0); do { @@ -87,12 +94,34 @@ int updateip(char *ipaddr, char *dhsdom, char *dhshost) strncat(databuf,tmpdatabuf,strlen(tmpdatabuf)); } } while (ibytes > 0); - pdebug(databuf); - fclose(sockfd); + close(sockfd); - /* Some error checking code could be handy... */ + /* Some very basic error checkin */ - return 0; + if(strstr(databuf,"401")) { +#if HAVE_SYSLOG_H + syslog(LOG_NOTICE,"%s: authorization failed",host); +#endif + pdebug("Auth Failed"); + return 0; + } + if (strstr(databuf,"wombat.dhs.org:")) { +#ifdef HAVE_SYSLOG_H + syslog(LOG_NOTICE,"%s: update complete",host); +#endif + return 0; + } + if (strstr(databuf,"The update has already been done previously.")) { +#ifdef HAVE_SYSLOG_H + syslog(LOG_NOTICE,"%s: update already occured",host); +#endif + pdebug("update already occured! returning success..."); + return 0; + } + + /* if all else fails...send a error */ + return -1; } + diff --git a/src/utils.c b/src/utils.c new file mode 100644 index 0000000..377032f --- /dev/null +++ b/src/utils.c @@ -0,0 +1,66 @@ +/* + DHSD utils.c - Utillity code + Copyright (C) 2000 Andrew Williams + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA + +*/ + + +void splitstr(char *src, char delim, char *dest1, char *dest2) +{ + int strl, i; + + i = 0; + strl = strlen(src); + + if (strl > 0) { + while (i < strl) { + if (src[i] == delim) { + strncpy(dest1, &src[0], i); + strncpy(dest2, &src[i+1], strlen(src)-i-1); + dest1[strlen(dest1)] = '\0'; + dest2[strlen(dest2)] = '\0'; + break; + } + i++; + }; + } +} + +void filtercr(char *str) +{ + int i; + int strl; + char tmpstr[256]; + + i = 0; + strl = strlen(str); + bzero(tmpstr,256); + + + if (strl > 0) { + while (i < strl) { + if (str[i] == '\n') { + strncpy(tmpstr, &str[0], i-1); + tmpstr[strlen(tmpstr)] = '\0'; + bzero(str,strl); + str = tmpstr; + } + i++; + }; + } +}