00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef _HP215_H
00043 #define _HP215_H
00044
00045
00046 #define NORMAL_MODE 1
00047 #define PRTCMD_MODE 2
00048 #define TSTDAT_MODE 3
00049
00050
00051 #define DATE 1
00052 #define ASCII 2
00053
00054 #define MAX_ITEMS 200
00055
00056
00057 #define PREVIEW_DIR "preview"
00058 #define FULLSIZE_DIR "fullsize"
00059
00060
00061 #define SUCCESS 0
00062 #define FAIL 1
00063
00064
00065 #define MUST_USE_A_PICTURE_NUMBER 1
00066 #define MUST_NOT_USE_A_PICTURE_NUMBER 2
00067
00068
00069 #define MAX_DS_STRLEN 1000
00070
00071
00072 #define MAX_PICS 1000
00073
00074
00075 #define ACK 0x06
00076
00077 #define HP_VENDOR_ID 0x3f0
00078 #define HP215_ID 0x6202
00079
00080
00081 #define HP_CMD_INIT {0x02, 0xce, 0x80, 0x8a, 0x84, 0x8d, 0x83, 0x03}
00082 #define HP_CMD_DATETIME {0x02, 0xc1, 0x80, 0x8b, 0x84, 0x8e, 0x8d, 0x03}
00083 #define HP_CMD_GET_PHOTO_ALBUM {0x02, 0xc6, 0x88, 0x80, 0x80, 0x83, 0x84, 0x38, 0x2f, 0x30, 0x32, 0x88, 0x84, 0x8e, 0x8b, 0x03}
00084 #define HP_CMD_DELETE_PICS {0x02, 0xb1, 0x84, 0x8f, 0x8f, 0x8f, 0x8f, 0x86, 0x80, 0x8a, 0x86, 0x03}
00085
00086
00087 enum myCodes
00088 {
00089 N_02,
00090 N_03,
00091 N_02_PLUS1,
00092 N_03_PLUS1,
00093
00094 SUM_PICS_02,
00095 SUM_PICS_03,
00096
00097 D_02,
00098
00099 M_LONG,
00100 M_SHORT,
00101 M_02,
00102 M_,
00103
00104 Y_02,
00105 Y_04,
00106
00107 H_02_12,
00108 H_02_24,
00109 H____12,
00110 H____24,
00111 H_AMPM,
00112
00113 K_02,
00114 };
00115
00116
00117
00118 typedef struct
00119 {
00120 unsigned int hour;
00121 unsigned int min;
00122 unsigned int sec;
00123
00124 unsigned int day;
00125 unsigned int month;
00126 unsigned int year;
00127
00128 } t_date;
00129
00130
00131
00132 typedef struct
00133 {
00134 char name [1000];
00135 char name_nsd [1000];
00136
00137 char preview_name [1000];
00138 char preview_name_nsd [1000];
00139
00140
00141 unsigned long int size;
00142 unsigned char *data;
00143 t_date date;
00144 char date_time [20];
00145 } CamFile;
00146
00147
00148 typedef struct
00149 {
00150 struct usb_device *device;
00151 struct usb_dev_handle *dh;
00152 int num_pics;
00153 CamFile *pic[MAX_PICS];
00154 } t_camera;
00155
00156
00157
00158
00159 typedef struct
00160 {
00161
00162 int main;
00163
00164
00165 int dateCam;
00166 int albm;
00167 int datePics;
00168 int prev;
00169 int pics;
00170 int delt;
00171 int html;
00172 int tmp_html;
00173
00174
00175 int tryInitCamTwice;
00176 int forceDeletion;
00177 int picNumbersAll;
00178 int picNumbers;
00179 int picNumber[MAX_PICS];
00180
00181 int picNumbersRL;
00182 int picNumberRL[MAX_PICS];
00183 int picNumbersRR;
00184 int picNumberRR[MAX_PICS];
00185 int picNumbersRH;
00186 int picNumberRH[MAX_PICS];
00187
00188 char subDir[100];
00189 int subDirPrev;
00190 int subDirFull;
00191
00192
00193
00194
00195
00196 int printCmd_cmd;
00197 int printCmd_picNo;
00198
00199 char dateStr[MAX_DS_STRLEN];
00200
00201 int dateInPic;
00202 char dateInPicStr[MAX_DS_STRLEN];
00203 } t_mode;
00204
00205
00206
00207 void dprint (char *);
00208 struct usb_device *
00209 find_device (int, int);
00210 int hp_open (t_camera *, int);
00211 int hp_init_sequence (t_camera *);
00212
00213 int hp_new_file (CamFile **);
00214 int hp_append_file (CamFile *, const unsigned char *, unsigned long int);
00215
00216 int hp_sent_ack (t_camera *, int);
00217 int hp_rcv_ack (t_camera *, int);
00218
00219 int hp_gen_cmd (int, int, unsigned char *);
00220 int hp_get_timeDate_cam (t_camera *);
00221 int hp_get_photo_album (t_camera *);
00222 int hp_get_timeDate_pics(t_camera *, int, int [MAX_PICS], char *, char *, int, int);
00223 int hp_get_previews (t_camera *, int, int [MAX_PICS], char *);
00224 int hp_write_previews (t_camera *, int, int [MAX_PICS]);
00225 int hp_get_write_pics (t_camera *, int, int [MAX_PICS], char *);
00226 int hp_delete_pics (t_camera *, int, int, int[MAX_PICS]);
00227 int hp_delete_all_pics (t_camera *);
00228 int hp_delete_some_pics (t_camera *, int, int[MAX_PICS]);
00229 void hp_create_html_page (t_camera *, int, int[MAX_PICS], char *, int, int, int);
00230
00231 int hp_close (t_camera *);
00232
00233 void read_ini (t_mode *mode);
00234 void read_cmd (int *, char ***, t_mode *);
00235 void usage (void);
00236 void gen_subDirName (char [100]);
00237 void gen_subDir (char [100]);
00238 void read_number (int *, int [1000], char *);
00239 void getDateStr (char *, unsigned int, unsigned int, t_date, char *,
00240 int);
00241 void test_dateString (char *);
00242 void check_dateStr (char *);
00243 void test_cmd (t_mode);
00244 void ini_getNoElements (int *, char *);
00245 void ini_delComment (char *);
00246 void acceptOptions (t_mode *, int *, char **[], int);
00247 void init_modeValues (t_mode *);
00248 void checkPid (void);
00249 void myExit (int, int);
00250 void removeLockFile (void);
00251 void add_dateInsidePicture (char *dateInPicStr,
00252 int picNumbers,
00253 int picNumber[MAX_PICS],
00254 t_camera *myCam);
00255 #endif