1 /* (PD) 2001 The Bitzi Corporation
2  * Please see file COPYING or http://bitzi.com/publicdomain
3  * for more info.
4  *
5  * $Id: bitcollider.h,v 1.14 2003/10/27 03:09:35 gojomo Exp $
6  */
7 #ifndef BITCOLLIDER_H
8 #define BITCOLLIDER_H
9 
10 #ifndef WIN32
11    #include "config.h"
12 #endif
13 #include "cache.h"
14 #include "plugin.h"
15 #include "defs.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #define SUBMIT_URL "http://bitzi.com/lookup/"
22 #define MAX_PLUGINS 256
23 
24 typedef struct _PluginInfo
25 {
26    PluginMethods   *methods;
27    SupportedFormat *formats;
28 #ifdef WIN32
29    HANDLE           handle;
30 #else
31    void            *handle;
32 #endif
33    char            *file;
34 } PluginInfo;
35 
36 typedef struct _Bitcollider
37 {
38     PluginInfo  plugins[MAX_PLUGINS];
39     int         numPluginsLoaded;
40     char       *warning;
41     char       *error;
42     void      (*progressCallback)(int, const char *, const char *);
43     b_bool      preview;
44     b_bool      calculateMD5;
45     b_bool      calculateCRC32;
46     b_bool      exitNow;
47 #if USE_BDB
48     cache_info *cache;
49     int         maxCacheSize;
50 #endif
51 } Bitcollider;
52 
53 typedef struct _BitcolliderSubmission
54 {
55     Bitcollider   *bc;
56     Attribute    **attrList;
57     int            numBitprints;
58     int            numItems;
59     int            numAllocated;
60     char          *fileName;          // The current filename and filesize
61     unsigned long  fileSize;
62     b_bool         autoSubmit;
63     char          *checkAsExt;
64     int            percentComplete;
65 } BitcolliderSubmission;
66 
67 typedef enum
68 {
69    eBrowserNetscape = 0,
70    eBrowserMozilla,
71    eBrowserKonqueror,
72    eBrowserOpera,
73    eBrowserLynx
74 } BrowserEnum;
75 
76 Bitcollider           *bitcollider_init    (b_bool printDebugInfo);
77 void                   bitcollider_shutdown(Bitcollider *bc);
78 
79 char                  *get_error           (Bitcollider *bc);
80 char                  *get_warning         (Bitcollider *bc);
81 void                  set_progress_callback(Bitcollider          *bc,
82                                             void (*progress_func)(int,
83                                                                  const char *,
84                                                                  const char *));
85 void                   set_preview         (Bitcollider          *bc,
86                                             b_bool                enable);
87 void                   set_calculateMD5    (Bitcollider          *bc,
88                                             b_bool                enable);
89 void                   set_calculateCRC32  (Bitcollider          *bc,
90                                             b_bool                enable);
91 void                   set_exit            (Bitcollider          *bc,
92                                             b_bool                enable);
93 void                   clear_bitprint_cache(Bitcollider          *bc);
94 
95 
96 BitcolliderSubmission *create_submission   (Bitcollider *bc);
97 void                   delete_submission   (BitcolliderSubmission *tag);
98 void                   set_auto_submit     (BitcolliderSubmission *tag,
99                                             b_bool                 autoSubmit);
100 void                   set_check_as        (BitcolliderSubmission *tag,
101                                             const char            *extension);
102 b_bool                 analyze_file        (BitcolliderSubmission *tag,
103                                             const char *fileName,
104                                             b_bool      matchingExtsOnly);
105 b_bool                 submit_submission   (BitcolliderSubmission *tag,
106                                             const char *url,
107                                             BrowserEnum browser);
108 BitcolliderSubmission *read_submission_from_file(Bitcollider *bc,
109                                             char *tagFile);
110 int                    get_num_bitprints   (BitcolliderSubmission *sub);
111 void                   print_submission    (BitcolliderSubmission *tag);
112 void                   convert_to_hex      (const unsigned char *buffer,
113                                             int size,
114                                              char *hexBuffer);
115 void                   add_attribute       (BitcolliderSubmission *tag,
116                                             const char *key,
117                                             const char *value);
118 const char            *get_attribute       (BitcolliderSubmission *tag,
119                                             const char *key);
120 void                   get_agent_string    (char *agentString);
121 
122 /* For debugging */
123 void                   set_plugin_debug    (BitcolliderSubmission *tag,
124                                             b_bool                 debug);
125 
126 /* Misc Win32 Support stuff */
127 #ifdef _WIN32
128 void getLongPathName(const char *shortName, int len, char *longName);
129 #endif
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif
136