From 71bdc5c08daec97443a0e192bfe35e1cd6b25621 Mon Sep 17 00:00:00 2001 From: stskeeps Date: Thu, 26 Oct 2000 17:09:35 +0000 Subject: [PATCH] +- Added protoctl SJB64, which adds B64-9 timestamps to many timestamping + operations +- Added ircsprintf %B (base64-9^10) with ! as prefix, and %b (no prefix) --- Changes | 3 +++ include/common.h | 12 +++++++++++- include/struct.h | 1 + src/aln.c | 21 +++++++++++++++++++++ src/channel.c | 21 +++++++++++++-------- src/ircsprintf.c | 23 +++++++++++++++++++++++ src/s_serv.c | 28 +++++++++++++++++++++++++--- src/s_user.c | 5 ++++- 8 files changed, 101 insertions(+), 13 deletions(-) diff --git a/Changes b/Changes index 418652bae..562d7e450 100644 --- a/Changes +++ b/Changes @@ -647,3 +647,6 @@ - Changed Cannot find server message to be to sendto_realops - Fixed a warning in CENSOR_QUIT - Fixed the G:Line user wrongly matching (ip-alike addys didnt check user) +- Added protoctl SJB64, which adds B64-9 timestamps to many timestamping + operations +- Added ircsprintf %B (base64-9^10) with ! as prefix, and %b (no prefix) diff --git a/include/common.h b/include/common.h index 9bfb704a1..eab4aa160 100644 --- a/include/common.h +++ b/include/common.h @@ -246,7 +246,17 @@ extern struct SLink *find_user_link( /* struct SLink *, struct Client * */ ); "(ohv)@%+" /* Server-Server PROTOCTL -Stskeeps */ -#define PROTOCTL_SERVER "NOQUIT TOKEN NICKv2 SJOIN SJOIN2 UMODE2 VL SJ3 NS" ZIPSTUFF +#define PROTOCTL_SERVER "NOQUIT" \ + " TOKEN" \ + " NICKv2" \ + " SJOIN" \ + " SJOIN2" \ + " UMODE2" \ + " VL" \ + " SJ3" \ + " NS" \ + " SJB64" \ + ZIPSTUFF #ifdef _WIN32 /* diff --git a/include/struct.h b/include/struct.h index 013f0af55..207b97940 100644 --- a/include/struct.h +++ b/include/struct.h @@ -286,6 +286,7 @@ typedef unsigned int u_int32_t; /* XXX Hope this works! */ #define PROTO_SJ3 0x200 /* Negotiated SJ3 protocol */ #define PROTO_VHP 0x400 /* Send hostnames in NICKv2 even if not sethosted */ +#define PROTO_SJB64 0x800 /* * flags macros. */ diff --git a/src/aln.c b/src/aln.c index e06f629f6..44604dcef 100644 --- a/src/aln.c +++ b/src/aln.c @@ -63,6 +63,13 @@ char *base64enc(unsigned long i) return int_to_base64(i); } +char *xbase64enc(unsigned long i) +{ + if (i > 1000) + i = i - 900000000; + return int_to_base64(i); +} + unsigned long base64dec(char *b64) { if (b64) @@ -71,6 +78,20 @@ unsigned long base64dec(char *b64) return 0; } +unsigned long xbase64dec(char *b64) +{ + unsigned long r; + if (b64) + { + r = base64_to_int(b64); + if (r > 1000) + r = r - 900000000; + return r; + } + else + return 0; +} + int numeric_collides(unsigned long numeric) { Link *lp; diff --git a/src/channel.c b/src/channel.c index 203dc56c6..aed9b2679 100644 --- a/src/channel.c +++ b/src/channel.c @@ -3422,8 +3422,8 @@ int m_topic(cptr, sptr, parc, parv) { if (!MyClient(sptr) && !IsULine(cptr, sptr)) { - sendto_realops - ("Remote TOPIC for unknown channel %s (%s)", + sendto_umode + (UMODE_JUNK,"Remote TOPIC for unknown channel %s (%s)", parv[1], backupbuf); } sendto_one(sptr, rpl_str(ERR_NOSUCHCHANNEL), @@ -3444,7 +3444,7 @@ int m_topic(cptr, sptr, parc, parv) if (parc > 4) { tnick = parv[2]; - ttime = atol(parv[3]); + ttime = (*parv[3] == '!' ? xbase64dec(parv[3] + 1) : atol(parv[3])); topic = parv[4]; } @@ -4523,8 +4523,10 @@ int m_sjoin(cptr, sptr, parc, parv) } chptr = get_channel(cptr, parv[2], CREATE); - ts = atol(parv[1]); - + if (*parv[1] != '!') + ts = atol(parv[1]); + else + ts = xbase64dec(parv[1] + 1); if (chptr->creationtime > ts) { removeours = 1; @@ -5366,20 +5368,23 @@ void send_channel_modes_sjoin3(cptr, chptr) if (nomode && nopara) { - ircsprintf(buf, "%s %ld %s :", + ircsprintf(buf, + (cptr->proto & PROTO_SJB64 ? "%s %B %s :" : "%s %ld %s :"), (IsToken(cptr) ? TOK_SJOIN : MSG_SJOIN), chptr->creationtime, chptr->chname); } if (nopara && !nomode) { - ircsprintf(buf, "%s %ld %s %s :", + ircsprintf(buf, + (cptr->proto & PROTO_SJB64 ? "%s %B %s %s :" : "%s %ld %s %s :"), (IsToken(cptr) ? TOK_SJOIN : MSG_SJOIN), chptr->creationtime, chptr->chname, modebuf); } if (!nopara && !nomode) { - ircsprintf(buf, "%s %ld %s %s %s :", + ircsprintf(buf, + (cptr->proto & PROTO_SJB64 ? "%s %B %s %s %s :" : "%s %ld %s %s %s :"), (IsToken(cptr) ? TOK_SJOIN : MSG_SJOIN), chptr->creationtime, chptr->chname, modebuf, parabuf); } diff --git a/src/ircsprintf.c b/src/ircsprintf.c index e560f4fa4..e705a1c3f 100644 --- a/src/ircsprintf.c +++ b/src/ircsprintf.c @@ -290,6 +290,7 @@ char *ircvsprintf(char *str, const char *format, va_list vl) while ((*++str = *++p1)); continue; } + if (c == 'l' && *format == 'u') /* Prints time_t value in interval [ 100000000 , 4294967295 ] Actually prints like "%09lu" */ @@ -364,6 +365,28 @@ char *ircvsprintf(char *str, const char *format, va_list vl) continue; } #endif + /* Send base64 value */ + if (c == 'b') + { + unsigned long v1; + char *ap; + + v1 = va_arg(vl, unsigned long); + for (ap = (char *) xbase64enc(v1); *ap; ap++) + *str++ = *ap; + continue; + } + if (c == 'B') + { + unsigned long v1; + char *ap; + + v1 = va_arg(vl, unsigned long); + *str++ = '!'; + for (ap = (char *) xbase64enc(v1); *ap; ap++) + *str++ = *ap; + continue; + } if (c == 'd') { unsigned int v1, v2; diff --git a/src/s_serv.c b/src/s_serv.c index 4717d4148..6eed2c619 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -544,6 +544,20 @@ int m_protoctl(cptr, sptr, parc, parv) proto, cptr->name)); SetSJ3(cptr); } + else if (strcmp(s, "SJB64") == 0) + { +#ifndef PROTOCTL_MADNESS + if (remove) + { + cptr->proto &=~ PROTO_SJB64; + continue; + } +#endif + Debug((DEBUG_ERROR, + "Chose protocol %s for link %s", + proto, cptr->name)); + cptr->proto |= PROTO_SJB64; + } /* * Add other protocol extensions here, with proto * containing the base option, and options containing @@ -1305,7 +1319,8 @@ int m_server_estab(cptr) if (!SupportNICKv2(cptr)) { - sendto_one(cptr, "%s %s %d %d %s %s %s %lu :%s", + sendto_one(cptr, + "%s %s %d %d %s %s %s %lu :%s", (IsToken(cptr) ? TOK_NICK : MSG_NICK), acptr->name, acptr->hopcount + 1, acptr->lastnick, acptr->user->username, @@ -1328,7 +1343,10 @@ int m_server_estab(cptr) send_umode(NULL, acptr, 0, SEND_UMODES, buf); if (!SupportVHP(cptr)) sendto_one(cptr, - "%s %s %d %d %s %s %s %lu %s %s :%s", + (cptr->proto & PROTO_SJB64 ? + "%s %s %d %B %s %s %s %lu %s %s :%s" + : + "%s %s %d %d %s %s %s %lu %s %s :%s"), (IsToken(cptr) ? TOK_NICK : MSG_NICK), acptr->name, acptr->hopcount + 1, @@ -1396,7 +1414,11 @@ int m_server_estab(cptr) else send_channel_modes_sjoin3(cptr, chptr); if (chptr->topic_time) - sendto_one(cptr, "%s %s %s %lu :%s", + sendto_one(cptr, + (cptr->proto & PROTO_SJB64 ? + "%s %s %s %B :%s" + : + "%s %s %s %lu :%s"), (IsToken(cptr) ? TOK_TOPIC : MSG_TOPIC), chptr->chname, chptr->topic_nick, chptr->topic_time, chptr->topic); diff --git a/src/s_user.c b/src/s_user.c index a8dbaa1c0..7a277d1ea 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -1358,7 +1358,10 @@ int m_nick(cptr, sptr, parc, parv) */ if (parc > 3) { - lastnick = atoi(parv[3]); + if (*parv[3] != '!') + lastnick = atoi(parv[3]); + else + lastnick = xbase64dec(parv[3] + 1); if (parc > 5) differ = (mycmp(acptr->user->username, parv[4]) || mycmp(acptr->user->realhost, parv[5]));