Some debian control files.
[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);
54 wchar_t *(*filebasename)(wchar_t *filename);
55};
56
57struct fnetpeerdatum
58{
59 struct fnetpeerdatum *next, *prev;
60 int refcount;
61 wchar_t *id;
62 int datatype;
63};
64
65struct fnetpeerdi
66{
67 struct fnetpeerdatum *datum;
68 union
69 {
70 int num;
71 long long lnum;
72 wchar_t *str;
73 } data;
74};
75
76struct fnetpeer
77{
78 struct fnetpeer *next, *prev;
79 struct fnetnode *fn;
80 wchar_t *id;
81 wchar_t *nick;
82 union
83 {
84 struct
85 {
86 int delete:1;
87 int op:1;
88 } b;
89 int w;
90 } flags;
91 int dinum;
92 struct fnetpeerdi *peerdi;
93};
94
95struct fnetnode
96{
97 struct fnetnode *next, *prev;
98 int refcount;
99 int id;
100 int state;
101 int linked;
fcd0627b 102 int regstatus;
ffa81d5f 103 int connected;
d3372da9 104 time_t srchwait, lastsrch;
d1e8b9fd 105 wchar_t *name, *pubid;
d3372da9 106 wchar_t *mynick;
a3a4a3a7 107 wchar_t *owner;
d3372da9 108 struct fnet *fnet;
d3372da9 109 struct fnetpeerdatum *peerdata;
110 struct fnetpeer *peers;
3ea7528f 111 struct wcspair *args;
112 int numpeers;
113 void *data;
d3372da9 114 CBCHAIN(fnetnode_ac, struct fnetnode *fn, wchar_t *attrib);
115 CBCHAIN(fnetnode_chat, struct fnetnode *fn, int public, wchar_t *name, wchar_t *peer, wchar_t *string);
116 CBCHAIN(fnetnode_unlink, struct fnetnode *fn);
117 CBCHAIN(fnetnode_destroy, struct fnetnode *fn);
61483336 118 CBCHAIN(fnetpeer_new, struct fnetnode *fn, struct fnetpeer *peer);
119 CBCHAIN(fnetpeer_del, struct fnetnode *fn, struct fnetpeer *peer);
120 CBCHAIN(fnetpeer_chdi, struct fnetnode *fn, struct fnetpeer *peer, struct fnetpeerdi *di);
d3372da9 121};
122
123void regfnet(struct fnet *fnet);
124void fnetsetname(struct fnetnode *fn, wchar_t *newname);
125void fnetsetstate(struct fnetnode *fn, int newstate);
126int fnetsetnick(struct fnetnode *fn, wchar_t *newnick);
127struct fnet *findfnet(wchar_t *name);
a3a4a3a7 128struct fnetnode *fnetinitconnect(wchar_t *name, wchar_t *owner, char *addr, struct wcspair *args);
d3372da9 129void linkfnetnode(struct fnetnode *fn);
130void unlinkfnetnode(struct fnetnode *fn);
cab0b442 131void getfnetnode(struct fnetnode *fn);
d3372da9 132void putfnetnode(struct fnetnode *fn);
133void killfnetnode(struct fnetnode *fn);
134struct fnetpeer *fnetaddpeer(struct fnetnode *fn, wchar_t *id, wchar_t *nick);
135void fnetdelpeer(struct fnetpeer *peer);
136struct fnetpeer *fnetfindpeer(struct fnetnode *fn, wchar_t *id);
137void fnetpeersetstr(struct fnetpeer *peer, wchar_t *id, wchar_t *value);
138void fnetpeersetnum(struct fnetpeer *peer, wchar_t *id, int value);
139void fnetpeersetlnum(struct fnetpeer *peer, wchar_t *id, long long value);
140void fnetpeerunset(struct fnetpeer *peer, wchar_t *id);
141struct fnetnode *findfnetnode(int id);
142void fnethandlechat(struct fnetnode *fn, int public, wchar_t *name, wchar_t *peer, wchar_t *chat);
143int fnetsendchat(struct fnetnode *fn, int public, wchar_t *to, wchar_t *string);
144int fnetsearch(struct fnetnode *fn, struct search *srch, struct srchfnnlist *ln);
145
146extern struct fnetnode *fnetnodes;
147EGCBCHAIN(newfncb, struct fnetnode *);
148
149#endif