#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
-#include <malloc.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <alloca.h>
#include <wctype.h>
#include <time.h>
#include <errno.h>
#include "transfer.h"
#include "sysevents.h"
#include "net.h"
-#include "tiger.h"
+#include <tiger.h>
/*
* The Direct Connect protocol is extremely ugly. Thus, this code must
static char *hmlistname = NULL;
static char *xmllistname = NULL;
static char *xmlbz2listname = NULL;
+static struct timer *listwritetimer = NULL;
static void peerconnect(struct socket *sk, int err, struct fnetnode *fn);
static void freedcpeer(struct dcpeer *peer);
static void updatexmllist(void);
static void updatexmlbz2list(void);
static void requestfile(struct dcpeer *peer);
+static void updatelists(int now);
static int reservedchar(unsigned char c)
{
freedcpeer(peer);
return;
}
- qstrf(peer->sk, "$UGetBlock %i %i %s|", peer->transfer->curpos, peer->transfer->size - peer->transfer->curpos, buf);
+ qstrf(peer->sk, "$UGetBlock %zi %zi %s|", peer->transfer->curpos, peer->transfer->size - peer->transfer->curpos, buf);
} else {
/* Use DCCHARSET for $Get paths until further researched... */
if((buf = icswcstombs(peer->transfer->path, DCCHARSET, NULL)) == NULL)
freedcpeer(peer);
return;
}
- qstrf(peer->sk, "$Get %s$%i|", buf, peer->transfer->curpos + 1);
+ qstrf(peer->sk, "$Get %s$%zi|", buf, peer->transfer->curpos + 1);
}
}
} else {
freeargs = 0;
}
- if((newfn = fnetinitconnect(L"dc", args, NULL)) != NULL)
+ if((newfn = fnetinitconnect(L"dc", fn->owner, args, NULL)) != NULL)
{
linkfnetnode(newfn);
putfnetnode(newfn);
if(node->f.b.hastth)
{
buf2 = base32encode(node->hashtth, 24);
- qstrf(dsk, "%s%s\005%i%sTTH:%.39s%s", prefix, buf, node->size, infix, buf2, postfix);
+ qstrf(dsk, "%s%s\005%zi%sTTH:%.39s%s", prefix, buf, node->size, infix, buf2, postfix);
free(buf2);
} else {
- qstrf(dsk, "%s%s\005%i%s%s%s", prefix, buf, node->size, infix, hub->nativename, postfix);
+ qstrf(dsk, "%s%s\005%zi%s%s%s", prefix, buf, node->size, infix, hub->nativename, postfix);
}
free(buf);
}
lesk = wrapsock(fd);
transferprepul(peer->transfer, sb.st_size, offset, -1, lesk);
putsock(lesk);
- qstrf(sk, "$FileLength %i|", peer->transfer->size);
+ qstrf(sk, "$FileLength %zi|", peer->transfer->size);
}
static void cmd_send(struct socket *sk, struct dcpeer *peer, char *cmd, char *args)
return(h1);
break;
case SOP_OR:
- h1 = findsehash(sexpr->l);
- h2 = findsehash(sexpr->r);
+ if((h1 = findsehash(sexpr->l)) == NULL)
+ return(NULL);
+ if((h2 = findsehash(sexpr->r)) == NULL)
+ return(NULL);
if(hashcmp(h1, h2))
return(h1);
break;
if((fn->sk != NULL) && (fn->sk->data == fn))
{
fn->sk->data = NULL;
+ fn->sk->readcb = NULL;
+ fn->sk->errcb = NULL;
putfnetnode(fn);
}
if(hub == NULL)
if(node->f.b.type == FILE_REG)
{
addtobuf(buf, '|');
- sprintf(numbuf, "%i", node->size);
+ sprintf(numbuf, "%zi", node->size);
bufcat(buf, numbuf, strlen(numbuf));
}
addtobuf(buf, 13);
lev++;
continue;
} else {
- fprintf(fs, "<File Name=\"%s\" Size=\"%i\"", namebuf, node->size);
+ fprintf(fs, "<File Name=\"%s\" Size=\"%zi\"", namebuf, node->size);
if(node->f.b.hastth)
{
hashbuf = base32encode(node->hashtth, 24);
fclose(real);
}
-static int shareupdate(unsigned long long uusharesize, void *data)
+static void listtimercb(int cancelled, void *uudata)
+{
+ listwritetimer = NULL;
+ if(!cancelled)
+ updatelists(1);
+}
+
+static void updatelists(int now)
{
+ if((hmlistname == NULL) || (xmllistname == NULL) || (xmlbz2listname == NULL))
+ now = 1;
+ if(!now)
+ {
+ if(listwritetimer == NULL)
+ listwritetimer = timercallback(ntime() + confgetint("cli", "hashwritedelay"), listtimercb, NULL);
+ return;
+ }
+ if(listwritetimer != NULL)
+ canceltimer(listwritetimer);
updatehmlist();
updatexmllist();
updatexmlbz2list();
+}
+
+static int shareupdate(unsigned long long uusharesize, void *data)
+{
+ updatelists(0);
return(0);
}
static struct configvar myvars[] =
{
+ /** Specifies the share description reported to other DC users. */
{CONF_VAR_STRING, "desc", {.str = L""}},
+ /** Specifies the speed reported to other DC users. Normal values
+ * are 28.8Kbps, 33.6Kbps, 56Kbps, Satellite, ISDN, DSL, Cable,
+ * LAN(T1) or LAN(T3)*/
{CONF_VAR_STRING, "speedstring", {.str = L"LAN(T1)"}},
+ /** The e-mail address to report to other DC users. */
{CONF_VAR_STRING, "email", {.str = L"spam@spam.org"}},
+ /** Specifies a specific UDP port to use for DC search results. If
+ * left unspecified, a port is allocated dynamically. Useful for
+ * NAT routers (see also the net.visibleipv4 address for those
+ * cases). */
{CONF_VAR_INT, "udpport", {.num = 0}},
+ /** Specifies a specific TCP port to use for DC peer
+ * connections. If left unspecified, a port is allocated
+ * dynamically. Useful for NAT routers (see also the
+ * net.visibleipv4 address for those cases). */
{CONF_VAR_INT, "tcpport", {.num = 0}},
+ /** If set to true, doldacond will do its best to emulate DC++
+ * (currently v0.674). This should be left off if at all possible,
+ * since turning it on will violate the rules of most hubs and
+ * thus give hub owners an actual reason to kick you if it is
+ * detected. It might be needed for some of the more bone-headed
+ * hub owners, though. Note that DC++ emulation can also be turned
+ * on or off for individual hubs, overriding this setting. */
{CONF_VAR_BOOL, "dcppemu", {.num = 0}},
{CONF_VAR_END}
};