From 458f934200d02435ab645dccac477febd560765d Mon Sep 17 00:00:00 2001 From: Lutz Mueller Date: Mon, 27 Aug 2001 22:19:01 +0000 Subject: [PATCH] =?UTF-8?q?2001-08-28=20=20Lutz=20M=EF=BF=BDller=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * camlibs/canon/psa50.c: * camlibs/kodak/dc120/library.c: * camlibs/minolta/dimagev/dimagev.c: * camlibs/panasonic/dc1000.c: * camlibs/panasonic/dc1580.c: * camlibs/sonydscf1/sonydscf1.c: Remove direct accesses to the CameraFile struct. git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2104 67ed7778-7388-44ab-90cf-0a291f65f57c --- ChangeLog | 10 +++++++++ camlibs/canon/psa50.c | 24 +++++++++++++--------- camlibs/kodak/dc120/library.c | 34 ++++++++++++++++++++++--------- camlibs/minolta/dimagev/dimagev.c | 6 ++++-- camlibs/panasonic/dc1000.c | 21 +++++++++++-------- camlibs/panasonic/dc1580.c | 19 ++++++++++------- camlibs/sonydscf1/sonydscf1.c | 13 +++++++----- 7 files changed, 85 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index b6f7a1cf5..c8f9fe061 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-08-28 Lutz Müller + + * camlibs/canon/psa50.c: + * camlibs/kodak/dc120/library.c: + * camlibs/minolta/dimagev/dimagev.c: + * camlibs/panasonic/dc1000.c: + * camlibs/panasonic/dc1580.c: + * camlibs/sonydscf1/sonydscf1.c: Remove direct accesses to the + CameraFile struct. + 2001-08-27 Lutz Müller Patch from Fabrice Bellet : diff --git a/camlibs/canon/psa50.c b/camlibs/canon/psa50.c index 0a25a4bb3..426698896 100644 --- a/camlibs/canon/psa50.c +++ b/camlibs/canon/psa50.c @@ -1851,22 +1851,26 @@ int psa50_put_file_serial(Camera *camera, CameraFile *file, char *destname, char char block_len2[4]; int sent=0; int i,j=0,len, hdr_len; + long int size; + const char *data, *name; cs->uploading = 1; - for(i=0;file->name[i];i++) - filename[i]=toupper(file->name[i]); + gp_file_get_name (file, &name); + for(i=0;name[i];i++) + filename[i]=toupper(name[i]); filename[i]='\0'; - hdr_len = HDR_FIXED_LEN + strlen(file->name) + strlen(destpath); + hdr_len = HDR_FIXED_LEN + strlen(name) + strlen(destpath); gp_frontend_progress(camera, NULL, 0); + gp_file_get_data_and_size (file, &data, &size); - while(sentsize) { + while(sentsize < DATA_BLOCK) - block_len = file->size; - else if ((file->size - sent < DATA_BLOCK)) - block_len = file->size - sent; + if(size < DATA_BLOCK) + block_len = size; + else if ((size - sent < DATA_BLOCK)) + block_len = size - sent; else block_len = DATA_BLOCK; @@ -1878,7 +1882,7 @@ int psa50_put_file_serial(Camera *camera, CameraFile *file, char *destname, char } for(i=0; idata[j]; + buf[i] = data[j]; j++; } @@ -1892,7 +1896,7 @@ int psa50_put_file_serial(Camera *camera, CameraFile *file, char *destname, char return GP_ERROR; } sent += block_len; - gp_frontend_progress(camera, NULL, file->size ? (sent/(float) file->size)*100 : 100); + gp_frontend_progress(camera, NULL, size ? (sent/(float) size)*100 : 100); } cs->uploading = 0; return GP_OK; diff --git a/camlibs/kodak/dc120/library.c b/camlibs/kodak/dc120/library.c index 9c3e12d2a..2c561190d 100644 --- a/camlibs/kodak/dc120/library.c +++ b/camlibs/kodak/dc120/library.c @@ -238,6 +238,8 @@ int dc120_get_albums (DC120Data *dd, int from_card, CameraList *list) { int size = 256; char *f; char *p = dc120_packet_new(0x44); + const char *file_data; + long int file_size; if (from_card) p[1] = 0x01; @@ -248,9 +250,10 @@ int dc120_get_albums (DC120Data *dd, int from_card, CameraList *list) { gp_file_free(file); free (p); } + gp_file_get_data_and_size (file, &file_data, &file_size); for (x=0; x<8; x++) { - f = &file->data[x*15]; + f = (char*)&file_data[x*15]; if (strlen(f)>0) gp_list_append(list, f, NULL); } @@ -268,6 +271,8 @@ int dc120_get_filenames (DC120Data *dd, int from_card, int album_number, CameraL int x=0, size=0; char *p = dc120_packet_new(0x4A); char buf[16]; + const char *file_data; + long int file_size; if (from_card) p[1] = 0x01; @@ -282,9 +287,10 @@ int dc120_get_filenames (DC120Data *dd, int from_card, int album_number, CameraL } /* extract the filenames from the packet data */ + gp_file_get_data_and_size (file, &file_data, &file_size); x=2; while (x < size) { - f=&file->data[x]; + f=(char*) &file_data[x]; strncpy(buf, f, 7); buf[7] = 0; strcat(buf, ".kdc"); @@ -304,6 +310,8 @@ int dc120_get_file_preview (DC120Data *dd, CameraFile *file, int file_number, ch CameraFile *f; int x; char buf[16]; + const char *f_data; + long int f_size; *size = 15680; @@ -316,10 +324,11 @@ int dc120_get_file_preview (DC120Data *dd, CameraFile *file, int file_number, ch /* Convert to PPM file for now */ gp_file_append(file, "P3\n80 60\n255\n", 13); for (x=0; x<14400; x+=3) { + gp_file_get_data_and_size (f, &f_data, &f_size); sprintf(buf, "%i %i %i\n", - (unsigned char)f->data[x+1280], - (unsigned char)f->data[x+1281], - (unsigned char)f->data[x+1282]); + (unsigned char)f_data[x+1280], + (unsigned char)f_data[x+1281], + (unsigned char)f_data[x+1282]); gp_file_append(file, buf, strlen(buf)); } @@ -330,6 +339,8 @@ int dc120_get_file_preview (DC120Data *dd, CameraFile *file, int file_number, ch int dc120_get_file (DC120Data *dd, CameraFile *file, int file_number, char *cmd_packet, int *size) { CameraFile *f; + const char *f_data; + long int f_size; char *p = dc120_packet_new(0x4A); int offset = 2 + (file_number-1) * 20 + 16; @@ -343,10 +354,11 @@ int dc120_get_file (DC120Data *dd, CameraFile *file, int file_number, char *cmd_ gp_file_free(file); return (GP_ERROR); } - *size = (unsigned char)f->data[offset] * 16777216 + - (unsigned char)f->data[offset + 1] * 65536 + - (unsigned char)f->data[offset + 2] * 256 + - (unsigned char)f->data[offset + 3]; + gp_file_get_data_and_size (f, &f_data, &f_size); + *size = (unsigned char)f_data[offset] * 16777216 + + (unsigned char)f_data[offset + 1] * 65536 + + (unsigned char)f_data[offset + 2] * 256 + + (unsigned char)f_data[offset + 3]; if (dc120_packet_read_data(dd, file, cmd_packet, size, 1024)==GP_ERROR) return (GP_ERROR); @@ -440,6 +452,7 @@ int dc120_capture (DC120Data *dd, CameraFile *file) { CameraList *list; char *cmd_packet = dc120_packet_new(0x77); int count; + const char *name; /* Take the picture to Flash memory */ gp_frontend_message (NULL, "Taking picture..."); @@ -454,7 +467,8 @@ int dc120_capture (DC120Data *dd, CameraFile *file) { gp_list_new(&list); dc120_get_filenames (dd, 0, 0, list); count = gp_list_count(list); - gp_list_set_name (list, count - 1, file->name); + gp_file_get_name (file, &name); + gp_list_set_name (list, count - 1, name); /* Download it */ dc120_file_action (dd, DC120_ACTION_IMAGE, 0, 0, count, file); diff --git a/camlibs/minolta/dimagev/dimagev.c b/camlibs/minolta/dimagev/dimagev.c index d0b323559..b6b6ac993 100644 --- a/camlibs/minolta/dimagev/dimagev.c +++ b/camlibs/minolta/dimagev/dimagev.c @@ -238,6 +238,7 @@ int camera_file_get (Camera *camera, const char *folder, const char *filename, { dimagev_t *dimagev; int file_number=0, result; + char buffer[128]; dimagev = camera->camlib_data; @@ -254,10 +255,11 @@ int camera_file_get (Camera *camera, const char *folder, const char *filename, case GP_FILE_TYPE_PREVIEW: gp_file_set_mime_type (file, "image/ppm"); #if defined HAVE_SNPRINTF - snprintf(file->name, sizeof(file->name), DIMAGEV_THUMBNAIL_FMT, ( file_number + 1) ); + snprintf(buffer, sizeof(buffer), DIMAGEV_THUMBNAIL_FMT, ( file_number + 1) ); #else - sprintf(file->name, DIMAGEV_THUMBNAIL_FMT, ( file_number + 1) ); + sprintf(buffer, DIMAGEV_THUMBNAIL_FMT, ( file_number + 1) ); #endif + gp_file_set_name (file, buffer); result = dimagev_get_thumbnail (dimagev, file_number + 1, file); break; default: diff --git a/camlibs/panasonic/dc1000.c b/camlibs/panasonic/dc1000.c index 7c7e19e31..6457d7faa 100644 --- a/camlibs/panasonic/dc1000.c +++ b/camlibs/panasonic/dc1000.c @@ -519,8 +519,12 @@ int camera_folder_put_file (Camera *camera, const char *folder, dsc_t *dsc = (dsc_t *)camera->camlib_data; int blocks, blocksize, i; int result; - - dsc_print_status(camera, _("Uploading image: %s."), file->name); + const char *name; + const char *data; + long int size; + + gp_file_get_name (file, &name); + dsc_print_status(camera, _("Uploading image: %s."), name); /* We can not figure out file type, at least by now. @@ -529,28 +533,29 @@ int camera_folder_put_file (Camera *camera, const char *folder, return GP_ERROR; } */ - if (file->size > DSC_MAXIMAGESIZE) { + gp_file_get_data_and_size (file, &data, &size); + if (size > DSC_MAXIMAGESIZE) { dsc_print_message (camera, _("File size is %i bytes. " "The size of the largest file possible to " - "upload is: %i bytes."), file->size, + "upload is: %i bytes."), size, DSC_MAXIMAGESIZE); return GP_ERROR; } - result = dsc1_setimageres (dsc, file->size); + result = dsc1_setimageres (dsc, size); if (result != GP_OK) return (result); gp_frontend_progress(camera, file, 0.00); - blocks = (file->size - 1)/DSC_BLOCKSIZE + 1; + blocks = (size - 1)/DSC_BLOCKSIZE + 1; for (i = 0; i < blocks; i++) { - blocksize = file->size - i*DSC_BLOCKSIZE; + blocksize = size - i*DSC_BLOCKSIZE; if (DSC_BLOCKSIZE < blocksize) blocksize = DSC_BLOCKSIZE; result = dsc1_writeimageblock (dsc, i, - &file->data[i*DSC_BLOCKSIZE], + (char*)&data[i*DSC_BLOCKSIZE], blocksize); if (result != GP_OK) return (result); diff --git a/camlibs/panasonic/dc1580.c b/camlibs/panasonic/dc1580.c index 0f32438b6..4d4450f3e 100644 --- a/camlibs/panasonic/dc1580.c +++ b/camlibs/panasonic/dc1580.c @@ -622,8 +622,12 @@ int camera_folder_put_file (Camera *camera, const char *folder, { dsc_t *dsc = (dsc_t *)camera->camlib_data; int blocks, blocksize, i, result; + const char *name; + const char *data; + long int size; - dsc_print_status(camera, _("Uploading image: %s."), file->name); + gp_file_get_name (file, &name); + dsc_print_status(camera, _("Uploading image: %s."), name); /* We can not figure out file type, at least by now. @@ -632,28 +636,29 @@ int camera_folder_put_file (Camera *camera, const char *folder, return GP_ERROR; } */ - if (file->size > DSC_MAXIMAGESIZE) { + gp_file_get_data_and_size (file, &data, &size); + if (size > DSC_MAXIMAGESIZE) { dsc_print_message (camera, _("File size is %i bytes. " "The size of the largest file possible to " - "upload is: %i bytes."), file->size, + "upload is: %i bytes."), size, DSC_MAXIMAGESIZE); return GP_ERROR; } - result = dsc2_setimagesize (dsc, file->size); + result = dsc2_setimagesize (dsc, size); if (result != GP_OK) return (result); gp_frontend_progress (camera, file, 0.00); - blocks = (file->size - 1)/DSC_BLOCKSIZE + 1; + blocks = (size - 1)/DSC_BLOCKSIZE + 1; for (i = 0; i < blocks; i++) { - blocksize = file->size - i*DSC_BLOCKSIZE; + blocksize = size - i*DSC_BLOCKSIZE; if (DSC_BLOCKSIZE < blocksize) blocksize = DSC_BLOCKSIZE; result = dsc2_writeimageblock (dsc, i, - &file->data[i*DSC_BLOCKSIZE], + (char*)&data[i*DSC_BLOCKSIZE], blocksize); if (result != GP_OK) return (result); diff --git a/camlibs/sonydscf1/sonydscf1.c b/camlibs/sonydscf1/sonydscf1.c index 0df6b5679..3d1084db7 100644 --- a/camlibs/sonydscf1/sonydscf1.c +++ b/camlibs/sonydscf1/sonydscf1.c @@ -144,7 +144,9 @@ int camera_file_count (Camera *camera) int camera_file_get (Camera *camera, const char *folder, const char *filename, CameraFileType type, CameraFile *file) { - int size, num; + int num; + long int size; + const char *data = NULL; SonyStruct *b = (SonyStruct*)camera->camlib_data; printf("folder: %s, file: %s\n", folder, filename); /*gp_frontend_progress(camera, NULL, 0.00);*/ @@ -159,20 +161,21 @@ int camera_file_get (Camera *camera, const char *folder, const char *filename, switch (type) { case GP_FILE_TYPE_NORMAL: - size = get_picture (num, &file->data, JPEG, 0, + size = get_picture (num, &data, JPEG, 0, camera_file_count (camera)); break; case GP_FILE_TYPE_PREVIEW: - size = get_picture (num, &file->data, JPEG_T, TRUE, + size = get_picture (num, &data, JPEG_T, TRUE, camera_file_count (camera)); break; default: return (GP_ERROR_NOT_SUPPORTED); } - if (!file->data) + if (!data) return GP_ERROR; - file->size = size; + + gp_file_set_data_and_size (file, data, size); return GP_OK; }