~ubuntu-branches/ubuntu/karmic/gtk-gnutella/karmic

« back to all changes in this revision

Viewing changes to src/share.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Kleineidam
  • Date: 2004-05-22 15:26:55 UTC
  • Revision ID: james.westby@ubuntu.com-20040522152655-lyi6iaswmy4hq4wy
Tags: upstream-0.93.3.0
ImportĀ upstreamĀ versionĀ 0.93.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: share.h,v 1.25 2004/01/01 18:28:24 rmanfredi Exp $
 
3
 *
 
4
 * Copyright (c) 2001-2003, Raphael Manfredi
 
5
 * Copyright (c) 2000 Daniel Walker (dwalker@cats.ucsc.edu)
 
6
 *
 
7
 *----------------------------------------------------------------------
 
8
 * This file is part of gtk-gnutella.
 
9
 *
 
10
 *  gtk-gnutella is free software; you can redistribute it and/or modify
 
11
 *  it under the terms of the GNU General Public License as published by
 
12
 *  the Free Software Foundation; either version 2 of the License, or
 
13
 *  (at your option) any later version.
 
14
 *
 
15
 *  gtk-gnutella is distributed in the hope that it will be useful,
 
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 *  GNU General Public License for more details.
 
19
 *
 
20
 *  You should have received a copy of the GNU General Public License
 
21
 *  along with gtk-gnutella; if not, write to the Free Software
 
22
 *  Foundation, Inc.:
 
23
 *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
24
 *----------------------------------------------------------------------
 
25
 */
 
26
 
 
27
#ifndef _share_h_
 
28
#define _share_h_
 
29
 
 
30
#include "huge.h"
 
31
 
 
32
struct gnutella_node;
 
33
struct query_hashvec;
 
34
struct dl_file_info;
 
35
 
 
36
/* A file extension we have to share */
 
37
struct extension {
 
38
        gchar *str;                     /* Extension string (e.g. "html") */
 
39
        gint len;                       /* Extension length (e.g. 4) */
 
40
};
 
41
 
 
42
typedef struct shared_file {
 
43
        gchar *file_path;               /* The full path of the file */
 
44
        gchar *file_name;               /* Pointer within file_path at start of filename */
 
45
        guint32 file_index;             /* the files index within our local DB */
 
46
        guint32 file_size;              /* File size in Bytes */
 
47
        guint32 flags;                  /* See below for definition */
 
48
        gint file_name_len;
 
49
        time_t mtime;                   /* Last modification time, for SHA1 computation */
 
50
        gchar sha1_digest[SHA1_RAW_SIZE];       /* SHA1 digest, binary form */
 
51
        struct dl_file_info *fi;                        /* PFSP-server: the holding fileinfo */
 
52
} shared_file_t;
 
53
 
 
54
/*
 
55
 * shared_file flags
 
56
 */
 
57
 
 
58
#define SHARE_F_HAS_DIGEST      0x00000001              /* Digest is set */
 
59
#define SHARE_F_RECOMPUTING     0x00000002              /* Digest being recomputed */
 
60
 
 
61
struct gnutella_search_results_out {
 
62
        guchar num_recs;
 
63
        guchar host_port[2];
 
64
        guchar host_ip[4];
 
65
        guchar host_speed[4];
 
66
 
 
67
        /* Last 16 bytes = client_id */
 
68
};
 
69
 
 
70
/*
 
71
 * Global Data
 
72
 */
 
73
 
 
74
extern guint32 files_scanned, bytes_scanned, kbytes_scanned;
 
75
extern GSList *extensions, *shared_dirs;
 
76
 
 
77
/*
 
78
 * Special return value from shared_file() during library rebuild time.
 
79
 * This is needed because we no longer block the GUI whilst scanning.
 
80
 */
 
81
 
 
82
#define SHARE_REBUILDING        ((struct shared_file *) 0x1)
 
83
 
 
84
/*
 
85
 * Global Functions
 
86
 */
 
87
 
 
88
void share_init(void);
 
89
struct shared_file *shared_file(guint idx);
 
90
struct shared_file *shared_file_by_name(const gchar *basename);
 
91
void share_scan(void);
 
92
void share_close(void);
 
93
gboolean search_request(struct gnutella_node *n, struct query_hashvec *qhv);
 
94
void parse_extensions(const gchar *);
 
95
gchar *get_file_path(gint);
 
96
void shared_dirs_update_prop(void);
 
97
gboolean shared_dirs_parse(const gchar *);
 
98
void shared_dir_add(const gchar *);
 
99
gint get_file_size(gint);
 
100
 
 
101
void shared_file_free(shared_file_t *sf);
 
102
 
 
103
void set_sha1(struct shared_file *, const gchar *sha1_digest);
 
104
struct shared_file *shared_file_by_sha1(gchar *sha1_digest);
 
105
gboolean sha1_hash_available(const struct shared_file *);
 
106
gboolean sha1_hash_is_uptodate(struct shared_file *sf);
 
107
gboolean is_latin_locale(void);
 
108
void use_map_on_query(guchar *query, int len);
 
109
 
 
110
#endif /* _share_h_ */