2001-08-24 Lutz M�ller <urc8@rz.uni-karlsruhe.de>
* camlibs/agfa-cl18/agfa.c: Use gp_file_* instead of directly
accessing the struct.
* camlibs/barbie/barbie.c: And here.
* camlibs/directory/directory.c: And here.
* camlibs/konica/library.c: And here.
* camlibs/sierra/sierra.c: And here.
* camlibs/panasonic/l859/l859.c: And here.
* camlibs/dimera/dimera3500.c: And here.
* frontends/command-line/main.c: And here.
* libgphoto2/camera.c: And here.
* libgphoto2/file.c:
* include/gphoto2-file.h: Introduce some more gp_file_* functions.
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@2059 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
||||
2001-08-24 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* camlibs/agfa-cl18/agfa.c: Use gp_file_* instead of directly
|
||||
accessing the struct.
|
||||
* camlibs/barbie/barbie.c: And here.
|
||||
* camlibs/directory/directory.c: And here.
|
||||
* camlibs/konica/library.c: And here.
|
||||
* camlibs/sierra/sierra.c: And here.
|
||||
* camlibs/panasonic/l859/l859.c: And here.
|
||||
* camlibs/dimera/dimera3500.c: And here.
|
||||
* frontends/command-line/main.c: And here.
|
||||
* libgphoto2/camera.c: And here.
|
||||
* libgphoto2/file.c:
|
||||
* include/gphoto2-file.h: Introduce some more gp_file_* functions.
|
||||
|
||||
2001-08-24 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
|
||||
* include/gphoto2-file.h: Make gp_file_new return an error code.
|
||||
|
||||
@@ -240,21 +240,19 @@ int camera_file_get (Camera *camera, const char *folder, const char *filename,
|
||||
|
||||
struct agfa_device *dev = camera->camlib_data;
|
||||
unsigned char *data;
|
||||
int buflen;
|
||||
int size;
|
||||
|
||||
if (!dev) return GP_ERROR;
|
||||
|
||||
if (folder[0] == '/') folder++;
|
||||
|
||||
data = agfa_file_get(camera, folder, filename, 0, &buflen);
|
||||
data = agfa_file_get(camera, folder, filename, 0, &size);
|
||||
|
||||
if (!data) return GP_ERROR;
|
||||
|
||||
file->data = data;
|
||||
file->size = buflen;
|
||||
|
||||
strcpy(file->name, filename);
|
||||
strcpy(file->type, "image/jpeg");
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
gp_file_set_name (file, filename);
|
||||
gp_file_set_type (file, "image/jpeg");
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
@@ -274,12 +272,10 @@ int camera_file_get_preview (Camera *camera, const char *folder,
|
||||
data = agfa_file_get(camera, folder, filename, 1, &size);
|
||||
|
||||
if (!data) return GP_ERROR;
|
||||
|
||||
file->data = data;
|
||||
file->size = size;
|
||||
|
||||
strcpy(file->type, "image/jpeg");
|
||||
strcpy(file->name, filename);
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
gp_file_set_type (file, "image/jpeg");
|
||||
gp_file_set_name (file, filename);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
@@ -151,19 +151,20 @@ int camera_file_get (Camera *camera, const char *folder, const char *filename,
|
||||
|
||||
int size, num;
|
||||
BarbieStruct *b = (BarbieStruct*)camera->camlib_data;
|
||||
char *data;
|
||||
|
||||
gp_frontend_progress(camera, NULL, 0.00);
|
||||
|
||||
strcpy(file->name, filename);
|
||||
strcpy(file->type, "image/ppm");
|
||||
gp_file_set_name (file, filename);
|
||||
gp_file_set_type (file, "image/ppm");
|
||||
|
||||
/* Retrieve the number of the photo on the camera */
|
||||
num = gp_filesystem_number(b->fs, "/", filename);
|
||||
|
||||
file->data = barbie_read_picture(b, num, 0, &size);
|
||||
if (!file->data)
|
||||
data = barbie_read_picture(b, num, 0, &size);
|
||||
if (!data)
|
||||
return GP_ERROR;
|
||||
file->size = size;
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
@@ -174,19 +175,20 @@ int camera_file_get_preview (Camera *camera, const char *folder,
|
||||
|
||||
int size, num;
|
||||
BarbieStruct *b = (BarbieStruct*)camera->camlib_data;
|
||||
char *data;
|
||||
|
||||
gp_frontend_progress(camera, NULL, 0.00);
|
||||
|
||||
strcpy(file->name, filename);
|
||||
strcpy(file->type, "image/ppm");
|
||||
gp_file_set_name (file, filename);
|
||||
gp_file_set_type (file, "image/ppm");
|
||||
|
||||
/* Retrieve the number of the photo on the camera */
|
||||
num = gp_filesystem_number(b->fs, "/", filename);
|
||||
|
||||
file->data = barbie_read_picture(b, num, 1, &size);;
|
||||
if (!file->data)
|
||||
data = barbie_read_picture(b, num, 1, &size);;
|
||||
if (!data)
|
||||
return GP_ERROR;
|
||||
file->size = size;
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,22 @@
|
||||
*
|
||||
* History:
|
||||
* $Log$
|
||||
* Revision 1.7 2001/08/23 12:02:20 lutz
|
||||
* 2001-08-24 Lutz Müller <urc8@rz.uni-karlsruhe.de>
|
||||
*
|
||||
* * camlibs/agfa-cl18/agfa.c: Use gp_file_* instead of directly
|
||||
* accessing the struct.
|
||||
* * camlibs/barbie/barbie.c: And here.
|
||||
* * camlibs/directory/directory.c: And here.
|
||||
* * camlibs/konica/library.c: And here.
|
||||
* * camlibs/sierra/sierra.c: And here.
|
||||
* * camlibs/panasonic/l859/l859.c: And here.
|
||||
* * camlibs/dimera/dimera3500.c: And here.
|
||||
* * frontends/command-line/main.c: And here.
|
||||
* * libgphoto2/camera.c: And here.
|
||||
* * libgphoto2/file.c:
|
||||
* * include/gphoto2-file.h: Introduce some more gp_file_* functions.
|
||||
*
|
||||
* Revision 1.6 2001/08/22 20:59:57 hfiguiere
|
||||
* * camlibs/dimera/dimera3500.c: removed * / * embedded inside comments
|
||||
* that issued warnings and broke the build...
|
||||
@@ -305,13 +321,15 @@ int camera_folder_list_files(Camera *camera, const char *folder, CameraList *lis
|
||||
|
||||
int camera_file_get (Camera *camera, const char *folder, const char *filename, CameraFile *file) {
|
||||
|
||||
int size, num;
|
||||
int num;
|
||||
DimeraStruct *cam = (DimeraStruct*)camera->camlib_data;
|
||||
char *data;
|
||||
long int size;
|
||||
|
||||
gp_frontend_progress(camera, NULL, 0.00);
|
||||
|
||||
strcpy(file->name, filename);
|
||||
strcpy(file->type, PNM_MIME_TYPE);
|
||||
gp_file_set_name (file, filename);
|
||||
gp_file_set_type (file, PNM_MIME_TYPE);
|
||||
|
||||
/* Retrieve the number of the photo on the camera */
|
||||
if (strcmp(filename, RAM_IMAGE_TEMPLATE) == 0)
|
||||
@@ -323,10 +341,10 @@ int camera_file_get (Camera *camera, const char *folder, const char *filename, C
|
||||
if (num < 0)
|
||||
return num;
|
||||
|
||||
file->data = Dimera_Get_Full_Image(num, &size, camera);
|
||||
if (!file->data)
|
||||
data = Dimera_Get_Full_Image(num, (int*) &size, camera);
|
||||
if (!data)
|
||||
return GP_ERROR;
|
||||
file->size = size;
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
@@ -376,20 +394,22 @@ int camera_file_set_info (Camera *camera, const char *folder, const char *filena
|
||||
|
||||
int camera_file_get_preview (Camera *camera, const char *folder, const char *filename, CameraFile *file) {
|
||||
DimeraStruct *cam = (DimeraStruct*)camera->camlib_data;
|
||||
int size, num;
|
||||
int num;
|
||||
long int size;
|
||||
char *data;
|
||||
|
||||
/* Retrieve the number of the photo on the camera */
|
||||
num = gp_filesystem_number(cam->fs, "/", filename);
|
||||
if (num < 0)
|
||||
return num;
|
||||
|
||||
strcpy(file->name, filename);
|
||||
strcpy(file->type, PNM_MIME_TYPE);
|
||||
gp_file_set_name (file, filename);
|
||||
gp_file_set_type (file, PNM_MIME_TYPE);
|
||||
|
||||
file->data = Dimera_Get_Thumbnail(num, &size, camera);
|
||||
if (!file->data)
|
||||
data = Dimera_Get_Thumbnail(num, (int*) &size, camera);
|
||||
if (!data)
|
||||
return GP_ERROR;
|
||||
file->size = size;
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
@@ -416,15 +436,16 @@ int camera_capture (Camera *camera, int capture_type, CameraFilePath *path) {
|
||||
}
|
||||
|
||||
int camera_capture_preview(Camera *camera, CameraFile *file) {
|
||||
int size;
|
||||
long int size;
|
||||
char *data;
|
||||
|
||||
strcpy(file->name, RAM_IMAGE_TEMPLATE);
|
||||
strcpy(file->type, PNM_MIME_TYPE);
|
||||
gp_file_set_name (file, RAM_IMAGE_TEMPLATE);
|
||||
gp_file_set_type (file, PNM_MIME_TYPE);
|
||||
|
||||
file->data = Dimera_Preview(&size, camera);
|
||||
if (!file->data)
|
||||
data = Dimera_Preview((int*) &size, camera);
|
||||
if (!data)
|
||||
return GP_ERROR;
|
||||
file->size = size;
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
|
||||
return GP_OK;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,8 @@ char *extension[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
int is_image (char *filename)
|
||||
static int
|
||||
is_image (char *filename)
|
||||
{
|
||||
|
||||
char *dot;
|
||||
@@ -131,6 +132,10 @@ int camera_file_get_info (Camera *camera, const char *folder, const char *file,
|
||||
int result;
|
||||
char buf [1024];
|
||||
CameraFile *cam_file;
|
||||
const char *name;
|
||||
const char *type;
|
||||
const char *data;
|
||||
long int size;
|
||||
|
||||
sprintf (buf, "%s/%s", folder, file);
|
||||
result = gp_file_new (&cam_file);
|
||||
@@ -145,9 +150,14 @@ int camera_file_get_info (Camera *camera, const char *folder, const char *file,
|
||||
info->preview.fields = GP_FILE_INFO_NONE;
|
||||
info->file.fields = GP_FILE_INFO_SIZE | GP_FILE_INFO_NAME |
|
||||
GP_FILE_INFO_TYPE;
|
||||
strcpy (info->file.type, cam_file->type);
|
||||
strcpy (info->file.name, cam_file->name);
|
||||
info->file.size = cam_file->size;
|
||||
|
||||
gp_file_get_name (cam_file, &name);
|
||||
gp_file_get_type (cam_file, &type);
|
||||
gp_file_get_data_and_size (cam_file, &data, &size);
|
||||
|
||||
strcpy (info->file.type, type);
|
||||
strcpy (info->file.name, name);
|
||||
info->file.size = size;
|
||||
|
||||
gp_file_free (cam_file);
|
||||
|
||||
@@ -281,7 +291,8 @@ int camera_folder_list_folders (Camera *camera, const char *folder,
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int folder_index(Camera *camera)
|
||||
static int
|
||||
folder_index(Camera *camera)
|
||||
{
|
||||
GP_SYSTEM_DIR dir;
|
||||
GP_SYSTEM_DIRENT de;
|
||||
@@ -307,7 +318,8 @@ int folder_index(Camera *camera)
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int directory_folder_set (Camera *camera, const char *folder_name)
|
||||
static int
|
||||
directory_folder_set (Camera *camera, const char *folder_name)
|
||||
{
|
||||
DirectoryStruct *d = (DirectoryStruct*)camera->camlib_data;
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ camera_abilities (CameraAbilitiesList* list)
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
gint
|
||||
static gint
|
||||
init_serial_connection (Camera *camera, gp_port *device)
|
||||
{
|
||||
gint i;
|
||||
@@ -536,12 +536,14 @@ camera_folder_list_files (Camera* camera, const gchar* folder, CameraList* list)
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
static gint
|
||||
camera_file_get_generic (Camera* camera, CameraFile* file, const gchar* folder, const gchar* filename, k_image_type_t image_type)
|
||||
{
|
||||
gulong image_id;
|
||||
gchar* image_id_string;
|
||||
konica_data_t* kd;
|
||||
char *data;
|
||||
long int size;
|
||||
|
||||
g_return_val_if_fail (camera, GP_ERROR_BAD_PARAMETERS);
|
||||
g_return_val_if_fail (file, GP_ERROR_BAD_PARAMETERS);
|
||||
@@ -565,14 +567,12 @@ camera_file_get_generic (Camera* camera, CameraFile* file, const gchar* folder,
|
||||
|
||||
/* Get the image. */
|
||||
CHECK (k_get_image (kd->device, kd->image_id_long, image_id,
|
||||
image_type, (guchar **) &file->data,
|
||||
(guint *) &file->size));
|
||||
image_type, (guchar **) &data,
|
||||
(guint *) &size));
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
gp_file_set_name (file, filename);
|
||||
gp_file_set_type (file, "image/jpeg");
|
||||
|
||||
strcpy (file->type, "image/jpeg");
|
||||
strcpy (file->name, filename);
|
||||
|
||||
gp_debug_printf (GP_DEBUG_LOW, "konica", "*** type: %s", file->type);
|
||||
gp_debug_printf (GP_DEBUG_LOW, "konica", "*** name: %s", file->name);
|
||||
gp_debug_printf (GP_DEBUG_LOW, "konica", "*** Leaving camera_file_get_generic ***");
|
||||
return (GP_OK);
|
||||
}
|
||||
@@ -670,6 +670,8 @@ gint
|
||||
camera_capture_preview (Camera* camera, CameraFile* file)
|
||||
{
|
||||
konica_data_t* kd;
|
||||
char *data;
|
||||
long int size;
|
||||
|
||||
gp_debug_printf (GP_DEBUG_LOW, "konica",
|
||||
"*** Entering camera_capture_preview ***");
|
||||
@@ -677,9 +679,10 @@ camera_capture_preview (Camera* camera, CameraFile* file)
|
||||
g_return_val_if_fail (file, GP_ERROR_BAD_PARAMETERS);
|
||||
|
||||
kd = (konica_data_t *) camera->camlib_data;
|
||||
CHECK (k_get_preview (kd->device, TRUE, (guchar**) &file->data,
|
||||
(guint*) &file->size));
|
||||
strcpy (file->type, "image/jpeg");
|
||||
CHECK (k_get_preview (kd->device, TRUE, (guchar**) &data,
|
||||
(guint*) &size));
|
||||
gp_file_set_data_and_size (file, data, size);
|
||||
gp_file_set_type (file, "image/jpeg");
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -1291,30 +1294,6 @@ int camera_set_config (Camera *camera, CameraWidget *window)
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
|
||||
gint
|
||||
camera_config (Camera *camera)
|
||||
{
|
||||
gint result;
|
||||
CameraWidget* window = NULL;
|
||||
|
||||
if ((result = camera_get_config (camera, &window)) == GP_OK) {
|
||||
|
||||
/* Prompt the user with the config window. */
|
||||
if (gp_frontend_prompt (camera, window) == GP_PROMPT_CANCEL) {
|
||||
gp_widget_unref (window);
|
||||
return (GP_OK);
|
||||
}
|
||||
result = camera_set_config (camera, window);
|
||||
gp_widget_unref (window);
|
||||
return (result);
|
||||
} else {
|
||||
if (window) gp_widget_unref (window);
|
||||
return (result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gchar*
|
||||
camera_result_as_string (Camera* camera, gint result)
|
||||
{
|
||||
|
||||
@@ -613,8 +613,8 @@ int camera_file_get (Camera *camera, const char *folder, const char *filename,
|
||||
return (int) NULL;
|
||||
}
|
||||
|
||||
strcpy (file->name, filename);
|
||||
strcpy (file->type, "image/jpg");
|
||||
gp_file_set_name (file, filename);
|
||||
gp_file_set_type (file, "image/jpeg");
|
||||
|
||||
gp_frontend_progress (camera, file, 0.00);
|
||||
|
||||
@@ -667,8 +667,8 @@ int camera_file_get_preview (Camera *camera, const char *folder,
|
||||
return (int) NULL;
|
||||
}
|
||||
|
||||
strcpy (file->name, filename);
|
||||
strcpy (file->type, "image/jpg");
|
||||
gp_file_set_name (file, filename);
|
||||
gp_file_set_type (file, "image/jpeg");
|
||||
|
||||
gp_frontend_progress (camera, file, 0.00);
|
||||
|
||||
|
||||
@@ -404,9 +404,10 @@ static int camera_file_get_generic (Camera *camera, CameraFile *file,
|
||||
{
|
||||
int regl, regd, file_number;
|
||||
SierraData *fd = (SierraData*)camera->camlib_data;
|
||||
CameraFile *tmp_file;
|
||||
char *jpeg_data, *wrk_s;
|
||||
int jpeg_size, result;
|
||||
int jpeg_size;
|
||||
const char *data;
|
||||
long int size;
|
||||
|
||||
gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** sierra_file_get_generic");
|
||||
gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** folder: %s", folder);
|
||||
@@ -432,74 +433,55 @@ static int camera_file_get_generic (Camera *camera, CameraFile *file,
|
||||
/* Fill in the file structure */
|
||||
CHECK_STOP (camera, gp_file_set_name (file, filename));
|
||||
|
||||
/* Creation of a temporary file */
|
||||
CHECK_STOP (camera, gp_file_new (&tmp_file));
|
||||
result = gp_file_set_name (tmp_file, filename);
|
||||
if (result != GP_OK) {
|
||||
gp_file_free (tmp_file);
|
||||
camera_stop (camera);
|
||||
}
|
||||
|
||||
/* Get the picture data */
|
||||
result = sierra_get_string_register (camera, regd, file_number + 1,
|
||||
tmp_file, NULL, NULL);
|
||||
if (result != GP_OK) {
|
||||
gp_file_free (tmp_file);
|
||||
camera_stop (camera);
|
||||
}
|
||||
|
||||
CHECK_STOP (camera, sierra_get_string_register (camera, regd,
|
||||
file_number + 1, file, NULL, NULL));
|
||||
CHECK_STOP (camera, gp_file_get_data_and_size (file, &data, &size));
|
||||
|
||||
/* Data postprocessing */
|
||||
if (thumbnail) {
|
||||
|
||||
|
||||
/* Thumbnails are always JPEG file (as far as we know...) */
|
||||
strcpy (file->type, "image/jpeg");
|
||||
CHECK_STOP (camera, gp_file_set_type (file, "image/jpeg"));
|
||||
|
||||
/* Corrects the file name to reflect that */
|
||||
if ( (wrk_s = rindex(file->name, '.')) ) {
|
||||
*wrk_s = '\0';
|
||||
strcat(file->name, ".JPG");
|
||||
*wrk_s = '\0';
|
||||
strcat(file->name, ".JPG");
|
||||
}
|
||||
|
||||
/* Some camera (e.g. Epson 3000z) send the EXIF application data
|
||||
as thumbnail of a picture. The JPEG file need to be extracted.
|
||||
Equally for movies, the JPEG thumbnail is contained within a
|
||||
.MOV file. It needs to be extracted. */
|
||||
|
||||
/* Extract the thumbnail from the data sent by the camera */
|
||||
get_jpeg_data(tmp_file->data, tmp_file->size, &jpeg_data, &jpeg_size);
|
||||
/*
|
||||
* Some camera (e.g. Epson 3000z) send the EXIF application
|
||||
* data as thumbnail of a picture. The JPEG file need to be
|
||||
* extracted. Equally for movies, the JPEG thumbnail is
|
||||
* contained within a .MOV file. It needs to be extracted.
|
||||
*/
|
||||
get_jpeg_data (data, size, &jpeg_data, &jpeg_size);
|
||||
|
||||
if (jpeg_data) {
|
||||
/* Append data to the output file. Free temporary variable */
|
||||
gp_file_append (file, jpeg_data, jpeg_size);
|
||||
free(jpeg_data);
|
||||
/* Append data to the output file */
|
||||
gp_file_set_data_and_size (file, jpeg_data, jpeg_size);
|
||||
}
|
||||
else {
|
||||
/* No valid JPEG data found */
|
||||
gp_file_free (tmp_file);
|
||||
camera_stop (camera);
|
||||
return GP_ERROR_CORRUPTED_DATA;
|
||||
}
|
||||
}
|
||||
else {
|
||||
gp_file_append (file, tmp_file->data, tmp_file->size);
|
||||
|
||||
/* Check the file type */
|
||||
if ( memcmp(tmp_file->data, TIFF_SOI_MARKER, 5) == 0 ) {
|
||||
/* This is a TIFF file */
|
||||
strcpy (file->type, "image/tiff");
|
||||
}
|
||||
else if ( memcmp(tmp_file->data, JPEG_SOI_MARKER, 2) == 0 ) {
|
||||
/* This is a TIFF file */
|
||||
strcpy (file->type, "image/jpeg");
|
||||
}
|
||||
else {
|
||||
/* This is probably a video. */
|
||||
gp_file_append (file, tmp_file->data, tmp_file->size);
|
||||
strcpy (file->type, "video/quicktime");
|
||||
}
|
||||
if (!memcmp (data, TIFF_SOI_MARKER, 5))
|
||||
CHECK_STOP (camera,
|
||||
gp_file_set_type (file, "image/tiff"))
|
||||
else if (!memcmp (data, JPEG_SOI_MARKER, 2))
|
||||
CHECK_STOP (camera,
|
||||
gp_file_set_type (file, "image/jpeg"))
|
||||
else
|
||||
CHECK_STOP (camera,
|
||||
gp_file_set_type (file, "video/quicktime"))
|
||||
}
|
||||
|
||||
gp_file_free (tmp_file);
|
||||
|
||||
return (camera_stop (camera));
|
||||
}
|
||||
|
||||
|
||||
@@ -487,6 +487,7 @@ save_camera_file_to_file (CameraFile *file, int thumbnail)
|
||||
int result;
|
||||
char *f;
|
||||
int resp1, resp2;
|
||||
const char *name;
|
||||
|
||||
/* Determine the folder and filename */
|
||||
strcpy(out_filename, "");
|
||||
@@ -505,7 +506,8 @@ save_camera_file_to_file (CameraFile *file, int thumbnail)
|
||||
sprintf(out_filename, glob_filename, glob_num++);
|
||||
}
|
||||
} else {
|
||||
strcat(out_filename, file->name);
|
||||
gp_file_get_name (file, &name);
|
||||
strcat(out_filename, name);
|
||||
}
|
||||
|
||||
if (thumbnail)
|
||||
@@ -566,9 +568,14 @@ int save_picture_to_file(char *folder, char *filename, int thumbnail) {
|
||||
}
|
||||
|
||||
if (glob_stdout) {
|
||||
const char *data;
|
||||
long int size;
|
||||
|
||||
gp_file_get_data_and_size (file, &data, &size);
|
||||
|
||||
if (glob_stdout_size)
|
||||
printf ("%li\n", file->size);
|
||||
fwrite (file->data, sizeof(char), file->size, stdout);
|
||||
printf ("%li\n", size);
|
||||
fwrite (data, sizeof(char), size, stdout);
|
||||
gp_file_free (file);
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
#ifndef __GPHOTO2_FILE_H__
|
||||
#define __GPHOTO2_FILE_H__
|
||||
|
||||
typedef struct {
|
||||
typedef struct _CameraFile CameraFile;
|
||||
|
||||
/* Don't use this - it'll disappear soon... */
|
||||
struct _CameraFile {
|
||||
char type [64];
|
||||
char name [64];
|
||||
long int size;
|
||||
@@ -29,7 +32,7 @@ typedef struct {
|
||||
int bytes_read;
|
||||
int session;
|
||||
int ref_count;
|
||||
} CameraFile;
|
||||
};
|
||||
|
||||
int gp_file_new (CameraFile **file);
|
||||
int gp_file_ref (CameraFile *file);
|
||||
@@ -46,8 +49,13 @@ int gp_file_free (CameraFile *file);
|
||||
int gp_file_set_name (CameraFile *file, const char *name);
|
||||
int gp_file_set_type (CameraFile *file, const char *type);
|
||||
|
||||
int gp_file_append (CameraFile *file, char *data, int size);
|
||||
int gp_file_get_last_chunk (CameraFile *file, char **data, int *size);
|
||||
int gp_file_get_name (CameraFile *file, const char **name);
|
||||
int gp_file_get_type (CameraFile *file, const char **type);
|
||||
|
||||
int gp_file_append (CameraFile*, const char *data, int size);
|
||||
int gp_file_get_last_chunk (CameraFile*, char **data, long int *size);
|
||||
int gp_file_set_data_and_size (CameraFile*, char *data, long int size);
|
||||
int gp_file_get_data_and_size (CameraFile*, const char **data, long int *size);
|
||||
|
||||
int gp_file_copy (CameraFile *destination, CameraFile *source);
|
||||
|
||||
|
||||
@@ -458,6 +458,9 @@ gp_camera_file_get_info (Camera *camera, const char *folder,
|
||||
const char *file, CameraFileInfo *info)
|
||||
{
|
||||
int result = GP_OK;
|
||||
const char *type;
|
||||
const char *data;
|
||||
long int size;
|
||||
|
||||
CHECK_NULL (camera && folder && file && info);
|
||||
|
||||
@@ -486,8 +489,10 @@ gp_camera_file_get_info (Camera *camera, const char *folder,
|
||||
== GP_OK) {
|
||||
info->preview.fields |= GP_FILE_INFO_SIZE |
|
||||
GP_FILE_INFO_TYPE;
|
||||
info->preview.size = cfile->size;
|
||||
strcpy (info->preview.type, cfile->type);
|
||||
gp_file_get_data_and_size (cfile, &data, &size);
|
||||
info->preview.size = size;
|
||||
gp_file_get_type (cfile, &type);
|
||||
strcpy (info->preview.type, type);
|
||||
}
|
||||
|
||||
CHECK_RESULT (gp_file_unref (cfile));
|
||||
|
||||
@@ -93,7 +93,7 @@ int gp_file_session (CameraFile *file)
|
||||
}
|
||||
|
||||
int
|
||||
gp_file_append (CameraFile *file, char *data, int size)
|
||||
gp_file_append (CameraFile *file, const char *data, int size)
|
||||
{
|
||||
char *t;
|
||||
|
||||
@@ -103,9 +103,9 @@ gp_file_append (CameraFile *file, char *data, int size)
|
||||
return (GP_ERROR_BAD_PARAMETERS);
|
||||
|
||||
if (!file->data)
|
||||
file->data = malloc(sizeof(char) * (size));
|
||||
file->data = malloc (sizeof(char) * (size));
|
||||
else {
|
||||
t = realloc (file->data, sizeof(char) * (file->size + size));
|
||||
t = realloc (file->data, sizeof (char) * (file->size + size));
|
||||
if (!t)
|
||||
return GP_ERROR_NO_MEMORY;
|
||||
file->data = t;
|
||||
@@ -119,7 +119,21 @@ gp_file_append (CameraFile *file, char *data, int size)
|
||||
}
|
||||
|
||||
int
|
||||
gp_file_get_last_chunk (CameraFile *file, char **data, int *size)
|
||||
gp_file_set_data_and_size (CameraFile *file, char *data, long int size)
|
||||
{
|
||||
CHECK_NULL (file);
|
||||
|
||||
if (file->data)
|
||||
free (file->data);
|
||||
file->data = data;
|
||||
file->size = size;
|
||||
file->bytes_read = size;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int
|
||||
gp_file_get_last_chunk (CameraFile *file, char **data, long int *size)
|
||||
{
|
||||
CHECK_NULL (file && data && size);
|
||||
|
||||
@@ -139,6 +153,17 @@ gp_file_get_last_chunk (CameraFile *file, char **data, int *size)
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int
|
||||
gp_file_get_data_and_size (CameraFile *file, const char **data, long int *size)
|
||||
{
|
||||
CHECK_NULL (file && data && size);
|
||||
|
||||
*data = file->data;
|
||||
*size = file->size;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int
|
||||
gp_file_save (CameraFile *file, char *filename)
|
||||
{
|
||||
@@ -270,6 +295,26 @@ gp_file_copy (CameraFile *destination, CameraFile *source)
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int
|
||||
gp_file_get_name (CameraFile *file, const char **name)
|
||||
{
|
||||
CHECK_NULL (file && name);
|
||||
|
||||
*name = file->name;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int
|
||||
gp_file_get_type (CameraFile *file, const char **type)
|
||||
{
|
||||
CHECK_NULL (file && type);
|
||||
|
||||
*type = file->type;
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
int
|
||||
gp_file_set_name (CameraFile *file, const char *name)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user