Fixed HTTP-client query-string handling bug.
[doldaconnect.git] / daemon / filenet.h
CommitLineData
d3372da9 1/*
2 * Dolda Connect - Modular multiuser Direct Connect-style client
302a2600 3 * Copyright (C) 2004 Fredrik Tolf <fredrik@dolda2000.com>
d3372da9 4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19#ifndef _FILENET_H
20#define _FILENET_H
21
22#include <wchar.h>
23#include "net.h"
24#include "utils.h"
25#include "search.h"
26
27#define FNN_SYN 0
28#define FNN_HS 1
29#define FNN_EST 2
30#define FNN_DEAD 3
31
fcd0627b 32#define FNNS_PUB 0
33#define FNNS_REG 1
34#define FNNS_OP 2
35
d3372da9 36#define FNPD_INT 0
37#define FNPD_LL 1
38#define FNPD_STR 2
39
40struct fnetnode;
41struct fnetpeer;
42
43struct fnet
44{
45 struct fnet *next;
46 wchar_t *name;
ffa81d5f 47 void (*connect)(struct fnetnode *fn, struct socket *sk);
d3372da9 48 void (*destroy)(struct fnetnode *fn);
ffa81d5f 49 void (*kill)(struct fnetnode *fn);
d3372da9 50 int (*setnick)(struct fnetnode *fn, wchar_t *newnick);
51 int (*reqconn)(struct fnetpeer *peer);
52 int (*sendchat)(struct fnetnode *fn, int public, wchar_t *to, wchar_t *string);
53 int (*search)(struct fnetnode *fn, struct search *srch, struct srchfnnlist *ln);
d3372da9 54};
55
56struct fnetpeerdatum
57{
58 struct fnetpeerdatum *next, *prev;
59 int refcount;
60 wchar_t *id;
61 int datatype;
62};
63
64struct fnetpeerdi
65{
66 struct fnetpeerdatum *datum;
67 union
68 {
69 int num;
70 long long lnum;
71 wchar_t *str;
72 } data;
73};
74
75struct fnetpeer
76{
d3372da9 77 struct fnetnode *fn;
78 wchar_t *id;
79 wchar_t *nick;
80 union
81 {
82 struct
83 {
84 int delete:1;
85 int op:1;
86 } b;
87 int w;
88 } flags;
89 int dinum;
90 struct fnetpeerdi *peerdi;
91};
92
93struct fnetnode
94{
95 struct fnetnode *next, *prev;
96 int refcount;
97 int id;
98 int state;
99 int linked;
fcd0627b 100 int regstatus;
ffa81d5f 101 int connected;
d3372da9 102 time_t srchwait, lastsrch;
d1e8b9fd 103 wchar_t *name, *pubid;
d3372da9 104 wchar_t *mynick;
a3a4a3a7 105 wchar_t *owner;
d3372da9 106 struct fnet *fnet;
d3372da9 107 struct fnetpeerdatum *peerdata;
0e227c1d 108 struct btree *peers;
3ea7528f 109 struct wcspair *args;
110 int numpeers;
111 void *data;
d3372da9 112 CBCHAIN(fnetnode_ac, struct fnetnode *fn, wchar_t *attrib);
113 CBCHAIN(fnetnode_chat, struct fnetnode *fn, int public, wchar_t *name, wchar_t *peer, wchar_t *string);
114 CBCHAIN(fnetnode_unlink, struct fnetnode *fn);
115 CBCHAIN(fnetnode_destroy, struct fnetnode *fn);
61483336 116 CBCHAIN(fnetpeer_new, struct fnetnode *fn, struct fnetpeer *peer);
117 CBCHAIN(fnetpeer_del, struct fnetnode *fn, struct fnetpeer *peer);
118 CBCHAIN(fnetpeer_chdi, struct fnetnode *fn, struct fnetpeer *peer, struct fnetpeerdi *di);
d3372da9 119};
120
121void regfnet(struct fnet *fnet);
122void fnetsetname(struct fnetnode *fn, wchar_t *newname);
123void fnetsetstate(struct fnetnode *fn, int newstate);
124int fnetsetnick(struct fnetnode *fn, wchar_t *newnick);
125struct fnet *findfnet(wchar_t *name);
a3a4a3a7 126struct fnetnode *fnetinitconnect(wchar_t *name, wchar_t *owner, char *addr, struct wcspair *args);
d3372da9 127void linkfnetnode(struct fnetnode *fn);
128void unlinkfnetnode(struct fnetnode *fn);
cab0b442 129void getfnetnode(struct fnetnode *fn);
d3372da9 130void putfnetnode(struct fnetnode *fn);
131void killfnetnode(struct fnetnode *fn);
132struct fnetpeer *fnetaddpeer(struct fnetnode *fn, wchar_t *id, wchar_t *nick);
133void fnetdelpeer(struct fnetpeer *peer);
0e227c1d 134void fnetpeerdm(struct fnetnode *fn);
d3372da9 135struct fnetpeer *fnetfindpeer(struct fnetnode *fn, wchar_t *id);
136void fnetpeersetstr(struct fnetpeer *peer, wchar_t *id, wchar_t *value);
137void fnetpeersetnum(struct fnetpeer *peer, wchar_t *id, int value);
138void fnetpeersetlnum(struct fnetpeer *peer, wchar_t *id, long long value);
139void fnetpeerunset(struct fnetpeer *peer, wchar_t *id);
140struct fnetnode *findfnetnode(int id);
141void fnethandlechat(struct fnetnode *fn, int public, wchar_t *name, wchar_t *peer, wchar_t *chat);
142int fnetsendchat(struct fnetnode *fn, int public, wchar_t *to, wchar_t *string);
143int fnetsearch(struct fnetnode *fn, struct search *srch, struct srchfnnlist *ln);
9c161e77 144wchar_t *fnfilebasename(wchar_t *path);
d3372da9 145
146extern struct fnetnode *fnetnodes;
147EGCBCHAIN(newfncb, struct fnetnode *);
148
149#endif