| 1 | /* |
| 2 | * Dolda Connect - Modular multiuser Direct Connect-style client |
| 3 | * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com) |
| 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 _CLIENT_H |
| 20 | #define _CLIENT_H |
| 21 | |
| 22 | #include <sys/types.h> |
| 23 | |
| 24 | #include <utils.h> |
| 25 | |
| 26 | #define FILE_REG 0 |
| 27 | #define FILE_DIR 1 |
| 28 | #define FILE_INT 2 |
| 29 | |
| 30 | #define HASHHASHSIZE 12 |
| 31 | |
| 32 | struct sharepoint |
| 33 | { |
| 34 | struct sharepoint *prev, *next; |
| 35 | char *path; |
| 36 | wchar_t *name; |
| 37 | int delete; |
| 38 | }; |
| 39 | |
| 40 | struct hash |
| 41 | { |
| 42 | wchar_t *algo; |
| 43 | size_t len; |
| 44 | char *buf; |
| 45 | }; |
| 46 | |
| 47 | struct hashcache |
| 48 | { |
| 49 | struct hashcache *next, *prev; |
| 50 | dev_t dev; |
| 51 | ino_t inode; |
| 52 | time_t mtime; |
| 53 | char tth[24]; |
| 54 | }; |
| 55 | |
| 56 | struct sharecache |
| 57 | { |
| 58 | struct sharecache *next, *prev, *child, *parent; |
| 59 | char *path; |
| 60 | wchar_t *name; |
| 61 | size_t size; |
| 62 | time_t mtime; |
| 63 | dev_t dev; |
| 64 | ino_t inode; |
| 65 | char hashtth[24]; |
| 66 | union |
| 67 | { |
| 68 | struct |
| 69 | { |
| 70 | int type:3; |
| 71 | int hastth:1; |
| 72 | int found:1; |
| 73 | } b; |
| 74 | int w; |
| 75 | } f; |
| 76 | CBCHAIN(share_delete, struct sharecache *); |
| 77 | }; |
| 78 | |
| 79 | void clientpreinit(void); |
| 80 | int clientinit(void); |
| 81 | int doscan(int quantum); |
| 82 | int opensharecache(struct sharecache *node); |
| 83 | struct sharecache *findcache(struct sharecache *parent, wchar_t *name); |
| 84 | void queuescan(struct sharecache *node); |
| 85 | char *getfspath(struct sharecache *node); |
| 86 | struct sharecache *nextscnode(struct sharecache *node); |
| 87 | struct hash *newhash(wchar_t *algo, size_t len, char *hash); |
| 88 | void freehash(struct hash *hash); |
| 89 | struct hash *duphash(struct hash *hash); |
| 90 | struct hash *parsehash(wchar_t *text); |
| 91 | wchar_t *unparsehash(struct hash *hash); |
| 92 | |
| 93 | extern struct sharecache *shareroot; |
| 94 | extern unsigned long long sharesize; |
| 95 | EGCBCHAIN(sharechangecb, unsigned long long); |
| 96 | |
| 97 | #endif |