diff -urN clussed-19981228/CHANGELOG clussed-19981229/CHANGELOG --- clussed-19981228/CHANGELOG Mon Dec 28 03:36:40 1998 +++ clussed-19981229/CHANGELOG Tue Dec 29 23:12:00 1998 @@ -71,4 +71,18 @@ The PC ^ token parser now ignores the trailing ~ (actually ignores a ~ in the beginning of any field). For clx & dxnet compatibility. +Tue Dec 29 23:11:36 EET 1998 + Added user commands: nroutes unetwork ulist uptime + Fixed bugs in net_nodeadd and net_useradd, returns before calling + link_* if all entries in the given node/user list were discarded as + duplicates or otherwice invalid. + Made ctime_init reset the timezone (TZ environment) to UTC, so that + mktime() and friends behave like everyone else does (and DX spots + can keep their valid timestamps). + Made the key values in nuser and luser data bases null terminated + for the sake of printing them. Remove your old db's. + The new unetwork and ulist commands are good (?) examples of + commands dumping a list of keys in a database, in sorted order. + Expanded frequency field in user_dx() to 10 characters, >9GHz spots. + diff -urN clussed-19981228/Makefile clussed-19981229/Makefile --- clussed-19981228/Makefile Sun Dec 27 21:08:37 1998 +++ clussed-19981229/Makefile Tue Dec 29 21:55:41 1998 @@ -77,7 +77,7 @@ crc.o: crc.h crc.c log.o: log.h log.c cstring.o: cstring.h cstring.c hmalloc.h ctypes.h -ctime.o: ctime.h ctime.c +ctime.o: ctime.h ctime.c timer.h timer.o: timer.h timer.c hmalloc.h hmalloc.o: hmalloc.h hmalloc.c log.h db.o: db.h db.c hmalloc.h log.h @@ -101,9 +101,9 @@ net_user.h f_luser.h timer.h ctime.h cluster.o: cluster.h cluster.c command.h help.h cmd_sys.h cmd_cluster.h \ cmd_net.h cmd_usercfg.h network.h net_ping.h luser.h ctime.h \ - config.h + config.h f_nuser.h f_luser.h command.o: command.h command.c csock.h cfgfile.h -cmd_sys.o: cmd_sys.h cmd_sys.c csock.h version.h hmalloc.h +cmd_sys.o: cmd_sys.h cmd_sys.c csock.h version.h hmalloc.h ctime.h cmd_cluster.o: cmd_cluster.h cmd_cluster.c csock.h hmalloc.h network.h \ cstring.h config.h net_user.h cfgfile.h cmd_net.o: cmd_net.h cmd_net.c csock.h network.h net_user.h ctime.h @@ -127,8 +127,8 @@ f_dx.o: f_dx.h f_dx.c f_ann.o: f_ann.h f_ann.c f_wwv.o: f_wwv.h f_wwv.c -f_luser.o: f_luser.h f_luser.c hmalloc.h log.h db.h config.h cstring.h -f_nuser.o: f_nuser.h f_nuser.c hmalloc.h log.h db.h ctypes.h +f_luser.o: f_luser.h f_luser.c hmalloc.h log.h db.h config.h cstring.h csock.h +f_nuser.o: f_nuser.h f_nuser.c hmalloc.h log.h db.h config.h cstring.h csock.h f_last.o: f_last.h f_last.c f_mid.o: f_mid.h f_mid.c hmalloc.h log.h db.h config.h timer.h Binary files clussed-19981228/base/data/luser.db and clussed-19981229/base/data/luser.db differ Binary files clussed-19981228/base/data/mid.db and clussed-19981229/base/data/mid.db differ Binary files clussed-19981228/base/data/nuser.db and clussed-19981229/base/data/nuser.db differ diff -urN clussed-19981228/base/etc/links.conf clussed-19981229/base/etc/links.conf --- clussed-19981228/base/etc/links.conf Thu Dec 24 19:31:53 1998 +++ clussed-19981229/base/etc/links.conf Tue Dec 29 12:42:13 1998 @@ -7,4 +7,7 @@ protocol pc mode incoming +#link pi5ehv-8 +#protocol pc +#script scripts/pi5ehv.con diff -urN clussed-19981228/base/scripts/pi5ehv.con clussed-19981229/base/scripts/pi5ehv.con --- clussed-19981228/base/scripts/pi5ehv.con Thu Jan 1 02:00:00 1970 +++ clussed-19981229/base/scripts/pi5ehv.con Tue Dec 29 03:01:39 1998 @@ -0,0 +1,21 @@ + +# +# Connection script for Clusse 0.40 +# + +ax25 lo0 oh7lzb-2 + +r "Welcome" +s "telnet soul.pspt.fi" +r "login:" "Unknown" "refused" "out" +s "oh7lzb-1" +r "Password:" +s "matala" +r "Welcome" +s "telnet pi5ehv.ampr.org" +r "login:" +s "oh7lzb-1" +r "FlexNode" +s "dx" +#r "Connected" + Binary files clussed-19981228/base2/data/luser.db and clussed-19981229/base2/data/luser.db differ Binary files clussed-19981228/base2/data/mid.db and clussed-19981229/base2/data/mid.db differ Binary files clussed-19981228/base2/data/nuser.db and clussed-19981229/base2/data/nuser.db differ Binary files clussed-19981228/base3/data/luser.db and clussed-19981229/base3/data/luser.db differ Binary files clussed-19981228/base3/data/mid.db and clussed-19981229/base3/data/mid.db differ Binary files clussed-19981228/base3/data/nuser.db and clussed-19981229/base3/data/nuser.db differ diff -urN clussed-19981228/cluster.c clussed-19981229/cluster.c --- clussed-19981228/cluster.c Sun Dec 27 21:18:28 1998 +++ clussed-19981229/cluster.c Tue Dec 29 21:54:55 1998 @@ -20,6 +20,8 @@ #include "luser.h" #include "ctime.h" #include "config.h" +#include "f_nuser.h" +#include "f_luser.h" /* * Cluster commands @@ -35,6 +37,7 @@ { "messages", cmd_messages }, { "memory", cmd_memory }, { "nodes", cmd_nodes }, + { "nroutes", cmd_nroutes }, { "name", cmd_name }, { "say", cmd_say }, { "shout", cmd_shout }, @@ -42,6 +45,9 @@ { "talk", cmd_talk }, { "treply", cmd_treply }, { "users", cmd_users }, + { "ulist", cmd_ulist }, + { "unetwork", cmd_unetwork }, + { "uptime", cmd_uptime }, { "ping", cmd_ping }, { "pstatus", cmd_pstatus }, { "version", cmd_version }, @@ -114,7 +120,7 @@ char s[sizeof(call_t)+2]; sprintf(s, "%s:", d->fromcall); - send_us(M_DX, "DX de %-10.10s%9.9s %-13.13s%sZ %s", + send_us(M_DX, "DX de %-10.10s%10.10s %-13.13s%sZ %s", s, freq2str(d->freq), d->call, timestr_s(d->time), d->info); } diff -urN clussed-19981228/cmd_net.c clussed-19981229/cmd_net.c --- clussed-19981228/cmd_net.c Sun Dec 27 22:35:46 1998 +++ clussed-19981229/cmd_net.c Tue Dec 29 02:23:12 1998 @@ -69,6 +69,39 @@ } /* + * Node route listing + */ + +int cmd_nroutes(struct csock_t *s, int argc, char **argv) +{ + struct link_t *l; + struct node_t *n; + char st[80]; + int i; + + csprintf(s, "Node routes: %d nodes, %d of %d links up\n", + node_count, link_count, link_max); + for (l = links; (l); l = l->next) { + sprintf(st, "%-9.9s (%d)", l->name, l->routes); + i = 0; + for (n = nodes; (n); n = n->next) + if (n->via == l) { + sprintf(st + strlen(st), " %s", n->call); + i++; + if (strlen(st) > 78 - 12) { + csprintf(s, "%s\n", st); + sprintf(st, " "); + i = 0; + } + } + if (i) + csprintf(s, "%s\n", st); + } + + return 0; +} + +/* * Link listing */ diff -urN clussed-19981228/cmd_net.h clussed-19981229/cmd_net.h --- clussed-19981228/cmd_net.h Thu Dec 24 19:43:07 1998 +++ clussed-19981229/cmd_net.h Tue Dec 29 01:09:35 1998 @@ -5,6 +5,7 @@ #include "csock.h" extern int cmd_nodes(struct csock_t *s, int argc, char **argv); +extern int cmd_nroutes(struct csock_t *s, int argc, char **argv); extern int cmd_links(struct csock_t *s, int argc, char **argv); extern int cmd_users(struct csock_t *s, int argc, char **argv); diff -urN clussed-19981228/cmd_sys.c clussed-19981229/cmd_sys.c --- clussed-19981228/cmd_sys.c Fri Dec 25 22:57:34 1998 +++ clussed-19981229/cmd_sys.c Tue Dec 29 21:55:23 1998 @@ -10,6 +10,7 @@ #include "cstring.h" #include "version.h" #include "hmalloc.h" +#include "ctime.h" /* * @@ -100,6 +101,16 @@ COMPILE_DATETIME, COMPILE_BY, COMPILE_HOST); csprintf(s, "Compiler: %s running on %s (%s)\n", COMPILER, COMPILE_KERNEL, COMPILE_PLATFORM); + return 0; +} + +/* + * Uptime + */ + +int cmd_uptime(struct csock_t *s, int argc, char **argv) +{ + csprintf(s, "Up: %s\n", secs2str_l(uptime())); return 0; } diff -urN clussed-19981228/cmd_sys.h clussed-19981229/cmd_sys.h --- clussed-19981228/cmd_sys.h Sun Dec 20 18:08:27 1998 +++ clussed-19981229/cmd_sys.h Tue Dec 29 21:54:40 1998 @@ -7,5 +7,6 @@ extern int cmd_sockets(struct csock_t *s, int argc, char **argv); extern int cmd_memory(struct csock_t *s, int argc, char **argv); extern int cmd_version(struct csock_t *s, int argc, char **argv); +extern int cmd_uptime(struct csock_t *s, int argc, char **argv); #endif diff -urN clussed-19981228/cstring.c clussed-19981229/cstring.c --- clussed-19981228/cstring.c Sun Dec 27 19:05:03 1998 +++ clussed-19981229/cstring.c Tue Dec 29 03:51:00 1998 @@ -230,6 +230,16 @@ } /* + * strcmp replacement which compares **char instead of *char. + * for qsort use only + */ + +int strpcmp(const char **a, const char **b) +{ + return strcmp(*a, *b); +} + +/* * Return spaces */ diff -urN clussed-19981228/cstring.h clussed-19981229/cstring.h --- clussed-19981228/cstring.h Mon Dec 21 20:52:18 1998 +++ clussed-19981229/cstring.h Tue Dec 29 04:02:04 1998 @@ -51,6 +51,9 @@ /* Safe string copying */ extern char *hstrncpy(char *dest, char *src, int n); /* Safe strncpy */ +/* strcmp for **char, for use with qsort */ +int strpcmp(const char **a, const char **b); + /* String formatting */ extern char *spaces(int n); /* Return N spaces */ extern char *backspaces(int n); /* Backspaces (CTRL-H) */ diff -urN clussed-19981228/ctime.c clussed-19981229/ctime.c --- clussed-19981228/ctime.c Sun Dec 27 20:17:19 1998 +++ clussed-19981229/ctime.c Tue Dec 29 21:52:31 1998 @@ -11,6 +11,7 @@ #include #include "ctime.h" +#include "timer.h" enum dateformat_t dateformat = dmy; char datesep = '.'; @@ -46,6 +47,8 @@ void ctime_init(void) { time(&start_time); + setenv("TZ", "UTC 0", 1); /* Any nicer way to get mktime() */ + tzset(); /* and friends to talk UTC ?? */ } /* @@ -54,7 +57,7 @@ long int uptime(void) { - return (time(NULL) - start_time); + return (now - start_time); } /* diff -urN clussed-19981228/f_luser.c clussed-19981229/f_luser.c --- clussed-19981228/f_luser.c Sun Dec 27 17:40:57 1998 +++ clussed-19981229/f_luser.c Tue Dec 29 04:02:35 1998 @@ -1,10 +1,14 @@ +#include +#include + #include "f_luser.h" #include "hmalloc.h" #include "log.h" #include "db.h" #include "config.h" #include "cstring.h" +#include "csock.h" struct db_t *luser_db = NULL; @@ -22,7 +26,7 @@ truncssid(&tcall); key.dptr = (void *)&tcall; - key.dsize = strlen(tcall); + key.dsize = strlen(tcall) + 1; content = db_fetch(luser_db, key); if (content.dptr) { @@ -51,7 +55,7 @@ truncssid(&tcall); key.dptr = (void *)&tcall; - key.dsize = strlen(tcall); + key.dsize = strlen(tcall) + 1; content.dptr = (void *)fp; content.dsize = sizeof(struct luserf_t); @@ -80,6 +84,63 @@ int close_luserf(void) { db_close(luser_db); + return 0; +} + +/* + * ulist + */ + +int cmd_ulist(struct csock_t *s, int argc, char **argv) +{ + char st[80]; + datum key; + char **l; + int llen = 20; + int lent = 0; + int n, i = 0; + + l = hmalloc(llen * sizeof(char *)); + + csputs(s, "Local user file list:\n"); + + /* Read keys to a array of pointers */ + key = db_firstkey(luser_db); + while (key.dptr) { + key.dptr[key.dsize - 1] = '\0'; /* just to be sure. */ + if (i == llen) + llen += 20; + l = hrealloc(l, llen * sizeof(char *)); + l[i] = key.dptr; + lent++; + i++; + key = db_nextkey(luser_db, key); + } + + /* Sort the array */ + qsort(l, lent, sizeof(char *), (int (*)(const void *, const void *))strpcmp); + + /* Print the array and free the data*/ + st[0] = '\0'; + n = 0; + for (i = 0; i < lent; i++) { + sprintf(st + strlen(st), " %-7.7s", l[i]); + hfree(l[i]); + n++; + if (n == 9) { + csprintf(s, "%s\n", st); + st[0] = '\0'; + n = 0; + } + } + if (n) { + csprintf(s, "%s\n", st); + st[0] = '\0'; + n = 0; + } + + hfree(l); /* free the array too */ + return 0; } diff -urN clussed-19981228/f_luser.h clussed-19981229/f_luser.h --- clussed-19981228/f_luser.h Mon Dec 21 20:53:44 1998 +++ clussed-19981229/f_luser.h Tue Dec 29 03:52:21 1998 @@ -4,9 +4,12 @@ #include "luser.h" -extern struct luserf_t *read_luserf(call_t *call); -extern void write_luserf(struct luserf_t *f); extern int open_luserf(void); extern int close_luserf(void); + +extern struct luserf_t *read_luserf(call_t *call); +extern void write_luserf(struct luserf_t *f); + +extern int cmd_ulist(struct csock_t *s, int argc, char **argv); #endif diff -urN clussed-19981228/f_nuser.c clussed-19981229/f_nuser.c --- clussed-19981228/f_nuser.c Sun Dec 27 17:42:40 1998 +++ clussed-19981229/f_nuser.c Tue Dec 29 04:02:39 1998 @@ -1,10 +1,14 @@ +#include +#include + #include "f_nuser.h" #include "hmalloc.h" #include "log.h" #include "db.h" #include "config.h" #include "cstring.h" +#include "csock.h" struct db_t *nuser_db = NULL; @@ -22,7 +26,7 @@ truncssid(&tcall); key.dptr = (void *)&tcall; - key.dsize = strlen(tcall); + key.dsize = strlen(tcall) + 1; content = db_fetch(nuser_db, key); if (content.dptr) { @@ -51,7 +55,7 @@ truncssid(&tcall); key.dptr = (void *)&tcall; - key.dsize = strlen(tcall); + key.dsize = strlen(tcall) + 1; content.dptr = (void *)fp; content.dsize = sizeof(struct nuserf_t); @@ -164,5 +168,62 @@ strcpy(n->name, fp->name); hfree(fp); +} + +/* + * unetwork + */ + +int cmd_unetwork(struct csock_t *s, int argc, char **argv) +{ + char st[80]; + datum key; + char **l; + int llen = 20; + int lent = 0; + int n, i = 0; + + l = hmalloc(llen * sizeof(char *)); + + csputs(s, "Network user file list:\n"); + + /* Read keys to a array of pointers */ + key = db_firstkey(nuser_db); + while (key.dptr) { + key.dptr[key.dsize - 1] = '\0'; /* just to be sure. */ + if (i == llen) + llen += 20; + l = hrealloc(l, llen * sizeof(char *)); + l[i] = key.dptr; + lent++; + i++; + key = db_nextkey(nuser_db, key); + } + + /* Sort the array */ + qsort(l, lent, sizeof(char *), (int (*)(const void *, const void *))strpcmp); + + /* Print the array and free the data*/ + st[0] = '\0'; + n = 0; + for (i = 0; i < lent; i++) { + sprintf(st + strlen(st), " %-7.7s", l[i]); + hfree(l[i]); + n++; + if (n == 9) { + csprintf(s, "%s\n", st); + st[0] = '\0'; + n = 0; + } + } + if (n) { + csprintf(s, "%s\n", st); + st[0] = '\0'; + n = 0; + } + + hfree(l); /* free the array too */ + + return 0; } diff -urN clussed-19981228/f_nuser.h clussed-19981229/f_nuser.h --- clussed-19981228/f_nuser.h Mon Dec 21 20:55:07 1998 +++ clussed-19981229/f_nuser.h Tue Dec 29 02:52:27 1998 @@ -4,6 +4,7 @@ #include "network.h" #include "ctypes.h" +#include "csock.h" struct nuserf_t { call_t call; @@ -18,13 +19,16 @@ time_t time; }; +extern int open_nuserf(void); +extern int close_nuserf(void); + +extern struct nuserf_t *read_nuserf(call_t *call); +extern void write_nuserf(struct nuserf_t *f); + extern void set_user_data(struct nuser_t *nu, struct link_t* l, call_t *call, int type, char *value); extern void set_homenode(struct nuser_t *n, call_t *call, call_t *node, int q); -extern struct nuserf_t *read_nuserf(call_t *call); -extern void write_nuserf(struct nuserf_t *f); -extern int open_nuserf(void); -extern int close_nuserf(void); +extern int cmd_unetwork(struct csock_t *s, int argc, char **argv); #endif diff -urN clussed-19981228/net_user.c clussed-19981229/net_user.c --- clussed-19981228/net_user.c Sun Dec 27 18:52:24 1998 +++ clussed-19981229/net_user.c Mon Dec 28 23:47:55 1998 @@ -248,6 +248,9 @@ p = next; } + if (!ul) + return; + link_useradd(ul); /* feed links */ /* Insert in user list */ diff -urN clussed-19981228/network.c clussed-19981229/network.c --- clussed-19981228/network.c Mon Dec 28 03:37:49 1998 +++ clussed-19981229/network.c Mon Dec 28 23:48:17 1998 @@ -744,6 +744,9 @@ p = next; } + if (!nl) + return; + link_nodeadd(nl); /* feed links */ /* insert in node list */