gi_protocol.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __GI_PROTOCOL_H
00018
#define __GI_PROTOCOL_H
00019
00020
00021
00032
00033
00034
00035
00036
00037
00038
#ifndef LIBGIFTPROTO_EXPORT
00039
# define LIBGIFTPROTO_EXPORT
00040
#endif
00041
00042
#ifndef GIFTD_EXPORT
00043
# define GIFTD_EXPORT
00044
#endif
00045
00046
00047
00048
00049
00050
00051
#ifdef GIFT_PLUGIN
00052
# ifdef _MSC_VER
00053
# define GIFT_PLUGIN_EXPORT __declspec(dllexport)
00054
# else
00055
# define GIFT_PLUGIN_EXPORT
00056
# endif
00057
#endif
00058
00059
00060
00061
struct gi_protocol;
00062
struct gi_file_share;
00063
00064
#include "gi_transfer_api.h"
00065
#include "gi_share_hash.h"
00066
00067
00068
00069
00070
#include "gi_protocol_ver.h"
00071
00072
00073
00078 typedef struct gi_protocol
00079 {
00080
00086 char *
name;
00087 char *
version;
00089 void *
udata;
00097 bool active;
00101 void *
handle;
00107 GiDataset *
hashes;
00125 GiDataset *
features;
00126
00127
00152 bool (*init) (
struct gi_protocol *p);
00153
00154
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00155
# define DBGFN(p,lvl,...) trace(p,GI_TRACE,lvl,__VA_ARGS__)
00156
# define MSGFN(p,lvl,...) trace(p,GI_TRACEL,lvl,__VA_ARGS__)
00157
# define DBGSOCK(p,c,lvl,...) tracesock(p,c,GI_TRACE,lvl,__VA_ARGS__)
00158
# define MSGSOCK(p,c,lvl,...) tracesock(p,c,GI_TRACEL,lvl,__VA_ARGS__)
00159
#elif defined (__GNUC__)
00160
# define DBGFN(p,lvl,fmt...) trace(p,GI_TRACE,lvl,fmt)
00161
# define MSGFN(p,lvl,fmt...) trace(p,GI_TRACEL,lvl,fmt)
00162
# define DBGSOCK(p,c,lvl,fmt...) tracesock(p,c,GI_TRACE,lvl,fmt)
00163
# define MSGSOCK(p,c,lvl,fmt...) tracesock(p,c,GI_TRACEL,lvl,fmt)
00164
#else
00165
# define DBGFN dbg
00166
# define MSGFN dbg
00167
# define DBGSOCK dbgsock
00168
# define MSGSOCK dbgsock
00169
#endif
00170
00175 int (*trace) (
struct gi_protocol *p,
const char *file,
unsigned int line,
00176
const char *funcname,
int level,
const char *fmt, ...)
00177 GI_PRINTF_ATTR (6, 7);
00178
00184 int (*tracesock) (
struct gi_protocol *p, GiTcp *conn,
00185
const char *file,
unsigned int line,
const char *funcname,
00186
int level,
const char *fmt, ...)
00187 GI_PRINTF_ATTR (7, 8);
00188
00194 int (*dbg) (
struct gi_protocol *p,
int level,
const char *fmt, ...)
00195 GI_PRINTF_ATTR (3 ,4);
00196
00200 int (*dbgsock) (
struct gi_protocol *p, GiTcp *conn,
int level,
00201
const char *fmt, ...)
00202 GI_PRINTF_ATTR (4, 5);
00203
00207 int (*warn) (
struct gi_protocol *p,
int level,
const char *fmt, ...)
00208 GI_PRINTF_ATTR (3, 4);
00209
00213 int (*err) (
struct gi_protocol *p,
int level,
const char *fmt, ...)
00214 GI_PRINTF_ATTR (3, 4);
00215
00240 bool (*hash_handler) (
struct gi_protocol *p,
00241
struct gi_hash_handler *handler);
00242
00261 void (*support) (
struct gi_protocol *p,
const char *feature,
bool spt);
00262
00263
#define SHARE_LOOKUP_HASH (1)
00264
#define SHARE_LOOKUP_HPATH (2)
00265
#define SHARE_LOOKUP_PATH (3)
00289
struct gi_file_share* (*share_lookup) (struct gi_protocol *p,
00290
int command, ...);
00291
00292
#define UPLOAD_AUTH_ALLOW (0)
00293
#define UPLOAD_AUTH_STALE (-1)
00294
#define UPLOAD_AUTH_MAX (-2)
00295
#define UPLOAD_AUTH_MAX_PERUSER (-3)
00296
#define UPLOAD_AUTH_NOTSHARED (-4)
00297
#define UPLOAD_AUTH_HIDDEN (-5)
00298
00353 int (*upload_auth) (
struct gi_protocol *p,
const char *user,
00354
struct gi_file_share *share,
upload_auth_t *auth_info);
00355
00400
struct transfer* (*upload_start) (
struct gi_protocol *p,
00401
struct chunk **
chunk,
00402
const char *user,
00403
struct gi_file_share *share,
00404 off_t
start, off_t
stop);
00405
00425 void (*chunk_write) (
struct gi_protocol *p,
00426
struct transfer *transfer,
00427
struct chunk *
chunk,
struct source *
source,
00428
unsigned char *data, size_t len);
00429
00444 void (*source_abort) (
struct gi_protocol *p,
00445
struct transfer *transfer,
struct source *
source);
00446
00460 void (*source_status) (
struct gi_protocol *p,
struct source *
source,
00461
enum source_status klass,
const char *disptxt);
00462
00488 void (*search_result) (
struct gi_protocol *p,
void *event,
00489
const char *user,
const char *node,
00490
const char *href,
unsigned int avail,
00491
struct gi_file_share *file);
00492
00500 void (*search_complete) (
struct gi_protocol *p,
void *event);
00501
00502
#ifdef DEPRECATED
00503
00516 void (*message) (
struct gi_protocol *p,
char *message);
00517
#endif
00518
00519
00538 bool (*start) (
struct gi_protocol *p);
00539
00545 void (*stop) (
struct gi_protocol *p);
00546
00555 void (*destroy) (
struct gi_protocol *p);
00556
00572 bool (*download_start) (
struct gi_protocol *p,
00573
struct transfer *transfer,
00574
struct chunk *
chunk,
struct source *
source);
00575
00596 void (*download_stop) (
struct gi_protocol *p,
00597
struct transfer *transfer,
00598
struct chunk *
chunk,
struct source *
source,
00599
int complete);
00600
00604 void (*upload_stop) (
struct gi_protocol *p,
00605
struct transfer *transfer,
00606
struct chunk *
chunk,
struct source *
source);
00607
00619 void (*upload_avail) (
struct gi_protocol *p,
unsigned long avail);
00620
00637 bool (*chunk_suspend) (
struct gi_protocol *p,
00638
struct transfer *transfer,
00639
struct chunk *
chunk,
struct source *
source);
00640
00644 bool (*chunk_resume) (
struct gi_protocol *p,
00645
struct transfer *transfer,
00646
struct chunk *
chunk,
struct source *
source);
00647
00659 bool (*source_add) (
struct gi_protocol *p,
00660
struct transfer *transfer,
struct source *
source);
00661
00668 void (*source_remove) (
struct gi_protocol *p,
00669
struct transfer *transfer,
struct source *
source);
00670
00695 bool (*search) (
struct gi_protocol *p,
const void *event,
00696
const char *query,
const char *exclude,
const char *realm,
00697 GiDataset *meta);
00698
00714 bool (*browse) (
struct gi_protocol *p,
const void *event,
00715
const char *user,
const char *node);
00716
00732 bool (*locate) (
struct gi_protocol *p,
const void *event,
00733
const char *htype,
const char *hash);
00734
00742 void (*search_cancel) (
struct gi_protocol *p,
void *event);
00743
00752 void (*share_sync_begin) (
struct gi_protocol *p);
00753
00757 void (*share_sync_end) (
struct gi_protocol *p);
00758
00783 void (*share_add) (
struct gi_protocol *p,
struct gi_file_share *file);
00784
00795 void (*share_remove) (
struct gi_protocol *p,
struct gi_file_share *file);
00796
00803 void (*share_hide) (
struct gi_protocol *p);
00804
00808 void (*share_show) (
struct gi_protocol *p);
00809
00827 int (*stats) (
struct gi_protocol *p,
00828
unsigned long *users,
unsigned long *files,
00829
double *size, GiDataset **extra);
00830
00831
00849 int (*source_cmp) (
struct gi_protocol *p,
struct source *a,
struct source *b);
00850
00856 int (*user_cmp) (
struct gi_protocol *p,
const char *a,
const char *b);
00857 }
GiProtocol;
00858
00859
00860
00861 EXTERN_C_BEGIN
00862
00863
00864
00869
#define gi_protocol_compat(p,dev_ver) \
00870
protocol_compat_ex(p,LIBGIFTPROTO_VERSION,dev_ver)
00871
00898 LIBGIFTPROTO_EXPORT
00899
int protocol_compat_ex (
GiProtocol *p, uint32_t link_ver, uint32_t dev_ver);
00900
00901
00902
00903 EXTERN_C_END
00904
00905
00906
00907
#endif
Generated on Sun Aug 22 08:11:13 2004 by
1.3.7