void CalcListID(SpoolControl *sc)
{
+ StrBuf *RoomName;
const char *err;
int fd;
struct CitContext *CCC = CC;
assoc_file_name(filename, sizeof filename, &sc->room, ctdl_info_dir);
fd = open(filename, 0);
- if (fd != 0) {
+ if (fd > 0) {
struct stat stbuf;
if ((fstat(fd, &stbuf) == 0) &&
}
StrBufAppendBufPlain(sc->ListID, HKEY("<"), 0);
+ RoomName = NewStrBufPlain (sc->room.QRname, -1);
+ StrBufAsciify(RoomName, '_');
+ StrBufReplaceChars(RoomName, ' ', '_');
if (StrLength(sc->Users[roommailalias]) > 0)
{
else
{
StrBufAppendBufPlain(sc->ListID, HKEY("room_"), 0);
- StrBufAppendBufPlain(sc->ListID, sc->room.QRname, -1, 0);
+ StrBufAppendBuf(sc->ListID, RoomName, 0);
StrBufAppendBufPlain(sc->ListID, HKEY("."), 0);
StrBufAppendBufPlain(sc->ListID, config.c_fqdn, -1, 0);
/*
{
sc->Users[roommailalias] = NewStrBuf();
- StrBufPrintf(sc->Users[roommailalias],
- "room_%s@%s",
- CCC->room.QRname,
- config.c_fqdn);
+ StrBufAppendBufPlain(sc->Users[roommailalias], HKEY("room_"), 0);
+ StrBufAppendBuf(sc->Users[roommailalias], RoomName, 0);
+ StrBufAppendBufPlain(sc->Users[roommailalias], HKEY("@"), 0);
+ StrBufAppendBufPlain(sc->Users[roommailalias], config.c_fqdn, -1, 0);
- StrBufAsciify(sc->Users[roommailalias], '_');
StrBufLowerCase(sc->Users[roommailalias]);
}
+ FreeStrBuf(&RoomName);
}
*/
void network_process_buffer(char *buffer, long size, HashList *working_ignetcfg, HashList *the_netmap, int *netmap_changed)
{
+ long len;
struct CitContext *CCC = CC;
StrBuf *Buf = NULL;
struct CtdlMessage *msg = NULL;
for (pos = 3; pos < size; ++pos) {
field = buffer[pos];
- msg->cm_fields[field] = strdup(&buffer[pos+1]);
- pos = pos + strlen(&buffer[(int)pos]);
+ len = strlen(buffer + pos + 1);
+ msg->cm_fields[field] = malloc(len + 1);
+ memcpy (msg->cm_fields[field], buffer+ pos + 1, len + 1);
+ pos = pos + len + 1;
}
/* Check for message routing */
- if (msg->cm_fields['D'] != NULL) {
- if (strcasecmp(msg->cm_fields['D'], config.c_nodename)) {
+ if (msg->cm_fields[eDestination] != NULL) {
+ if (strcasecmp(msg->cm_fields[eDestination], config.c_nodename)) {
/* route the message */
- Buf = NewStrBufPlain(msg->cm_fields['D'], -1);
+ Buf = NewStrBufPlain(msg->cm_fields[eDestination], -1);
if (CtdlIsValidNode(&nexthop,
NULL,
Buf,
the_netmap) == 0)
{
/* prepend our node to the path */
- if (msg->cm_fields['P'] != NULL) {
- oldpath = msg->cm_fields['P'];
- msg->cm_fields['P'] = NULL;
+ if (msg->cm_fields[eMessagePath] != NULL) {
+ oldpath = msg->cm_fields[eMessagePath];
+ msg->cm_fields[eMessagePath] = NULL;
}
else {
oldpath = strdup("unknown_user");
}
size = strlen(oldpath) + SIZ;
- msg->cm_fields['P'] = malloc(size);
- snprintf(msg->cm_fields['P'], size, "%s!%s",
+ msg->cm_fields[eMessagePath] = malloc(size);
+ snprintf(msg->cm_fields[eMessagePath], size, "%s!%s",
config.c_nodename, oldpath);
free(oldpath);
}
/* Learn network topology from the path */
- if ((msg->cm_fields['N'] != NULL) && (msg->cm_fields['P'] != NULL)) {
- NetworkLearnTopology(msg->cm_fields['N'],
- msg->cm_fields['P'],
+ if ((msg->cm_fields[eNodeName] != NULL) && (msg->cm_fields[eMessagePath] != NULL)) {
+ NetworkLearnTopology(msg->cm_fields[eNodeName],
+ msg->cm_fields[eMessagePath],
the_netmap,
netmap_changed);
}
/* Is the sending node giving us a very persuasive suggestion about
* which room this message should be saved in? If so, go with that.
*/
- if (msg->cm_fields['C'] != NULL) {
- safestrncpy(target_room, msg->cm_fields['C'], sizeof target_room);
+ if (msg->cm_fields[eRemoteRoom] != NULL) {
+ safestrncpy(target_room, msg->cm_fields[eRemoteRoom], sizeof target_room);
}
/* Otherwise, does it have a recipient? If so, validate it... */
- else if (msg->cm_fields['R'] != NULL) {
- recp = validate_recipients(msg->cm_fields['R'], NULL, 0);
+ else if (msg->cm_fields[eRecipient] != NULL) {
+ recp = validate_recipients(msg->cm_fields[eRecipient], NULL, 0);
if (recp != NULL) if (recp->num_error != 0) {
network_bounce(msg,
"A message you sent could not be delivered due to an invalid address.\n"
}
/* Our last shot at finding a home for this message is to see if
- * it has the O field (Originating room) set.
+ * it has the eOriginalRoom (O) field (Originating room) set.
*/
- else if (msg->cm_fields['O'] != NULL) {
- safestrncpy(target_room, msg->cm_fields['O'], sizeof target_room);
+ else if (msg->cm_fields[eOriginalRoom] != NULL) {
+ safestrncpy(target_room, msg->cm_fields[eOriginalRoom], sizeof target_room);
}
/* Strip out fields that are only relevant during transit */
- if (msg->cm_fields['D'] != NULL) {
- free(msg->cm_fields['D']);
- msg->cm_fields['D'] = NULL;
+ if (msg->cm_fields[eDestination] != NULL) {
+ free(msg->cm_fields[eDestination]);
+ msg->cm_fields[eDestination] = NULL;
}
- if (msg->cm_fields['C'] != NULL) {
- free(msg->cm_fields['C']);
- msg->cm_fields['C'] = NULL;
+ if (msg->cm_fields[eRemoteRoom] != NULL) {
+ free(msg->cm_fields[eRemoteRoom]);
+ msg->cm_fields[eRemoteRoom] = NULL;
}
/* save the message into a room */
do {} while ((FileMoveChunked(&FDIO, &err) > 0) && (err == NULL));
if (err == NULL) {
unlink(filename);
+ QN_syslog(LOG_DEBUG,
+ "Spoolfile %s now "SIZE_T_FMT" k\n",
+ spooloutfilename,
+ (dsize + fsize)/1024
+ );
}
else {
nFailed++;