From 6ea237f94639e6a18824331a66f1b7ac0e465ef5 Mon Sep 17 00:00:00 2001 From: axxel Date: Sat, 14 Sep 2024 18:26:05 +0200 Subject: [PATCH] fix white-space and indentation inconsistencies (second round) This is basically a continuation of the work from #1002 but her for the camlibs directory. The purpose was to replace spaces as a means for indentation with tab characters. Note: there are some files which are still offending the general rule but are (mostly) consistent within themselves. I let them be for the moment. Fixing them would basically replace the whole file. Also: there are still a ton of whitespace related inconsistencies like "x=10" vs "x = 10" or "func(10)" vs "func (10)". This is a whitespace only change (if you include newlines as whitespace). --- camlibs/adc65/adc65.c | 32 +- camlibs/agfa-cl20/agfa_cl20.c | 16 +- camlibs/aox/aox.c | 44 +- camlibs/aox/library.c | 114 +- camlibs/ax203/ax203.c | 2 +- camlibs/ax203/library.c | 4 +- camlibs/barbie/barbie.c | 178 +-- camlibs/canon/canon.h | 3 +- camlibs/canon/library.c | 223 ++- camlibs/casio/casio-qv-commands.c | 28 +- camlibs/casio/casio-qv.c | 72 +- camlibs/clicksmart310/clicksmart.c | 30 +- camlibs/clicksmart310/library.c | 82 +- camlibs/digigr8/digi_postprocess.c | 12 +- camlibs/digigr8/library.c | 7 +- camlibs/digita/digita.c | 8 +- camlibs/dimera/dimera3500.c | 150 +- camlibs/directory/directory.c | 110 +- camlibs/docupen/calibration.c | 2 +- camlibs/docupen/docupen.c | 164 +- camlibs/enigma13/enigma13.c | 181 +-- camlibs/fuji/fuji.c | 89 +- camlibs/fuji/fuji.h | 16 +- camlibs/fuji/library.c | 41 +- camlibs/gsmart300/gsmart300.c | 12 +- camlibs/gsmart300/library.c | 17 +- camlibs/iclick/library.c | 77 +- camlibs/jd11/jd11.c | 26 +- camlibs/jd11/serial.c | 545 ++++--- camlibs/jl2005a/jl2005a.c | 16 +- camlibs/jl2005a/library.c | 4 +- camlibs/jl2005c/library.c | 2 +- camlibs/kodak/dc120/dc120.c | 100 +- camlibs/kodak/dc120/library.c | 228 ++- camlibs/kodak/dc210/dc210.c | 374 +++-- camlibs/kodak/dc210/dc210.h | 4 +- camlibs/kodak/dc210/library.c | 509 +++--- camlibs/kodak/dc240/dc240.c | 114 +- camlibs/kodak/dc3200/dc3200.c | 16 +- camlibs/kodak/dc3200/library.c | 6 +- camlibs/kodak/ez200/ez200.c | 81 +- camlibs/konica/library.c | 1388 ++++++++--------- camlibs/konica/lowlevel.c | 8 +- camlibs/konica/qm150.c | 671 ++++---- camlibs/largan/lmini/largan.c | 8 +- camlibs/largan/lmini/lmini.c | 80 +- camlibs/lg_gsm/lg_gsm.c | 8 +- camlibs/lg_gsm/library.c | 50 +- camlibs/lumix/lumix.c | 186 +-- camlibs/mars/library.c | 140 +- camlibs/mars/mars.c | 120 +- camlibs/minolta/dimagev/dimagev.c | 52 +- camlibs/mustek/io.c | 2 +- camlibs/mustek/mdc800.c | 30 +- camlibs/mustek/mustek-config.c | 24 +- camlibs/panasonic/dc.c | 234 +-- camlibs/panasonic/dc.h | 20 +- camlibs/panasonic/dc1000.c | 26 +- camlibs/panasonic/dc1580.c | 570 +++---- camlibs/panasonic/l859/l859.c | 18 +- camlibs/pentax/library.c | 106 +- camlibs/polaroid/pdc320.c | 4 +- camlibs/polaroid/pdc640.c | 8 +- camlibs/polaroid/pdc700.c | 20 +- camlibs/ptp2/config.c | 2 +- camlibs/ptp2/ptp-pack.c | 2 +- camlibs/ptp2/ptp.h | 12 +- camlibs/ricoh/g3.c | 26 +- camlibs/ricoh/library.c | 12 +- camlibs/ricoh/ricoh.c | 14 +- camlibs/ricoh/ricoh.h | 2 +- camlibs/samsung/samsung.c | 24 +- camlibs/sierra/library.c | 45 +- camlibs/sierra/sierra-desc.c | 13 +- camlibs/sierra/sierra.c | 548 +++---- camlibs/sipix/blink.c | 10 +- camlibs/sipix/blink2.c | 92 +- camlibs/sipix/web2.c | 4 +- camlibs/smal/smal.c | 245 ++- camlibs/sonix/library.c | 36 +- camlibs/sonix/sonix.c | 8 +- camlibs/sonydscf55/camera.c | 2 +- camlibs/sonydscf55/sony.c | 2 +- camlibs/soundvision/commands.h | 6 +- camlibs/soundvision/soundvision.h | 15 +- camlibs/spca50x/library.c | 12 +- camlibs/spca50x/spca50x-flash.c | 2 +- camlibs/spca50x/spca50x-sdram.c | 10 +- camlibs/spca50x/spca50x.c | 2 +- camlibs/sq905/library.c | 25 +- camlibs/sq905/postprocess.c | 20 +- camlibs/sq905/sq905.c | 20 +- camlibs/st2205/st2205.c | 6 +- camlibs/stv0674/stv0674.c | 68 +- camlibs/stv0680/sharpen.c | 288 ++-- camlibs/stv0680/stv0680-bayer.c | 202 +-- camlibs/stv0680/stv0680.c | 116 +- camlibs/stv0680/stv0680.h | 4 +- camlibs/sx330z/library.c | 165 +- camlibs/template/template.c | 18 +- camlibs/topfield/crc16.c | 78 +- camlibs/topfield/puppy.c | 110 +- camlibs/toshiba/pdrm11/library.c | 6 +- camlibs/tp6801/library.c | 7 +- coverity-model.c | 11 +- examples/sample-capture.c | 6 +- examples/sample-justfocus.c | 40 +- examples/sample-libfuzz.c | 5 +- examples/sample-multi-detect.c | 18 +- examples/sample-tether.c | 6 +- examples/sample-trigger-capture.c | 6 +- libgphoto2/ahd_bayer.c | 6 +- libgphoto2_port/disk/disk.c | 38 +- .../gphoto2/gphoto2-port-library.h | 70 +- libgphoto2_port/gphoto2/gphoto2-port-log.h | 4 +- libgphoto2_port/gphoto2/gphoto2-port.h | 10 +- libgphoto2_port/libusb1/libusb1.c | 186 ++- libgphoto2_port/ptpip/ptpip.c | 6 +- libgphoto2_port/serial/unix.c | 296 ++-- libgphoto2_port/usb/libusb.c | 24 +- libgphoto2_port/vusb/vcamera.c | 52 +- libgphoto2_port/vusb/vusb.c | 126 +- tests/test-i18n.c | 8 +- 123 files changed, 5302 insertions(+), 5407 deletions(-) diff --git a/camlibs/adc65/adc65.c b/camlibs/adc65/adc65.c index 1b771e7918..933b318224 100644 --- a/camlibs/adc65/adc65.c +++ b/camlibs/adc65/adc65.c @@ -74,15 +74,15 @@ adc65_ping(Camera *camera) { static int adc65_file_count (Camera *camera) { - unsigned char cmd, resp[65538]; + unsigned char cmd, resp[65538]; int ret; - GP_DEBUG("Getting the number of pictures."); - cmd = 0x00; - ret = adc65_exchange(camera, &cmd, 1, resp, 65538); + GP_DEBUG("Getting the number of pictures."); + cmd = 0x00; + ret = adc65_exchange(camera, &cmd, 1, resp, 65538); if (ret < 2) /* must have at least a 2 byte reply */ - return ret; - return resp[1] - 1; + return ret; + return resp[1] - 1; } static char * @@ -102,7 +102,7 @@ adc65_read_data (Camera *camera, unsigned char *cmd, int cmd_size, int data_type /* get the picture */ ret = adc65_exchange (camera, cmd, cmd_size, resp, 2); if (ret < 2) - return NULL; + return NULL; us = malloc (65536); if (!us) @@ -224,23 +224,23 @@ get_file_func ( CameraFilesystem *fs, const char *folder, CameraFile *file, void *user_data, GPContext *context) { Camera *camera = user_data; - int size, num; - char *data; + int size, num; + char* data; - gp_file_set_mime_type (file, GP_MIME_PPM); - num = gp_filesystem_number (fs, folder, filename, context); + gp_file_set_mime_type (file, GP_MIME_PPM); + num = gp_filesystem_number (fs, folder, filename, context); if (num < 0) return num; - data = adc65_read_picture (camera, num, &size); - if (!data) + data = adc65_read_picture (camera, num, &size); + if (!data) return GP_ERROR; - return gp_file_append (file,data,size); + return gp_file_append (file, data, size); } static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("Adc65\nBenjamin Moos ")); - return GP_OK; + strcpy (about->text, _("Adc65\nBenjamin Moos ")); + return GP_OK; } static CameraFilesystemFuncs fsfuncs = { diff --git a/camlibs/agfa-cl20/agfa_cl20.c b/camlibs/agfa-cl20/agfa_cl20.c index ad63da1f90..c986f90a3a 100644 --- a/camlibs/agfa-cl20/agfa_cl20.c +++ b/camlibs/agfa-cl20/agfa_cl20.c @@ -233,8 +233,8 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, result[19] = 0x00; memmove(&result[20], - &result[app1len + 4], - (unsigned int)(size - app1len - 4)); + &result[app1len + 4], + (unsigned int)(size - app1len - 4)); size = size - app1len + 20 + 4; @@ -439,8 +439,8 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, result[19] = 0x00; memmove(&result[20], - &result[app1len + 4], - (unsigned int)(size - app1len - 4)); + &result[app1len + 4], + (unsigned int)(size - app1len - 4)); size = size - app1len + 24; @@ -664,10 +664,10 @@ camera_init (Camera *camera, GPContext *context) GP_DEBUG(" * camera_init()"); - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); diff --git a/camlibs/aox/aox.c b/camlibs/aox/aox.c index f81e2f209d..43d4dde0fe 100644 --- a/camlibs/aox/aox.c +++ b/camlibs/aox/aox.c @@ -49,27 +49,27 @@ int aox_init (GPPort *port, Model *model, Info *info) READ(port, 1, 0, 0, c,0x10); WRITE(port, 8, 1, 0, c, 0x10); - READ(port, 0xff, 0x07, 0xfffc, c, 4); /* Returns version number, apparently */ - READ(port, 0x06, 0x0, 0x0, c, 2); - READ(port, 0x04, 0x1, 0x1, (char *)lo, 2); - GP_DEBUG("%02x %02x number of lo-res pics\n", lo[0],lo[1]); + READ(port, 0xff, 0x07, 0xfffc, c, 4); /* Returns version number, apparently */ + READ(port, 0x06, 0x0, 0x0, c, 2); + READ(port, 0x04, 0x1, 0x1, (char*)lo, 2); + GP_DEBUG("%02x %02x number of lo-res pics\n", lo[0], lo[1]); /* We need to keep this information. We presume that * more than 255 pictures is impossible with this camera. */ memcpy (info, &lo[0], 1); - READ(port, 0x04, 0x2, 0x1, c, 2); - READ(port, 0x04, 0x3, 0x1, c, 2); - READ(port, 0x04, 0x4, 0x1, c, 2); - READ(port, 0x04, 0x5, 0x1, (char *)hi, 2); + READ(port, 0x04, 0x2, 0x1, c, 2); + READ(port, 0x04, 0x3, 0x1, c, 2); + READ(port, 0x04, 0x4, 0x1, c, 2); + READ(port, 0x04, 0x5, 0x1, (char*)hi, 2); GP_DEBUG("%02i %02i number of hi-res pics\n", hi[0], hi[1]); /* This information, too. */ - memcpy (info +1, &hi[0], 1); - READ(port, 0x04, 0x6, 0x1, c, 2); /* "Completion" flag.*/ + memcpy (info + 1, &hi[0], 1); + READ(port, 0x04, 0x6, 0x1, c, 2); /* "Completion" flag.*/ GP_DEBUG("info[0] = 0x%x\n", info[0]); GP_DEBUG("info[1] = 0x%x\n", info[1]); GP_DEBUG("Leaving aox_init\n"); - return GP_OK; + return GP_OK; } @@ -89,16 +89,16 @@ int aox_get_picture_size (GPPort *port, int lo, int hi, int n, int k) { unsigned char c[4]; - unsigned int size; + unsigned int size; memset (c,0,4); GP_DEBUG("Running aox_get_picture_size for aox_pic%03i\n", k+1); if ( ( (lo) && ( n ==k ) && (k ==0)) ) { - READ(port, 0x04, 0x1, 0x1, (char *)c, 2); + READ(port, 0x04, 0x1, 0x1, (char *)c, 2); } if ( ( (hi) && ( n < k ) && (n == 0)) ) { - READ(port, 0x04, 0x5, 0x1, (char *)c, 2); + READ(port, 0x04, 0x5, 0x1, (char *)c, 2); } READ(port, 0x05, n+1, 0x1, (char *)c, 4); size = (int)c[0] + (int)c[1]*0x100 + (int)c[2]*0x10000; @@ -113,21 +113,21 @@ static int aox_read_data (GPPort *port, char *data, int size) { int MAX_BULK = 0x1000; - while(size > 0) { - int len = (size>MAX_BULK)?MAX_BULK:size; - gp_port_read (port, data, len); /* 0x84 = EP IN NEEDED HERE.*/ - data += len; + while (size > 0) { + int len = (size > MAX_BULK) ? MAX_BULK : size; + gp_port_read (port, data, len); /* 0x84 = EP IN NEEDED HERE.*/ + data += len; size -= len; } - return 1; + return 1; } int aox_read_picture_data (GPPort *port, char *data, int size, int n) { char c[4]; memset(c,0,4); - READ(port, 0x06, n+1, 0x1, c, 4); - aox_read_data (port, data , size); + READ(port, 0x06, n + 1, 0x1, c, 4); + aox_read_data (port, data, size); - return GP_OK; + return GP_OK; } diff --git a/camlibs/aox/library.c b/camlibs/aox/library.c index aa43eb1906..4180545f57 100644 --- a/camlibs/aox/library.c +++ b/camlibs/aox/library.c @@ -56,81 +56,81 @@ struct _CameraPrivateLibrary { }; static struct { - char *name; + char *name; CameraDriverStatus status; - unsigned short idVendor; - unsigned short idProduct; + unsigned short idVendor; + unsigned short idProduct; } models[] = { - {"Concord EyeQMini_1", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2182}, - {"Concord EyeQMini_2", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2180}, - {"D-MAX DM3588", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2130}, + {"Concord EyeQMini_1", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2182}, + {"Concord EyeQMini_2", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2180}, + {"D-MAX DM3588", GP_DRIVER_STATUS_EXPERIMENTAL, 0x03e8, 0x2130}, {NULL,0,0,0} }; int camera_id (CameraText *id) { - strcpy (id->text, "Aox chipset camera"); - return GP_OK; + strcpy (id->text, "Aox chipset camera"); + return GP_OK; } int camera_abilities (CameraAbilitiesList *list) { - int i; - CameraAbilities a; - - for (i = 0; models[i].name; i++) { - memset (&a, 0, sizeof(a)); - strcpy (a.model, models[i].name); - a.status = models[i].status; - a.port = GP_PORT_USB; - a.speed[0] = 0; - a.usb_vendor = models[i].idVendor; - a.usb_product= models[i].idProduct; - if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) + int i; + CameraAbilities a; + + for (i = 0; models[i].name; i++) { + memset (&a, 0, sizeof(a)); + strcpy (a.model, models[i].name); + a.status = models[i].status; + a.port = GP_PORT_USB; + a.speed[0] = 0; + a.usb_vendor = models[i].idVendor; + a.usb_product = models[i].idProduct; + if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) a.operations = GP_OPERATION_NONE; else a.operations = GP_OPERATION_CAPTURE_IMAGE; - a.folder_operations = GP_FOLDER_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_PREVIEW; - gp_abilities_list_append (list, a); - } - return GP_OK; + a.folder_operations = GP_FOLDER_OPERATION_NONE; + a.file_operations = GP_FILE_OPERATION_PREVIEW; + gp_abilities_list_append (list, a); + } + return GP_OK; } static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { - int num_lo_pics =aox_get_num_lo_pics(camera->pl->info); - int num_hi_pics =aox_get_num_hi_pics(camera->pl->info); + int num_lo_pics = aox_get_num_lo_pics(camera->pl->info); + int num_hi_pics = aox_get_num_hi_pics(camera->pl->info); - sprintf (summary->text,_("Your USB camera has an Aox chipset.\n" + sprintf (summary->text, _("Your USB camera has an Aox chipset.\n" "Number of lo-res PICs = %i\n" "Number of hi-res PICs = %i\n" "Number of PICs = %i\n" - ), num_lo_pics, num_hi_pics, num_lo_pics+num_hi_pics); + ), num_lo_pics, num_hi_pics, num_lo_pics + num_hi_pics); - return GP_OK; + return GP_OK; } static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("Aox generic driver\n" - "Theodore Kilgore \n")); - return GP_OK; + strcpy (about->text, _("Aox generic driver\n" + "Theodore Kilgore \n")); + return GP_OK; } /*************** File and Downloading Functions *******************/ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, - void *data, GPContext *context) + void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; int num_lo_pics = aox_get_num_lo_pics (camera->pl->info); int num_hi_pics = aox_get_num_hi_pics (camera->pl->info); int n = num_hi_pics + num_lo_pics; @@ -148,7 +148,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, snprintf( name, sizeof(name), "aox_pic%03i.ppm", i+1 ); gp_list_append(list, name, NULL); } - return GP_OK; + return GP_OK; } static int @@ -156,7 +156,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *user_data, GPContext *context) { - Camera *camera = user_data; + Camera *camera = user_data; /* The camera will always download the low-resolution pictures first, if any. * As those are compressed, they are not of fixed size. Unfortunately, the @@ -166,7 +166,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, * resolution pictures are just Bayer data; their headers will be discarded. */ - int i, j, k, n, num_lo_pics, num_hi_pics, w = 0, h = 0; + int i, j, k, n, num_lo_pics, num_hi_pics, w = 0, h = 0; unsigned char temp; unsigned char *data; unsigned char *p_data = NULL; @@ -204,7 +204,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, data = malloc(len); if (!data) { printf("Malloc failed\n"); return 0;} - aox_read_picture_data (camera->port, (char *)data, len, n); + aox_read_picture_data (camera->port, (char *)data, len, n); switch (type) { case GP_FILE_TYPE_EXIF: @@ -229,19 +229,19 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, /* Stripping useless header */ p_data = data + 0x98; /* Picture is mirror-imaged.*/ - for (i = 0; i < h; ++i) { - for (j = 0 ; j < w/2; j++) { - temp = p_data[w*i +j]; - p_data[w*i +j] = p_data[w*i+ w -1 -j]; - p_data[w*i + w - 1 - j] = temp; + for (i = 0; i < h; ++i) { + for (j = 0; j < w / 2; j++) { + temp = p_data[w * i + j]; + p_data[w * i + j] = p_data[w * i + w - 1 - j]; + p_data[w * i + w - 1 - j] = temp; } - } + } /* Not only this, but some columns are * interchanged, too. */ for (i = 0; i < w*h/4; i++) { - temp = p_data[4*i +1]; - p_data[4*i + 1] = p_data[4*i+2]; - p_data[4*i+2] = temp; + temp = p_data[4 * i + 1]; + p_data[4 * i + 1] = p_data[4 * i + 2]; + p_data[4 * i + 2] = temp; } /* And now create a ppm file, with our own header */ header_len = snprintf(header, 127, @@ -256,16 +256,14 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, return GP_ERROR_NO_MEMORY; } if (camera->pl->model == AOX_MODEL_DMAX) - gp_bayer_decode (p_data, w, h, - output, BAYER_TILE_RGGB); + gp_bayer_decode (p_data, w, h, output, BAYER_TILE_RGGB); else - gp_bayer_decode (p_data, w, h, - output, BAYER_TILE_GRBG); + gp_bayer_decode (p_data, w, h, output, BAYER_TILE_GRBG); /* gamma correction of .70 may not be optimal. */ gp_gamma_fill_table (gtable, .65); gp_gamma_correct_single (gtable, output, w * h); - gp_file_set_mime_type (file, GP_MIME_PPM); - gp_file_append (file, header, header_len); + gp_file_set_mime_type (file, GP_MIME_PPM); + gp_file_append (file, header, header_len); gp_file_append (file, (char *)output, 3*w*h); } free (data); @@ -317,9 +315,9 @@ camera_init(Camera *camera, GPContext *context) ret = gp_port_get_settings(camera->port,&settings); if (ret < 0) return ret; - ret = gp_camera_get_abilities(camera,&abilities); - if (ret < 0) return ret; - GP_DEBUG("product number is 0x%x\n", abilities.usb_product); + ret = gp_camera_get_abilities(camera, &abilities); + if (ret < 0) return ret; + GP_DEBUG("product number is 0x%x\n", abilities.usb_product); switch (camera->port->type) { case GP_PORT_SERIAL: @@ -342,7 +340,7 @@ camera_init(Camera *camera, GPContext *context) GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("outep = %x\n", settings.usb.outep); - /* Tell the CameraFilesystem where to get lists from */ + /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); diff --git a/camlibs/ax203/ax203.c b/camlibs/ax203/ax203.c index 68204b6f50..0670bbd586 100644 --- a/camlibs/ax203/ax203.c +++ b/camlibs/ax203/ax203.c @@ -1264,7 +1264,7 @@ ax203_encode_image(Camera *camera, int **src, char *dest, unsigned int dest_size free (jpeg_dest); /* Round size up to a multiple of 256 because of ax3003 abfs size granularity. */ - return (jpeg_size + 0xff) & ~0xff; + return (jpeg_size + 0xff) & ~0xff; #else return GP_ERROR_NOT_SUPPORTED; #endif diff --git a/camlibs/ax203/library.c b/camlibs/ax203/library.c index b0134a9dd0..31760dc31f 100644 --- a/camlibs/ax203/library.c +++ b/camlibs/ax203/library.c @@ -403,8 +403,8 @@ storage_info_func (CameraFilesystem *fs, imagesize = ax203_filesize (camera); if (imagesize) { - sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES; - sinfo->freeimages = free / imagesize; + sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES; + sinfo->freeimages = free / imagesize; } return GP_OK; diff --git a/camlibs/barbie/barbie.c b/camlibs/barbie/barbie.c index 50608f1b27..4cf6eb1c63 100644 --- a/camlibs/barbie/barbie.c +++ b/camlibs/barbie/barbie.c @@ -108,17 +108,17 @@ barbie_ping(GPPort *port) { static int barbie_file_count (GPPort *port) { - unsigned char cmd[4], resp[4]; + unsigned char cmd[4], resp[4]; - GP_DEBUG ("Getting the number of pictures..."); + GP_DEBUG ("Getting the number of pictures..."); - memcpy(cmd, packet_1, 4); - cmd[COMMAND_BYTE] = 'I'; - cmd[DATA1_BYTE] = 0; + memcpy(cmd, packet_1, 4); + cmd[COMMAND_BYTE] = 'I'; + cmd[DATA1_BYTE] = 0; - if (barbie_exchange(port, cmd, 4, resp, 4) != 1) - return (0); - return (resp[DATA1_BYTE]); + if (barbie_exchange(port, cmd, 4, resp, 4) != 1) + return (0); + return (resp[DATA1_BYTE]); } static unsigned char * @@ -240,53 +240,53 @@ barbie_read_picture(GPPort *port, int picture_number, int get_thumbnail, CameraF /* GPhoto specific stuff */ static char *models[] = { - "Barbie", - "Nick Click", - "WWF", - "Hot Wheels", - NULL + "Barbie", + "Nick Click", + "WWF", + "Hot Wheels", + NULL }; int camera_id (CameraText *id) { - strcpy(id->text, "barbie"); - return (GP_OK); + strcpy(id->text, "barbie"); + return (GP_OK); } int camera_abilities (CameraAbilitiesList *list) { - int x=0; - CameraAbilities a; + int x=0; + CameraAbilities a; - while (models[x]) { - /* Fill in the appropriate flags/data */ + while (models[x]) { + /* Fill in the appropriate flags/data */ memset (&a, 0, sizeof(a)); - strcpy(a.model, models[x]); + strcpy(a.model, models[x]); a.status = GP_DRIVER_STATUS_PRODUCTION; - a.port = GP_PORT_SERIAL; - a.speed[0] = 57600; - a.speed[1] = 0; - a.operations = GP_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_PREVIEW; - a.folder_operations = GP_FOLDER_OPERATION_NONE; - - /* Append it to the list */ - gp_abilities_list_append(list, a); - - x++; - } - return (GP_OK); + a.port = GP_PORT_SERIAL; + a.speed[0] = 57600; + a.speed[1] = 0; + a.operations = GP_OPERATION_NONE; + a.file_operations = GP_FILE_OPERATION_PREVIEW; + a.folder_operations = GP_FOLDER_OPERATION_NONE; + + /* Append it to the list */ + gp_abilities_list_append(list, a); + + x++; + } + return (GP_OK); } static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; - return gp_list_populate (list, "mattel%02i.ppm", barbie_file_count (camera->port)); + return gp_list_populate (list, "mattel%02i.ppm", barbie_file_count (camera->port)); } static int @@ -295,67 +295,67 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context) { Camera *camera = user_data; - int num; + int num; - /* Retrieve the number of the photo on the camera */ - num = gp_filesystem_number (camera->fs, "/", filename, context); + /* Retrieve the number of the photo on the camera */ + num = gp_filesystem_number (camera->fs, "/", filename, context); if (num < GP_OK) return num; - gp_file_set_mime_type (file, GP_MIME_PPM); - switch (type) { - case GP_FILE_TYPE_NORMAL: - return barbie_read_picture (camera->port, num, 0, file); - break; - case GP_FILE_TYPE_PREVIEW: - return barbie_read_picture (camera->port, num, 1, file); - break; - default: - return GP_ERROR_NOT_SUPPORTED; - } - return GP_ERROR_NOT_SUPPORTED; + gp_file_set_mime_type (file, GP_MIME_PPM); + switch (type) { + case GP_FILE_TYPE_NORMAL: + return barbie_read_picture (camera->port, num, 0, file); + break; + case GP_FILE_TYPE_PREVIEW: + return barbie_read_picture (camera->port, num, 1, file); + break; + default: + return GP_ERROR_NOT_SUPPORTED; + } + return GP_ERROR_NOT_SUPPORTED; } #if 0 int camera_capture (Camera *camera, int capture_type, CameraFilePath *path) { - char cmd[4], resp[4]; + char cmd[4], resp[4]; - memcpy(cmd, packet_1, 4); + memcpy(cmd, packet_1, 4); - cmd[COMMAND_BYTE] = 'G'; - cmd[DATA1_BYTE] = 0x40; - if (barbie_exchange(cmd, 4, resp, 4) == 0) - return (0); + cmd[COMMAND_BYTE] = 'G'; + cmd[DATA1_BYTE] = 0x40; + if (barbie_exchange(cmd, 4, resp, 4) == 0) + return (0); - cmd[COMMAND_BYTE] = 'Y'; - cmd[DATA1_BYTE] = 0; - if (barbie_exchange(cmd, 4, resp, 4) == 0) - return (0); + cmd[COMMAND_BYTE] = 'Y'; + cmd[DATA1_BYTE] = 0; + if (barbie_exchange(cmd, 4, resp, 4) == 0) + return (0); - return(resp[DATA1_BYTE] == 0? GP_OK: GP_ERROR); + return(resp[DATA1_BYTE] == 0 ? GP_OK : GP_ERROR); - return (GP_ERROR); + return (GP_ERROR); } #endif static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { - int num; - char *firm; - - num = barbie_file_count (camera->port); - firm = (char*)barbie_read_firmware (camera->port); - sprintf(summary->text, _("Number of pictures: %i\nFirmware Version: %s"), num,firm); - free(firm); - return GP_OK; + int num; + char *firm; + + num = barbie_file_count (camera->port); + firm = (char*)barbie_read_firmware (camera->port); + sprintf(summary->text, _("Number of pictures: %i\nFirmware Version: %s"), num, firm); + free(firm); + return GP_OK; } static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text,_("Barbie/HotWheels/WWF\nScott Fritzinger \nAndreas Meyer \nPete Zaitcev \n\nReverse engineering of image data by:\nJeff Laing \n\nImplemented using documents found on\nthe web. Permission given by Vision.")); - return GP_OK; + strcpy (about->text, _("Barbie/HotWheels/WWF\nScott Fritzinger \nAndreas Meyer \nPete Zaitcev \n\nReverse engineering of image data by:\nJeff Laing \n\nImplemented using documents found on\nthe web. Permission given by Vision.")); + return GP_OK; } static CameraFilesystemFuncs fsfuncs = { @@ -367,26 +367,26 @@ int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; - int res; + int res; - /* First, set up all the function pointers */ - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; - /* Set up the CameraFilesystem */ - gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); + /* Set up the CameraFilesystem */ + gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* Set up the port */ - gp_port_set_timeout (camera->port, 5000); + gp_port_set_timeout (camera->port, 5000); gp_port_get_settings (camera->port, &settings); - settings.serial.speed = 57600; - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits= 1; - gp_port_set_settings (camera->port, settings); - - res = barbie_ping (camera->port); - if (res) - return (GP_OK); - return (GP_ERROR); + settings.serial.speed = 57600; + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits= 1; + gp_port_set_settings (camera->port, settings); + + res = barbie_ping (camera->port); + if (res) + return (GP_OK); + return (GP_ERROR); } diff --git a/camlibs/canon/canon.h b/camlibs/canon/canon.h index 9e58256bcb..8f9c470aff 100644 --- a/camlibs/canon/canon.h +++ b/camlibs/canon/canon.h @@ -513,8 +513,7 @@ struct _CameraPrivateLibrary int remote_control; /* is the camera currently under USB control? */ - canonCaptureSizeClass capture_size; /* Size class for remote- - captured images */ + canonCaptureSizeClass capture_size; /* Size class for remote-captured images */ unsigned int body_id; /* hardware serial number for some cameras */ diff --git a/camlibs/canon/library.c b/camlibs/canon/library.c index 5e57653c14..dc89b49963 100644 --- a/camlibs/canon/library.c +++ b/camlibs/canon/library.c @@ -78,8 +78,8 @@ extern long int timezone; static const struct canonCaptureSizeClassStruct captureSizeArray[] = { {CAPTURE_COMPATIBILITY, N_("Compatibility Mode")}, - {CAPTURE_THUMB, N_("Thumbnail")}, - {CAPTURE_FULL_IMAGE, N_("Full Image")}, + {CAPTURE_THUMB, N_("Thumbnail")}, + {CAPTURE_FULL_IMAGE, N_("Full Image")}, {0, NULL} }; @@ -103,62 +103,62 @@ static const struct canonIsoStateStruct isoStateArray[] = { }; static const struct canonShutterSpeedStateStruct shutterSpeedStateArray[] = { - {SHUTTER_SPEED_BULB, N_("Bulb")}, - {SHUTTER_SPEED_30_SEC,"30"}, - {SHUTTER_SPEED_25_SEC,"25"}, - {SHUTTER_SPEED_20_SEC,"20"}, - {SHUTTER_SPEED_15_SEC,"15"}, - {SHUTTER_SPEED_13_SEC,"13"}, - {SHUTTER_SPEED_10_SEC,"10"}, - {SHUTTER_SPEED_8_SEC,"8"}, - {SHUTTER_SPEED_6_SEC,"6"}, - {SHUTTER_SPEED_5_SEC,"5"}, - {SHUTTER_SPEED_4_SEC,"4"}, - {SHUTTER_SPEED_3_2_SEC,"3.2"}, - {SHUTTER_SPEED_2_5_SEC,"2.5"}, - {SHUTTER_SPEED_2_SEC,"2"}, - {SHUTTER_SPEED_1_6_SEC,"1.6"}, - {SHUTTER_SPEED_1_3_SEC,"1.3"}, - {SHUTTER_SPEED_1_SEC,"1"}, + {SHUTTER_SPEED_BULB, N_("Bulb")}, + {SHUTTER_SPEED_30_SEC,"30"}, + {SHUTTER_SPEED_25_SEC,"25"}, + {SHUTTER_SPEED_20_SEC,"20"}, + {SHUTTER_SPEED_15_SEC,"15"}, + {SHUTTER_SPEED_13_SEC,"13"}, + {SHUTTER_SPEED_10_SEC,"10"}, + {SHUTTER_SPEED_8_SEC,"8"}, + {SHUTTER_SPEED_6_SEC,"6"}, + {SHUTTER_SPEED_5_SEC,"5"}, + {SHUTTER_SPEED_4_SEC,"4"}, + {SHUTTER_SPEED_3_2_SEC,"3.2"}, + {SHUTTER_SPEED_2_5_SEC,"2.5"}, + {SHUTTER_SPEED_2_SEC,"2"}, + {SHUTTER_SPEED_1_6_SEC,"1.6"}, + {SHUTTER_SPEED_1_3_SEC,"1.3"}, + {SHUTTER_SPEED_1_SEC,"1"}, {SHUTTER_SPEED_0_8_SEC,"0.8"}, {SHUTTER_SPEED_0_6_SEC,"0.6"}, {SHUTTER_SPEED_0_5_SEC,"0.5"}, {SHUTTER_SPEED_0_4_SEC,"0.4"}, {SHUTTER_SPEED_0_3_SEC,"0.3"}, - {SHUTTER_SPEED_1_4,"1/4"}, - {SHUTTER_SPEED_1_5,"1/5"}, - {SHUTTER_SPEED_1_6,"1/6"}, - {SHUTTER_SPEED_1_8,"1/8"}, - {SHUTTER_SPEED_1_10,"1/10"}, - {SHUTTER_SPEED_1_13,"1/13"}, - {SHUTTER_SPEED_1_15,"1/15"}, - {SHUTTER_SPEED_1_20,"1/20"}, - {SHUTTER_SPEED_1_25,"1/25"}, - {SHUTTER_SPEED_1_30,"1/30"}, - {SHUTTER_SPEED_1_40,"1/40"}, - {SHUTTER_SPEED_1_50,"1/50"}, - {SHUTTER_SPEED_1_60,"1/60"}, - {SHUTTER_SPEED_1_80,"1/80"}, - {SHUTTER_SPEED_1_100,"1/100"}, - {SHUTTER_SPEED_1_125,"1/125"}, - {SHUTTER_SPEED_1_160,"1/160"}, - {SHUTTER_SPEED_1_200,"1/200"}, - {SHUTTER_SPEED_1_250,"1/250"}, - {SHUTTER_SPEED_1_320,"1/320"}, - {SHUTTER_SPEED_1_400,"1/400"}, - {SHUTTER_SPEED_1_500,"1/500"}, - {SHUTTER_SPEED_1_640,"1/640"}, - {SHUTTER_SPEED_1_800,"1/800"}, - {SHUTTER_SPEED_1_1000,"1/1000"}, - {SHUTTER_SPEED_1_1250,"1/1250"}, - {SHUTTER_SPEED_1_1600,"1/1600"}, - {SHUTTER_SPEED_1_2000,"1/2000"}, - {SHUTTER_SPEED_1_2500,"1/2500"}, - {SHUTTER_SPEED_1_3200,"1/3200"}, - {SHUTTER_SPEED_1_4000,"1/4000"}, - {SHUTTER_SPEED_1_5000,"1/5000"}, - {SHUTTER_SPEED_1_6400,"1/6400"}, - {SHUTTER_SPEED_1_8000,"1/8000"}, + {SHUTTER_SPEED_1_4,"1/4"}, + {SHUTTER_SPEED_1_5,"1/5"}, + {SHUTTER_SPEED_1_6,"1/6"}, + {SHUTTER_SPEED_1_8,"1/8"}, + {SHUTTER_SPEED_1_10,"1/10"}, + {SHUTTER_SPEED_1_13,"1/13"}, + {SHUTTER_SPEED_1_15,"1/15"}, + {SHUTTER_SPEED_1_20,"1/20"}, + {SHUTTER_SPEED_1_25,"1/25"}, + {SHUTTER_SPEED_1_30,"1/30"}, + {SHUTTER_SPEED_1_40,"1/40"}, + {SHUTTER_SPEED_1_50,"1/50"}, + {SHUTTER_SPEED_1_60,"1/60"}, + {SHUTTER_SPEED_1_80,"1/80"}, + {SHUTTER_SPEED_1_100,"1/100"}, + {SHUTTER_SPEED_1_125,"1/125"}, + {SHUTTER_SPEED_1_160,"1/160"}, + {SHUTTER_SPEED_1_200,"1/200"}, + {SHUTTER_SPEED_1_250,"1/250"}, + {SHUTTER_SPEED_1_320,"1/320"}, + {SHUTTER_SPEED_1_400,"1/400"}, + {SHUTTER_SPEED_1_500,"1/500"}, + {SHUTTER_SPEED_1_640,"1/640"}, + {SHUTTER_SPEED_1_800,"1/800"}, + {SHUTTER_SPEED_1_1000,"1/1000"}, + {SHUTTER_SPEED_1_1250,"1/1250"}, + {SHUTTER_SPEED_1_1600,"1/1600"}, + {SHUTTER_SPEED_1_2000,"1/2000"}, + {SHUTTER_SPEED_1_2500,"1/2500"}, + {SHUTTER_SPEED_1_3200,"1/3200"}, + {SHUTTER_SPEED_1_4000,"1/4000"}, + {SHUTTER_SPEED_1_5000,"1/5000"}, + {SHUTTER_SPEED_1_6400,"1/6400"}, + {SHUTTER_SPEED_1_8000,"1/8000"}, {0, NULL}, }; @@ -196,10 +196,10 @@ static const struct canonApertureStateStruct apertureStateArray[] = { }; static const struct canonFocusModeStateStruct focusModeStateArray[] = { - {AUTO_FOCUS_ONE_SHOT, N_("Auto focus: one-shot")}, - {AUTO_FOCUS_AI_SERVO, N_("Auto focus: AI servo")}, - {AUTO_FOCUS_AI_FOCUS, N_("Auto focus: AI focus")}, - {MANUAL_FOCUS, N_("Manual focus")}, + {AUTO_FOCUS_ONE_SHOT, N_("Auto focus: one-shot")}, + {AUTO_FOCUS_AI_SERVO, N_("Auto focus: AI servo")}, + {AUTO_FOCUS_AI_FOCUS, N_("Auto focus: AI focus")}, + {MANUAL_FOCUS, N_("Manual focus")}, {0, NULL}, }; @@ -1200,46 +1200,45 @@ get_last_file (Camera *camera, char *directory, char *destname, int t; GP_DEBUG ("get_last_file()"); - if(directory[1] == ':') { - /* gp_file_list_folder() needs absolute filenames - starting with '/' */ - GP_DEBUG ("get_last_file(): replacing '%c:%c' by '/'", - directory[0], directory[2]); - sprintf(dir2, "/%s", &directory[3]); - directory = dir2; + if (directory[1] == ':') { + /* gp_file_list_folder() needs absolute filenames + starting with '/' */ + GP_DEBUG ("get_last_file(): replacing '%c:%c' by '/'", + directory[0], directory[2]); + sprintf(dir2, "/%s", &directory[3]); + directory = dir2; } gp_list_new(&list); - if(getdirectory) { - CHECK_RESULT (gp_filesystem_list_folders (fs, directory, list, context)); - GP_DEBUG ("get_last_file(): %d folders", list->count); - } - else { - CHECK_RESULT (gp_filesystem_list_files (fs, directory, list, context)); - GP_DEBUG ("get_last_file(): %d files", list->count); + if (getdirectory) { + CHECK_RESULT (gp_filesystem_list_folders (fs, directory, list, context)); + GP_DEBUG ("get_last_file(): %d folders", list->count); + } else { + CHECK_RESULT (gp_filesystem_list_files (fs, directory, list, context)); + GP_DEBUG ("get_last_file(): %d files", list->count); } - for(t=0;tcount;t++) + for (t=0;tcount;t++) { - char* name = list->entry[t].name; - if(getdirectory) - GP_DEBUG ("get_last_file(): folder: %s", name); - else - GP_DEBUG ("get_last_file(): file: %s", name); - - /* we search only for directories of the form [0-9]{3}CANON... */ - if(getdirectory && ((strlen (name)!=8) || - (!isdigit(name[0]) || - !isdigit(name[1]) || - !isdigit(name[2])) || strcmp(&name[3],"CANON"))) - continue; - - /* ...and only for files similar to AUT_[0-9]{4} */ - if(!getdirectory && (!isdigit(name[6]) || - !isdigit(name[7]))) - continue; - - if(!result[0] || strcmp((list->entry[t].name)+4, result+4) > 0) - strcpy(result, list->entry[t].name); + char* name = list->entry[t].name; + if (getdirectory) + GP_DEBUG ("get_last_file(): folder: %s", name); + else + GP_DEBUG ("get_last_file(): file: %s", name); + + /* we search only for directories of the form [0-9]{3}CANON... */ + if (getdirectory && ((strlen (name)!=8) || + (!isdigit(name[0]) || + !isdigit(name[1]) || + !isdigit(name[2])) || strcmp(&name[3], "CANON"))) + continue; + + /* ...and only for files similar to AUT_[0-9]{4} */ + if (!getdirectory && (!isdigit(name[6]) || + !isdigit(name[7]))) + continue; + + if (!result[0] || strcmp((list->entry[t].name)+4, result+4) > 0) + strcpy(result, list->entry[t].name); } gp_list_free(list); @@ -1692,7 +1691,7 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) /* DSLRs have only "Manual" Zoom */ - if ( camera->pl->md->id_str && !strstr(camera->pl->md->id_str,"EOS") && !strstr(camera->pl->md->id_str,"Rebel")) { + if (camera->pl->md->id_str && !strstr(camera->pl->md->id_str, "EOS") && !strstr(camera->pl->md->id_str, "Rebel")) { /* Zoom level */ gp_widget_new (GP_WIDGET_RANGE, _("Zoom"), &t); gp_widget_set_name (t, "zoom"); @@ -1902,7 +1901,7 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) res = canon_int_get_time (camera, &camtime, context); if (res == GP_OK) { strftime (formatted_camera_time, sizeof (formatted_camera_time), - "%Y-%m-%d %H:%M:%S", gmtime (&camtime)); + "%Y-%m-%d %H:%M:%S", gmtime (&camtime)); gp_widget_set_value (t, formatted_camera_time); } else { gp_widget_set_value (t, _("Error")); @@ -1974,7 +1973,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Owner Name"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -1988,7 +1987,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Capture Size Class"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); i = 0; @@ -2006,7 +2005,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) } - /* Enable remote control, if not already enabled */ + /* Enable remote control, if not already enabled */ if (!camera->pl->remote_control) { res = canon_int_start_remote_control (camera, context); if (res != GP_OK) @@ -2015,7 +2014,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("ISO Speed"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2045,7 +2044,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Shooting mode"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2075,7 +2074,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Shutter Speed"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2104,7 +2103,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Aperture"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2134,7 +2133,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) if (gp_widget_changed (w)) { unsigned char expbias; - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2163,7 +2162,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Image Format"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2192,7 +2191,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Focus Mode"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2222,7 +2221,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) /* Beep */ gp_widget_get_child_by_label (window, _("Beep"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2251,13 +2250,13 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) /* DSLRs have only "Manual" Zoom */ - if ( camera->pl->md->id_str && !strstr(camera->pl->md->id_str,"EOS") && !strstr(camera->pl->md->id_str,"Rebel")) { + if (camera->pl->md->id_str && !strstr(camera->pl->md->id_str, "EOS") && !strstr(camera->pl->md->id_str, "Rebel")) { /* Zoom */ gp_widget_get_child_by_label (window, _("Zoom"), &w); if (gp_widget_changed (w)) { float zoom; - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &zoom); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2273,7 +2272,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) /* Aperture */ gp_widget_get_child_by_label (window, _("Aperture"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2303,7 +2302,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) /* Flash mode */ gp_widget_get_child_by_label (window, _("Flash Mode"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2333,7 +2332,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Synchronize camera date and time with PC"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (!check_readiness (camera, context)) { gp_context_status (context, _("Camera unavailable")); @@ -2349,7 +2348,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("List all files"), &w); if (gp_widget_changed (w)) { /* XXXXX mark CameraFS as dirty */ - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &val); camera->pl->list_all_files = val; sprintf (str, "%d", val); @@ -2362,7 +2361,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) #ifdef CANON_EXPERIMENTAL_UPLOAD gp_widget_get_child_by_label (window, _("Keep filename on upload"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &camera->pl->upload_keep_filename); GP_DEBUG ("New config value for \"Keep filename on upload\": %i", camera->pl->upload_keep_filename); diff --git a/camlibs/casio/casio-qv-commands.c b/camlibs/casio/casio-qv-commands.c index cf9972452c..bf77339a15 100644 --- a/camlibs/casio/casio-qv-commands.c +++ b/camlibs/casio/casio-qv-commands.c @@ -269,8 +269,8 @@ QVpicattr (Camera *camera, int n, unsigned char *picattr) cmd[0] = 'D'; cmd[1] = 'Y'; - cmd[2] = STX; - cmd[3] = n+1; + cmd[2] = STX; + cmd[3] = n+1; CR (QVsend (camera, cmd, 4, &b, 1)); *picattr = b; @@ -386,33 +386,33 @@ QVcapture (Camera *camera) int QVstatus (Camera *camera, char *status) { - unsigned char cmd[3]; + unsigned char cmd[3]; - cmd[0] = 'D'; - cmd[1] = 'S'; - cmd[2] = STX; - CR (QVsend (camera, cmd, 3, (unsigned char *)status, 2)); + cmd[0] = 'D'; + cmd[1] = 'S'; + cmd[2] = STX; + CR (QVsend (camera, cmd, 3, (unsigned char *)status, 2)); - return (GP_OK); + return (GP_OK); } int QVreset (Camera *camera) { - unsigned char cmd[2]; + unsigned char cmd[2]; cmd[0] = 'Q'; cmd[1] = 'R'; CR (QVsend (camera, cmd, 2, NULL, 0)); - return (GP_OK); + return (GP_OK); } int QVsetspeed (Camera *camera, int speed) { unsigned char cmd[3]; - gp_port_settings settings; + gp_port_settings settings; cmd[0] = 'C'; cmd[1] = 'B'; @@ -426,9 +426,9 @@ QVsetspeed (Camera *camera, int speed) } CR (QVsend (camera, cmd, 3, NULL, 0)); - CR (gp_port_get_settings (camera->port, &settings)); - settings.serial.speed = speed; - CR (gp_port_set_settings (camera->port, settings)); + CR (gp_port_get_settings (camera->port, &settings)); + settings.serial.speed = speed; + CR (gp_port_set_settings (camera->port, settings)); CR (QVping (camera)); diff --git a/camlibs/casio/casio-qv.c b/camlibs/casio/casio-qv.c index c659aeb1e2..07ddf9b16a 100644 --- a/camlibs/casio/casio-qv.c +++ b/camlibs/casio/casio-qv.c @@ -111,8 +111,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, long int camSize = 0; /* Get the number of the picture from the filesystem */ - CHECK_RESULT (n = gp_filesystem_number (camera->fs, folder, filename, - context)); + CHECK_RESULT (n = gp_filesystem_number (camera->fs, folder, filename, context)); /* Prepare the transaction */ CHECK_RESULT (QVpicattr (camera, n, &attr)); @@ -149,25 +148,24 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context) { - Camera *camera = data; - int nr ; + Camera *camera = data; + int nr ; CameraFileInfo info; - nr = gp_filesystem_number(fs, folder, filename, context); - if (nr < 0) - return nr; + nr = gp_filesystem_number(fs, folder, filename, context); + if (nr < 0) + return nr; CHECK_RESULT (get_info_func(fs, folder, filename, &info, data, context)); - if (info.file.permissions == GP_FILE_PERM_READ) { - gp_context_error(context, _("Image %s is delete protected."), - filename); - return (GP_ERROR); - } + if (info.file.permissions == GP_FILE_PERM_READ) { + gp_context_error(context, _("Image %s is delete protected."), filename); + return (GP_ERROR); + } CHECK_RESULT (QVdelete (camera, nr)); - return GP_OK; + return GP_OK; } static int @@ -234,10 +232,10 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *file, info->preview.size = size_thumb; CHECK_RESULT (QVpicattr (camera, n, &attr)); - if (attr&1) - info->file.permissions = GP_FILE_PERM_READ; - else - info->file.permissions = GP_FILE_PERM_ALL; + if (attr&1) + info->file.permissions = GP_FILE_PERM_READ; + else + info->file.permissions = GP_FILE_PERM_ALL; return (GP_OK); } @@ -245,33 +243,33 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *file, static int camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) { - CameraWidget *child; - float battery; + CameraWidget *child; + float battery; char status[2]; - char t[1024]; + char t[1024]; - gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); + gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); - CHECK_RESULT (QVbattery (camera, &battery)); + CHECK_RESULT (QVbattery (camera, &battery)); gp_widget_new (GP_WIDGET_TEXT, _("Battery"), &child); - gp_widget_set_name (child, "battery"); - snprintf(t,sizeof(t),"%.1f V",battery); + gp_widget_set_name (child, "battery"); + snprintf(t,sizeof(t),"%.1f V",battery); gp_widget_set_value (child, t); - gp_widget_append (*window, child); + gp_widget_append (*window, child); CHECK_RESULT (QVstatus (camera, status)); gp_widget_new (GP_WIDGET_RADIO, _("Brightness"), &child); - gp_widget_set_name (child, "brightness"); - gp_widget_add_choice (child, _("Too bright")); - gp_widget_add_choice (child, _("Too dark")); - gp_widget_add_choice (child, _("OK")); - if (status[0]&0x80) strcpy (t, _("Too bright")); - else if (status[0]&0x40) strcpy (t, _("Too dark")); + gp_widget_set_name (child, "brightness"); + gp_widget_add_choice (child, _("Too bright")); + gp_widget_add_choice (child, _("Too dark")); + gp_widget_add_choice (child, _("OK")); + if (status[0]&0x80) strcpy (t, _("Too bright")); + else if (status[0]&0x40) strcpy (t, _("Too dark")); else strcpy (t, _("OK")); - gp_widget_set_value (child, t); - gp_widget_append (*window, child); + gp_widget_set_value (child, t); + gp_widget_append (*window, child); - return (GP_OK); + return (GP_OK); } static int @@ -321,12 +319,12 @@ camera_init (Camera *camera, GPContext *context) gp_port_settings settings; int selected_speed; - /* First, set up all the function pointers */ - camera->functions->get_config = camera_config_get; + /* First, set up all the function pointers */ + camera->functions->get_config = camera_config_get; camera->functions->capture = camera_capture; camera->functions->summary = camera_summary; camera->functions->exit = camera_exit; - camera->functions->about = camera_about; + camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); diff --git a/camlibs/clicksmart310/clicksmart.c b/camlibs/clicksmart310/clicksmart.c index b2caa02fcb..17371209b7 100644 --- a/camlibs/clicksmart310/clicksmart.c +++ b/camlibs/clicksmart310/clicksmart.c @@ -148,10 +148,10 @@ clicksmart_read_pic_data (CameraPrivateLibrary *priv, GPPort *port, gp_port_usb_msg_interface_write(port, 6, 0x1fff - n, 1, NULL, 0); c = 0; - while (c != 1){ - int r; - if ((r = CLICKSMART_READ_STATUS (port, &c)) < GP_OK) - return r; + while (c != 1) { + int r; + if ((r = CLICKSMART_READ_STATUS (port, &c)) < GP_OK) + return r; } /* Get the size of the data and calculate the size to download, which * is the next multiple of 0x100. Only for the hi-res photos is the @@ -160,9 +160,9 @@ clicksmart_read_pic_data (CameraPrivateLibrary *priv, GPPort *port, size=(priv->catalog[16*n + 12] * 0x100)+(priv->catalog[16*n + 11]); if (size == 0) /* for lo-res photos the above calculation gives 0 */ - size = (priv->catalog[16*n + 5] * 0x100); + size = (priv->catalog[16*n + 5] * 0x100); if (size == 0) /* this means data corruption */ - return GP_ERROR; + return GP_ERROR; remainder = size%0x200; @@ -171,10 +171,10 @@ clicksmart_read_pic_data (CameraPrivateLibrary *priv, GPPort *port, if (!*data) return GP_ERROR; /* Download the data */ while (offset < size-remainder) { - GP_DEBUG("offset: %x\n", offset); - if (gp_port_read(port, (char *)*data + offset, 0x200) < GP_OK) - break; - offset = offset + 0x200; + GP_DEBUG("offset: %x\n", offset); + if (gp_port_read(port, (char *)*data + offset, 0x200) < GP_OK) + break; + offset = offset + 0x200; } remainder=((remainder+0xff)/0x100)*0x100; @@ -215,7 +215,7 @@ clicksmart_reset (GPPort *port) gp_port_usb_msg_interface_write(port, 0, 2, CS_CH_READY, NULL, 0); CLICKSMART_READ (port, CS_CH_CLEAR, &c); CLICKSMART_READ (port, CS_CH_CLEAR, &c); - return GP_OK; + return GP_OK; } /* create_jpeg_from_data adapted from camlibs/spca50x */ @@ -223,7 +223,7 @@ clicksmart_reset (GPPort *port) int create_jpeg_from_data (unsigned char * dst, unsigned char * src, int qIndex, int w, int h, unsigned char format, int o_size, int *size, - int omit_huffman_table, int omit_escape) + int omit_huffman_table, int omit_escape) { int i = 0; unsigned char *start; @@ -241,9 +241,9 @@ int create_jpeg_from_data (unsigned char * dst, unsigned char * src, /* copy Huffman table */ if (!omit_huffman_table) { - memcpy (dst, SPCA50xJPGDefaultHeaderPart2, - SPCA50X_JPG_DEFAULT_HEADER_PART2_LENGTH); - dst += SPCA50X_JPG_DEFAULT_HEADER_PART2_LENGTH; + memcpy (dst, SPCA50xJPGDefaultHeaderPart2, + SPCA50X_JPG_DEFAULT_HEADER_PART2_LENGTH); + dst += SPCA50X_JPG_DEFAULT_HEADER_PART2_LENGTH; } memcpy (dst, SPCA50xJPGDefaultHeaderPart3, SPCA50X_JPG_DEFAULT_HEADER_PART3_LENGTH); diff --git a/camlibs/clicksmart310/library.c b/camlibs/clicksmart310/library.c index 6654c53846..e4d9272246 100644 --- a/camlibs/clicksmart310/library.c +++ b/camlibs/clicksmart310/library.c @@ -48,59 +48,59 @@ #define GP_MODULE "clicksmart310" static const struct { - char *name; + char *name; CameraDriverStatus status; - unsigned short idVendor; - unsigned short idProduct; + unsigned short idVendor; + unsigned short idProduct; } models[] = { - {"Logitech Clicksmart 310", GP_DRIVER_STATUS_TESTING, 0x46d, 0x0900}, + {"Logitech Clicksmart 310", GP_DRIVER_STATUS_TESTING, 0x46d, 0x0900}, {NULL,0,0,0} }; int camera_id (CameraText *id) { - strcpy (id->text, "Logitech Clicksmart 310"); + strcpy (id->text, "Logitech Clicksmart 310"); - return GP_OK; + return GP_OK; } int camera_abilities (CameraAbilitiesList *list) { - int i; - CameraAbilities a; - - for (i = 0; models[i].name; i++) { - memset (&a, 0, sizeof(a)); - strcpy (a.model, models[i].name); - a.status = models[i].status; - a.port = GP_PORT_USB; - a.speed[0] = 0; - a.usb_vendor = models[i].idVendor; - a.usb_product= models[i].idProduct; + int i; + CameraAbilities a; + + for (i = 0; models[i].name; i++) { + memset (&a, 0, sizeof(a)); + strcpy (a.model, models[i].name); + a.status = models[i].status; + a.port = GP_PORT_USB; + a.speed[0] = 0; + a.usb_vendor = models[i].idVendor; + a.usb_product= models[i].idProduct; a.operations = GP_OPERATION_NONE; - a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; -; + a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; + ; a.file_operations = GP_FILE_OPERATION_PREVIEW - + GP_FILE_OPERATION_RAW; - gp_abilities_list_append (list, a); - } + + GP_FILE_OPERATION_RAW; + gp_abilities_list_append (list, a); + } - return GP_OK; + return GP_OK; } static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { - sprintf (summary->text,ngettext( + sprintf (summary->text, ngettext( "Your Logitech Clicksmart 310 has %i picture in it.\n", "Your Logitech Clicksmart 310 has %i pictures in it.\n", camera->pl->num_pics ), camera->pl->num_pics); - return GP_OK; + return GP_OK; } @@ -135,10 +135,10 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("Logitech Clicksmart 310 driver\n" + strcpy (about->text, _("Logitech Clicksmart 310 driver\n" "Theodore Kilgore \n")); - return GP_OK; + return GP_OK; } /*************** File and Downloading Functions *******************/ @@ -148,10 +148,10 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; int n; GP_DEBUG ("List files in %s\n", folder); - n = camera->pl->num_pics; + n = camera->pl->num_pics; gp_list_populate(list, "cs%03i.jpeg", n); return GP_OK; } @@ -162,7 +162,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *user_data, GPContext *context) { - Camera *camera = user_data; + Camera *camera = user_data; int w=0, h=0, b=0; int k, res; unsigned char *data; @@ -171,7 +171,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, unsigned char jpeg_format; /* Get the entry number of the photo on the camera */ - k = gp_filesystem_number (camera->fs, "/", filename, context); + k = gp_filesystem_number (camera->fs, "/", filename, context); if (GP_FILE_TYPE_EXIF==type) return GP_ERROR_FILE_EXISTS; @@ -180,7 +180,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, res = clicksmart_get_res_setting (camera->pl, k); - switch (res) { + switch (res) { case 0: w = 352; h = 288; jpeg_format = JPEG_CIF_FORMAT; @@ -202,10 +202,10 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, if (GP_FILE_TYPE_RAW == type) { /* type is GP_FILE_TYPE_RAW */ gp_file_set_mime_type (file, GP_MIME_RAW); - gp_file_set_data_and_size (file, (char *)data, b); + gp_file_set_data_and_size (file, (char *)data, b); /* Reset camera when done, for more graceful exit. */ if (k +1 == camera->pl->num_pics) { - clicksmart_reset (camera->port); + clicksmart_reset (camera->port); } return GP_OK; } @@ -225,13 +225,13 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, GP_DEBUG("width: %d, height: %d, data size: %d\n", w, h, b); create_jpeg_from_data (jpeg_out, data, 3, w, h, jpeg_format, - b, &file_size, 0, 0); + b, &file_size, 0, 0); gp_file_set_mime_type (file, GP_MIME_JPEG); gp_file_set_data_and_size (file, (char *)jpeg_out, file_size); /* Reset camera when done, for more graceful exit. */ if (k +1 == camera->pl->num_pics) { - clicksmart_reset (camera->port); + clicksmart_reset (camera->port); } free(data); return GP_OK; @@ -276,10 +276,10 @@ camera_init(Camera *camera, GPContext *context) int ret = 0; /* First, set up all the function pointers */ - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; - camera->functions->exit = camera_exit; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; + camera->functions->exit = camera_exit; GP_DEBUG ("Initializing the camera\n"); @@ -303,7 +303,7 @@ camera_init(Camera *camera, GPContext *context) ret = gp_port_set_settings(camera->port,settings); if (ret < 0) return ret; - /* Tell the CameraFilesystem where to get lists from */ + /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) return GP_ERROR_NO_MEMORY; diff --git a/camlibs/digigr8/digi_postprocess.c b/camlibs/digigr8/digi_postprocess.c index 5c78191516..12693a6c37 100644 --- a/camlibs/digigr8/digi_postprocess.c +++ b/camlibs/digigr8/digi_postprocess.c @@ -53,18 +53,18 @@ digi_first_decompress (unsigned char *output, unsigned char *input, unsigned int bit_counter = 8; unsigned int cycles = 0; int table[9] = { -1, 0, 2, 6, 0x0e, 0x0e, 0x0e, 0x0e, 0xfb}; - unsigned char lookup_table[16] - ={0, 2, 6, 0x0e, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, - 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb}; + unsigned char lookup_table[16] = + {0, 2, 6, 0x0e, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, + 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb}; unsigned char translator[16] = - {8, 7, 9, 6, 10, 11, 12, 13, 14, 15, 5, 4, 3, 2, 1, 0}; + {8, 7, 9, 6, 10, 11, 12, 13, 14, 15, 5, 4, 3, 2, 1, 0}; GP_DEBUG ("Running first_decompress.\n"); nibble_to_keep[0] = 0; nibble_to_keep[1] = 0; - while (bytes_done < outputsize) { - while (parity < 2 ) { + while (bytes_done < outputsize) { + while (parity < 2 ) { while ( lookup > table[cycles]) { if (bit_counter == 8) { input_byte = input[bytes_used]; diff --git a/camlibs/digigr8/library.c b/camlibs/digigr8/library.c index 1bbcbca394..6b0f7a486a 100644 --- a/camlibs/digigr8/library.c +++ b/camlibs/digigr8/library.c @@ -357,8 +357,7 @@ camera_capture_preview(Camera *camera, CameraFile *file, GPContext *context) gp_port_read(camera->port, (char *)get_size, 0x50); GP_DEBUG("get_size[0x40] = 0x%x\n", get_size[0x40]); lighting = get_size[0x48]; - b = get_size[0x40] | get_size[0x41] << 8 | get_size[0x42] << 16 - | get_size[0x43]<<24; + b = get_size[0x40] | get_size[0x41] << 8 | get_size[0x42] << 16 | get_size[0x43]<<24; GP_DEBUG("b = 0x%x\n", b); raw_data = malloc(b); @@ -393,7 +392,7 @@ camera_capture_preview(Camera *camera, CameraFile *file, GPContext *context) GP_DEBUG ("size = %i\n", size); gp_ahd_decode (frame_data, w , h , ptr, BAYER_TILE_BGGR); free(frame_data); - if (lighting < 0x40) { + if (lighting < 0x40) { GP_DEBUG( "Low light condition. Default gamma. No white balance.\n"); gp_gamma_fill_table (gtable, .65); @@ -441,7 +440,7 @@ camera_init(Camera *camera, GPContext *context) /* Now, set up all the function pointers */ camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; + camera->functions->manual = camera_manual; camera->functions->about = camera_about; camera->functions->capture_preview = camera_capture_preview; diff --git a/camlibs/digita/digita.c b/camlibs/digita/digita.c index 78e8910bbd..f090085adb 100644 --- a/camlibs/digita/digita.c +++ b/camlibs/digita/digita.c @@ -313,7 +313,7 @@ static int get_file_func(CameraFilesystem *fs, const char *folder, switch (type) { case GP_FILE_TYPE_NORMAL: GP_DEBUG("digita/get_file_func: Getting picture"); - data = digita_file_get(camera, folder, filename, 0, &buflen, context); + data = digita_file_get(camera, folder, filename, 0, &buflen, context); break; case GP_FILE_TYPE_PREVIEW: GP_DEBUG("digita/get_file_func: Getting thumbnail"); @@ -407,18 +407,18 @@ static int digita_file_delete(Camera *camera, const char *folder, if (digita_get_file_list(camera->pl) < 0) return 0; - return GP_OK; + return GP_OK; } static int delete_file_func(CameraFilesystem *fs, const char *folder, const char *filename, void *user_data, GPContext *context) { - Camera *camera = user_data; + Camera *camera = user_data; if (folder[0] == '/') folder++; - return digita_file_delete(camera, folder, filename, context); + return digita_file_delete(camera, folder, filename, context); } static CameraFilesystemFuncs fsfuncs = { diff --git a/camlibs/dimera/dimera3500.c b/camlibs/dimera/dimera3500.c index 87660ce115..9e0fe04d1a 100644 --- a/camlibs/dimera/dimera3500.c +++ b/camlibs/dimera/dimera3500.c @@ -82,17 +82,17 @@ Dimera_Preview( long *size, Camera *camera, GPContext *context ); /* Gphoto2 */ struct _CameraPrivateLibrary { - unsigned exposure; - int auto_exposure; - int auto_flash; + unsigned exposure; + int auto_exposure; + int auto_flash; }; static const char *models[] = { - "Mustek:VDC-3500", - "Relisys:Dimera 3500", - "Trust:DC-3500", - NULL + "Mustek:VDC-3500", + "Relisys:Dimera 3500", + "Trust:DC-3500", + NULL }; @@ -376,14 +376,14 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat } static int camera_capture_preview(Camera *camera, CameraFile *file, GPContext *context) { - long size; + long size; uint8_t *data; gp_file_set_mime_type (file, GP_MIME_PGM); - data = Dimera_Preview( &size, camera, context); - if (!data) - return GP_ERROR; + data = Dimera_Preview (&size, camera, context); + if (!data) + return GP_ERROR; return gp_file_set_data_and_size (file, (char *)data, size); } @@ -860,7 +860,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Exposure level on preview"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); camera->pl->exposure = MAX(MIN_EXPOSURE,MIN(MAX_EXPOSURE,atoi(wvalue))); gp_setting_set ("dimera3500", "exposure", wvalue); @@ -869,7 +869,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Automatic exposure adjustment on preview"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &val); camera->pl->auto_exposure = val; sprintf(str, "%d", val); @@ -879,7 +879,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Automatic flash on capture"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &val); camera->pl->auto_flash = val; sprintf(str, "%d", val); @@ -901,18 +901,18 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; - int ret, selected_speed; - char buf[1024]; - - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->capture = camera_capture; - camera->functions->capture_preview = camera_capture_preview; - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; - camera->functions->get_config = camera_get_config; - camera->functions->set_config = camera_set_config; + int ret, selected_speed; + char buf[1024]; + + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->capture = camera_capture; + camera->functions->capture_preview = camera_capture_preview; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; + camera->functions->get_config = camera_get_config; + camera->functions->set_config = camera_set_config; /* Get the settings and remember the selected speed */ gp_port_get_settings (camera->port, &settings); @@ -926,77 +926,77 @@ int camera_init (Camera *camera, GPContext *context) { return (GP_ERROR_NO_MEMORY); } - /* Set the default exposure */ - if (gp_setting_get ("dimera3500", "exposure", buf) == GP_OK) - camera->pl->exposure = atoi(buf); - else - camera->pl->exposure = DEFAULT_EXPOSURE; - - /* Set automatic exposure enable setting for capture preview mode */ - if (gp_setting_get ("dimera3500", "auto_exposure", buf) == GP_OK) - camera->pl->auto_exposure = atoi(buf); - else - camera->pl->auto_exposure = 1; - - /* Set flag to use flash, if necessary, when capturing picture */ - if (gp_setting_get ("dimera3500", "auto_flash", buf) == GP_OK) - camera->pl->auto_flash = atoi(buf); - else - camera->pl->auto_flash = 1; - - GP_DEBUG("Opening port"); - if ( (ret = mesa_port_open(camera->port)) != GP_OK) - { - gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Open Failed"); + /* Set the default exposure */ + if (gp_setting_get ("dimera3500", "exposure", buf) == GP_OK) + camera->pl->exposure = atoi(buf); + else + camera->pl->exposure = DEFAULT_EXPOSURE; + + /* Set automatic exposure enable setting for capture preview mode */ + if (gp_setting_get ("dimera3500", "auto_exposure", buf) == GP_OK) + camera->pl->auto_exposure = atoi(buf); + else + camera->pl->auto_exposure = 1; + + /* Set flag to use flash, if necessary, when capturing picture */ + if (gp_setting_get ("dimera3500", "auto_flash", buf) == GP_OK) + camera->pl->auto_flash = atoi(buf); + else + camera->pl->auto_flash = 1; + + GP_DEBUG("Opening port"); + if ((ret = mesa_port_open(camera->port)) != GP_OK) + { + gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Open Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem opening port")); - return ret; - } + return ret; + } - GP_DEBUG("Resetting camera"); - if ( (ret = mesa_reset(camera->port)) != GP_OK ) - { - gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Reset Failed"); + GP_DEBUG("Resetting camera"); + if ((ret = mesa_reset(camera->port)) != GP_OK) + { + gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Reset Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem resetting camera")); - return ret; - } + return ret; + } - GP_DEBUG("Setting speed"); - if ( (ret = mesa_set_speed(camera->port, selected_speed)) != GP_OK ) - { - gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Speed Setting Failed"); + GP_DEBUG("Setting speed"); + if ((ret = mesa_set_speed(camera->port, selected_speed)) != GP_OK) + { + gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Camera Speed Setting Failed"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Problem setting camera communication speed")); - return ret; - } + return ret; + } - GP_DEBUG("Checking for modem"); - switch ( ret = mesa_modem_check(camera->port) ) - { - case GP_ERROR_IO: - case GP_ERROR_TIMEOUT: - gp_log(GP_LOG_ERROR, "dimera/dimera3500", "No or Unknown Response"); + GP_DEBUG("Checking for modem"); + switch (ret = mesa_modem_check(camera->port)) + { + case GP_ERROR_IO: + case GP_ERROR_TIMEOUT: + gp_log(GP_LOG_ERROR, "dimera/dimera3500", "No or Unknown Response"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("No response from camera")); - return GP_ERROR_TIMEOUT; - case GP_ERROR_MODEL_NOT_FOUND: - gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Probably a modem"); + return GP_ERROR_TIMEOUT; + case GP_ERROR_MODEL_NOT_FOUND: + gp_log(GP_LOG_ERROR, "dimera/dimera3500", "Probably a modem"); free (camera->pl); camera->pl = NULL; gp_context_error (context, _("Looks like a modem, not a camera")); - return GP_ERROR_MODEL_NOT_FOUND; - case GP_OK: - break; + return GP_ERROR_MODEL_NOT_FOUND; + case GP_OK: + break; default: /* Hopefully, gp_camera_set_error was called for this error */ return ret; - } + } /* Tell the filesystem where to get listings and info from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); return (GP_OK); diff --git a/camlibs/directory/directory.c b/camlibs/directory/directory.c index c22a31fbed..790405d54f 100644 --- a/camlibs/directory/directory.c +++ b/camlibs/directory/directory.c @@ -125,60 +125,60 @@ static const char * get_mime_type (const char *filename) { - char *dot; - int x=0; + char *dot; + int x=0; - dot = strrchr(filename, '.'); - if (dot) { + dot = strrchr(filename, '.'); + if (dot) { for (x = 0; mime_table[x].extension; x++) { if (!strcasecmp (mime_table[x].extension, dot+1)) return (mime_table[x].mime_type); - } + } } - return (NULL); + return (NULL); } int camera_id (CameraText *id) { - strcpy(id->text, "directory"); + strcpy(id->text, "directory"); - return (GP_OK); + return (GP_OK); } int camera_abilities (CameraAbilitiesList *list) { - CameraAbilities a; + CameraAbilities a; memset(&a, 0, sizeof(a)); - strcpy(a.model, "Directory Browse"); + strcpy(a.model, "Directory Browse"); a.status = GP_DRIVER_STATUS_PRODUCTION; - a.port = GP_PORT_DISK; - a.speed[0] = 0; + a.port = GP_PORT_DISK; + a.speed[0] = 0; - a.operations = GP_OPERATION_NONE; + a.operations = GP_OPERATION_NONE; #ifdef DEBUG - a.file_operations = GP_FILE_OPERATION_PREVIEW | + a.file_operations = GP_FILE_OPERATION_PREVIEW | GP_FILE_OPERATION_DELETE | GP_FILE_OPERATION_EXIF; #else a.file_operations = GP_FILE_OPERATION_DELETE | GP_FILE_OPERATION_EXIF; #endif - a.folder_operations = GP_FOLDER_OPERATION_MAKE_DIR | + a.folder_operations = GP_FOLDER_OPERATION_MAKE_DIR | GP_FOLDER_OPERATION_REMOVE_DIR | GP_FOLDER_OPERATION_PUT_FILE; - gp_abilities_list_append(list, a); + gp_abilities_list_append(list, a); /* Since "Directory Browse" is hardcoded in clients, * better also add a new name here. */ - strcpy(a.model, "Mass Storage Camera"); - gp_abilities_list_append(list, a); - return (GP_OK); + strcpy(a.model, "Mass Storage Camera"); + gp_abilities_list_append(list, a); + return (GP_OK); } static int @@ -395,9 +395,9 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *file, return (GP_ERROR); } - info->preview.fields = GP_FILE_INFO_NONE; - info->file.fields = GP_FILE_INFO_SIZE | - GP_FILE_INFO_TYPE | GP_FILE_INFO_PERMISSIONS | + info->preview.fields = GP_FILE_INFO_NONE; + info->file.fields = GP_FILE_INFO_SIZE | + GP_FILE_INFO_TYPE | GP_FILE_INFO_PERMISSIONS | GP_FILE_INFO_MTIME; info->file.mtime = st.st_mtime; @@ -406,12 +406,12 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *file, info->file.permissions |= GP_FILE_PERM_READ; if (st.st_mode & S_IWUSR) info->file.permissions |= GP_FILE_PERM_DELETE; - info->file.size = st.st_size; + info->file.size = st.st_size; mime_type = get_mime_type (file); if (!mime_type) mime_type = GP_MIME_UNKNOWN; strcpy (info->file.type, mime_type); - return (GP_OK); + return (GP_OK); } static int @@ -446,10 +446,10 @@ set_info_func (CameraFilesystem *fs, const char *folder, const char *file, #if 0 /* implement this using new api -Marcus */ if (info.file.fields & GP_FILE_INFO_NAME) { - if (!strcasecmp (info.file.name, file)) - return (GP_OK); + if (!strcasecmp (info.file.name, file)) + return (GP_OK); - /* We really have to rename the poor file... */ + /* We really have to rename the poor file... */ if (strlen (folder) == 1) { snprintf (path_old, sizeof (path_old), "/%s", file); @@ -461,29 +461,29 @@ set_info_func (CameraFilesystem *fs, const char *folder, const char *file, snprintf (path_new, sizeof (path_new), "%s/%s", folder, info.file.name); } - retval = rename (path_old, path_new); + retval = rename (path_old, path_new); if (retval != 0) { - switch (errno) { - case EISDIR: - return (GP_ERROR_DIRECTORY_EXISTS); - case EEXIST: - return (GP_ERROR_FILE_EXISTS); - case EINVAL: - return (GP_ERROR_BAD_PARAMETERS); - case EIO: - return (GP_ERROR_IO); - case ENOMEM: - return (GP_ERROR_NO_MEMORY); - case ENOENT: - return (GP_ERROR_FILE_NOT_FOUND); - default: - return (GP_ERROR); - } - } + switch (errno) { + case EISDIR: + return (GP_ERROR_DIRECTORY_EXISTS); + case EEXIST: + return (GP_ERROR_FILE_EXISTS); + case EINVAL: + return (GP_ERROR_BAD_PARAMETERS); + case EIO: + return (GP_ERROR_IO); + case ENOMEM: + return (GP_ERROR_NO_MEMORY); + case ENOENT: + return (GP_ERROR_FILE_NOT_FOUND); + default: + return (GP_ERROR); + } + } } #endif - return (GP_OK); + return (GP_OK); } static int @@ -491,7 +491,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *user_data, GPContext *context) { - char path[1024]; + char path[1024]; int result = GP_OK; struct stat stbuf; int fd, id; @@ -589,19 +589,19 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) { - strcpy (manual->text, _("The Directory Browse \"camera\" lets " + strcpy (manual->text, _("The Directory Browse \"camera\" lets " "you index photos on your hard drive.")); - return (GP_OK); + return (GP_OK); } static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("Directory Browse Mode - written " + strcpy (about->text, _("Directory Browse Mode - written " "by Scott Fritzinger .")); - return (GP_OK); + return (GP_OK); } static int @@ -783,8 +783,8 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - /* First, set up all the function pointers */ - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; - return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); + /* First, set up all the function pointers */ + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; + return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); } diff --git a/camlibs/docupen/calibration.c b/camlibs/docupen/calibration.c index b6b87e8aa2..81762f0a70 100644 --- a/camlibs/docupen/calibration.c +++ b/camlibs/docupen/calibration.c @@ -110,7 +110,7 @@ bool dp_init_calibration(Camera *camera, bool force) int i, j; if (camera->pl->lut) - return true; + return true; lut_file = malloc(64 + strlen(getenv("HOME"))); if (!lut_file) diff --git a/camlibs/docupen/docupen.c b/camlibs/docupen/docupen.c index 6612cf2a0b..f1628fd98e 100644 --- a/camlibs/docupen/docupen.c +++ b/camlibs/docupen/docupen.c @@ -157,90 +157,90 @@ camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) gp_widget_new (GP_WIDGET_SECTION, _("Mono mode"), §ion); gp_widget_append (*window, section); - gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Mono (b/w)")); - gp_widget_add_choice (widget, _("Grey (4bpp)")); - gp_widget_add_choice (widget, _("Grey (8bpp)")); - switch(camera->pl->profile[0x80]) { - case 0x00: gp_widget_set_value (widget, _("Mono (b/w)")); break; - case 0x01: gp_widget_set_value (widget, _("Grey (4bpp)")); break; - case 0x02: gp_widget_set_value (widget, _("Grey (8bpp)")); break; - } - - gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("100 DPI")); - gp_widget_add_choice (widget, _("200 DPI")); - switch(camera->pl->profile[0x81]) { - case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; - case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; - } - - gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("200 DPI")); - gp_widget_add_choice (widget, _("400 DPI")); - switch(camera->pl->profile[0x82]) { - case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; - case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; - } + gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Mono (b/w)")); + gp_widget_add_choice (widget, _("Grey (4bpp)")); + gp_widget_add_choice (widget, _("Grey (8bpp)")); + switch (camera->pl->profile[0x80]) { + case 0x00: gp_widget_set_value (widget, _("Mono (b/w)")); break; + case 0x01: gp_widget_set_value (widget, _("Grey (4bpp)")); break; + case 0x02: gp_widget_set_value (widget, _("Grey (8bpp)")); break; + } + + gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("100 DPI")); + gp_widget_add_choice (widget, _("200 DPI")); + switch (camera->pl->profile[0x81]) { + case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; + case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; + } + + gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("200 DPI")); + gp_widget_add_choice (widget, _("400 DPI")); + switch (camera->pl->profile[0x82]) { + case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; + case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; + } gp_widget_new (GP_WIDGET_SECTION, _("Color Document mode"), §ion); gp_widget_append (*window, section); - gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("NQ (12bpp)")); - switch(camera->pl->profile[0x83]) { - case 0x04: gp_widget_set_value (widget, _("NQ (12bpp)")); break; - } - - gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("100 DPI")); - gp_widget_add_choice (widget, _("200 DPI")); - switch(camera->pl->profile[0x84]) { - case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; - case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; - } - - gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("200 DPI")); - gp_widget_add_choice (widget, _("400 DPI")); - switch(camera->pl->profile[0x85]) { - case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; - case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; - } + gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("NQ (12bpp)")); + switch (camera->pl->profile[0x83]) { + case 0x04: gp_widget_set_value (widget, _("NQ (12bpp)")); break; + } + + gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("100 DPI")); + gp_widget_add_choice (widget, _("200 DPI")); + switch (camera->pl->profile[0x84]) { + case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; + case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; + } + + gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("200 DPI")); + gp_widget_add_choice (widget, _("400 DPI")); + switch (camera->pl->profile[0x85]) { + case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; + case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; + } gp_widget_new (GP_WIDGET_SECTION, _("Color Photo mode"), §ion); gp_widget_append (*window, section); - gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("HQ (24bpp)")); - switch(camera->pl->profile[0x86]) { - case 0x08: gp_widget_set_value (widget, _("HQ (24bpp)")); break; - } - - gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("100 DPI")); - gp_widget_add_choice (widget, _("200 DPI")); - switch(camera->pl->profile[0x87]) { - case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; - case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; - } - - gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("200 DPI")); - gp_widget_add_choice (widget, _("400 DPI")); - switch(camera->pl->profile[0x88]) { - case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; - case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; - } + gp_widget_new (GP_WIDGET_RADIO, _("Depth"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("HQ (24bpp)")); + switch (camera->pl->profile[0x86]) { + case 0x08: gp_widget_set_value (widget, _("HQ (24bpp)")); break; + } + + gp_widget_new (GP_WIDGET_RADIO, _("Lo Resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("100 DPI")); + gp_widget_add_choice (widget, _("200 DPI")); + switch (camera->pl->profile[0x87]) { + case RES_100DPI: gp_widget_set_value (widget, _("100 DPI")); break; + case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; + } + + gp_widget_new (GP_WIDGET_RADIO, _("Hi Resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("200 DPI")); + gp_widget_add_choice (widget, _("400 DPI")); + switch (camera->pl->profile[0x88]) { + case RES_200DPI: gp_widget_set_value (widget, _("200 DPI")); break; + case RES_400DPI: gp_widget_set_value (widget, _("400 DPI")); break; + } return GP_OK; } @@ -654,12 +654,12 @@ camera_init (Camera *camera, GPContext *context) { char buf[64]; - camera->functions->exit = camera_exit; - camera->functions->get_config = camera_config_get; - camera->functions->set_config = camera_config_set; - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; + camera->functions->exit = camera_exit; + camera->functions->get_config = camera_config_get; + camera->functions->set_config = camera_config_set; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera); diff --git a/camlibs/enigma13/enigma13.c b/camlibs/enigma13/enigma13.c index c0f31aa910..573cf25430 100644 --- a/camlibs/enigma13/enigma13.c +++ b/camlibs/enigma13/enigma13.c @@ -62,10 +62,10 @@ static char* enigma13_static_toc=NULL; static int enigma13_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("Download program for Digital Dream Enigma 1.3. " - "by , and adapted from spca50x driver. " - "Thank you, spca50x team, it was easy to port your driver on this cam! ")); - return (GP_OK); + strcpy (about->text, _("Download program for Digital Dream Enigma 1.3. " + "by , and adapted from spca50x driver. " + "Thank you, spca50x team, it was easy to port your driver on this cam! ")); + return (GP_OK); } @@ -78,17 +78,16 @@ static int enigma13_about (Camera *camera, CameraText *about, GPContext *context */ static int enigma13_detect_storage_type (Camera *camera) { - int i; - char buf[3]; - - for (i=0;i<3;i++) - { - CHECK (gp_port_usb_msg_read (camera->port, 0x28, 0x0000, - i, &buf[i], 0x01)); - } - gp_log(GP_LOG_DEBUG, "enigma13","Camera storage information sdram: 0x%x flash 0x%x card: 0x%x\n" - , buf[0], buf[1], buf[2]); - return GP_OK; + int i; + char buf[3]; + + for (i=0;i<3;i++) + { + CHECK (gp_port_usb_msg_read (camera->port, 0x28, 0x0000, i, &buf[i], 0x01)); + } + gp_log(GP_LOG_DEBUG, "enigma13","Camera storage information sdram: 0x%x flash 0x%x card: 0x%x\n" + , buf[0], buf[1], buf[2]); + return GP_OK; } #endif @@ -106,11 +105,11 @@ static int enigma13_flash_delete_all(CameraFilesystem *fs, const char *folder, void *data, GPContext *context) { - Camera *cam; - gp_log(GP_LOG_DEBUG, "enigma13","Delete all files"); - cam = data; - CHECK (gp_port_usb_msg_write (cam->port, 0x52, 0x0, 0x0, NULL, 0x0) ); - return GP_OK; + Camera *cam; + gp_log(GP_LOG_DEBUG, "enigma13", "Delete all files"); + cam = data; + CHECK (gp_port_usb_msg_write (cam->port, 0x52, 0x0, 0x0, NULL, 0x0)); + return GP_OK; } @@ -124,17 +123,15 @@ enigma13_flash_delete_all(CameraFilesystem *fs, const char *folder, void *data, */ static int enigma13_wait_for_ready(Camera *camera) { - int timeout = ENIGMA13_WAIT_FOR_READY_TIMEOUT_S; - char ready = 1; - while (timeout--) { - sleep(1); - CHECK (gp_port_usb_msg_read (camera->port, - 0x21, 0x0000, 0x0000, - (char*)&ready, 0x01)); - if (ready==0) - return GP_OK; - } - return GP_ERROR; + int timeout = ENIGMA13_WAIT_FOR_READY_TIMEOUT_S; + char ready = 1; + while (timeout--) { + sleep(1); + CHECK (gp_port_usb_msg_read (camera->port, 0x21, 0x0000, 0x0000, (char*)&ready, 0x01)); + if (ready==0) + return GP_OK; + } + return GP_ERROR; } @@ -148,14 +145,12 @@ static int enigma13_wait_for_ready(Camera *camera) */ static int enigma13_get_filecount (Camera *camera, int *filecount) { - uint16_t response = 0; - CHECK(enigma13_wait_for_ready(camera)); - CHECK (gp_port_usb_msg_read (camera->port, - 0x54, 0x0000, 0x0000, - (char*)&response, 0x02)); - le16toh (response); - *filecount = response; - return GP_OK; + uint16_t response = 0; + CHECK(enigma13_wait_for_ready(camera)); + CHECK (gp_port_usb_msg_read (camera->port, 0x54, 0x0000, 0x0000, (char*)&response, 0x02)); + le16toh (response); + *filecount = response; + return GP_OK; } #endif @@ -169,52 +164,44 @@ static int enigma13_get_filecount (Camera *camera, int *filecount) */ static int enigma13_get_toc(Camera *camera, int *filecount, char** toc) { - char* flash_toc=NULL; - int toc_size = 0; - char buf[10]; - uint16_t response = 0; - int ret=1; + char* flash_toc=NULL; + int toc_size = 0; + char buf[10]; + uint16_t response = 0; + int ret=1; - CHECK(enigma13_wait_for_ready(camera)); - CHECK (gp_port_usb_msg_read (camera->port, - 0x54, 0x0000, 0x0000, - (char*)&response, 0x02)); - le16toh (response); - *filecount = response; + CHECK(enigma13_wait_for_ready(camera)); + CHECK (gp_port_usb_msg_read (camera->port, 0x54, 0x0000, 0x0000, (char*)&response, 0x02)); + le16toh (response); + *filecount = response; - /* Calc toc size */ - toc_size = (response) * 0x20; + /* Calc toc size */ + toc_size = (response) * 0x20; - if (toc_size % 0x200 != 0) - toc_size = ((toc_size / 0x200) + 1) * 0x200; + if (toc_size % 0x200 != 0) + toc_size = ((toc_size / 0x200) + 1) * 0x200; CHECK(enigma13_wait_for_ready(camera)); - CHECK (gp_port_usb_msg_write (camera->port, 0x54, - response, 0x0001, - NULL, 0x0000)); - /* Wait until cam is ready to send the T.O.C */ + CHECK (gp_port_usb_msg_write (camera->port, 0x54, response, 0x0001, NULL, 0x0000)); + /* Wait until cam is ready to send the T.O.C */ usleep(ENIGMA13_WAIT_TOC_DELAY_MS * 1000); - CHECK (gp_port_usb_msg_read (camera->port, 0x21, - 0x0000, 0x0000, - buf, 0x01)); - if (buf[0]!=0x41) return GP_ERROR; + CHECK (gp_port_usb_msg_read (camera->port, 0x21, 0x0000, 0x0000, buf, 0x01)); + if (buf[0]!=0x41) return GP_ERROR; - CHECK (gp_port_usb_msg_read (camera->port, 0x21, - 0x0000, 0x0002, - buf, 0x01)); - if (buf[0]!=0x01) return GP_ERROR; + CHECK (gp_port_usb_msg_read (camera->port, 0x21, 0x0000, 0x0002, buf, 0x01)); + if (buf[0]!=0x01) return GP_ERROR; - flash_toc = (char*)malloc(toc_size); - if (!flash_toc) - return GP_ERROR_NO_MEMORY; + flash_toc = (char*)malloc(toc_size); + if (!flash_toc) + return GP_ERROR_NO_MEMORY; - ret=gp_port_read (camera->port, flash_toc, toc_size); - *toc= flash_toc; + ret=gp_port_read (camera->port, flash_toc, toc_size); + *toc= flash_toc; gp_log(GP_LOG_DEBUG, "enigma13","Byte transferred :%d ", ret); - return ret; + return ret; } @@ -313,12 +300,12 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList { Camera *camera = data; int i, numpics; - char tmp[20]; + char tmp[20]; - CHECK(enigma13_get_toc(camera,&numpics,&enigma13_static_toc)); + CHECK(enigma13_get_toc(camera,&numpics,&enigma13_static_toc)); for ( i=0; i < numpics; i=i+2 ) { - sprintf(tmp,"sunp%04d.jpg",(i/2)); + sprintf(tmp,"sunp%04d.jpg",(i/2)); gp_list_append( list, tmp, NULL); } return (GP_OK); @@ -337,30 +324,30 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, Camera *camera = data; - int image_no, result; + int image_no, result; char* img_data=NULL; - int img_size=-1; + int img_size=-1; - image_no = gp_filesystem_number(fs, folder, filename, context); - gp_log(GP_LOG_DEBUG, "enigma13","Index of image %d is %s",image_no, filename); - switch (type) { - case GP_FILE_TYPE_NORMAL: - { - gp_log(GP_LOG_DEBUG, "enigma13","Downloading raw image"); + image_no = gp_filesystem_number(fs, folder, filename, context); + gp_log(GP_LOG_DEBUG, "enigma13","Index of image %d is %s",image_no, filename); + switch (type) { + case GP_FILE_TYPE_NORMAL: + { + gp_log(GP_LOG_DEBUG, "enigma13","Downloading raw image"); - CHECK(enigma13_download_img(camera, enigma13_static_toc, image_no, &img_data, &img_size)); - result = gp_file_append( file, img_data, img_size); + CHECK(enigma13_download_img(camera, enigma13_static_toc, image_no, &img_data, &img_size)); + result = gp_file_append( file, img_data, img_size); break; } default: - result = GP_ERROR_NOT_SUPPORTED; + result = GP_ERROR_NOT_SUPPORTED; break; - } - if (result < 0) - return result; - return (GP_OK); + } + if (result < 0) + return result; + return (GP_OK); } int @@ -400,16 +387,16 @@ camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; - camera->functions->about = enigma13_about; + camera->functions->about = enigma13_about; CHECK(gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); CHECK(gp_port_get_settings( camera->port, &settings)); - settings.usb.inep = 0x82; - settings.usb.outep = 0x03; - settings.usb.config = 1; - settings.usb.interface = 0; - settings.usb.altsetting = 0; - CHECK(gp_port_set_timeout (camera->port, ENIGMA13_USB_TIMEOUT_MS)); + settings.usb.inep = 0x82; + settings.usb.outep = 0x03; + settings.usb.config = 1; + settings.usb.interface = 0; + settings.usb.altsetting = 0; + CHECK(gp_port_set_timeout (camera->port, ENIGMA13_USB_TIMEOUT_MS)); CHECK(gp_port_set_settings( camera->port, settings)); return GP_OK; diff --git a/camlibs/fuji/fuji.c b/camlibs/fuji/fuji.c index b5c874575a..a6cdaaeeae 100644 --- a/camlibs/fuji/fuji.c +++ b/camlibs/fuji/fuji.c @@ -121,38 +121,38 @@ static int fuji_send (Camera *camera, unsigned char *cmd, unsigned int cmd_len, unsigned char last, GPContext *context) { - unsigned char b[1024], check; - unsigned int i; + unsigned char b[1024], check; + unsigned int i; - /* Send header */ - b[0] = ESC; - b[1] = STX; - CR (gp_port_write (camera->port, (char *)b, 2)); + /* Send header */ + b[0] = ESC; + b[1] = STX; + CR (gp_port_write (camera->port, (char *)b, 2)); - /* + /* * Escape the data we are going to send. * Calculate the checksum. */ check = (last ? ETX : ETB); - memcpy (b, cmd, cmd_len); - for (i = 0; i < cmd_len; i++) { + memcpy (b, cmd, cmd_len); + for (i = 0; i < cmd_len; i++) { check ^= b[i]; - if (b[i] == ESC) { - memmove (b + i + 1, b + i, cmd_len - i); - b[i] = ESC; - i++; - cmd_len++; - } - } - - /* Send data */ - CR (gp_port_write (camera->port, (char *)b, cmd_len)); - - /* Send footer */ - b[0] = ESC; - b[1] = (last ? ETX : ETB); - b[2] = check; - CR (gp_port_write (camera->port, (char *)b, 3)); + if (b[i] == ESC) { + memmove (b + i + 1, b + i, cmd_len - i); + b[i] = ESC; + i++; + cmd_len++; + } + } + + /* Send data */ + CR (gp_port_write (camera->port, (char *)b, cmd_len)); + + /* Send footer */ + b[0] = ESC; + b[1] = (last ? ETX : ETB); + b[2] = check; + CR (gp_port_write (camera->port, (char *)b, 3)); return (GP_OK); } @@ -300,8 +300,7 @@ fuji_transmit (Camera *camera, unsigned char *cmd, unsigned int cmd_len, */ p = ((*buf_len > 1024) ? 1 : 0); if (p) - id = gp_context_progress_start (context, *buf_len, - _("Downloading...")); + id = gp_context_progress_start (context, *buf_len, _("Downloading...")); *buf_len = 0; retries = 0; while (!last) { @@ -310,7 +309,7 @@ fuji_transmit (Camera *camera, unsigned char *cmd, unsigned int cmd_len, retries++; while (gp_port_read (camera->port, (char *)&c, 1) >= 0); if (++retries > 2) - return (r); + return (r); GP_DEBUG ("Retrying..."); c = NAK; CR (gp_port_write (camera->port, (char *)&c, 1)); @@ -842,22 +841,22 @@ fuji_get_cmds (Camera *camera, unsigned char *cmds, GPContext *context) static int get_picture_info(int num,char *name,CameraPrivateLibrary *camdata){ - DBG("Getting name..."); + DBG("Getting name..."); - strncpy(name,fuji_picture_name(num),100); + strncpy(name, fuji_picture_name(num), 100); - DBG2("%s\n",name); + DBG2("%s\n", name); - /* - * To find the picture number, go to the first digit. According to - * recent Exif specs, n_off can be either 3 or 4. - */ - if (camdata->has_cmd[FUJI_SIZE]) fuji_size=fuji_picture_size(num); - else { - fuji_size=70000; /* this is an overestimation for DS7 */ - DBG2("Image size not obtained, guessing %d",fuji_size); - }; - return (fuji_size); + /* + * To find the picture number, go to the first digit. According to + * recent Exif specs, n_off can be either 3 or 4. + */ + if (camdata->has_cmd[FUJI_SIZE]) fuji_size=fuji_picture_size(num); + else { + fuji_size=70000; /* this is an overestimation for DS7 */ + DBG2("Image size not obtained, guessing %d", fuji_size); + }; + return (fuji_size); }; static void get_picture_list (FujiData *fjd) @@ -875,10 +874,10 @@ static void get_picture_list (FujiData *fjd) }; for (i = 1; i <= pictures; i++) { - DBG("Getting name..."); + DBG("Getting name..."); - name = strdup(fuji_picture_name(i)); - pinfo[i].name = name; + name = strdup(fuji_picture_name(i)); + pinfo[i].name = name; DBG2("%s\n",name); @@ -905,7 +904,7 @@ static int download_picture(int n,int thumb,CameraFile *file,CameraPrivateLibrar DBG3("download_picture: %d,%s",n,thumb?"thumb":"pic"); if (!thumb) { - fuji_size=get_picture_info(n,name,fjd); + fuji_size=get_picture_info(n,name,fjd); DBG3("Info %3d %12s ", n, name); } else fuji_size=10500; /* Probably not same for all cams, better way ? */ diff --git a/camlibs/fuji/fuji.h b/camlibs/fuji/fuji.h index 87026dd224..2372c67e3c 100644 --- a/camlibs/fuji/fuji.h +++ b/camlibs/fuji/fuji.h @@ -28,7 +28,7 @@ enum _FujiCmd { FUJI_CMD_PIC_GET = 0x02, FUJI_CMD_PIC_GET_THUMB = 0x00, FUJI_CMD_SPEED = 0x07, - FUJI_CMD_VERSION = 0x09, + FUJI_CMD_VERSION = 0x09, FUJI_CMD_PIC_NAME = 0x0a, FUJI_CMD_PIC_COUNT = 0x0b, @@ -40,30 +40,30 @@ enum _FujiCmd { FUJI_CMD_UNKNOWN4 = 0x11, /* Figure this out! */ FUJI_CMD_UNKNOWN5 = 0x13, /* Figure this out! */ - FUJI_CMD_PIC_SIZE = 0x17, - FUJI_CMD_PIC_DEL = 0x19, + FUJI_CMD_PIC_SIZE = 0x17, + FUJI_CMD_PIC_DEL = 0x19, FUJI_CMD_AVAIL_MEM = 0x1b, FUJI_CMD_UNKNOWN10 = 0x20, /* Figure this out! */ FUJI_CMD_UNKNOWN11 = 0x22, /* Figure this out! */ - FUJI_CMD_TAKE = 0x27, + FUJI_CMD_TAKE = 0x27, FUJI_CMD_MODEL = 0x29, - FUJI_CMD_UNKNOWN13 = 0x2a, /* Figure this out! */ + FUJI_CMD_UNKNOWN13 = 0x2a, /* Figure this out! */ FUJI_CMD_UNKNOWN14 = 0x2b, /* Figure this out! */ FUJI_CMD_UNKNOWN15 = 0x2e, /* Figure this out! */ /* Flash related commands */ FUJI_CMD_FLASH_GET = 0x30, FUJI_CMD_FLASH_SET = 0x32, - FUJI_CMD_FLASH_CHARGE = 0x34, + FUJI_CMD_FLASH_CHARGE = 0x34, - FUJI_CMD_CMDS_VALID = 0x4c, + FUJI_CMD_CMDS_VALID = 0x4c, FUJI_CMD_UNKNOWN16 = 0x51, /* Figure this out! */ - FUJI_CMD_PREVIEW = 0x64, + FUJI_CMD_PREVIEW = 0x64, /* Configurable settings */ FUJI_CMD_ID_GET = 0x80, diff --git a/camlibs/fuji/library.c b/camlibs/fuji/library.c index 4f9eb65a6f..49d3eb1a43 100644 --- a/camlibs/fuji/library.c +++ b/camlibs/fuji/library.c @@ -67,25 +67,25 @@ struct _CameraPrivateLibrary { }; static const struct { - FujiCmd command; - const char *name; + FujiCmd command; + const char *name; } Commands[] = { - {FUJI_CMD_PIC_GET, "get picture"}, - {FUJI_CMD_PIC_GET_THUMB, "get thumbnail"}, - {FUJI_CMD_SPEED, "change speed"}, - {FUJI_CMD_VERSION, "get version"}, - {FUJI_CMD_PIC_NAME, "get name of picture"}, - {FUJI_CMD_PIC_COUNT, "get number of pictures"}, - {FUJI_CMD_PIC_SIZE, "get size of picture"}, - {FUJI_CMD_PIC_DEL, "delete picture"}, - {FUJI_CMD_TAKE, "capture picture"}, - {FUJI_CMD_FLASH_GET, "get flash mode"}, - {FUJI_CMD_FLASH_SET, "set flash mode"}, + {FUJI_CMD_PIC_GET, "get picture"}, + {FUJI_CMD_PIC_GET_THUMB, "get thumbnail"}, + {FUJI_CMD_SPEED, "change speed"}, + {FUJI_CMD_VERSION, "get version"}, + {FUJI_CMD_PIC_NAME, "get name of picture"}, + {FUJI_CMD_PIC_COUNT, "get number of pictures"}, + {FUJI_CMD_PIC_SIZE, "get size of picture"}, + {FUJI_CMD_PIC_DEL, "delete picture"}, + {FUJI_CMD_TAKE, "capture picture"}, + {FUJI_CMD_FLASH_GET, "get flash mode"}, + {FUJI_CMD_FLASH_SET, "set flash mode"}, {FUJI_CMD_FLASH_CHARGE, "charge flash"}, - {FUJI_CMD_CMDS_VALID, "list valid commands"}, - {FUJI_CMD_PREVIEW, "capture preview"}, + {FUJI_CMD_CMDS_VALID, "list valid commands"}, + {FUJI_CMD_PREVIEW, "capture preview"}, {FUJI_CMD_DATE_GET, "get date"}, - {0, NULL}}; + {0, NULL} }; static const char * cmd_get_name (FujiCmd command) @@ -384,10 +384,9 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) const char *id; /* Date & Time */ - if ((gp_widget_get_child_by_label (window, _("Date & Time"), - &widget) >= 0) && - gp_widget_changed (widget)) { - gp_widget_set_changed (widget, 0); + if ((gp_widget_get_child_by_label (window, _("Date & Time"), &widget) >= 0) && + gp_widget_changed (widget)) { + gp_widget_set_changed (widget, 0); CR (gp_widget_get_value (widget, &t)); tm = localtime (&t); date.year = tm->tm_year; @@ -402,7 +401,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) /* ID */ if ((gp_widget_get_child_by_label (window, _("ID"), &widget) >= 0) && gp_widget_changed (widget)) { - gp_widget_set_changed (widget, 0); + gp_widget_set_changed (widget, 0); CR (gp_widget_get_value (widget, &id)); CR (fuji_id_set (camera, id, context)); } diff --git a/camlibs/gsmart300/gsmart300.c b/camlibs/gsmart300/gsmart300.c index 07e6e102cd..dd7a0c2137 100644 --- a/camlibs/gsmart300/gsmart300.c +++ b/camlibs/gsmart300/gsmart300.c @@ -161,8 +161,7 @@ gsmart300_request_file (CameraPrivateLibrary * lib, CameraFile *file, if (!mybuf) return GP_ERROR_NO_MEMORY; - ret = gsmart300_download_data (lib, __GS300_PIC, g_file->index, - flash_size, mybuf); + ret = gsmart300_download_data (lib, __GS300_PIC, g_file->index, flash_size, mybuf); if (ret < GP_OK) { free (mybuf); return ret; @@ -258,8 +257,7 @@ gsmart300_get_image_thumbnail (CameraPrivateLibrary * lib, CameraFile *file, mybuf = malloc (size); if (!mybuf) return (GP_ERROR_NO_MEMORY); - ret = gsmart300_download_data (lib, __GS300_THUMB, g_file->index, - size, mybuf); + ret = gsmart300_download_data (lib, __GS300_THUMB, g_file->index, size, mybuf); if (ret < GP_OK) { free (mybuf); return ret; @@ -393,14 +391,12 @@ gsmart300_get_FATs (CameraPrivateLibrary * lib) p = lib->fats; while (index < lib->num_files) { - CHECK (gsmart300_download_data (lib, __GS300_FAT, index, - FLASH_PAGE_SIZE_300, p)); + CHECK (gsmart300_download_data (lib, __GS300_FAT, index, FLASH_PAGE_SIZE_300, p)); if (p[0] == 0xFF) break; type = p[0]; if (type == 0x00) { - lib->files[file_index].mime_type = - GSMART_FILE_TYPE_IMAGE; + lib->files[file_index].mime_type = GSMART_FILE_TYPE_IMAGE; lib->files[file_index].index = index; lib->files[file_index].fat = p; lib->files[file_index].width = (p[8] & 0xFF) * 16; diff --git a/camlibs/gsmart300/library.c b/camlibs/gsmart300/library.c index 58040841c8..6609440cdc 100644 --- a/camlibs/gsmart300/library.c +++ b/camlibs/gsmart300/library.c @@ -260,15 +260,14 @@ get_file_func (CameraFilesystem *fs, const char *folder, Camera *camera = user_data; int number, filetype; - CHECK (number = gp_filesystem_number (camera->fs, folder, filename, - context)); + CHECK (number = gp_filesystem_number (camera->fs, folder, filename, context)); switch (type) { case GP_FILE_TYPE_NORMAL: CHECK (gsmart300_request_file (camera->pl, file, number)); break; case GP_FILE_TYPE_PREVIEW: CHECK (gsmart300_request_thumbnail - (camera->pl, file, number, &filetype)); + (camera->pl, file, number, &filetype)); if (filetype == GSMART_FILE_TYPE_IMAGE) { CHECK (gp_file_set_mime_type (file, GP_MIME_BMP)); } @@ -289,8 +288,7 @@ get_info_func (CameraFilesystem *fs, const char *folder, struct GsmartFile *file; /* Get the file number from the CameraFileSystem */ - CHECK (n = gp_filesystem_number (camera->fs, folder, filename, - context)); + CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context)); CHECK (gsmart300_get_file_info (camera->pl, n, &file)); @@ -321,17 +319,16 @@ delete_file_func (CameraFilesystem *fs, const char *folder, int n, c; /* Get the file number from the CameraFileSystem */ - CHECK (n = gp_filesystem_number (camera->fs, folder, filename, - context)); + CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context)); CHECK (c = gp_filesystem_count (camera->fs, folder, context)); if (n + 1 != c) { const char *name; gp_filesystem_name (fs, "/", c - 1, &name, context); gp_context_error (context, - _("Your camera only supports deleting " - "the last file on the camera. In this " - "case, this is file '%s'."), name); + _("Your camera only supports deleting " + "the last file on the camera. In this " + "case, this is file '%s'."), name); return (GP_ERROR); } CHECK (gsmart300_delete_file (camera->pl, n)); diff --git a/camlibs/iclick/library.c b/camlibs/iclick/library.c index f9cbdd5f57..1b5ce959d1 100644 --- a/camlibs/iclick/library.c +++ b/camlibs/iclick/library.c @@ -54,59 +54,58 @@ #define GP_MODULE "iclick" static struct { - char *name; + char *name; CameraDriverStatus status; - unsigned short idVendor; - unsigned short idProduct; + unsigned short idVendor; + unsigned short idProduct; } models[] = { - {"iClick 5X", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9153}, + {"iClick 5X", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9153}, {NULL,0,0,0} }; int camera_id (CameraText *id) { - strcpy (id->text, "iClick 5X"); + strcpy (id->text, "iClick 5X"); - return GP_OK; + return GP_OK; } int camera_abilities (CameraAbilitiesList *list) { - int i; - CameraAbilities a; - - for (i = 0; models[i].name; i++) { - memset (&a, 0, sizeof(a)); - strcpy (a.model, models[i].name); - a.status = models[i].status; - a.port = GP_PORT_USB; - a.speed[0] = 0; - a.usb_vendor = models[i].idVendor; - a.usb_product= models[i].idProduct; - if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) + int i; + CameraAbilities a; + + for (i = 0; models[i].name; i++) { + memset (&a, 0, sizeof(a)); + strcpy (a.model, models[i].name); + a.status = models[i].status; + a.port = GP_PORT_USB; + a.speed[0] = 0; + a.usb_vendor = models[i].idVendor; + a.usb_product= models[i].idProduct; + if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) a.operations = GP_OPERATION_NONE; else a.operations = GP_OPERATION_CAPTURE_PREVIEW; - a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; + a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; a.file_operations = GP_FILE_OPERATION_PREVIEW + GP_FILE_OPERATION_RAW; - gp_abilities_list_append (list, a); - } + gp_abilities_list_append (list, a); + } - return GP_OK; + return GP_OK; } static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { - sprintf (summary->text,_("Your USB camera is an iClick 5X.\n" - "The total number of pictures taken is %i\n"), + sprintf (summary->text, _("Your USB camera is an iClick 5X.\n" + "The total number of pictures taken is %i\n"), + camera->pl->nb_entries); - camera->pl->nb_entries); - - return GP_OK; + return GP_OK; } static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) @@ -131,10 +130,10 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("iClick 5X driver\n" - "Theodore Kilgore \n")); + strcpy (about->text, _("iClick 5X driver\n" + "Theodore Kilgore \n")); - return GP_OK; + return GP_OK; } /*************** File and Downloading Functions *******************/ @@ -144,7 +143,7 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; int i; unsigned char buf[1024]; GP_DEBUG ("List files in %s\n", folder); @@ -166,7 +165,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *user_data, GPContext *context) { - Camera *camera = user_data; + Camera *camera = user_data; int entry, w, h; /* frame; */ unsigned char *frame_data, *frame_ptr; unsigned char *ppm, *ptr; @@ -259,7 +258,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, case GP_FILE_TYPE_RAW: gp_file_set_mime_type (file, GP_MIME_RAW); gp_file_adjust_name_for_mime_type (file); - gp_file_set_data_and_size (file, (char *)frame_data, datasize); + gp_file_set_data_and_size (file, (char *)frame_data, datasize); return (GP_OK); default: return GP_ERROR_NOT_SUPPORTED; @@ -297,7 +296,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_data_and_size (file, (char *)ppm, ppmsize); free (frame_data); - return GP_OK; + return GP_OK; } @@ -333,10 +332,10 @@ camera_init(Camera *camera, GPContext *context) int ret = 0; /* First, set up all the function pointers */ - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; - camera->functions->exit = camera_exit; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; + camera->functions->exit = camera_exit; GP_DEBUG ("Initializing the camera\n"); @@ -346,7 +345,7 @@ camera_init(Camera *camera, GPContext *context) ret = gp_port_set_settings(camera->port,settings); if (ret < 0) return ret; - /* Tell the CameraFilesystem where to get lists from */ + /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); diff --git a/camlibs/jd11/jd11.c b/camlibs/jd11/jd11.c index 3fdd02dfaa..0150848114 100644 --- a/camlibs/jd11/jd11.c +++ b/camlibs/jd11/jd11.c @@ -273,25 +273,25 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - gp_port_settings settings; + gp_port_settings settings; - /* First, set up all the function pointers */ - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; camera->functions->get_config = camera_config_get; camera->functions->set_config = camera_config_set; - /* Configure port */ - gp_port_set_timeout(camera->port, 1000); + /* Configure port */ + gp_port_set_timeout(camera->port, 1000); gp_port_get_settings(camera->port, &settings); - settings.serial.speed = 115200; - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits= 1; - gp_port_set_settings(camera->port, settings); + settings.serial.speed = 115200; + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits= 1; + gp_port_set_settings(camera->port, settings); /* Set up the filesystem */ gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera); - /* test camera */ - return jd11_ping(camera->port); + /* test camera */ + return jd11_ping(camera->port); } diff --git a/camlibs/jd11/serial.c b/camlibs/jd11/serial.c index 29ea032898..97cd6d1e21 100644 --- a/camlibs/jd11/serial.c +++ b/camlibs/jd11/serial.c @@ -41,42 +41,42 @@ #if 0 static int dread(GPPort *port, caddr_t buf, int xsize) { - int i; - int ret = gp_port_read(port,buf,xsize); - - if (ret == -1) { - perror("dread"); - return -1; - } - fprintf(stderr,"dread[%d]:",ret); - for (i=0;i>8; - buf[1] = cmd&0xff; - return WRITE(port,buf,2); +static int _send_cmd(GPPort *port, unsigned short cmd) { + unsigned char buf[2]; + buf[0] = cmd>>8; + buf[1] = cmd&0xff; + return WRITE(port, buf, 2); } static int _read_cmd(GPPort *port,unsigned short *xcmd) { @@ -109,29 +109,29 @@ static void _dump_buf(unsigned char *buf,int size) { #endif -static int _send_cmd_2(GPPort *port,unsigned short cmd, unsigned short *xcmd) { - unsigned char buf[2]; - int ret, tries = 3; - *xcmd = 0x4242; - while (tries--) { - int i = 0; - buf[0] = cmd>>8; - buf[1] = cmd&0xff; - ret = WRITE(port,buf,2); - do { - if (1==(ret=READ(port,buf,1))) { - if (buf[0]==0xff) { - if (1==READ(port,buf+1,1)) { - *xcmd = (buf[0] << 8)| buf[1]; - return GP_OK; - } +static int _send_cmd_2(GPPort *port, unsigned short cmd, unsigned short *xcmd) { + unsigned char buf[2]; + int ret, tries = 3; + *xcmd = 0x4242; + while (tries--) { + int i = 0; + buf[0] = cmd>>8; + buf[1] = cmd&0xff; + ret = WRITE(port, buf, 2); + do { + if (1==(ret=READ(port, buf, 1))) { + if (buf[0]==0xff) { + if (1==READ(port, buf+1, 1)) { + *xcmd = (buf[0] << 8)| buf[1]; + return GP_OK; + } + } + } else { + return ret; } - } else { - return ret; - } - } while (i++<3); - } - return GP_ERROR_IO; + } while (i++<3); + } + return GP_ERROR_IO; } int jd11_ping(GPPort *port) { @@ -140,12 +140,12 @@ int jd11_ping(GPPort *port) { int ret,tries = 3; while (tries--) { - ret = GP_ERROR_IO; - while (1==READ(port,buf,1)) - /* drain input queue before PING */; - ret=_send_cmd_2(port,0xff08,&xcmd); - if ((ret>=GP_OK) && (xcmd==0xfff1)) - return GP_OK; + ret = GP_ERROR_IO; + while (1==READ(port, buf, 1)) + /* drain input queue before PING */; + ret=_send_cmd_2(port, 0xff08, &xcmd); + if ((ret>=GP_OK) && (xcmd==0xfff1)) + return GP_OK; } return ret; } @@ -155,18 +155,18 @@ jd11_get_rgb(GPPort *port,float *red, float *green, float *blue) { char buf[10]; int ret=GP_OK,tries=0,curread=0; - _send_cmd(port,0xffa7); + _send_cmd(port, 0xffa7); while ((curread<10) && (tries++<30)) { - ret=READ(port,buf+curread,sizeof(buf)-curread); - if (ret < 0) - continue; - if (ret == 0) - break; - curread+=ret; + ret=READ(port, buf+curread, sizeof(buf)-curread); + if (ret < 0) + continue; + if (ret == 0) + break; + curread+=ret; } - if(curread<10) { - fprintf(stderr,"%d returned bytes on float query.\n",ret); - return GP_ERROR_IO; + if (curread<10) { + fprintf(stderr, "%d returned bytes on float query.\n", ret); + return GP_ERROR_IO; } /*_dump_buf(buf,10);*/ *green = buf[1]+buf[2]*0.1+buf[3]*0.01; @@ -201,9 +201,9 @@ jd11_select_index(GPPort *port) { /* select index */ ret = _send_cmd_2(port,0xffa4,&xcmd); if (ret < GP_OK) - return ret; + return ret; if (xcmd!=0xff01) - return GP_ERROR_IO; + return GP_ERROR_IO; return GP_OK; } @@ -211,11 +211,11 @@ int jd11_select_image(GPPort *port,int nr) { /* select image */ unsigned short xcmd; - _send_cmd(port,0xffa1); - _send_cmd(port,0xff00|nr); - _read_cmd(port,&xcmd); + _send_cmd(port, 0xffa1); + _send_cmd(port, 0xff00|nr); + _read_cmd(port, &xcmd); if (xcmd != 0xff01) - return GP_ERROR_IO; + return GP_ERROR_IO; return GP_OK; } @@ -224,7 +224,7 @@ jd11_set_bulb_exposure(GPPort *port,int i) { unsigned short xcmd; if ((i<1) || (i>9)) - return GP_ERROR_BAD_PARAMETERS; + return GP_ERROR_BAD_PARAMETERS; _send_cmd(port,0xffa9); _send_cmd(port,0xff00|i); @@ -275,26 +275,26 @@ jd11_imgsize(GPPort *port) { int ret; int i=0,curread=0; - _send_cmd(port,0xfff0); + _send_cmd(port, 0xfff0); do { - ret=READ(port,&buf[curread],10-curread); + ret=READ(port, &buf[curread], 10-curread); if (ret>0) - curread+=ret; + curread+=ret; usleep(1000); } while ((i++<20) && (curread<10)); /*_dump_buf(buf,curread);*/ if (!curread) /* We get 0 bytes return for 0 images. */ - return 0; - ret=strtol(&buf[2],NULL,16); + return 0; + ret=strtol(&buf[2], NULL, 16); return ret; } static int getpacket(GPPort *port,unsigned char *buf, int expect) { - int curread = 0, csum = 0; + int curread = 0, csum = 0; int tries = 0; if (expect == 200) - expect++; + expect++; while (tries++<5) { int i=0,ret; @@ -308,11 +308,11 @@ getpacket(GPPort *port,unsigned char *buf, int expect) { usleep(100); } while ((i++<2) && (curread200) readsize = 200; - ret=getpacket(port,indexbuf+curread,readsize); - if (ret==0) - break; - curread+=ret; - if (ret<200) - break; - gp_context_progress_update (context, id, curread); - if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) { - /* What to do...Just free the stuff we allocated for now.*/ - free(indexbuf); - return GP_ERROR_CANCEL; - } - _send_cmd(port,0xfff1); - } - gp_context_progress_stop (context, id); - for (i=0;i200) readsize = 200; + ret=getpacket(port, indexbuf+curread, readsize); + if (ret==0) + break; + curread+=ret; + if (ret<200) + break; + gp_context_progress_update (context, id, curread); + if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) { + /* What to do...Just free the stuff we allocated for now.*/ + free(indexbuf); + return GP_ERROR_CANCEL; + } + _send_cmd(port, 0xfff1); } + gp_context_progress_stop (context, id); + for (i=0;iport; - unsigned int id; - - jd11_select_image(port,nr); - *imagebufs = (unsigned char**)malloc(3*sizeof(unsigned char*)); - for (picnum=0;picnum<3;picnum++) { - curread=0; - sizes[picnum] = jd11_imgsize(port); - (*imagebufs)[picnum]=(unsigned char*)malloc(sizes[picnum]+400); - _send_cmd(port,0xfff1); - id = gp_context_progress_start (context, sizes[picnum], +serial_image_reader(Camera *camera, CameraFile *file, int nr, unsigned char ***imagebufs, int *sizes, GPContext *context) { + int picnum, curread, ret=0; + GPPort *port = camera->port; + unsigned int id; + + jd11_select_image(port, nr); + *imagebufs = (unsigned char**)malloc(3*sizeof(unsigned char*)); + for (picnum=0;picnum<3;picnum++) { + curread=0; + sizes[picnum] = jd11_imgsize(port); + (*imagebufs)[picnum]=(unsigned char*)malloc(sizes[picnum]+400); + _send_cmd(port, 0xfff1); + id = gp_context_progress_start (context, sizes[picnum], _("Downloading data...")); - while (curread 200) readsize = 200; - ret=getpacket(port,(*imagebufs)[picnum]+curread,readsize); - if (ret==0) - break; - curread+=ret; - if (ret<200) - break; - gp_context_progress_update (context, id, curread); - if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) { - int j; - /* What to do ... Just free the stuff we allocated for now. */ - for (j=0;j 200) readsize = 200; + ret=getpacket(port, (*imagebufs)[picnum]+curread, readsize); + if (ret==0) + break; + curread+=ret; + if (ret<200) + break; + gp_context_progress_update (context, id, curread); + if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) { + int j; + /* What to do ... Just free the stuff we allocated for now. */ + for (j=0;jright mirrored */ - for (h=480;h--;) { - int w; - for (w=320;w--;) { - if (h&1) { - /* G B G B G B G B G */ - *s++ = uncomp[0][h*320+w]; - *s++ = uncomp[2][(h/2)*320+w]; - } else { - /* R G R G R G R G R */ - *s++ = uncomp[1][(h/2)*320+w]; - *s++ = uncomp[0][h*320+w]; - } - } +jd11_get_image_full(Camera *camera, CameraFile*file, int nr, int raw, GPContext *context) +{ + unsigned char *s, *uncomp[3], **imagebufs; + int ret, sizes[3]; + unsigned char *data; + int h; + + ret = serial_image_reader(camera, file, nr, &imagebufs, sizes, context); + if (ret!=GP_OK) + return ret; + uncomp[0] = malloc(320*480); + uncomp[1] = malloc(320*480/2); + uncomp[2] = malloc(320*480/2); + if (sizes[0]!=115200) { + picture_decomp_v1(imagebufs[0], uncomp[0], 320, 480); + picture_decomp_v1(imagebufs[1], uncomp[1], 320, 480/2); + picture_decomp_v1(imagebufs[2], uncomp[2], 320, 480/2); + } else { + picture_decomp_v2(imagebufs[0], uncomp[0], 320, 480); + picture_decomp_v2(imagebufs[1], uncomp[1], 320, 480/2); + picture_decomp_v2(imagebufs[2], uncomp[2], 320, 480/2); + } + gp_file_append(file, IMGHEADER, strlen(IMGHEADER)); + data = malloc(640*480*3); + if (!data) { + free(uncomp[0]);free(uncomp[1]);free(uncomp[2]); + free(imagebufs[0]);free(imagebufs[1]);free(imagebufs[2]);free(imagebufs); + return GP_ERROR_NO_MEMORY; } - /*gp_bayer_decode(bayerpre,640,480,data,BAYER_TILE_GRBG);*/ - gp_ahd_decode(bayerpre,640,480,data,BAYER_TILE_GRBG); - free(bayerpre); - } else { - s=data; - for (h=480;h--;) { /* upside down */ - int w; - for (w=640;w--;) { /* right to left */ - /* and images are in green red blue */ - *s++=uncomp[1][(h/2)*320+(w/2)]; - *s++=uncomp[0][h*320+(w/2)]; - *s++=uncomp[2][(h/2)*320+(w/2)]; - } + + if (!raw) { + unsigned char *bayerpre; + s = bayerpre = malloc(640*480); + /* note that picture is upside down and left<->right mirrored */ + for (h=480;h--;) { + int w; + for (w=320;w--;) { + if (h&1) { + /* G B G B G B G B G */ + *s++ = uncomp[0][h*320+w]; + *s++ = uncomp[2][(h/2)*320+w]; + } else { + /* R G R G R G R G R */ + *s++ = uncomp[1][(h/2)*320+w]; + *s++ = uncomp[0][h*320+w]; + } + } + } + /*gp_bayer_decode(bayerpre,640,480,data,BAYER_TILE_GRBG);*/ + gp_ahd_decode(bayerpre, 640, 480, data, BAYER_TILE_GRBG); + free(bayerpre); + } else { + s=data; + for (h=480;h--;) { /* upside down */ + int w; + for (w=640;w--;) { /* right to left */ + /* and images are in green red blue */ + *s++=uncomp[1][(h/2)*320+(w/2)]; + *s++=uncomp[0][h*320+(w/2)]; + *s++=uncomp[2][(h/2)*320+(w/2)]; + } + } } - } - free(uncomp[0]);free(uncomp[1]);free(uncomp[2]); - free(imagebufs[0]);free(imagebufs[1]);free(imagebufs[2]);free(imagebufs); - gp_file_append(file, (char*)data, 640*480*3); - free(data); - return GP_OK; + free(uncomp[0]);free(uncomp[1]);free(uncomp[2]); + free(imagebufs[0]);free(imagebufs[1]);free(imagebufs[2]);free(imagebufs); + gp_file_append(file, (char*)data, 640*480*3); + free(data); + return GP_OK; } diff --git a/camlibs/jl2005a/jl2005a.c b/camlibs/jl2005a/jl2005a.c index eaf6e781b2..8094e5be6a 100644 --- a/camlibs/jl2005a/jl2005a.c +++ b/camlibs/jl2005a/jl2005a.c @@ -136,14 +136,14 @@ jl2005a_read_picture_data (Camera *camera, GPPort *port, * downloading them. There is only a starting point and an indicator * for each frame. */ - gp_port_write (port, "\xab\x00", 2); - gp_port_write (port, "\xa1\x04", 2); - gp_port_write (port, "\xab\x00", 2); - gp_port_write (port, "\xa2\x08", 2); - gp_port_write (port, "\xab\x00", 2); - gp_port_write (port, "\xa1\x05", 2); - gp_port_write (port, "\xab\x00", 2); - gp_port_write (port, "\xa2\x08", 2); + gp_port_write (port, "\xab\x00", 2); + gp_port_write (port, "\xa1\x04", 2); + gp_port_write (port, "\xab\x00", 2); + gp_port_write (port, "\xa2\x08", 2); + gp_port_write (port, "\xab\x00", 2); + gp_port_write (port, "\xa1\x05", 2); + gp_port_write (port, "\xab\x00", 2); + gp_port_write (port, "\xa2\x08", 2); /* Switch the inep over to 0x81. */ set_usb_in_endpoint (camera, 0x81); diff --git a/camlibs/jl2005a/library.c b/camlibs/jl2005a/library.c index afbffa200f..fbde6badf8 100644 --- a/camlibs/jl2005a/library.c +++ b/camlibs/jl2005a/library.c @@ -112,7 +112,7 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context { strcpy(manual->text, _( - "This driver supports cameras with Jeilin jl2005a chip \n" + "This driver supports cameras with Jeilin jl2005a chip \n" "These cameras do not support deletion of photos, nor uploading\n" "of data. \n" "Decoding of compressed photos may or may not work well\n" @@ -130,7 +130,7 @@ static int camera_about (Camera *camera, CameraText *about, GPContext *context) { strcpy (about->text, _("jl2005a camera library\n" - "Theodore Kilgore \n")); + "Theodore Kilgore \n")); return GP_OK; } diff --git a/camlibs/jl2005c/library.c b/camlibs/jl2005c/library.c index c896a455eb..d0f953a928 100644 --- a/camlibs/jl2005c/library.c +++ b/camlibs/jl2005c/library.c @@ -453,7 +453,7 @@ camera_init (Camera *camera, GPContext *context) int ret = 0; /* First, set up all the function pointers */ - camera->functions->manual = camera_manual; + camera->functions->manual = camera_manual; camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->exit = camera_exit; diff --git a/camlibs/kodak/dc120/dc120.c b/camlibs/kodak/dc120/dc120.c index e1a085e892..a0b65021da 100644 --- a/camlibs/kodak/dc120/dc120.c +++ b/camlibs/kodak/dc120/dc120.c @@ -300,7 +300,7 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder, static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { CameraList *list; int count; - const char* name; + const char* name; if (type != GP_CAPTURE_IMAGE) return (GP_ERROR_NOT_SUPPORTED); @@ -323,53 +323,51 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat CHECK_RESULT (gp_filesystem_append (camera->fs, path->folder, path->name, context)); - return (GP_OK); + return (GP_OK); } -static int camera_summary (Camera *camera, CameraText *summary, - GPContext *context) +static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { - static char summary_string[2048] = ""; - char buff[1024]; - Kodak_dc120_status status; + static char summary_string[2048] = ""; + char buff[1024]; + Kodak_dc120_status status; - if (dc120_get_status (camera, &status, context)) - { - strcpy(summary_string,"Kodak DC120\n"); + if (dc120_get_status (camera, &status, context)) + { + strcpy(summary_string, "Kodak DC120\n"); - snprintf(buff,1024,"Camera Identification: %s\n",status.camera_id); - strcat(summary_string,buff); + snprintf(buff, 1024, "Camera Identification: %s\n", status.camera_id); + strcat(summary_string, buff); - snprintf(buff,1024,"Camera Type: %d\n",status.camera_type_id); - strcat(summary_string,buff); + snprintf(buff, 1024, "Camera Type: %d\n", status.camera_type_id); + strcat(summary_string, buff); - snprintf(buff,1024,"Firmware: %d.%d\n",status.firmware_major,status.firmware_minor); - strcat(summary_string,buff); + snprintf(buff, 1024, "Firmware: %d.%d\n", status.firmware_major, status.firmware_minor); + strcat(summary_string, buff); - snprintf(buff,1024,"Battery Status: %d\n",status.batteryStatusId); - strcat(summary_string,buff); + snprintf(buff, 1024, "Battery Status: %d\n", status.batteryStatusId); + strcat(summary_string, buff); - snprintf(buff,1024,"AC Status: %d\n",status.acStatusId); - strcat(summary_string,buff); + snprintf(buff, 1024, "AC Status: %d\n", status.acStatusId); + strcat(summary_string, buff); - strftime(buff,1024,"Time: %a, %d %b %Y %T\n",localtime((time_t *)&status.time)); - strcat(summary_string,buff); + strftime(buff, 1024, "Time: %a, %d %b %Y %T\n", localtime((time_t *)&status.time)); + strcat(summary_string, buff); - snprintf(buff,1024,"Total Pictures Taken: %d\n", - status.taken_pict_mem + status.taken_pict_card ); - strcat(summary_string,buff); + snprintf(buff, 1024, "Total Pictures Taken: %d\n", + status.taken_pict_mem + status.taken_pict_card); + strcat(summary_string, buff); - } + } - strcpy(summary->text, summary_string); + strcpy(summary->text, summary_string); - return (GP_OK); + return (GP_OK); } -static int camera_manual (Camera *camera, CameraText *manual, - GPContext *context) +static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) { strcpy (manual->text, _("The Kodak DC120 camera uses the KDC file format " @@ -401,41 +399,41 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - GPPortSettings settings; + GPPortSettings settings; int speed; - /* First, set up all the function pointers */ + /* First, set up all the function pointers */ camera->functions->capture = camera_capture; camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); /* Configure the port (remember the speed) */ gp_port_get_settings (camera->port, &settings); speed = settings.serial.speed; - settings.serial.speed = 9600; - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits = 1; - gp_port_set_settings (camera->port, settings); - gp_port_set_timeout (camera->port, TIMEOUT); + settings.serial.speed = 9600; + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits = 1; + gp_port_set_settings (camera->port, settings); + gp_port_set_timeout (camera->port, TIMEOUT); - /* Reset the camera to 9600 */ - gp_port_send_break (camera->port, 2); + /* Reset the camera to 9600 */ + gp_port_send_break (camera->port, 2); - /* Wait for it to update */ - usleep(1500 * 1000); + /* Wait for it to update */ + usleep(1500 * 1000); if (dc120_set_speed (camera, speed) == GP_ERROR) { - return (GP_ERROR); - } + return (GP_ERROR); + } - /* Try to talk after speed change */ - if (dc120_get_status(camera, NULL, context) == GP_ERROR) { - return (GP_ERROR); - } + /* Try to talk after speed change */ + if (dc120_get_status(camera, NULL, context) == GP_ERROR) { + return (GP_ERROR); + } - return (GP_OK); + return (GP_OK); } diff --git a/camlibs/kodak/dc120/library.c b/camlibs/kodak/dc120/library.c index 68584a9377..8480966679 100644 --- a/camlibs/kodak/dc120/library.c +++ b/camlibs/kodak/dc120/library.c @@ -59,14 +59,14 @@ dc120_packet_new (int command_byte) { */ static int dc120_response_ok (unsigned char response) { - /* This is stupid. how do you get a constant of type signed char?? (Ralf) */ - if( response == 0x00 || /* Command completed */ - response == 0x10 || /* Command ready */ - response == 0xd1 || /* Command received (ACK) */ - response == 0xd2 ) /* Correct packet */ - return (GP_OK); - else - return (GP_ERROR); + /* This is stupid. how do you get a constant of type signed char?? (Ralf) */ + if (response == 0x00 || /* Command completed */ + response == 0x10 || /* Command ready */ + response == 0xd1 || /* Command received (ACK) */ + response == 0xd2 ) /* Correct packet */ + return (GP_OK); + else + return (GP_ERROR); } /** Writes a packet to the port. @@ -169,21 +169,21 @@ static int dc120_packet_read_data (Camera *camera, CameraFile *file, char *cmd_p /* Do some command-specific stuff */ switch (cmd_packet[0]) { - case 0x4A: + case 0x4A: /* Set size and num_packets for camera filenames*/ if (packets_received==1) *size = ((unsigned char)packet[0] * 256 + (unsigned char)packet[1])* 20 + 2; num_packets = (*size + block_size-1) / block_size; break; - case 0x64: - case 0x54: + case 0x64: + case 0x54: /* If thumbnail, cancel rest of image transfer */ if ((num_packets == 16)&&(packets_received==16)) p[0] = CANCL; /* No break on purpose */ break; - default: + default: /* Nada */ break; } @@ -194,10 +194,10 @@ static int dc120_packet_read_data (Camera *camera, CameraFile *file, char *cmd_p /* Copy in data */ if (packets_received == num_packets) - bytes_received = *size - ((num_packets-1) * block_size); + bytes_received = *size - ((num_packets-1) * block_size); else - bytes_received = block_size; - gp_file_append(file, packet, bytes_received ); + bytes_received = block_size; + gp_file_append(file, packet, bytes_received); } } @@ -295,66 +295,66 @@ int dc120_get_status (Camera *camera, Kodak_dc120_status *status, GPContext *con size = 256; retval = dc120_packet_read_data(camera, file, p, &size, 256, context); - if( retval == (GP_OK) && status != NULL ) - { - const char *data; - long unsigned int lsize; - - gp_file_get_data_and_size( file, &data, &lsize ); - if( lsize<122 ) { - gp_file_free (file); - free (p); - return (GP_ERROR); - } - - memset((char*)status,0,sizeof(*status)); - - status->camera_type_id = data[1]; - status->firmware_major = data[2]; - status->firmware_minor = data[3]; - status->batteryStatusId = data[8]; - status->acStatusId = data[9]; - - /* seconds since unix epoc */ - status->time = CAMERA_EPOC + ( - data[12] * 0x1000000 + - data[13] * 0x10000 + - data[14] * 0x100 + - data[15]) / 2; - - status->af_mode = data[16] & 0x0f; - status->zoom_mode = (data[16] & 0x30)>>4; - status->flash_charged = data[18]; - status->compression_mode_id = data[19]; - status->flash_mode = data[20]; - status->exposure_compensation = (data[2]&0x40?-1:1) * (data[21] & 0x3f); - status->light_value = data[22]; - status->manual_exposure = data[23]; - status->exposure_time = (data[24] * 0x1000000 + - data[25] * 0x10000 + - data[26] * 0x100 + - data[27]) / 2; - status->shutter_delay = data[29]; - status->memory_card = data[30]; - status->front_cover = data[31]; - status->date_format = data[32]; - status->time_format = data[33]; - status->distance_format = data[34]; - status->taken_pict_mem = data[36] * 0x100 + data[37]; - for( i=0; i<4; i++ ) { - status->remaining_pic_mem[i] = - data[46+i*2] * 0x100 + - data[47+i*2]; - } - status->taken_pict_card = data[56] * 0x100 + data[57]; - for( i=0; i<4; i++ ) { - status->remaining_pic_card[i] = - data[66+i*2] * 0x100 + - data[67+i*2]; - } - strncpy( status->card_id, data + 77, 32 ); - strncpy( status->camera_id, data + 90, 32 ); - } + if (retval == (GP_OK) && status != NULL) + { + const char *data; + long unsigned int lsize; + + gp_file_get_data_and_size(file, &data, &lsize); + if (lsize<122) { + gp_file_free (file); + free (p); + return (GP_ERROR); + } + + memset((char*)status, 0, sizeof(*status)); + + status->camera_type_id = data[1]; + status->firmware_major = data[2]; + status->firmware_minor = data[3]; + status->batteryStatusId = data[8]; + status->acStatusId = data[9]; + + /* seconds since unix epoc */ + status->time = CAMERA_EPOC + ( + data[12] * 0x1000000 + + data[13] * 0x10000 + + data[14] * 0x100 + + data[15]) / 2; + + status->af_mode = data[16] & 0x0f; + status->zoom_mode = (data[16] & 0x30)>>4; + status->flash_charged = data[18]; + status->compression_mode_id = data[19]; + status->flash_mode = data[20]; + status->exposure_compensation = (data[2]&0x40 ? -1 : 1) * (data[21] & 0x3f); + status->light_value = data[22]; + status->manual_exposure = data[23]; + status->exposure_time = (data[24] * 0x1000000 + + data[25] * 0x10000 + + data[26] * 0x100 + + data[27]) / 2; + status->shutter_delay = data[29]; + status->memory_card = data[30]; + status->front_cover = data[31]; + status->date_format = data[32]; + status->time_format = data[33]; + status->distance_format = data[34]; + status->taken_pict_mem = data[36] * 0x100 + data[37]; + for (i=0; i<4; i++) { + status->remaining_pic_mem[i] = + data[46+i*2] * 0x100 + + data[47+i*2]; + } + status->taken_pict_card = data[56] * 0x100 + data[57]; + for (i=0; i<4; i++) { + status->remaining_pic_card[i] = + data[66+i*2] * 0x100 + + data[67+i*2]; + } + strncpy(status->card_id, data + 77, 32); + strncpy(status->camera_id, data + 90, 32); + } gp_file_free(file); @@ -431,11 +431,11 @@ int dc120_get_filenames (Camera *camera, int from_card, int album_number, Camera gp_file_get_data_and_size (file, &file_data, &file_size); x=2; while (x < size) { - if( file_data[x] != '\0' ) { - strncpy(buf, (char*) &file_data[x], 11); - buf[7] = '.'; - buf[11] = '\0'; - gp_list_append(list, buf, NULL); + if (file_data[x] != '\0') { + strncpy(buf, (char*)&file_data[x], 11); + buf[7] = '.'; + buf[11] = '\0'; + gp_list_append(list, buf, NULL); } x += 20; } @@ -483,8 +483,8 @@ static int dc120_get_file_preview (Camera *camera, CameraFile *file, int file_nu static int dc120_get_file (Camera *camera, CameraFile *file, int file_number, char *cmd_packet, int *size, GPContext *context) { - CameraFile *size_file; /* file used to determine the filesize */ - char *p; + CameraFile *size_file; /* file used to determine the filesize */ + char *p; const char *file_data; long unsigned int file_size; unsigned int offset; @@ -508,12 +508,12 @@ static int dc120_get_file (Camera *camera, CameraFile *file, int file_number, ch gp_file_get_data_and_size (size_file, &file_data, &file_size); offset = 2 + (file_number-1) * 20; - if( file_size < (offset+19) ) - { - gp_file_free(size_file); - free (p); - return (GP_ERROR); - } + if (file_size < (offset+19)) + { + gp_file_free(size_file); + free (p); + return (GP_ERROR); + } *size = (unsigned char)file_data[offset + 16] * 256*256*256 + (unsigned char)file_data[offset + 17] * 256*256 + @@ -525,7 +525,7 @@ static int dc120_get_file (Camera *camera, CameraFile *file, int file_number, ch free (p); if (dc120_packet_read_data(camera, file, cmd_packet, size, 1024, context)==GP_ERROR) - return (GP_ERROR); + return (GP_ERROR); return (GP_OK); @@ -544,12 +544,12 @@ static int dc120_wait_for_completion (Camera *camera, GPContext *context) { retval = dc120_packet_read(camera, p, 1); switch (retval) { - case GP_ERROR: + case GP_ERROR: return (GP_ERROR); break; - case GP_ERROR_TIMEOUT: + case GP_ERROR_TIMEOUT: break; - default: + default: done = 1; } gp_context_progress_update (context, id, x); @@ -596,19 +596,19 @@ int dc120_file_action (Camera *camera, int action, int from_card, int album_numb p[4] = album_number; switch (action) { - case DC120_ACTION_PREVIEW: - p[0] = (from_card? 0x64 : 0x54); + case DC120_ACTION_PREVIEW: + p[0] = (from_card ? 0x64 : 0x54); retval = dc120_get_file_preview(camera, file, file_number, p, &size, context); break; - case DC120_ACTION_IMAGE: - p[0] = (from_card? 0x64 : 0x54); + case DC120_ACTION_IMAGE: + p[0] = (from_card ? 0x64 : 0x54); retval = dc120_get_file(camera, file, file_number, p, &size, context); break; - case DC120_ACTION_DELETE: - p[0] = (from_card? 0x7B : 0x7A); + case DC120_ACTION_DELETE: + p[0] = (from_card ? 0x7B : 0x7A); retval = dc120_delete_file(camera, p, context); break; - default: + default: retval = GP_ERROR; } free(p); @@ -617,20 +617,18 @@ int dc120_file_action (Camera *camera, int action, int from_card, int album_numb int dc120_capture (Camera *camera, CameraFilePath *path, GPContext *context) { - int retval; - char *p = dc120_packet_new(0x77); - - /* Take the picture to Flash memory */ - if (dc120_packet_write(camera, p, 8, 1) == GP_ERROR) { - retval = (GP_ERROR); - } - else if ( dc120_wait_for_completion(camera, context) == GP_ERROR ) { - retval = (GP_ERROR); - } - else { - retval = (GP_OK); - } - - free( p ); - return retval; + int retval; + char *p = dc120_packet_new(0x77); + + /* Take the picture to Flash memory */ + if (dc120_packet_write(camera, p, 8, 1) == GP_ERROR) { + retval = (GP_ERROR); + } else if (dc120_wait_for_completion(camera, context) == GP_ERROR) { + retval = (GP_ERROR); + } else { + retval = (GP_OK); + } + + free(p); + return retval; } diff --git a/camlibs/kodak/dc210/dc210.c b/camlibs/kodak/dc210/dc210.c index 09e7acee0b..b5dc4d0e6d 100644 --- a/camlibs/kodak/dc210/dc210.c +++ b/camlibs/kodak/dc210/dc210.c @@ -122,7 +122,7 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder, static int get_info_func (CameraFilesystem *fs, const char *folder, const char *file, CameraFileInfo *info, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; dc210_picture_info picinfo; if (dc210_get_picture_info_by_name(camera, &picinfo, file) == GP_ERROR) @@ -186,10 +186,10 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) gp_widget_new (GP_WIDGET_SECTION, _("File"), §ion); gp_widget_append (*window, section); - gp_widget_new (GP_WIDGET_RADIO, _("File type"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("JPEG")); - gp_widget_add_choice (widget, _("FlashPix")); + gp_widget_new (GP_WIDGET_RADIO, _("File type"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("JPEG")); + gp_widget_add_choice (widget, _("FlashPix")); switch (status.file_type){ case DC210_FILE_TYPE_JPEG: @@ -199,10 +199,10 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) }; gp_widget_get_value (widget, &wvalue); - gp_widget_new (GP_WIDGET_RADIO, _("File resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("640 x 480")); - gp_widget_add_choice (widget, _("1152 x 864")); + gp_widget_new (GP_WIDGET_RADIO, _("File resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("640 x 480")); + gp_widget_add_choice (widget, _("1152 x 864")); switch (status.resolution){ case DC210_FILE_640: @@ -214,11 +214,11 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) }; gp_widget_get_value (widget, &wvalue); - gp_widget_new (GP_WIDGET_MENU, _("File compression"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Low (best quality)")); - gp_widget_add_choice (widget, _("Medium (better quality)")); - gp_widget_add_choice (widget, _("High (good quality)")); + gp_widget_new (GP_WIDGET_MENU, _("File compression"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Low (best quality)")); + gp_widget_add_choice (widget, _("Medium (better quality)")); + gp_widget_add_choice (widget, _("High (good quality)")); switch (status.compression_type){ case DC210_LOW_COMPRESSION: @@ -233,14 +233,14 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) gp_widget_new (GP_WIDGET_SECTION, _("Capture"), §ion); gp_widget_append (*window, section); - gp_widget_new (GP_WIDGET_MENU, _("Zoom"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, "58 mm"); /* no need to translate strings with SI units! */ - gp_widget_add_choice (widget, "51 mm"); - gp_widget_add_choice (widget, "41 mm"); - gp_widget_add_choice (widget, "34 mm"); - gp_widget_add_choice (widget, "29 mm"); - gp_widget_add_choice (widget, _("Macro")); + gp_widget_new (GP_WIDGET_MENU, _("Zoom"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, "58 mm"); /* no need to translate strings with SI units! */ + gp_widget_add_choice (widget, "51 mm"); + gp_widget_add_choice (widget, "41 mm"); + gp_widget_add_choice (widget, "34 mm"); + gp_widget_add_choice (widget, "29 mm"); + gp_widget_add_choice (widget, _("Macro")); switch (status.zoom){ case DC210_ZOOM_58: @@ -258,19 +258,19 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) }; gp_widget_get_value (widget, &wvalue); - gp_widget_new (GP_WIDGET_MENU, _("Exposure compensation"), &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_MENU, _("Exposure compensation"), &widget); + gp_widget_append (section, widget); for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){ gp_widget_add_choice (widget, exp_comp[i]); if ((unsigned int)(status.exp_compensation + 4) == i) gp_widget_set_value (widget, exp_comp[i]); }; - gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Auto")); - gp_widget_add_choice (widget, _("Force")); - gp_widget_add_choice (widget, _("None")); + gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Auto")); + gp_widget_add_choice (widget, _("Force")); + gp_widget_add_choice (widget, _("None")); switch (status.flash){ case DC210_FLASH_AUTO: @@ -282,10 +282,10 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) }; gp_widget_get_value (widget, &wvalue); - gp_widget_new (GP_WIDGET_RADIO, _("Red eye flash"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("On")); - gp_widget_add_choice (widget, _("Off")); + gp_widget_new (GP_WIDGET_RADIO, _("Red eye flash"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("On")); + gp_widget_add_choice (widget, _("Off")); if (status.preflash) gp_widget_set_value (widget, _("On")); @@ -296,15 +296,15 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) gp_widget_new (GP_WIDGET_SECTION, _("Other"), §ion); gp_widget_append (*window, section); - gp_widget_new (GP_WIDGET_BUTTON, "Set time to system time", &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_BUTTON, "Set time to system time", &widget); + gp_widget_append (section, widget); gp_widget_set_value (widget, dc210_system_time_callback); gp_widget_set_info (widget, _("Set clock in camera")); gp_camera_get_abilities(camera, &abilities); gp_port_get_settings (camera->port, &settings); - gp_widget_new (GP_WIDGET_MENU, _("Port speed"), &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_MENU, _("Port speed"), &widget); + gp_widget_append (section, widget); for (i = 0; i < sizeof(abilities.speed); i++){ if (abilities.speed[i] == 0) break; snprintf(stringbuffer, 12, "%d", abilities.speed[i]); @@ -313,13 +313,13 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) gp_widget_set_value (widget, stringbuffer); }; - gp_widget_new (GP_WIDGET_TEXT, _("Album name"), &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_TEXT, _("Album name"), &widget); + gp_widget_append (section, widget); gp_widget_set_value (widget, status.album_name); gp_widget_set_info (widget, _("Name to set on card when formatting.")); - gp_widget_new (GP_WIDGET_BUTTON, _("Format compact flash"), &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_BUTTON, _("Format compact flash"), &widget); + gp_widget_append (section, widget); gp_widget_set_value (widget, dc210_format_callback); gp_widget_set_info (widget, _("Format card and set album name.")); @@ -327,20 +327,20 @@ camera_get_config (Camera *camera, CameraWidget **window, GPContext *context) gp_widget_new (GP_WIDGET_SECTION, _("Debug"), §ion); gp_widget_append (*window, section); - gp_widget_new (GP_WIDGET_TEXT, "Parameter 1", &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_TEXT, "Parameter 1", &widget); + gp_widget_append (section, widget); gp_widget_set_value (widget, "0"); - gp_widget_new (GP_WIDGET_TEXT, "Parameter 2", &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_TEXT, "Parameter 2", &widget); + gp_widget_append (section, widget); gp_widget_set_value (widget, "0"); - gp_widget_new (GP_WIDGET_TEXT, "Parameter 3", &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_TEXT, "Parameter 3", &widget); + gp_widget_append (section, widget); gp_widget_set_value (widget, "0"); - gp_widget_new (GP_WIDGET_BUTTON, "Execute debug command", &widget); - gp_widget_append (section, widget); + gp_widget_new (GP_WIDGET_BUTTON, "Execute debug command", &widget); + gp_widget_append (section, widget); gp_widget_set_value (widget, dc210_debug_callback); gp_widget_set_info (widget, _("Execute predefined command\nwith parameter values.")); #endif @@ -357,7 +357,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("File type"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); if (wvalue[0] == 'J') dc210_set_file_type(camera, DC210_FILE_TYPE_JPEG); @@ -367,7 +367,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("File resolution"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); switch(wvalue[0]){ case '6': @@ -381,7 +381,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("File compression"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); switch(wvalue[0]){ case 'L': @@ -397,7 +397,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Zoom"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); switch(wvalue[0]){ case '5': @@ -423,7 +423,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Exposure compensation"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); for (i = 0; i < sizeof(exp_comp)/sizeof(*exp_comp); i++){ if (strncmp(wvalue, exp_comp[i], 4) == 0){ @@ -435,7 +435,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Port speed"), &w); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &wvalue); dc210_set_speed(camera, atoi(wvalue)); }; @@ -443,8 +443,8 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) gp_widget_get_child_by_label (window, _("Flash"), &w); gp_widget_get_child_by_label (window, _("Red eye flash"), &w2); if (gp_widget_changed (w) || gp_widget_changed(w2)) { - gp_widget_set_changed (w, 0); - gp_widget_set_changed (w2, 0); + gp_widget_set_changed (w, 0); + gp_widget_set_changed (w2, 0); gp_widget_get_value (w, &wvalue); gp_widget_get_value (w2, &w2value); switch(wvalue[0]){ @@ -479,7 +479,7 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat } static int camera_capture_preview (Camera* camera, CameraFile* file, GPContext *context){ - /* this function is to slow; don't export it */ + /* this function is to slow; don't export it */ int fatal_error = 0; if (dc210_take_picture(camera, context) == GP_ERROR) return GP_ERROR; @@ -492,150 +492,148 @@ static int camera_capture_preview (Camera* camera, CameraFile* file, GPContext * }; -static int camera_summary (Camera *camera, CameraText *summary, - GPContext *context) +static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { - static char summary_string[2048] = ""; - char buff[1024]; - dc210_status status; - - if (GP_OK == dc210_get_status (camera, &status)) - { - strcpy(summary_string,"Kodak DC210\n"); - - snprintf(buff,1024,_("Pictures in camera: %d\n"), - status.numPicturesInCamera); - strcat(summary_string,buff); - - snprintf(buff,1024,_("There is space for another\n %d low compressed\n %d medium compressed or\n %d high compressed pictures\n"), - status.remainingLow, status.remainingMedium, status.remainingHigh); - strcat(summary_string,buff); - - snprintf(buff,1024,_("Total pictures taken: %d\n"), - status.totalPicturesTaken); - strcat(summary_string,buff); + static char summary_string[2048] = ""; + char buff[1024]; + dc210_status status; - snprintf(buff,1024,_("Total flashes fired: %d\n"), - status.totalFlashesFired); - strcat(summary_string,buff); + if (GP_OK == dc210_get_status (camera, &status)) + { + strcpy(summary_string, "Kodak DC210\n"); - snprintf(buff,1024,_("Firmware: %d.%d\n"),status.firmwareMajor,status.firmwareMinor); - strcat(summary_string,buff); + snprintf(buff, 1024, _("Pictures in camera: %d\n"), + status.numPicturesInCamera); + strcat(summary_string, buff); - switch (status.file_type){ - case DC210_FILE_TYPE_JPEG: - snprintf(buff, 1024, _("Filetype: JPEG (")); break; - case DC210_FILE_TYPE_FPX: - snprintf(buff, 1024, _("Filetype: FlashPix (")); break; - }; - strcat(summary_string, buff); + snprintf(buff, 1024, _("There is space for another\n %d low compressed\n %d medium compressed or\n %d high compressed pictures\n"), + status.remainingLow, status.remainingMedium, status.remainingHigh); + strcat(summary_string, buff); - switch (status.compression_type){ - case DC210_LOW_COMPRESSION: - snprintf(buff, 1024, _("low compression, ")); break; - case DC210_MEDIUM_COMPRESSION: - snprintf(buff, 1024, _("medium compression, ")); break; - case DC210_HIGH_COMPRESSION: - snprintf(buff, 1024, _("high compression, ")); break; - default: - snprintf(buff, 1024, _("unknown compression %d, "), status.compression_type); break; - }; - strcat(summary_string, buff); + snprintf(buff, 1024, _("Total pictures taken: %d\n"), + status.totalPicturesTaken); + strcat(summary_string, buff); - switch (status.resolution){ - case DC210_FILE_640: - snprintf(buff, 1024, "640x480 pixel)\n"); break; - case DC210_FILE_1152: - snprintf(buff, 1024, "1152x864 pixel)\n"); break; - default: - snprintf(buff, 1024, _("unknown resolution %d)\n"), status.resolution); break; - }; - strcat(summary_string, buff); + snprintf(buff, 1024, _("Total flashes fired: %d\n"), + status.totalFlashesFired); + strcat(summary_string, buff); - /* battery check still doesn't work */ - /* switch (status.battery){ - case 0: snprintf(buff,1024,"Battery charge is good\n"); break; - case 1: snprintf(buff,1024,"Battery charge is low\n"); break; - case 2: snprintf(buff,1024,"Battery is not charged\n"); break; - }; - strcat(summary_string,buff);*/ + snprintf(buff, 1024, _("Firmware: %d.%d\n"), status.firmwareMajor, status.firmwareMinor); + strcat(summary_string, buff); - if (status.acstatus) - snprintf(buff,1024,_("AC adapter is connected.\n")); - else - snprintf(buff,1024,_("AC adapter is not connected.\n")); - strcat(summary_string,buff); + switch (status.file_type) { + case DC210_FILE_TYPE_JPEG: + snprintf(buff, 1024, _("Filetype: JPEG (")); break; + case DC210_FILE_TYPE_FPX: + snprintf(buff, 1024, _("Filetype: FlashPix (")); break; + }; + strcat(summary_string, buff); + + switch (status.compression_type) { + case DC210_LOW_COMPRESSION: + snprintf(buff, 1024, _("low compression, ")); break; + case DC210_MEDIUM_COMPRESSION: + snprintf(buff, 1024, _("medium compression, ")); break; + case DC210_HIGH_COMPRESSION: + snprintf(buff, 1024, _("high compression, ")); break; + default: + snprintf(buff, 1024, _("unknown compression %d, "), status.compression_type); break; + }; + strcat(summary_string, buff); + + switch (status.resolution) { + case DC210_FILE_640: + snprintf(buff, 1024, "640x480 pixel)\n"); break; + case DC210_FILE_1152: + snprintf(buff, 1024, "1152x864 pixel)\n"); break; + default: + snprintf(buff, 1024, _("unknown resolution %d)\n"), status.resolution); break; + }; + strcat(summary_string, buff); - /* time string, do not change the % escapes */ - strftime(buff,1024,_("Time: %a, %d %b %Y %T\n"), - localtime((time_t *)&status.time)); - strcat(summary_string,buff); + /* battery check still doesn't work */ + /* switch (status.battery){ + case 0: snprintf(buff,1024,"Battery charge is good\n"); break; + case 1: snprintf(buff,1024,"Battery charge is low\n"); break; + case 2: snprintf(buff,1024,"Battery is not charged\n"); break; + }; + strcat(summary_string,buff);*/ - switch (status.zoom){ - case DC210_ZOOM_58: - snprintf(buff, 1024, _("Zoom: 58 mm\n")); break; - case DC210_ZOOM_51: - snprintf(buff, 1024, _("Zoom: 51 mm\n")); break; - case DC210_ZOOM_41: - snprintf(buff, 1024, _("Zoom: 41 mm\n")); break; - case DC210_ZOOM_34: - snprintf(buff, 1024, _("Zoom: 34 mm\n")); break; - case DC210_ZOOM_29: - snprintf(buff, 1024, _("Zoom: 29 mm\n")); break; - case DC210_ZOOM_MACRO: - snprintf(buff, 1024, _("Zoom: macro\n")); break; - default: - snprintf(buff, 1024, _("Unknown zoom mode %d\n"), - status.zoom); break; - }; - strcat(summary_string,buff); + if (status.acstatus) + snprintf(buff, 1024, _("AC adapter is connected.\n")); + else + snprintf(buff, 1024, _("AC adapter is not connected.\n")); + strcat(summary_string, buff); + + /* time string, do not change the % escapes */ + strftime(buff, 1024, _("Time: %a, %d %b %Y %T\n"), + localtime((time_t *)&status.time)); + strcat(summary_string, buff); + + switch (status.zoom) { + case DC210_ZOOM_58: + snprintf(buff, 1024, _("Zoom: 58 mm\n")); break; + case DC210_ZOOM_51: + snprintf(buff, 1024, _("Zoom: 51 mm\n")); break; + case DC210_ZOOM_41: + snprintf(buff, 1024, _("Zoom: 41 mm\n")); break; + case DC210_ZOOM_34: + snprintf(buff, 1024, _("Zoom: 34 mm\n")); break; + case DC210_ZOOM_29: + snprintf(buff, 1024, _("Zoom: 29 mm\n")); break; + case DC210_ZOOM_MACRO: + snprintf(buff, 1024, _("Zoom: macro\n")); break; + default: + snprintf(buff, 1024, _("Unknown zoom mode %d\n"), + status.zoom); break; + }; + strcat(summary_string, buff); - if (status.exp_compensation > -5 && status.exp_compensation < 4) - snprintf(buff, 1024, _("Exposure compensation: %s\n"), exp_comp[status.exp_compensation + 4]); - else - snprintf(buff, 1024, _("Exposure compensation: %d\n"), status.exp_compensation); - strcat(summary_string,buff); + if (status.exp_compensation > -5 && status.exp_compensation < 4) + snprintf(buff, 1024, _("Exposure compensation: %s\n"), exp_comp[status.exp_compensation + 4]); + else + snprintf(buff, 1024, _("Exposure compensation: %d\n"), status.exp_compensation); + strcat(summary_string, buff); + + switch (status.flash) { + case DC210_FLASH_AUTO: + snprintf(buff, 1024, _("Flash mode: auto, ")); break; + case DC210_FLASH_FORCE: + snprintf(buff, 1024, _("Flash mode: force, ")); break; + case DC210_FLASH_NONE: + snprintf(buff, 1024, _("Flash mode: off\n")); break; + default: + snprintf(buff, 1024, _("Unknown flash mode %d, "), + status.flash); break; + }; + strcat(summary_string, buff); - switch (status.flash){ - case DC210_FLASH_AUTO: - snprintf(buff, 1024, _("Flash mode: auto, ")); break; - case DC210_FLASH_FORCE: - snprintf(buff, 1024, _("Flash mode: force, ")); break; - case DC210_FLASH_NONE: - snprintf(buff, 1024, _("Flash mode: off\n")); break; - default: - snprintf(buff, 1024, _("Unknown flash mode %d, "), - status.flash); break; - }; - strcat(summary_string,buff); + if (status.flash != DC210_FLASH_NONE) { + if (status.preflash) + /* trans: continuation of "Flash mode:" line */ + snprintf(buff, 1024, _("red eye flash on.\n")); + else + /* trans: continuation of "Flash mode:" line */ + snprintf(buff, 1024, _("red eye flash off.\n")); + strcat(summary_string, buff); + }; - if (status.flash != DC210_FLASH_NONE){ - if (status.preflash) - /* trans: continuation of "Flash mode:" line */ - snprintf(buff,1024,_("red eye flash on.\n")); + if (status.card_status.open == 0) + snprintf(buff, 1024, _("No card in camera.\n")); else - /* trans: continuation of "Flash mode:" line */ - snprintf(buff,1024,_("red eye flash off.\n")); - strcat(summary_string,buff); - }; - - if (status.card_status.open == 0) - snprintf(buff, 1024, _("No card in camera.\n")); - else - snprintf(buff,1024, _("Card name: %s\nFree space on card: %d kB\n"), - status.album_name, - status.card_status.space); + snprintf(buff, 1024, _("Card name: %s\nFree space on card: %d kB\n"), + status.album_name, + status.card_status.space); - strcat(summary_string,buff); + strcat(summary_string, buff); - } - else{ - DC210_DEBUG("Couldn't get summary for camera\n"); - }; + } else { + DC210_DEBUG("Couldn't get summary for camera\n"); + }; - strcpy(summary->text, summary_string); + strcpy(summary->text, summary_string); - return (GP_OK); + return (GP_OK); } @@ -671,20 +669,20 @@ int camera_init (Camera *camera, GPContext *context) { DC210_DEBUG("Initializing camera.\n"); - /* First, set up all the function pointers */ + /* First, set up all the function pointers */ camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; camera->functions->capture = camera_capture; camera->functions->capture_preview = camera_capture_preview; camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); if (dc210_init_port (camera) == GP_ERROR) return GP_ERROR; if (dc210_open_card (camera) == GP_ERROR) return GP_ERROR; - return (GP_OK); + return (GP_OK); } /****************************************************************************/ diff --git a/camlibs/kodak/dc210/dc210.h b/camlibs/kodak/dc210/dc210.h index 39454c29f3..38065f87db 100644 --- a/camlibs/kodak/dc210/dc210.h +++ b/camlibs/kodak/dc210/dc210.h @@ -82,11 +82,11 @@ typedef struct { dc210_zoom_type zoom; char flash_charged; dc210_compression_type compression_type; - signed char exp_compensation; + signed char exp_compensation; dc210_flash_type flash; char preflash; dc210_resolution_type resolution; - dc210_file_type_type file_type; + dc210_file_type_type file_type; int totalPicturesTaken; int totalFlashesFired; int numPicturesInCamera; diff --git a/camlibs/kodak/dc210/library.c b/camlibs/kodak/dc210/library.c index 97c4cedeaf..cc9a64a197 100644 --- a/camlibs/kodak/dc210/library.c +++ b/camlibs/kodak/dc210/library.c @@ -47,9 +47,8 @@ static char oldstatus[DC210_STATUS_SIZE]; ****************************************************************************/ -static void cfa2ppm -(CameraFile * file) -{ +static void cfa2ppm (CameraFile * file) { + /* this is a very quick and dirty hack to convert cfa into ppm */ unsigned char buf[THUMBHEIGHT][THUMBWIDTH]; unsigned char rgb[THUMBHEIGHT][THUMBWIDTH][3]; @@ -138,9 +137,8 @@ static void cfa2ppm /* Utility procedures for command execution */ -static void dc210_cmd_init -(char * cmd, unsigned char command_byte) -{ +static void dc210_cmd_init (char * cmd, unsigned char command_byte) { + /* utility procedure to initialize a command string */ memset (cmd, 0, 8); @@ -150,9 +148,8 @@ static void dc210_cmd_init }; -static void dc210_cmd_packet_init -(char * cmd_packet, const char * filename) -{ +static void dc210_cmd_packet_init (char * cmd_packet, const char * filename) { + /* prepare command packet */ memset (cmd_packet, 0x00, DC210_CMD_DATA_SIZE); memset (cmd_packet + 48, 0xFF, 8); @@ -163,9 +160,8 @@ static void dc210_cmd_packet_init }; -static int dc210_write_single_char -(Camera *camera, unsigned char response) -{ +static int dc210_write_single_char (Camera *camera, unsigned char response) { + /* utility procedure to write a single character */ int i; @@ -179,9 +175,7 @@ static int dc210_write_single_char }; -static int dc210_read_single_char -(Camera *camera, unsigned char * response) -{ +static int dc210_read_single_char (Camera *camera, unsigned char * response) { /* utility procedure to read a single character */ @@ -211,9 +205,7 @@ static int dc210_read_single_char /* Command execution */ -static int dc210_execute_command -(Camera *camera, char *cmd) -{ +static int dc210_execute_command (Camera *camera, char *cmd) { /* This procedure sends a command to the camera and waits for acknowledgement. Calling procedures have @@ -221,7 +213,7 @@ static int dc210_execute_command there are three possible follow ups: - Read a DC210_COMMAND_COMPLETE in case of simple commands - - Send an additional command package in case of + - Send an additional command package in case of sophisticated commands - Read data from the camera But all this depends on the command and should not @@ -285,9 +277,7 @@ static int dc210_execute_command /* appropriate actions to a command */ -static int dc210_write_command_packet -(Camera * camera, char * data) -{ +static int dc210_write_command_packet (Camera * camera, char * data) { unsigned char checksum; int i, error; @@ -331,9 +321,8 @@ static int dc210_write_command_packet }; -static int dc210_wait_for_response -(Camera *camera, int expect_busy, GPContext *context) -{ +static int dc210_wait_for_response (Camera *camera, int expect_busy, GPContext *context) { + /* Waits for a command to finish. Expects either a timeout, a DC210_BUSY, a DC210_COMMAND_COMPLETE or a @@ -346,155 +335,151 @@ static int dc210_wait_for_response int progress_id = 0; if (context) - progress_id = gp_context_progress_start (context, expect_busy, _("Waiting...")); - - while (1){ - - error = dc210_read_single_char(camera, &response); - if (error < 0){ - if (context) - gp_context_progress_stop (context, progress_id); - return error; - }; - - switch (response){ - case DC210_BUSY: - /* wait a little bit longer */ - if (context && counter <= expect_busy) - gp_context_progress_update (context, progress_id, counter++); - break; - case DC210_COMMAND_COMPLETE: - case DC210_PACKET_FOLLOWING: - if (context) - gp_context_progress_stop (context, progress_id); - return response; - break; - default: - if (context) - gp_context_progress_stop (context, progress_id); - DC210_DEBUG("Command terminated with errorcode 0x%02X.\n", response); - return GP_ERROR; - }; + progress_id = gp_context_progress_start (context, expect_busy, _("Waiting...")); + + while (1) { + + error = dc210_read_single_char(camera, &response); + if (error < 0) { + if (context) + gp_context_progress_stop (context, progress_id); + return error; + }; + + switch (response) { + case DC210_BUSY: + /* wait a little bit longer */ + if (context && counter <= expect_busy) + gp_context_progress_update (context, progress_id, counter++); + break; + case DC210_COMMAND_COMPLETE: + case DC210_PACKET_FOLLOWING: + if (context) + gp_context_progress_stop (context, progress_id); + return response; + break; + default: + if (context) + gp_context_progress_stop (context, progress_id); + DC210_DEBUG("Command terminated with errorcode 0x%02X.\n", response); + return GP_ERROR; + }; }; }; -static int dc210_read_single_block -(Camera *camera, unsigned char * b, int blocksize) -{ +static int dc210_read_single_block (Camera *camera, unsigned char * b, int blocksize) { - int i, k, error; - char cs_read, cs_computed; + int i, k, error; + char cs_read, cs_computed; - for (i = 0; i < RETRIES; i++){ + for (i = 0; i < RETRIES; i++) { - if (dc210_wait_for_response(camera, 0, NULL) != DC210_PACKET_FOLLOWING) - return GP_ERROR; + if (dc210_wait_for_response(camera, 0, NULL) != DC210_PACKET_FOLLOWING) + return GP_ERROR; - error = 1; - for (k = 0; k < RETRIES; k++){ - if (gp_port_read(camera->port, (char *)b, blocksize) < 0){ - continue; - }; - error = 0; - break; - }; + error = 1; + for (k = 0; k < RETRIES; k++) { + if (gp_port_read(camera->port, (char *)b, blocksize) < 0) { + continue; + }; + error = 0; + break; + }; - if (error) return GP_ERROR; + if (error) return GP_ERROR; - if (dc210_read_single_char(camera, (unsigned char *)&cs_read) < 0) - return GP_ERROR; + if (dc210_read_single_char(camera, (unsigned char *)&cs_read) < 0) + return GP_ERROR; - cs_computed = 0; - for (k = 0 ; k < blocksize; k++) - cs_computed ^= b[k]; - if (cs_computed == cs_read){ - dc210_write_single_char(camera, DC210_CORRECT_PACKET); - return GP_OK; - }; + cs_computed = 0; + for (k = 0; k < blocksize; k++) + cs_computed ^= b[k]; + if (cs_computed == cs_read) { + dc210_write_single_char(camera, DC210_CORRECT_PACKET); + return GP_OK; + }; - dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); + dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); - }; + }; - return GP_ERROR; + return GP_ERROR; }; -static int dc210_read_to_file -(Camera *camera, CameraFile * f, int blocksize, long int expectsize, GPContext *context) -{ +static int dc210_read_to_file (Camera *camera, CameraFile * f, int blocksize, long int expectsize, GPContext *context) { + + int packets, k, l, fatal_error, packet_following; + unsigned int progress_id = 0; + unsigned char cs_read, cs_computed; + unsigned char * b; + + int blocks = expectsize / blocksize; + int remaining = expectsize % blocksize; + + if (NULL == (b = malloc(blocksize))) return GP_ERROR; + + if (remaining) blocks++; + + if (context) + progress_id = gp_context_progress_start (context, blocks, _("Getting data...")); + + fatal_error = 0; + packets = 0; + + packet_following = dc210_wait_for_response(camera, 0, NULL); + while (DC210_PACKET_FOLLOWING == packet_following) { + fatal_error = 1; + for (k = 0; k < RETRIES; k++) { + /* read packet */ + if (gp_port_read(camera->port, (char *)b, blocksize) < 0) { + dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); + packet_following = dc210_wait_for_response(camera, 0, NULL); + continue; + }; + /* read checksum */ + if (dc210_read_single_char(camera, &cs_read) == GP_ERROR) { + free(b); + return GP_ERROR; + }; + /* test checksum */ + cs_computed = 0; + for (l = 0; l < blocksize; l++) + cs_computed ^= b[l]; + if (cs_computed != cs_read) { + dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); + packet_following = dc210_wait_for_response(camera, 0, NULL); + continue; + }; + /* append to file */ + if (packets == blocks - 1 && remaining) + gp_file_append(f, (char *)b, remaining); + else + gp_file_append(f, (char *)b, blocksize); + /* request next packet */ + dc210_write_single_char(camera, DC210_CORRECT_PACKET); + packet_following = dc210_wait_for_response(camera, 0, NULL); + fatal_error = 0; + if (context) + gp_context_progress_update (context, progress_id, packets); + packets++; + break; + }; + if (fatal_error) break; + }; + + if (packet_following < 0) + fatal_error = 1; - int packets, k, l, fatal_error, packet_following; - unsigned int progress_id = 0; - unsigned char cs_read, cs_computed; - unsigned char * b; - - int blocks = expectsize / blocksize; - int remaining = expectsize % blocksize; - - if (NULL == (b = malloc(blocksize))) return GP_ERROR; - - if (remaining) blocks++; - - if (context) - progress_id = gp_context_progress_start (context, blocks, _("Getting data...")); - - fatal_error = 0; - packets = 0; - - packet_following = dc210_wait_for_response(camera, 0, NULL); - while (DC210_PACKET_FOLLOWING == packet_following){ - fatal_error = 1; - for (k = 0; k < RETRIES; k++){ - /* read packet */ - if (gp_port_read(camera->port, (char *)b, blocksize) < 0){ - dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); - packet_following = dc210_wait_for_response(camera, 0, NULL); - continue; - }; - /* read checksum */ - if (dc210_read_single_char(camera, &cs_read) == GP_ERROR){ - free(b); - return GP_ERROR; - }; - /* test checksum */ - cs_computed = 0; - for (l = 0 ; l < blocksize; l++) - cs_computed ^= b[l]; - if (cs_computed != cs_read){ - dc210_write_single_char(camera, DC210_ILLEGAL_PACKET); - packet_following = dc210_wait_for_response(camera, 0, NULL); - continue; - }; - /* append to file */ - if (packets == blocks - 1 && remaining) - gp_file_append(f, (char *)b, remaining); - else - gp_file_append(f, (char *)b, blocksize); - /* request next packet */ - dc210_write_single_char(camera, DC210_CORRECT_PACKET); - packet_following = dc210_wait_for_response(camera, 0, NULL); - fatal_error = 0; - if (context) - gp_context_progress_update (context, progress_id, packets); - packets++; - break; - }; - if (fatal_error) break; - }; - - if (packet_following < 0) - fatal_error = 1; - - if (context) - gp_context_progress_stop (context, progress_id); - - free(b); - - if (fatal_error) return GP_ERROR; - - return GP_OK; + if (context) + gp_context_progress_stop (context, progress_id); + + free(b); + + if (fatal_error) return GP_ERROR; + + return GP_OK; }; @@ -506,7 +491,7 @@ static int dc210_read_to_file /***** Set procedures *****/ -static int dc210_set_option (Camera * camera, char command, unsigned int value, int valuesize){ +static int dc210_set_option (Camera * camera, char command, unsigned int value, int valuesize) { char cmd[8]; dc210_cmd_init(cmd, command); @@ -539,15 +524,15 @@ static int dc210_set_option (Camera * camera, char command, unsigned int value, }; -int dc210_set_compression (Camera * camera, dc210_compression_type compression){ +int dc210_set_compression (Camera * camera, dc210_compression_type compression) { return dc210_set_option(camera, DC210_SET_QUALITY, compression, 1); }; -int dc210_set_flash (Camera * camera, dc210_flash_type flash, char preflash){ +int dc210_set_flash (Camera * camera, dc210_flash_type flash, char preflash) { - if (flash != DC210_FLASH_NONE && preflash){ + if (flash != DC210_FLASH_NONE && preflash) { return dc210_set_option(camera, DC210_SET_FLASH, flash + 3, 1); } else @@ -555,25 +540,25 @@ int dc210_set_flash (Camera * camera, dc210_flash_type flash, char preflash){ }; -int dc210_set_zoom (Camera * camera, dc210_zoom_type zoom){ +int dc210_set_zoom (Camera * camera, dc210_zoom_type zoom) { return dc210_set_option(camera, DC210_SET_ZOOM, zoom, 1); }; -int dc210_set_file_type (Camera * camera, dc210_file_type_type file_type){ +int dc210_set_file_type (Camera * camera, dc210_file_type_type file_type) { return dc210_set_option(camera, DC210_SET_FILE_TYPE, file_type, 1); }; -int dc210_set_resolution (Camera * camera, dc210_resolution_type res){ +int dc210_set_resolution (Camera * camera, dc210_resolution_type res) { return dc210_set_option(camera, DC210_SET_RESOLUTION, res, 1); }; -int dc210_set_delay (Camera * camera){ +int dc210_set_delay (Camera * camera) { /* This function works, but I do no have the slightest idea, what the effect is / should be. @@ -584,7 +569,7 @@ int dc210_set_delay (Camera * camera){ }; -int dc210_set_exp_compensation (Camera * camera, signed int compensation){ +int dc210_set_exp_compensation (Camera * camera, signed int compensation) { unsigned char param = abs(compensation); @@ -594,100 +579,100 @@ int dc210_set_exp_compensation (Camera * camera, signed int compensation){ }; -int dc210_system_time_callback (Camera * camera, CameraWidget * widget, GPContext * context){ +int dc210_system_time_callback (Camera * camera, CameraWidget * widget, GPContext * context) { return dc210_set_option(camera, DC210_SET_TIME, (time(NULL) - CAMERA_SET_EPOC) << 1, 4); }; -static int dc210_format_card (Camera * camera, char * album_name, GPContext * context){ +static int dc210_format_card (Camera * camera, char * album_name, GPContext * context) { - char data[DC210_CMD_DATA_SIZE]; - char cmd[8]; - char * subst; - unsigned char answer[16]; - unsigned char checksum_read, checksum; - int i; - - memset (data, 0, DC210_CMD_DATA_SIZE); + char data[DC210_CMD_DATA_SIZE]; + char cmd[8]; + char * subst; + unsigned char answer[16]; + unsigned char checksum_read, checksum; + int i; - /* Make the album name acceptable - we need at least 8 characters - which are not blank and there are no blanks allowed before the - last character. - */ - if (album_name != NULL && strlen(album_name) > 0){ - strncpy(data, album_name, 11); - /* substitute blanks in the first 8 characters*/ - while (NULL != (subst = strchr(data, ' '))) *subst = '_'; - if (strlen(data) < 8) strncat(data, "________", 8 - strlen(data)); - }; + memset (data, 0, DC210_CMD_DATA_SIZE); + + /* Make the album name acceptable - we need at least 8 characters + which are not blank and there are no blanks allowed before the + last character. + */ + if (album_name != NULL && strlen(album_name) > 0) { + strncpy(data, album_name, 11); + /* substitute blanks in the first 8 characters*/ + while (NULL != (subst = strchr(data, ' '))) *subst = '_'; + if (strlen(data) < 8) strncat(data, "________", 8 - strlen(data)); + }; - DC210_DEBUG("Album name is '%s'\n", data); + DC210_DEBUG("Album name is '%s'\n", data); - dc210_cmd_init(cmd, DC210_CARD_FORMAT); + dc210_cmd_init(cmd, DC210_CARD_FORMAT); - dc210_execute_command(camera, cmd); - dc210_write_command_packet(camera, data); - if (dc210_wait_for_response(camera, 3, context) != DC210_PACKET_FOLLOWING) return GP_ERROR; + dc210_execute_command(camera, cmd); + dc210_write_command_packet(camera, data); + if (dc210_wait_for_response(camera, 3, context) != DC210_PACKET_FOLLOWING) return GP_ERROR; - gp_port_read(camera->port, (char *)answer, 16); - gp_port_read(camera->port, (char *)&checksum_read, 1); - checksum = 0; + gp_port_read(camera->port, (char *)answer, 16); + gp_port_read(camera->port, (char *)&checksum_read, 1); + checksum = 0; - for (i = 0; i < 16; i++) checksum ^= answer[i]; - if (checksum_read != checksum) return GP_ERROR; + for (i = 0; i < 16; i++) checksum ^= answer[i]; + if (checksum_read != checksum) return GP_ERROR; - DC210_DEBUG("Flash card formatted.\n"); + DC210_DEBUG("Flash card formatted.\n"); - if (dc210_write_single_char(camera, DC210_CORRECT_PACKET) == GP_ERROR) return GP_ERROR; - if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; + if (dc210_write_single_char(camera, DC210_CORRECT_PACKET) == GP_ERROR) return GP_ERROR; + if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; - gp_filesystem_reset(camera->fs); + gp_filesystem_reset(camera->fs); - return GP_OK; + return GP_OK; }; -static int dc210_get_card_status (Camera * camera, dc210_card_status * card_status){ +static int dc210_get_card_status (Camera * camera, dc210_card_status * card_status) { - char cmd[8]; - unsigned char answer[16]; - unsigned char checksum_read, checksum; - int i; + char cmd[8]; + unsigned char answer[16]; + unsigned char checksum_read, checksum; + int i; - card_status->open = 0; - card_status->program = 0; - card_status->space = 0; + card_status->open = 0; + card_status->program = 0; + card_status->space = 0; - dc210_cmd_init(cmd, DC210_CARD_STATUS); - dc210_execute_command(camera, cmd); - if (dc210_wait_for_response(camera, 0, NULL) != DC210_PACKET_FOLLOWING) return GP_ERROR; + dc210_cmd_init(cmd, DC210_CARD_STATUS); + dc210_execute_command(camera, cmd); + if (dc210_wait_for_response(camera, 0, NULL) != DC210_PACKET_FOLLOWING) return GP_ERROR; - gp_port_read(camera->port, (char *)answer, 16); - gp_port_read(camera->port, (char *)&checksum_read, 1); + gp_port_read(camera->port, (char *)answer, 16); + gp_port_read(camera->port, (char *)&checksum_read, 1); - checksum = 0; - for (i = 0; i < 16; i++) checksum ^= answer[i]; + checksum = 0; + for (i = 0; i < 16; i++) checksum ^= answer[i]; - if (checksum_read != checksum) - DC210_DEBUG("Error reading card status.\n"); - else - DC210_DEBUG("Card status correctly read.\n"); + if (checksum_read != checksum) + DC210_DEBUG("Error reading card status.\n"); + else + DC210_DEBUG("Card status correctly read.\n"); - if (answer[0] & 0x08) card_status->open = 1; - DC210_DEBUG("Card status open is %d\n", card_status->open); - card_status->program = answer[1] * 0x100 + answer[2]; - /* set the space in kb */ - card_status->space = (answer[3] * 0x1000000 + answer[4] * 0x10000 + answer[5] * 0x100 + answer[6]) / 1024; + if (answer[0] & 0x08) card_status->open = 1; + DC210_DEBUG("Card status open is %d\n", card_status->open); + card_status->program = answer[1] * 0x100 + answer[2]; + /* set the space in kb */ + card_status->space = (answer[3] * 0x1000000 + answer[4] * 0x10000 + answer[5] * 0x100 + answer[6]) / 1024; - if (dc210_write_single_char(camera, DC210_CORRECT_PACKET) == GP_ERROR) return GP_ERROR; - if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; + if (dc210_write_single_char(camera, DC210_CORRECT_PACKET) == GP_ERROR) return GP_ERROR; + if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; - return GP_OK; + return GP_OK; }; -int dc210_format_callback(Camera * camera, CameraWidget * widget, GPContext * context){ +int dc210_format_callback(Camera * camera, CameraWidget * widget, GPContext * context) { CameraWidget * window; char * album_name; @@ -701,19 +686,19 @@ int dc210_format_callback(Camera * camera, CameraWidget * widget, GPContext * co }; -static int dc210_check_battery (Camera *camera){ +static int dc210_check_battery (Camera *camera) { - char cmd[8]; - dc210_cmd_init(cmd, DC210_CHECK_BATTERY); + char cmd[8]; + dc210_cmd_init(cmd, DC210_CHECK_BATTERY); - if (dc210_execute_command(camera, cmd) == GP_ERROR) return GP_ERROR; - if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; + if (dc210_execute_command(camera, cmd) == GP_ERROR) return GP_ERROR; + if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; - return GP_OK; + return GP_OK; }; -int dc210_init_port (Camera *camera){ +int dc210_init_port (Camera *camera) { /* sending a break command resets the speed to 9600 */ @@ -820,27 +805,24 @@ int dc210_set_speed (Camera *camera, int speed) { /****** Picture actions *****/ -int dc210_take_picture -(Camera * camera, GPContext * context) +int dc210_take_picture (Camera * camera, GPContext * context) { char cmd[8]; dc210_cmd_init(cmd, DC210_TAKE_PICTURE); if (dc210_execute_command(camera, cmd) == GP_ERROR) return GP_ERROR; - switch (dc210_wait_for_response(camera, 5, context)){ - /* we allow a timeout error here and check the result via status */ - case DC210_COMMAND_COMPLETE: - case GP_ERROR_TIMEOUT: return GP_OK; break; - default: return GP_ERROR; break; + switch (dc210_wait_for_response(camera, 5, context)) { + /* we allow a timeout error here and check the result via status */ + case DC210_COMMAND_COMPLETE: + case GP_ERROR_TIMEOUT: return GP_OK; break; + default: return GP_ERROR; break; }; return GP_ERROR; }; -int dc210_delete_picture -(Camera * camera, unsigned int picno) -{ +int dc210_delete_picture (Camera * camera, unsigned int picno) { char cmd[8]; unsigned int pic_offset = picno - 1; @@ -856,27 +838,23 @@ int dc210_delete_picture }; -int dc210_delete_last_picture -(Camera * camera ) -{ +int dc210_delete_last_picture (Camera * camera) { - dc210_status status; + dc210_status status; - if (dc210_get_status(camera, &status) == GP_ERROR) - return GP_ERROR; + if (dc210_get_status(camera, &status) == GP_ERROR) + return GP_ERROR; - if (0 == status.numPicturesInCamera) - return GP_ERROR; + if (0 == status.numPicturesInCamera) + return GP_ERROR; - return dc210_delete_picture(camera, status.numPicturesInCamera); + return dc210_delete_picture(camera, status.numPicturesInCamera); }; -int dc210_delete_picture_by_name -(Camera * camera, const char * filename ) -{ +int dc210_delete_picture_by_name (Camera * camera, const char * filename ) { - char cmd[8]; + char cmd[8]; char cmd_packet[DC210_CMD_DATA_SIZE]; dc210_cmd_init(cmd, DC210_CARD_FILE_DEL); @@ -887,12 +865,9 @@ int dc210_delete_picture_by_name if (dc210_wait_for_response(camera, 0, NULL) != DC210_COMMAND_COMPLETE) return GP_ERROR; return GP_OK; - }; -int dc210_download_last_picture -(Camera * camera, CameraFile *file, dc210_picture_type type, GPContext *context) -{ +int dc210_download_last_picture (Camera * camera, CameraFile *file, dc210_picture_type type, GPContext *context) { dc210_status status; dc210_picture_info picinfo; @@ -910,9 +885,7 @@ int dc210_download_last_picture }; -int dc210_open_card -(Camera * camera) -{ +int dc210_open_card (Camera * camera) { char cmd[8]; dc210_card_status card_status; @@ -944,11 +917,9 @@ static int dc210_close_card }; #endif -int dc210_download_picture_by_name -(Camera * camera, CameraFile *file, const char *filename, dc210_picture_type type, GPContext *context) -{ +int dc210_download_picture_by_name (Camera * camera, CameraFile *file, const char *filename, dc210_picture_type type, GPContext *context) { - char cmd[8]; + char cmd[8]; char cmd_packet[DC210_CMD_DATA_SIZE]; dc210_picture_info picinfo; diff --git a/camlibs/kodak/dc240/dc240.c b/camlibs/kodak/dc240/dc240.c index c18a753b86..607cf4978d 100644 --- a/camlibs/kodak/dc240/dc240.c +++ b/camlibs/kodak/dc240/dc240.c @@ -57,7 +57,7 @@ static const struct camera_to_usb { { "Kodak:DC280", 0x040A, 0x0130 }, { "Kodak:DC3400", 0x040A, 0x0132 }, { "Kodak:DC5000", 0x040A, 0x0131 }, - { NULL, 0, 0 } + { NULL, 0, 0 } }; /* @@ -69,29 +69,29 @@ int camera_abilities (CameraAbilitiesList *list) { CameraAbilities a; - int i; - - for (i = 0; camera_to_usb[i].name; i++) - { - memset (&a, 0, sizeof (a)); - strcpy(a.model, camera_to_usb[i].name); - a.status = GP_DRIVER_STATUS_PRODUCTION; - a.port = GP_PORT_SERIAL | GP_PORT_USB; - a.speed[0] = 9600; - a.speed[1] = 19200; - a.speed[2] = 38400; - a.speed[3] = 57600; - a.speed[4] = 115200; - a.speed[5] = 0; - a.usb_vendor = camera_to_usb[i].idVendor; - a.usb_product = camera_to_usb[i].idProduct; - a.operations = GP_OPERATION_CAPTURE_IMAGE; - a.file_operations = GP_FILE_OPERATION_DELETE | - GP_FILE_OPERATION_PREVIEW; - a.folder_operations = GP_FOLDER_OPERATION_NONE; - - gp_abilities_list_append(list, a); - } + int i; + + for (i = 0; camera_to_usb[i].name; i++) + { + memset (&a, 0, sizeof (a)); + strcpy(a.model, camera_to_usb[i].name); + a.status = GP_DRIVER_STATUS_PRODUCTION; + a.port = GP_PORT_SERIAL | GP_PORT_USB; + a.speed[0] = 9600; + a.speed[1] = 19200; + a.speed[2] = 38400; + a.speed[3] = 57600; + a.speed[4] = 115200; + a.speed[5] = 0; + a.usb_vendor = camera_to_usb[i].idVendor; + a.usb_product = camera_to_usb[i].idProduct; + a.operations = GP_OPERATION_CAPTURE_IMAGE; + a.file_operations = GP_FILE_OPERATION_DELETE | + GP_FILE_OPERATION_PREVIEW; + a.folder_operations = GP_FOLDER_OPERATION_NONE; + + gp_abilities_list_append(list, a); + } return (GP_OK); } @@ -148,7 +148,7 @@ delete_file_func (CameraFilesystem *fs, const char *folder, Camera *camera = data; return (dc240_file_action (camera, DC240_ACTION_DELETE, NULL, folder, - filename, context)); + filename, context)); } static int @@ -176,38 +176,38 @@ camera_capture (Camera *camera, CameraCaptureType type, static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { - char buf [32 * 1024]; - char temp [1024]; - int retval; - DC240StatusTable table; - - retval = dc240_get_status (camera, &table, context); - if (retval == GP_OK) { - sprintf (buf, _("Model: Kodak %s\n"), dc240_convert_type_to_camera(table.cameraType)); - sprintf (temp, _("Firmware version: %d.%02d\n"), table.fwVersInt, table.fwVersDec); - strcat (buf, temp); - sprintf (temp, _("Battery status: %s, AC Adapter: %s\n"), - dc240_get_battery_status_str(table.battStatus), - dc240_get_ac_status_str(table.acAdapter)); - strcat (buf, temp); - sprintf (temp, _("Number of pictures: %d\n"), table.numPict); - strcat (buf, temp); - sprintf (temp, _("Space remaining: High: %d, Medium: %d, Low: %d\n"), - table.remPictHigh, table.remPictMed, table.remPictLow); - strcat (buf, temp); - - sprintf (temp, _("Memory card status (%d): %s\n"), table.memCardStatus, - dc240_get_memcard_status_str(table.memCardStatus)); - strcat (buf, temp); - - sprintf (temp, _("Total pictures captured: %d, Flashes fired: %d\n"), - table.totalPictTaken, table.totalStrobeFired); - strcat (buf, temp); - - - strcpy(summary->text, buf); - } - return retval; + char buf[32 * 1024]; + char temp[1024]; + int retval; + DC240StatusTable table; + + retval = dc240_get_status (camera, &table, context); + if (retval == GP_OK) { + sprintf (buf, _("Model: Kodak %s\n"), dc240_convert_type_to_camera(table.cameraType)); + sprintf (temp, _("Firmware version: %d.%02d\n"), table.fwVersInt, table.fwVersDec); + strcat (buf, temp); + sprintf (temp, _("Battery status: %s, AC Adapter: %s\n"), + dc240_get_battery_status_str(table.battStatus), + dc240_get_ac_status_str(table.acAdapter)); + strcat (buf, temp); + sprintf (temp, _("Number of pictures: %d\n"), table.numPict); + strcat (buf, temp); + sprintf (temp, _("Space remaining: High: %d, Medium: %d, Low: %d\n"), + table.remPictHigh, table.remPictMed, table.remPictLow); + strcat (buf, temp); + + sprintf (temp, _("Memory card status (%d): %s\n"), table.memCardStatus, + dc240_get_memcard_status_str(table.memCardStatus)); + strcat (buf, temp); + + sprintf (temp, _("Total pictures captured: %d, Flashes fired: %d\n"), + table.totalPictTaken, table.totalStrobeFired); + strcat (buf, temp); + + + strcpy(summary->text, buf); + } + return retval; } static int diff --git a/camlibs/kodak/dc3200/dc3200.c b/camlibs/kodak/dc3200/dc3200.c index e72315f8a1..853c74841e 100644 --- a/camlibs/kodak/dc3200/dc3200.c +++ b/camlibs/kodak/dc3200/dc3200.c @@ -478,23 +478,23 @@ int camera_init (Camera *camera, GPContext *context) if (!camera->pl) return (GP_ERROR_NO_MEMORY); - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; /* Set up the CameraFilesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); - /* initialize the camera */ + /* initialize the camera */ ret = init (camera); if (ret < 0) { free (camera->pl); camera->pl = NULL; - return (ret); - } + return (ret); + } - ret = dc3200_keep_alive (camera); + ret = dc3200_keep_alive (camera); if (ret < 0) { free (camera->pl); camera->pl = NULL; diff --git a/camlibs/kodak/dc3200/library.c b/camlibs/kodak/dc3200/library.c index ad05e02a8d..c802bc8264 100644 --- a/camlibs/kodak/dc3200/library.c +++ b/camlibs/kodak/dc3200/library.c @@ -195,9 +195,9 @@ int dc3200_setup(Camera *camera) */ /* command to get the picture unsigned char get_pkt[DEF_PACKET_LEN] = {0x01, calc_seqnum(), 0x80, 0x00, 0x20, 0x03, 26 + strlen(filename), - 0xC1, 0x50, 0x00, 0x00, 0x00, 0x00, 19 + strlen(filename), - 0x04, 0x01, 0x00, 0x01, 0x01, 0x04, 0x60, 0x10, 0x00, 0x01, 0x00, 0x05, - 0x00, 0x00, 0x00, 2 + strlen(filename), 0x01}; + 0xC1, 0x50, 0x00, 0x00, 0x00, 0x00, 19 + strlen(filename), + 0x04, 0x01, 0x00, 0x01, 0x01, 0x04, 0x60, 0x10, 0x00, 0x01, 0x00, 0x05, + 0x00, 0x00, 0x00, 2 + strlen(filename), 0x01}; */ int dc3200_get_data(Camera *camera, unsigned char **data, unsigned long *data_len, int command, const char *folder, const char *filename) diff --git a/camlibs/kodak/ez200/ez200.c b/camlibs/kodak/ez200/ez200.c index 246d800c1a..127eeb0454 100644 --- a/camlibs/kodak/ez200/ez200.c +++ b/camlibs/kodak/ez200/ez200.c @@ -75,7 +75,7 @@ ez200_init (GPPort *port, Model *model, Info *info) { READ(port, PICTURE, 0, 0, &c, 1); memcpy (info, &c, 1); GP_DEBUG("number of pics : %i", c); - return GP_OK; + return GP_OK; } /* quit photo mode */ @@ -91,7 +91,7 @@ ez200_exit (GPPort *port) { static int ez200_get_picture_size (GPPort *port, int n) { unsigned char c[4]; - unsigned int size = 0; + unsigned int size = 0; memset (c,0,sizeof(c)); GP_DEBUG("Running ez200_get_picture_size"); @@ -112,12 +112,12 @@ ez200_read_data (GPPort *port, char *data, int size) { /* Read Data by blocks */ while(size > 0) { int len = (size>MAX_BULK)?MAX_BULK:size; - ret = gp_port_read (port, data, len); + ret = gp_port_read (port, data, len); if (ret < GP_OK) return ret; data += len; size -= len; } - return GP_OK; + return GP_OK; } static int @@ -126,8 +126,8 @@ ez200_read_picture_data (GPPort *port, char *data, int size, int n) { memset(c,0,sizeof(c)); /* ask picture n transfert */ - READ(port, PICTURE, n, 1, c, 3); - return ez200_read_data (port, data, size); + READ(port, PICTURE, n, 1, c, 3); + return ez200_read_data (port, data, size); } @@ -145,55 +145,55 @@ struct _CameraPrivateLibrary { }; static const struct { - char *name; + char *name; CameraDriverStatus status; - unsigned short idVendor; - unsigned short idProduct; + unsigned short idVendor; + unsigned short idProduct; } models[] = { - {"Kodak EZ200", GP_DRIVER_STATUS_PRODUCTION, 0x040a, 0x0300}, + {"Kodak EZ200", GP_DRIVER_STATUS_PRODUCTION, 0x040a, 0x0300}, {NULL,0,0,0} }; int camera_id (CameraText *id) { - strcpy (id->text, "Kodak EZ200 camera"); - return GP_OK; + strcpy (id->text, "Kodak EZ200 camera"); + return GP_OK; } int camera_abilities (CameraAbilitiesList *list) { - int i; - CameraAbilities a; - - for (i = 0; models[i].name; i++) { - memset (&a, 0, sizeof(a)); - strcpy (a.model, models[i].name); - a.status = models[i].status; - a.port = GP_PORT_USB; - a.usb_vendor = models[i].idVendor; - a.usb_product= models[i].idProduct; + int i; + CameraAbilities a; + + for (i = 0; models[i].name; i++) { + memset (&a, 0, sizeof(a)); + strcpy (a.model, models[i].name); + a.status = models[i].status; + a.port = GP_PORT_USB; + a.usb_vendor = models[i].idVendor; + a.usb_product= models[i].idProduct; a.operations = GP_OPERATION_NONE; - a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; - a.file_operations = GP_FILE_OPERATION_NONE; - gp_abilities_list_append (list, a); - } - return GP_OK; + a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; + a.file_operations = GP_FILE_OPERATION_NONE; + gp_abilities_list_append (list, a); + } + return GP_OK; } static int camera_summary (Camera *camera, CameraText *summary, GPContext *context) { - sprintf (summary->text,_("Your USB camera is a Kodak EZ200.\n" - "Number of PICs = %i\n" - ), ez200_get_num_pics(camera->pl->info)); + sprintf (summary->text, _("Your USB camera is a Kodak EZ200.\n" + "Number of PICs = %i\n" + ), ez200_get_num_pics(camera->pl->info)); return GP_OK; } static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("Kodak EZ200 driver\nBucas Jean-Francois \n")); - return GP_OK; + strcpy (about->text, _("Kodak EZ200 driver\nBucas Jean-Francois \n")); + return GP_OK; } /* @@ -207,19 +207,18 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, WRITE(camera->port,0,0x8003,0,NULL,0); WRITE(camera->port,5,0x0000,0,NULL,0); - return GP_OK; + return GP_OK; } */ static int -delete_all_func (CameraFilesystem *fs, const char *folder, void *data, - GPContext *context) { - Camera *camera = data; +delete_all_func (CameraFilesystem *fs, const char *folder, void *data, GPContext *context) { + Camera *camera = data; WRITE (camera->port, ERASE, 0, 1, NULL, 0); ez200_wait_status_ok(camera->port); - return GP_OK; + return GP_OK; } static int @@ -235,8 +234,8 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *user_data, GPContext *context) { - Camera *camera = user_data; - int n, len, ret; + Camera *camera = user_data; + int n, len, ret; char *data, *data_start; n = gp_filesystem_number(camera->fs, "/", filename, context); @@ -253,7 +252,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, data_start = data + (HEADER_SIZE - DATA_HEADER_SIZE); GP_DEBUG("data - data_start : %p %p : %lx",data, data_start, (long) (data_start - data)); - ret = ez200_read_picture_data (camera->port, data_start, len, n); + ret = ez200_read_picture_data (camera->port, data_start, len, n); if (ret < GP_OK) return ret; ret = ez200_read_picture_header (camera->port, data); if (ret < GP_OK) return ret; @@ -326,7 +325,7 @@ camera_init(Camera *camera, GPContext *context) GP_DEBUG("inep = %x", settings.usb.inep); GP_DEBUG("outep = %x", settings.usb.outep); - /* Tell the CameraFilesystem where to get lists from */ + /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = calloc (1, sizeof (CameraPrivateLibrary)); diff --git a/camlibs/konica/library.c b/camlibs/konica/library.c index 0bfdea6ec3..c643906e77 100644 --- a/camlibs/konica/library.c +++ b/camlibs/konica/library.c @@ -42,30 +42,30 @@ #define PING_TIMEOUT 60 static struct { - const char *model; - int image_id_long; - int vendor; - int product; + const char *model; + int image_id_long; + int vendor; + int product; } konica_cameras[] = { - {"Konica Q-EZ", 0, 0, 0}, - {"Konica Q-M100", 0, 0, 0}, - {"Konica Q-M100V", 0, 0, 0}, - {"Konica Q-M200", 1, 0, 0}, - {"HP PhotoSmart", 0, 0, 0}, - {"HP PhotoSmart C20", 0, 0, 0}, - {"HP PhotoSmart C30", 0, 0, 0}, - {"HP PhotoSmart C200", 0, 0, 0}, - {NULL, 0, 0, 0} + {"Konica Q-EZ", 0, 0, 0}, + {"Konica Q-M100", 0, 0, 0}, + {"Konica Q-M100V", 0, 0, 0}, + {"Konica Q-M200", 1, 0, 0}, + {"HP PhotoSmart", 0, 0, 0}, + {"HP PhotoSmart C20", 0, 0, 0}, + {"HP PhotoSmart C30", 0, 0, 0}, + {"HP PhotoSmart C200", 0, 0, 0}, + {NULL, 0, 0, 0} }; struct _CameraPrivateLibrary { unsigned int speed, timeout; - int image_id_long; + int image_id_long; }; static int localization_file_read (Camera* camera, const char* file_name, - unsigned char** data, long int* data_size, + unsigned char** data, long int* data_size, GPContext *context); static int @@ -121,27 +121,27 @@ get_info (Camera *camera, unsigned int n, CameraFileInfo *info, static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, - void *data, GPContext *context) + void *data, GPContext *context) { CameraFile *file; CameraFileInfo info; - KStatus status; - unsigned int i, id; - Camera *camera = data; + KStatus status; + unsigned int i, id; + Camera *camera = data; int result; - /* - * We can't get the filename from the camera. - * But we decide to call the images %6i.jpeg', with the image id as - * parameter. Therefore, let's get the image ids. - */ - C(k_get_status (camera->port, context, &status)); + /* + * We can't get the filename from the camera. + * But we decide to call the images %6i.jpeg', with the image id as + * parameter. Therefore, let's get the image ids. + */ + C(k_get_status (camera->port, context, &status)); id = gp_context_progress_start (context, status.pictures, _("Getting file list...")); - for (i = 0; i < status.pictures; i++) { + for (i = 0; i < status.pictures; i++) { char fn[40]; - /* Get information */ + /* Get information */ gp_file_new (&file); result = get_info (camera, i + 1, &info, fn, file, context); if (result < 0) { @@ -149,7 +149,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, return (result); } - /* + /* * Append directly to the filesystem instead of to the list, * because we have additional information. */ @@ -162,59 +162,59 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, gp_context_progress_update (context, id, i + 1); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) return (GP_ERROR_CANCEL); - } + } gp_context_progress_stop (context, id); - return (GP_OK); + return (GP_OK); } int camera_id (CameraText* id) { - strcpy (id->text, "konica"); + strcpy (id->text, "konica"); - return (GP_OK); + return (GP_OK); } int camera_abilities (CameraAbilitiesList* list) { - int i; - CameraAbilities a; + int i; + CameraAbilities a; - for (i = 0; konica_cameras [i].model; i++) { + for (i = 0; konica_cameras [i].model; i++) { memset(&a, 0, sizeof(a)); a.status = GP_DRIVER_STATUS_PRODUCTION; - strcpy (a.model, konica_cameras [i].model); + strcpy (a.model, konica_cameras [i].model); a.usb_vendor = konica_cameras [i].vendor; a.usb_product = konica_cameras [i].product; - if (konica_cameras [i].vendor) - a.port = GP_PORT_USB; - else { - a.port = GP_PORT_SERIAL; - a.speed[0] = 300; - a.speed[1] = 600; - a.speed[2] = 1200; - a.speed[3] = 2400; - a.speed[4] = 4800; - a.speed[5] = 9600; - a.speed[6] = 19200; - a.speed[7] = 38400; - a.speed[8] = 57600; - a.speed[9] = 115200; - a.speed[10] = 0; - } - a.operations = GP_OPERATION_CONFIG | - GP_OPERATION_CAPTURE_IMAGE | - GP_OPERATION_CAPTURE_PREVIEW; - a.file_operations = GP_FILE_OPERATION_DELETE | - GP_FILE_OPERATION_PREVIEW | + if (konica_cameras [i].vendor) + a.port = GP_PORT_USB; + else { + a.port = GP_PORT_SERIAL; + a.speed[0] = 300; + a.speed[1] = 600; + a.speed[2] = 1200; + a.speed[3] = 2400; + a.speed[4] = 4800; + a.speed[5] = 9600; + a.speed[6] = 19200; + a.speed[7] = 38400; + a.speed[8] = 57600; + a.speed[9] = 115200; + a.speed[10] = 0; + } + a.operations = GP_OPERATION_CONFIG | + GP_OPERATION_CAPTURE_IMAGE | + GP_OPERATION_CAPTURE_PREVIEW; + a.file_operations = GP_FILE_OPERATION_DELETE | + GP_FILE_OPERATION_PREVIEW | GP_FILE_OPERATION_EXIF; - a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; - gp_abilities_list_append (list, a); - } + a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; + gp_abilities_list_append (list, a); + } - return (GP_OK); + return (GP_OK); } static int @@ -280,7 +280,7 @@ set_speed (Camera *camera, int speed, GPContext *context) return (GP_ERROR_IO_SERIAL_SPEED); } - /* Request the new speed */ + /* Request the new speed */ bit_flags = K_BIT_FLAG_8_BITS; C(k_set_io_capability (camera->port, context, bit_rates, bit_flags)); @@ -330,35 +330,35 @@ test_speed (Camera *camera, GPContext *context) static int set_info_func (CameraFilesystem *fs, const char *folder, const char *file, - CameraFileInfo info, void *data, GPContext *context) + CameraFileInfo info, void *data, GPContext *context) { - Camera *camera = data; - char tmp[7]; - int protected; - unsigned long image_id; - - /* Permissions? */ - if (info.file.fields & GP_FILE_INFO_PERMISSIONS) { - strncpy (tmp, file, 6); - tmp[6] = '\0'; - image_id = atol (tmp); - if (info.file.permissions & GP_FILE_PERM_DELETE) - protected = FALSE; - else - protected = TRUE; - C(k_set_protect_status (camera->port, context, + Camera *camera = data; + char tmp[7]; + int protected; + unsigned long image_id; + + /* Permissions? */ + if (info.file.fields & GP_FILE_INFO_PERMISSIONS) { + strncpy (tmp, file, 6); + tmp[6] = '\0'; + image_id = atol (tmp); + if (info.file.permissions & GP_FILE_PERM_DELETE) + protected = FALSE; + else + protected = TRUE; + C(k_set_protect_status (camera->port, context, camera->pl->image_id_long, image_id, protected)); - } - return (GP_OK); + } + return (GP_OK); } static int get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, - CameraFileInfo *info, void *data, GPContext *context) + CameraFileInfo *info, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; CameraFile *file; - int n, result; + int n, result; char fn[40]; /* We need image numbers starting with 1 */ @@ -375,19 +375,19 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, } gp_filesystem_set_file_noop (fs, folder, filename, GP_FILE_TYPE_PREVIEW, file, context); gp_file_unref (file); - return (GP_OK); + return (GP_OK); } static int camera_exit (Camera* camera, GPContext *context) { - if (camera->pl) { + if (camera->pl) { gp_camera_stop_timeout (camera, camera->pl->timeout); - free (camera->pl); - camera->pl = NULL; - } + free (camera->pl); + camera->pl = NULL; + } - return (GP_OK); + return (GP_OK); } static int @@ -395,40 +395,40 @@ delete_all_func (CameraFilesystem *fs, const char* folder, void *data, GPContext *context) { Camera *camera = data; - unsigned int not_erased = 0; + unsigned int not_erased = 0; - if (strcmp (folder, "/")) - return (GP_ERROR_DIRECTORY_NOT_FOUND); + if (strcmp (folder, "/")) + return (GP_ERROR_DIRECTORY_NOT_FOUND); - C(k_erase_all (camera->port, context, ¬_erased)); + C(k_erase_all (camera->port, context, ¬_erased)); - if (not_erased) { + if (not_erased) { gp_context_error (context, _("%i pictures could not be " "deleted because they are protected"), not_erased); gp_filesystem_reset (camera->fs); return (GP_ERROR); - } + } - return (GP_OK); + return (GP_OK); } static int get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, - CameraFileType type, CameraFile *file, void *data, + CameraFileType type, CameraFile *file, void *data, GPContext *context) { - Camera *camera = data; - unsigned long image_id; + Camera *camera = data; + unsigned long image_id; char image_id_string[] = {0, 0, 0, 0, 0, 0, 0}; - unsigned char *fdata = NULL; - unsigned int size; + unsigned char *fdata = NULL; + unsigned int size; CameraFileInfo info; int r; - if (strlen (filename) != 11) - return (GP_ERROR_FILE_NOT_FOUND); - if (strcmp (folder, "/")) - return (GP_ERROR_DIRECTORY_NOT_FOUND); + if (strlen (filename) != 11) + return (GP_ERROR_FILE_NOT_FOUND); + if (strcmp (folder, "/")) + return (GP_ERROR_DIRECTORY_NOT_FOUND); /* Check if we can get the image id from the filename. */ strncpy (image_id_string, filename, 6); @@ -444,30 +444,30 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, * afterwards. */ gp_camera_stop_timeout (camera, camera->pl->timeout); - switch (type) { - case GP_FILE_TYPE_PREVIEW: + switch (type) { + case GP_FILE_TYPE_PREVIEW: size = 2048; r = k_get_image (camera->port, context, camera->pl->image_id_long, image_id, K_THUMBNAIL, &fdata, &size); - break; - case GP_FILE_TYPE_NORMAL: + break; + case GP_FILE_TYPE_NORMAL: size = info.file.size; r = k_get_image (camera->port, context, camera->pl->image_id_long, image_id, K_IMAGE_EXIF, &fdata, &size); - break; - default: + break; + default: return (GP_ERROR_NOT_SUPPORTED); - } + } C(r); camera->pl->timeout = gp_camera_start_timeout (camera, PING_TIMEOUT, timeout_func); - C(gp_file_set_data_and_size (file, (char*)fdata, size)); - return gp_file_set_mime_type (file, GP_MIME_JPEG); + C(gp_file_set_data_and_size (file, (char*)fdata, size)); + return gp_file_set_mime_type (file, GP_MIME_JPEG); } static int @@ -475,22 +475,22 @@ delete_file_func (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context) { Camera *camera = data; - char tmp[] = {0, 0, 0, 0, 0, 0, 0}; - unsigned long image_id; + char tmp[] = {0, 0, 0, 0, 0, 0, 0}; + unsigned long image_id; C_NULL (camera && folder && filename); /* We don't support folders */ - if (strcmp (folder, "/")) return (GP_ERROR_DIRECTORY_NOT_FOUND); + if (strcmp (folder, "/")) return (GP_ERROR_DIRECTORY_NOT_FOUND); /* Extract the image id from the filename */ strncpy (tmp, filename, 6); - image_id = atol (tmp); + image_id = atol (tmp); - C(k_erase_image (camera->port, context, camera->pl->image_id_long, + C(k_erase_image (camera->port, context, camera->pl->image_id_long, image_id)); - return (GP_OK); + return (GP_OK); } static int @@ -498,45 +498,44 @@ camera_summary (Camera* camera, CameraText* summary, GPContext *context) { KInformation info; - GP_DEBUG ("*** ENTER: camera_summary " - "***"); - C(k_get_information (camera->port, context, &info)); + GP_DEBUG ("*** ENTER: camera_summary ***"); + C(k_get_information (camera->port, context, &info)); snprintf (summary->text, sizeof (summary->text), - _("Model: %s\n" - "Serial Number: %s,\n" - "Hardware Version: %i.%i\n" - "Software Version: %i.%i\n" - "Testing Software Version: %i.%i\n" - "Name: %s,\n" - "Manufacturer: %s\n"), + _("Model: %s\n" + "Serial Number: %s,\n" + "Hardware Version: %i.%i\n" + "Software Version: %i.%i\n" + "Testing Software Version: %i.%i\n" + "Name: %s,\n" + "Manufacturer: %s\n"), info.model, info.serial_number, info.hardware.major, info.hardware.minor, info.software.major, info.software.minor, info.testing.major, info.testing.minor, - info.name, info.manufacturer); + info.name, info.manufacturer); - return (GP_OK); + return (GP_OK); } static int camera_capture_preview (Camera* camera, CameraFile* file, GPContext *context) { - unsigned char *data = NULL; - unsigned int size = 0; + unsigned char *data = NULL; + unsigned int size = 0; - C(k_get_preview (camera->port, context, TRUE, &data, &size)); - C(gp_file_set_data_and_size (file, (char*)data, size)); - C(gp_file_set_mime_type (file, GP_MIME_JPEG)); + C(k_get_preview (camera->port, context, TRUE, &data, &size)); + C(gp_file_set_data_and_size (file, (char*)data, size)); + C(gp_file_set_mime_type (file, GP_MIME_JPEG)); - return (GP_OK); + return (GP_OK); } static int camera_capture (Camera* camera, CameraCaptureType type, CameraFilePath* path, GPContext *context) { - unsigned long image_id; + unsigned long image_id; unsigned int exif_size; unsigned char *buffer = NULL; unsigned int buffer_size; @@ -586,7 +585,7 @@ camera_capture (Camera* camera, CameraCaptureType type, CameraFilePath* path, gp_filesystem_set_file_noop (camera->fs, path->folder, fn, GP_FILE_TYPE_EXIF, file, context); gp_file_unref (file); - return (GP_OK); + return (GP_OK); } static int @@ -596,579 +595,571 @@ camera_about (Camera* camera, CameraText* about, GPContext *context) /* Translators: please write 'M"uller' (that is, with u-umlaut) if your charset allows it. If not, use "Mueller". */ - strcpy (about->text, _("Konica library\n" - "Lutz Mueller \n" - "Support for all Konica and several HP cameras.")); + strcpy (about->text, _("Konica library\n" + "Lutz Mueller \n" + "Support for all Konica and several HP cameras.")); - return (GP_OK); + return (GP_OK); } static int camera_get_config (Camera* camera, CameraWidget** window, GPContext *context) { - CameraWidget *widget; - CameraWidget *section; - KStatus status; - KPreferences preferences; - int year_4_digits; - struct tm tm_struct; - time_t t; - float value_float; - const char *name; - gp_system_dir d; - gp_system_dirent de; + CameraWidget *widget; + CameraWidget *section; + KStatus status; + KPreferences preferences; + int year_4_digits; + struct tm tm_struct; + time_t t; + float value_float; + const char *name; + gp_system_dir d; + gp_system_dirent de; unsigned int id; - /* Get the current settings. */ + /* Get the current settings. */ id = gp_context_progress_start (context, 2, _("Getting configuration...")); - C(k_get_status (camera->port, context, &status)); + C(k_get_status (camera->port, context, &status)); gp_context_progress_update (context, id, 1); - C(k_get_preferences (camera->port, context, &preferences)); + C(k_get_preferences (camera->port, context, &preferences)); gp_context_progress_stop (context, id); - /* Create the window. */ - gp_widget_new (GP_WIDGET_WINDOW, _("Konica Configuration"), window); - - /************************/ - /* Persistent Settings */ - /************************/ - gp_widget_new (GP_WIDGET_SECTION, _("Persistent Settings"), §ion); - gp_widget_append (*window, section); - - /* Date */ - gp_widget_new (GP_WIDGET_DATE, _("Date and Time"), &widget); - gp_widget_append (section, widget); - if (status.date.year > 80) year_4_digits = status.date.year + 1900; - else year_4_digits = status.date.year + 2000; - tm_struct.tm_year = year_4_digits - 1900; - tm_struct.tm_mon = status.date.month - 1; - tm_struct.tm_mday = status.date.day; - tm_struct.tm_hour = status.date.hour; - tm_struct.tm_min = status.date.minute; - tm_struct.tm_sec = status.date.second; - t = mktime (&tm_struct); - gp_widget_set_value (widget, &t); - - /* Beep */ - gp_widget_new (GP_WIDGET_RADIO, _("Beep"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("On")); - gp_widget_add_choice (widget, _("Off")); - switch (preferences.beep) { - case 0: - gp_widget_set_value (widget, _("Off")); - break; - default: - gp_widget_set_value (widget, _("On")); - break; - } - gp_widget_set_info (widget, _("Shall the camera beep when taking a " - "picture?")); - - /* Self Timer Time */ - gp_widget_new (GP_WIDGET_RANGE, _("Self Timer Time"), &widget); - gp_widget_append (section, widget); - gp_widget_set_range (widget, 3, 40, 1); - value_float = preferences.self_timer_time; - gp_widget_set_value (widget, &value_float); - - /* Auto Off Time */ - gp_widget_new (GP_WIDGET_RANGE, _("Auto Off Time"), &widget); - gp_widget_append (section, widget); - gp_widget_set_range (widget, 1, 255, 1); - value_float = preferences.shutoff_time; - gp_widget_set_value (widget, &value_float); - - /* Slide Show Interval */ - gp_widget_new (GP_WIDGET_RANGE, _("Slide Show Interval"), &widget); - gp_widget_append (section, widget); - gp_widget_set_range (widget, 1, 30, 1); - value_float = preferences.slide_show_interval; - gp_widget_set_value (widget, &value_float); - - /* Resolution */ - gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Low (576 x 436)")); - gp_widget_add_choice (widget, _("Medium (1152 x 872)")); - gp_widget_add_choice (widget, _("High (1152 x 872)")); - switch (status.resolution) { - case 1: - gp_widget_set_value (widget, _("High (1152 x 872)")); - break; - case 3: - gp_widget_set_value (widget, _("Low (576 x 436)")); - break; - default: - gp_widget_set_value (widget, _("Medium (1152 x 872)")); - break; - } - - /****************/ - /* Localization */ - /****************/ - gp_widget_new (GP_WIDGET_SECTION, _("Localization"), §ion); - gp_widget_append (*window, section); - - /* Language */ - d = gp_system_opendir (LOCALIZATION); - if (d) { - gp_widget_new (GP_WIDGET_MENU, _("Language"), &widget); - gp_widget_append (section, widget); - while ((de = gp_system_readdir (d))) { - name = gp_system_filename (de); - if (name && (*name != '.')) - gp_widget_add_choice (widget, name); - } - gp_widget_set_value (widget, _("None selected")); - gp_system_closedir (d); - } - - /* TV output format */ - gp_widget_new (GP_WIDGET_MENU, _("TV Output Format"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("NTSC")); - gp_widget_add_choice (widget, _("PAL")); - gp_widget_add_choice (widget, _("Do not display TV menu")); - gp_widget_set_value (widget, _("None selected")); - - /* Date format */ - gp_widget_new (GP_WIDGET_MENU, _("Date Format"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Month/Day/Year")); - gp_widget_add_choice (widget, _("Day/Month/Year")); - gp_widget_add_choice (widget, _("Year/Month/Day")); - gp_widget_set_value (widget, _("None selected")); - - /********************************/ - /* Session-persistent Settings */ - /********************************/ - gp_widget_new (GP_WIDGET_SECTION, _("Session-persistent Settings"), - §ion); - gp_widget_append (*window, section); - - /* Flash */ - gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Off")); - gp_widget_add_choice (widget, _("On")); - gp_widget_add_choice (widget, _("On, red-eye reduction")); - gp_widget_add_choice (widget, _("Auto")); - gp_widget_add_choice (widget, _("Auto, red-eye reduction")); - switch (status.flash) { - case 0: - gp_widget_set_value (widget, _("Off")); - break; - case 1: - gp_widget_set_value (widget, _("On")); - break; - case 5: - gp_widget_set_value (widget, _("On, red-eye reduction")); - break; - case 6: - gp_widget_set_value (widget, _("Auto, red-eye reduction")); - break; - default: - gp_widget_set_value (widget, _("Auto")); - break; - } - - /* Exposure */ - gp_widget_new (GP_WIDGET_RANGE, _("Exposure"), &widget); - gp_widget_append (section, widget); - gp_widget_set_range (widget, 0, 255, 1); - value_float = status.exposure; - gp_widget_set_value (widget, &value_float); - - /* Focus */ - gp_widget_new (GP_WIDGET_RADIO, _("Focus"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Fixed")); - gp_widget_add_choice (widget, _("Auto")); - switch ((unsigned int) (status.focus / 2)) { - case 1: - gp_widget_set_value (widget, _("Auto")); - break; - default: - gp_widget_set_value (widget, _("Fixed")); - break; - } - - /************************/ - /* Volatile Settings */ - /************************/ - gp_widget_new (GP_WIDGET_SECTION, _("Volatile Settings"), §ion); - gp_widget_append (*window, section); - - /* Self Timer */ - gp_widget_new (GP_WIDGET_RADIO, _("Self Timer"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Self Timer (next picture only)")); - gp_widget_add_choice (widget, _("Normal")); - switch (status.focus % 2) { - case 1: - gp_widget_set_value (widget, _("Self Timer (" - "next picture only)")); - break; - default: - gp_widget_set_value (widget, _("Normal")); - break; - } - - /* That's it. */ - return (GP_OK); + /* Create the window. */ + gp_widget_new (GP_WIDGET_WINDOW, _("Konica Configuration"), window); + + /************************/ + /* Persistent Settings */ + /************************/ + gp_widget_new (GP_WIDGET_SECTION, _("Persistent Settings"), §ion); + gp_widget_append (*window, section); + + /* Date */ + gp_widget_new (GP_WIDGET_DATE, _("Date and Time"), &widget); + gp_widget_append (section, widget); + if (status.date.year > 80) year_4_digits = status.date.year + 1900; + else year_4_digits = status.date.year + 2000; + tm_struct.tm_year = year_4_digits - 1900; + tm_struct.tm_mon = status.date.month - 1; + tm_struct.tm_mday = status.date.day; + tm_struct.tm_hour = status.date.hour; + tm_struct.tm_min = status.date.minute; + tm_struct.tm_sec = status.date.second; + t = mktime (&tm_struct); + gp_widget_set_value (widget, &t); + + /* Beep */ + gp_widget_new (GP_WIDGET_RADIO, _("Beep"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("On")); + gp_widget_add_choice (widget, _("Off")); + switch (preferences.beep) { + case 0: + gp_widget_set_value (widget, _("Off")); + break; + default: + gp_widget_set_value (widget, _("On")); + break; + } + gp_widget_set_info (widget, _("Shall the camera beep when taking a " + "picture?")); + + /* Self Timer Time */ + gp_widget_new (GP_WIDGET_RANGE, _("Self Timer Time"), &widget); + gp_widget_append (section, widget); + gp_widget_set_range (widget, 3, 40, 1); + value_float = preferences.self_timer_time; + gp_widget_set_value (widget, &value_float); + + /* Auto Off Time */ + gp_widget_new (GP_WIDGET_RANGE, _("Auto Off Time"), &widget); + gp_widget_append (section, widget); + gp_widget_set_range (widget, 1, 255, 1); + value_float = preferences.shutoff_time; + gp_widget_set_value (widget, &value_float); + + /* Slide Show Interval */ + gp_widget_new (GP_WIDGET_RANGE, _("Slide Show Interval"), &widget); + gp_widget_append (section, widget); + gp_widget_set_range (widget, 1, 30, 1); + value_float = preferences.slide_show_interval; + gp_widget_set_value (widget, &value_float); + + /* Resolution */ + gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Low (576 x 436)")); + gp_widget_add_choice (widget, _("Medium (1152 x 872)")); + gp_widget_add_choice (widget, _("High (1152 x 872)")); + switch (status.resolution) { + case 1: + gp_widget_set_value (widget, _("High (1152 x 872)")); + break; + case 3: + gp_widget_set_value (widget, _("Low (576 x 436)")); + break; + default: + gp_widget_set_value (widget, _("Medium (1152 x 872)")); + break; + } + + /****************/ + /* Localization */ + /****************/ + gp_widget_new (GP_WIDGET_SECTION, _("Localization"), §ion); + gp_widget_append (*window, section); + + /* Language */ + d = gp_system_opendir (LOCALIZATION); + if (d) { + gp_widget_new (GP_WIDGET_MENU, _("Language"), &widget); + gp_widget_append (section, widget); + while ((de = gp_system_readdir (d))) { + name = gp_system_filename (de); + if (name && (*name != '.')) + gp_widget_add_choice (widget, name); + } + gp_widget_set_value (widget, _("None selected")); + gp_system_closedir (d); + } + + /* TV output format */ + gp_widget_new (GP_WIDGET_MENU, _("TV Output Format"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("NTSC")); + gp_widget_add_choice (widget, _("PAL")); + gp_widget_add_choice (widget, _("Do not display TV menu")); + gp_widget_set_value (widget, _("None selected")); + + /* Date format */ + gp_widget_new (GP_WIDGET_MENU, _("Date Format"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Month/Day/Year")); + gp_widget_add_choice (widget, _("Day/Month/Year")); + gp_widget_add_choice (widget, _("Year/Month/Day")); + gp_widget_set_value (widget, _("None selected")); + + /********************************/ + /* Session-persistent Settings */ + /********************************/ + gp_widget_new (GP_WIDGET_SECTION, _("Session-persistent Settings"), + §ion); + gp_widget_append (*window, section); + + /* Flash */ + gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Off")); + gp_widget_add_choice (widget, _("On")); + gp_widget_add_choice (widget, _("On, red-eye reduction")); + gp_widget_add_choice (widget, _("Auto")); + gp_widget_add_choice (widget, _("Auto, red-eye reduction")); + switch (status.flash) { + case 0: + gp_widget_set_value (widget, _("Off")); + break; + case 1: + gp_widget_set_value (widget, _("On")); + break; + case 5: + gp_widget_set_value (widget, _("On, red-eye reduction")); + break; + case 6: + gp_widget_set_value (widget, _("Auto, red-eye reduction")); + break; + default: + gp_widget_set_value (widget, _("Auto")); + break; + } + + /* Exposure */ + gp_widget_new (GP_WIDGET_RANGE, _("Exposure"), &widget); + gp_widget_append (section, widget); + gp_widget_set_range (widget, 0, 255, 1); + value_float = status.exposure; + gp_widget_set_value (widget, &value_float); + + /* Focus */ + gp_widget_new (GP_WIDGET_RADIO, _("Focus"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Fixed")); + gp_widget_add_choice (widget, _("Auto")); + switch ((unsigned int) (status.focus / 2)) { + case 1: + gp_widget_set_value (widget, _("Auto")); + break; + default: + gp_widget_set_value (widget, _("Fixed")); + break; + } + + /************************/ + /* Volatile Settings */ + /************************/ + gp_widget_new (GP_WIDGET_SECTION, _("Volatile Settings"), §ion); + gp_widget_append (*window, section); + + /* Self Timer */ + gp_widget_new (GP_WIDGET_RADIO, _("Self Timer"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Self Timer (next picture only)")); + gp_widget_add_choice (widget, _("Normal")); + switch (status.focus % 2) { + case 1: + gp_widget_set_value (widget, _("Self Timer (next picture only)")); + break; + default: + gp_widget_set_value (widget, _("Normal")); + break; + } + + /* That's it. */ + return (GP_OK); } static int camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) { - CameraWidget *section; - CameraWidget *widget_focus; - CameraWidget *widget_self_timer; - CameraWidget *widget; - KDate date; - KDateFormat date_format = K_DATE_FORMAT_YEAR_MONTH_DAY; - KTVOutputFormat tv_output_format = K_TV_OUTPUT_FORMAT_HIDE; - unsigned int beep = 0; + CameraWidget *section; + CameraWidget *widget_focus; + CameraWidget *widget_self_timer; + CameraWidget *widget; + KDate date; + KDateFormat date_format = K_DATE_FORMAT_YEAR_MONTH_DAY; + KTVOutputFormat tv_output_format = K_TV_OUTPUT_FORMAT_HIDE; + unsigned int beep = 0; int i, j = 0; - unsigned char *data; - long int data_size; - unsigned char focus_self_timer = 0; + unsigned char *data; + long int data_size; + unsigned char focus_self_timer = 0; float f; - char *c; - struct tm *tm_struct; - int result; - - GP_DEBUG ("*** ENTER: camera_set_config ***"); - - /************************/ - /* Persistent Settings */ - /************************/ - gp_widget_get_child_by_label (window, _("Persistent Settings"), - §ion); - - /* Date & Time */ - gp_widget_get_child_by_label (section, _("Date and Time"), &widget); - if (gp_widget_changed (widget)) { - time_t xtime; - - gp_widget_get_value (widget, &i); - gp_widget_set_changed (widget, 0); - xtime = i; - tm_struct = localtime (&xtime); - date.year = tm_struct->tm_year - 100; - date.month = tm_struct->tm_mon + 1; - date.day = tm_struct->tm_mday; - date.hour = tm_struct->tm_hour; - date.minute = tm_struct->tm_min; - date.second = tm_struct->tm_sec; - C(k_set_date_and_time (camera->port, context, date)); - } - - /* Beep */ - gp_widget_get_child_by_label (section, _("Beep"), &widget); - if (gp_widget_changed (widget)) { - gp_widget_get_value (widget, &c); - gp_widget_set_changed (widget, 0); - if (strcmp (c, _("Off")) == 0) - beep = 0; - else - beep = 1; - C(k_set_preference (camera->port, context, - K_PREFERENCE_BEEP, beep)); - } - - /* Self Timer Time */ - gp_widget_get_child_by_label (section, _("Self Timer Time"), &widget); - if (gp_widget_changed (widget)) { - gp_widget_get_value (widget, &f); - gp_widget_set_changed (widget, 0); - C(k_set_preference (camera->port, context, - K_PREFERENCE_SELF_TIMER_TIME, (int) f)); - } - - /* Auto Off Time */ - gp_widget_get_child_by_label (section, _("Auto Off Time"), &widget); - if (gp_widget_changed (widget)) { - gp_widget_get_value (widget, &f); - gp_widget_set_changed (widget, 0); - C(k_set_preference (camera->port, context, - K_PREFERENCE_AUTO_OFF_TIME, (int) f)); - } - - /* Slide Show Interval */ - gp_widget_get_child_by_label (section, _("Slide Show Interval"), - &widget); - if (gp_widget_changed (widget)) { - gp_widget_get_value (widget, &f); - gp_widget_set_changed (widget, 0); - C(k_set_preference (camera->port, context, - K_PREFERENCE_SLIDE_SHOW_INTERVAL, (int) f)); - } - - /* Resolution */ - gp_widget_get_child_by_label (section, _("Resolution"), &widget); - if (gp_widget_changed (widget)) { - gp_widget_get_value (widget, &c); - gp_widget_set_changed (widget, 0); - if (!strcmp (c, _("High (1152 x 872)"))) - j = 1; - else if (!strcmp (c, _("Low (576 x 436)"))) - j = 3; - else - j = 0; - C(k_set_preference (camera->port, context, - K_PREFERENCE_RESOLUTION, j)); - } - - /****************/ - /* Localization */ - /****************/ - gp_widget_get_child_by_label (window, _("Localization"), §ion); - - /* Localization File */ - C(gp_widget_get_child_by_label (section, _("Language"), &widget)); + char *c; + struct tm *tm_struct; + int result; + + GP_DEBUG ("*** ENTER: camera_set_config ***"); + + /************************/ + /* Persistent Settings */ + /************************/ + gp_widget_get_child_by_label (window, _("Persistent Settings"), §ion); + + /* Date & Time */ + gp_widget_get_child_by_label (section, _("Date and Time"), &widget); + if (gp_widget_changed (widget)) { + time_t xtime; + + gp_widget_get_value (widget, &i); + gp_widget_set_changed (widget, 0); + xtime = i; + tm_struct = localtime (&xtime); + date.year = tm_struct->tm_year - 100; + date.month = tm_struct->tm_mon + 1; + date.day = tm_struct->tm_mday; + date.hour = tm_struct->tm_hour; + date.minute = tm_struct->tm_min; + date.second = tm_struct->tm_sec; + C(k_set_date_and_time (camera->port, context, date)); + } + + /* Beep */ + gp_widget_get_child_by_label (section, _("Beep"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_get_value (widget, &c); + gp_widget_set_changed (widget, 0); + if (strcmp (c, _("Off")) == 0) + beep = 0; + else + beep = 1; + C(k_set_preference (camera->port, context, K_PREFERENCE_BEEP, beep)); + } + + /* Self Timer Time */ + gp_widget_get_child_by_label (section, _("Self Timer Time"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_get_value (widget, &f); + gp_widget_set_changed (widget, 0); + C(k_set_preference (camera->port, context, + K_PREFERENCE_SELF_TIMER_TIME, (int) f)); + } + + /* Auto Off Time */ + gp_widget_get_child_by_label (section, _("Auto Off Time"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_get_value (widget, &f); + gp_widget_set_changed (widget, 0); + C(k_set_preference (camera->port, context, + K_PREFERENCE_AUTO_OFF_TIME, (int) f)); + } + + /* Slide Show Interval */ + gp_widget_get_child_by_label (section, _("Slide Show Interval"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_get_value (widget, &f); + gp_widget_set_changed (widget, 0); + C(k_set_preference (camera->port, context, + K_PREFERENCE_SLIDE_SHOW_INTERVAL, (int) f)); + } + + /* Resolution */ + gp_widget_get_child_by_label (section, _("Resolution"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_get_value (widget, &c); + gp_widget_set_changed (widget, 0); + if (!strcmp (c, _("High (1152 x 872)"))) + j = 1; + else if (!strcmp (c, _("Low (576 x 436)"))) + j = 3; + else + j = 0; + C(k_set_preference (camera->port, context, + K_PREFERENCE_RESOLUTION, j)); + } + + /****************/ + /* Localization */ + /****************/ + gp_widget_get_child_by_label (window, _("Localization"), §ion); + + /* Localization File */ + C(gp_widget_get_child_by_label (section, _("Language"), &widget)); C(result = gp_widget_changed (widget)); if (result) { - gp_widget_set_changed (widget, 0); + gp_widget_set_changed (widget, 0); C(gp_widget_get_value (widget, &c)); - if (strcmp (c, _("None selected"))) { - data = NULL; - data_size = 0; + if (strcmp (c, _("None selected"))) { + data = NULL; + data_size = 0; - /* Read localization file */ - result = localization_file_read (camera, c, - &data, &data_size, + /* Read localization file */ + result = localization_file_read (camera, c, + &data, &data_size, context); - if (result != GP_OK) { - free (data); - return (result); - } - - /* Go! */ - result = k_localization_data_put (camera->port, context, - data, data_size); - free (data); - C(result); - } - } - - /* TV Output Format */ - gp_widget_get_child_by_label (section, _("TV Output Format"), &widget); - if (gp_widget_changed (widget)) { - gp_widget_set_changed (widget, 0); - gp_widget_get_value (widget, &c); - if (strcmp (c, _("None selected"))) { - if (!strcmp (c, _("NTSC"))) - tv_output_format = K_TV_OUTPUT_FORMAT_NTSC; - else if (!strcmp (c, _("PAL"))) - tv_output_format = K_TV_OUTPUT_FORMAT_PAL; - else if (!strcmp (c, _("Do not display TV menu"))) - tv_output_format = K_TV_OUTPUT_FORMAT_HIDE; - else + if (result != GP_OK) { + free (data); + return (result); + } + + /* Go! */ + result = k_localization_data_put (camera->port, context, data, data_size); + free (data); + C(result); + } + } + + /* TV Output Format */ + gp_widget_get_child_by_label (section, _("TV Output Format"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_set_changed (widget, 0); + gp_widget_get_value (widget, &c); + if (strcmp (c, _("None selected"))) { + if (!strcmp (c, _("NTSC"))) + tv_output_format = K_TV_OUTPUT_FORMAT_NTSC; + else if (!strcmp (c, _("PAL"))) + tv_output_format = K_TV_OUTPUT_FORMAT_PAL; + else if (!strcmp (c, _("Do not display TV menu"))) + tv_output_format = K_TV_OUTPUT_FORMAT_HIDE; + else return (GP_ERROR); - C(k_localization_tv_output_format_set ( - camera->port, context, tv_output_format)); - } - } - - /* Date Format */ - gp_widget_get_child_by_label (section, _("Date Format"), &widget); - if (gp_widget_changed (widget)) { - gp_widget_set_changed (widget, 0); - gp_widget_get_value (widget, &c); - if (strcmp (c, _("None selected"))) { - if (!strcmp (c, _("Month/Day/Year"))) - date_format = K_DATE_FORMAT_MONTH_DAY_YEAR; - else if (!strcmp (c, _("Day/Month/Year"))) - date_format = K_DATE_FORMAT_DAY_MONTH_YEAR; - else if (!strcmp (c, _("Year/Month/Day"))) - date_format = K_DATE_FORMAT_YEAR_MONTH_DAY; - else + C(k_localization_tv_output_format_set ( + camera->port, context, tv_output_format)); + } + } + + /* Date Format */ + gp_widget_get_child_by_label (section, _("Date Format"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_set_changed (widget, 0); + gp_widget_get_value (widget, &c); + if (strcmp (c, _("None selected"))) { + if (!strcmp (c, _("Month/Day/Year"))) + date_format = K_DATE_FORMAT_MONTH_DAY_YEAR; + else if (!strcmp (c, _("Day/Month/Year"))) + date_format = K_DATE_FORMAT_DAY_MONTH_YEAR; + else if (!strcmp (c, _("Year/Month/Day"))) + date_format = K_DATE_FORMAT_YEAR_MONTH_DAY; + else return (GP_ERROR); - C(k_localization_date_format_set ( + C(k_localization_date_format_set ( camera->port, context, date_format)); - } - } - - /********************************/ - /* Session-persistent Settings */ - /********************************/ - gp_widget_get_child_by_label (window, _("Session-persistent Settings"), - §ion); - - /* Flash */ - gp_widget_get_child_by_label (section, _("Flash"), &widget); - if (gp_widget_changed (widget)) { - gp_widget_set_changed (widget, 0); - gp_widget_get_value (widget, &c); - if (!strcmp (c, _("Off"))) - j = 0; - else if (!strcmp (c, _("On"))) - j = 1; - else if (!strcmp (c, _("On, red-eye reduction"))) - j = 5; - else if (!strcmp (c, _("Auto"))) - j = 2; - else - j = 6; - C(k_set_preference (camera->port, context, - K_PREFERENCE_FLASH, j)); - } - - /* Exposure */ - gp_widget_get_child_by_label (section, _("Exposure"), &widget); - if (gp_widget_changed (widget)) { - gp_widget_set_changed (widget, 0); - gp_widget_get_value (widget, &f); - C(k_set_preference (camera->port, context, - K_PREFERENCE_EXPOSURE, (int) f)); - } - - /* Focus will be set together with self timer. */ - gp_widget_get_child_by_label (section, _("Focus"), &widget_focus); - - /************************/ - /* Volatile Settings */ - /************************/ - gp_widget_get_child_by_label (window, _("Volatile Settings"), §ion); - - /* Self Timer (and Focus) */ - gp_widget_get_child_by_label (section, _("Self Timer"), - &widget_self_timer); - if (gp_widget_changed (widget_focus) && - gp_widget_changed (widget_self_timer)) { - gp_widget_set_changed (widget_focus, 0); - gp_widget_set_changed (widget_self_timer, 0); - gp_widget_get_value (widget_focus, &c); - if (!strcmp (c, _("Auto"))) - focus_self_timer = 2; - else - focus_self_timer = 0; - gp_widget_get_value (widget_self_timer, &c); - if (!strcmp (c, _("Self Timer (next picture only)"))) - focus_self_timer++; - C(k_set_preference (camera->port, context, - K_PREFERENCE_FOCUS_SELF_TIMER, focus_self_timer)); - } - - /* We are done. */ - return (GP_OK); + } + } + + /********************************/ + /* Session-persistent Settings */ + /********************************/ + gp_widget_get_child_by_label (window, _("Session-persistent Settings"), §ion); + + /* Flash */ + gp_widget_get_child_by_label (section, _("Flash"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_set_changed (widget, 0); + gp_widget_get_value (widget, &c); + if (!strcmp (c, _("Off"))) + j = 0; + else if (!strcmp (c, _("On"))) + j = 1; + else if (!strcmp (c, _("On, red-eye reduction"))) + j = 5; + else if (!strcmp (c, _("Auto"))) + j = 2; + else + j = 6; + C(k_set_preference (camera->port, context, K_PREFERENCE_FLASH, j)); + } + + /* Exposure */ + gp_widget_get_child_by_label (section, _("Exposure"), &widget); + if (gp_widget_changed (widget)) { + gp_widget_set_changed (widget, 0); + gp_widget_get_value (widget, &f); + C(k_set_preference (camera->port, context, + K_PREFERENCE_EXPOSURE, (int) f)); + } + + /* Focus will be set together with self timer. */ + gp_widget_get_child_by_label (section, _("Focus"), &widget_focus); + + /************************/ + /* Volatile Settings */ + /************************/ + gp_widget_get_child_by_label (window, _("Volatile Settings"), §ion); + + /* Self Timer (and Focus) */ + gp_widget_get_child_by_label (section, _("Self Timer"), &widget_self_timer); + if (gp_widget_changed (widget_focus) && + gp_widget_changed (widget_self_timer)) { + gp_widget_set_changed (widget_focus, 0); + gp_widget_set_changed (widget_self_timer, 0); + gp_widget_get_value (widget_focus, &c); + if (!strcmp (c, _("Auto"))) + focus_self_timer = 2; + else + focus_self_timer = 0; + gp_widget_get_value (widget_self_timer, &c); + if (!strcmp (c, _("Self Timer (next picture only)"))) + focus_self_timer++; + C(k_set_preference (camera->port, context, + K_PREFERENCE_FOCUS_SELF_TIMER, focus_self_timer)); + } + + /* We are done. */ + return (GP_OK); } int localization_file_read (Camera *camera, const char *file_name, - unsigned char **data, long int *data_size, + unsigned char **data, long int *data_size, GPContext *context) { - FILE *file; - unsigned int j; - int f; - unsigned char c[] = "\0\0"; - unsigned long line_number; - unsigned int d; - char path[1024]; - - strcpy (path, LOCALIZATION); - strcat (path, "/"); - strcat (path, file_name); + FILE *file; + unsigned int j; + int f; + unsigned char c[] = "\0\0"; + unsigned long line_number; + unsigned int d; + char path[1024]; + + strcpy (path, LOCALIZATION); + strcat (path, "/"); + strcat (path, file_name); gp_log (GP_LOG_DEBUG, "konica", "Uploading '%s'...", path); - file = fopen (path, "r"); - if (!file) { + file = fopen (path, "r"); + if (!file) { gp_context_error (context, _("Could not find localization " "data at '%s'"), path); - return (GP_ERROR_FILE_NOT_FOUND); + return (GP_ERROR_FILE_NOT_FOUND); } - /* Allocate the memory */ - *data_size = 0; - *data = malloc (sizeof (char) * 65536); - if (!*data) { + /* Allocate the memory */ + *data_size = 0; + *data = malloc (sizeof (char) * 65536); + if (!*data) { fclose (file); - return (GP_ERROR_NO_MEMORY); + return (GP_ERROR_NO_MEMORY); } - j = 0; - line_number = 1; - do { - f = fgetc (file); - switch (f) { - case '\n': - line_number++; - continue; - case EOF: - break; - case '#': - /************************/ - /* Comment: Discard. */ - /************************/ - do { - f = fgetc (file); - } while ((f != '\n') && (f != EOF)); - if (f == '\n') line_number++; - continue; - case '\t': - continue; - case ' ': - continue; - default: - /****************************************/ - /* j == 0: We have to read the second */ - /* half of the byte to send. */ - /* j == 1: We'll compose our byte. */ - /****************************************/ - if ((f != '0') && (f != '1') && (f != '2') && - (f != '3') && (f != '4') && (f != '5') && - (f != '6') && (f != '7') && (f != '8') && - (f != '9') && (f != 'A') && (f != 'B') && - (f != 'C') && (f != 'D') && (f != 'E') && - (f != 'F')) { - GP_DEBUG ("Error in localization " + j = 0; + line_number = 1; + do { + f = fgetc (file); + switch (f) { + case '\n': + line_number++; + continue; + case EOF: + break; + case '#': + /************************/ + /* Comment: Discard. */ + /************************/ + do { + f = fgetc (file); + } while ((f != '\n') && (f != EOF)); + if (f == '\n') line_number++; + continue; + case '\t': + continue; + case ' ': + continue; + default: + /****************************************/ + /* j == 0: We have to read the second */ + /* half of the byte to send. */ + /* j == 1: We'll compose our byte. */ + /****************************************/ + if ((f != '0') && (f != '1') && (f != '2') && + (f != '3') && (f != '4') && (f != '5') && + (f != '6') && (f != '7') && (f != '8') && + (f != '9') && (f != 'A') && (f != 'B') && + (f != 'C') && (f != 'D') && (f != 'E') && + (f != 'F')) { + GP_DEBUG ("Error in localization " "file: '%c' in line %i is " "not allowed.", f, (int) line_number); - fclose (file); - return (GP_ERROR_CORRUPTED_DATA); - } - c[j] = (char) f; - if (j == 1) { - if (sscanf ((char *)&c[0], "%X", &d) != 1) { + fclose (file); + return (GP_ERROR_CORRUPTED_DATA); + } + c[j] = (char) f; + if (j == 1) { + if (sscanf ((char *)&c[0], "%X", &d) != 1) { GP_DEBUG ("Error in localization " "file."); - fclose (file); - return (GP_ERROR_CORRUPTED_DATA); - } - (*data)[*data_size] = d; - (*data_size)++; - if (*data_size == 65536) { - gp_context_error (context, + fclose (file); + return (GP_ERROR_CORRUPTED_DATA); + } + (*data)[*data_size] = d; + (*data_size)++; + if (*data_size == 65536) { + gp_context_error (context, _("Localization file too long!")); - fclose (file); - return (GP_ERROR_CORRUPTED_DATA); - } - } - j = 1 - j; - continue; - } - } while (f != EOF); - fclose (file); - - /* Calculate and check checksum. */ + fclose (file); + return (GP_ERROR_CORRUPTED_DATA); + } + } + j = 1 - j; + continue; + } + } while (f != EOF); + fclose (file); + + /* Calculate and check checksum. */ gp_log (GP_LOG_DEBUG, "konica", "Checksum not implemented!"); - /*FIXME: There's a checksum at (*data)[100]. I could not - figure out how it is calculated. */ + /*FIXME: There's a checksum at (*data)[100]. I could not + figure out how it is calculated. */ - /* Calculate and check frame check sequence. */ + /* Calculate and check frame check sequence. */ gp_log (GP_LOG_DEBUG, "konica", "Frame check sequence " "not implemented!"); - /* FIXME: There's a frame check sequence at (*data)[108] - and (*data)[109]. I could not figure out how it is - calculated. */ - gp_log (GP_LOG_DEBUG, "konica", "-> %i bytes read.\n", + /* FIXME: There's a frame check sequence at (*data)[108] + and (*data)[109]. I could not figure out how it is + calculated. */ + gp_log (GP_LOG_DEBUG, "konica", "-> %i bytes read.\n", (int) *data_size); - return (GP_OK); + return (GP_OK); } static int @@ -1201,46 +1192,46 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera* camera, GPContext *context) { - int i, speed; - GPPortSettings settings; + int i, speed; + GPPortSettings settings; CameraAbilities a; - /* First, set up all the function pointers. */ + /* First, set up all the function pointers. */ camera->functions->pre_func = camera_pre_func; camera->functions->post_func = camera_post_func; - camera->functions->exit = camera_exit; - camera->functions->get_config = camera_get_config; - camera->functions->set_config = camera_set_config; - camera->functions->capture = camera_capture; - camera->functions->capture_preview = camera_capture_preview; - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; - - /* Lookup model information */ + camera->functions->exit = camera_exit; + camera->functions->get_config = camera_get_config; + camera->functions->set_config = camera_set_config; + camera->functions->capture = camera_capture; + camera->functions->capture_preview = camera_capture_preview; + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; + + /* Lookup model information */ gp_camera_get_abilities (camera, &a); - for (i = 0; konica_cameras [i].model; i++) - if (!strcmp (konica_cameras [i].model, a.model)) - break; - if (!konica_cameras [i].model) - return (GP_ERROR_MODEL_NOT_FOUND); + for (i = 0; konica_cameras[i].model; i++) + if (!strcmp (konica_cameras[i].model, a.model)) + break; + if (!konica_cameras[i].model) + return (GP_ERROR_MODEL_NOT_FOUND); /* Store some data we constantly need. */ camera->pl = malloc (sizeof (CameraPrivateLibrary)); memset (camera->pl, 0, sizeof (CameraPrivateLibrary)); - camera->pl->image_id_long = konica_cameras [i].image_id_long; + camera->pl->image_id_long = konica_cameras[i].image_id_long; - /* Initiate the connection */ + /* Initiate the connection */ C(gp_port_get_settings (camera->port, &settings)); - switch (camera->port->type) { - case GP_PORT_SERIAL: + switch (camera->port->type) { + case GP_PORT_SERIAL: - /* Set up the device */ - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits = 1; - C(gp_port_set_settings (camera->port, settings)); + /* Set up the device */ + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits = 1; + C(gp_port_set_settings (camera->port, settings)); - /* Initiate the connection */ + /* Initiate the connection */ C(speed = test_speed (camera, context)); #if 0 /* Ideally, we need to reset the speed to the speed that we encountered @@ -1249,24 +1240,23 @@ camera_init (Camera* camera, GPContext *context) camera->pl->speed = speed; #endif - break; - case GP_PORT_USB: + break; + case GP_PORT_USB: /* Use the defaults the core parsed */ - C(gp_port_set_settings (camera->port, settings)); + C(gp_port_set_settings (camera->port, settings)); - /* Initiate the connection */ - C(k_init (camera->port, context)); + /* Initiate the connection */ + C(k_init (camera->port, context)); - break; - default: - return (GP_ERROR_UNKNOWN_PORT); - } - /* Set up the filesystem */ + break; + default: + return (GP_ERROR_UNKNOWN_PORT); + } + /* Set up the filesystem */ C(gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); /* Ping the camera every minute to prevent shut-down. */ - camera->pl->timeout = gp_camera_start_timeout (camera, PING_TIMEOUT, - timeout_func); - return (GP_OK); + camera->pl->timeout = gp_camera_start_timeout (camera, PING_TIMEOUT, timeout_func); + return (GP_OK); } diff --git a/camlibs/konica/lowlevel.c b/camlibs/konica/lowlevel.c index 2bc8732361..e590cf0a6b 100644 --- a/camlibs/konica/lowlevel.c +++ b/camlibs/konica/lowlevel.c @@ -429,11 +429,11 @@ while (read < rbs_internal) { * these, it now downloads images etc. */ #ifndef LESSER_ESCAPES - if ((*buf == STX) || (*buf == ETX) || (*buf == ENQ ) || + if ((*buf == STX) || (*buf == ETX) || (*buf == ENQ) || (*buf == ACK) || (*buf == XOFF) || (*buf == XON) || (*buf == NACK) || (*buf == ETB)) { #else /* LESSER_ESCAPES */ - if ((*buf == STX) || (*buf == XOFF) || (*buf == XON)) { + if ((*buf == STX) || (*buf == XOFF) || (*buf == XON)) { #endif /* LESSER_ESCAPES */ GP_DEBUG ("Wrong ESC masking!"); error_flag = 1; @@ -610,7 +610,7 @@ l_send_receive ( /* Send data. */ CHECK (l_send (p, c, send_buffer, send_buffer_size)); - /* Receive data. */ + /* Receive data. */ if (image_buffer_size) *receive_buffer_size = *image_buffer_size; CHECK (l_receive (p, c, receive_buffer, receive_buffer_size, @@ -620,7 +620,7 @@ l_send_receive ( if ((*receive_buffer_size > 1) && (((*receive_buffer)[0] == send_buffer[0]) && ((*receive_buffer)[1] == send_buffer[1]))) - return (GP_OK); + return (GP_OK); /* We didn't receive control data yet. */ *image_buffer = *receive_buffer; diff --git a/camlibs/konica/qm150.c b/camlibs/konica/qm150.c index cf4469ad0c..120e32f94c 100644 --- a/camlibs/konica/qm150.c +++ b/camlibs/konica/qm150.c @@ -337,7 +337,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, GP_DEBUG ("*** ENTER: get_file_func ***"); - image_no = gp_filesystem_number(fs, folder, filename, context); + image_no = gp_filesystem_number(fs, folder, filename, context); if (image_no < 0) return image_no; /* Search the image informations */ @@ -425,7 +425,7 @@ delete_file_func (CameraFilesystem *fs, const char *folder, GP_DEBUG ("*** ENTER: delete_file_func ***"); - image_no = gp_filesystem_number(fs, folder, filename, context); + image_no = gp_filesystem_number(fs, folder, filename, context); if (image_no < 0) return image_no; image_no++; @@ -676,7 +676,7 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, GP_DEBUG ("*** ENTER: get_info_func ***"); - image_no = gp_filesystem_number(fs, folder, filename, context); + image_no = gp_filesystem_number(fs, folder, filename, context); if (image_no < 0) return image_no; image_no++; @@ -723,8 +723,8 @@ camera_get_config (Camera* camera, CameraWidget** window, GPContext *context) { unsigned char cmd[2], buf[INFO_BUFFER]; int ret; - CameraWidget *widget; - CameraWidget *section; + CameraWidget *widget; + CameraWidget *section; time_t timestamp=0; float value_float; @@ -753,357 +753,354 @@ camera_get_config (Camera* camera, CameraWidget** window, GPContext *context) /* Window creation */ gp_widget_new (GP_WIDGET_WINDOW, _("Konica Configuration"), window); - /************************/ - /* Persistent Settings */ - /************************/ - gp_widget_new (GP_WIDGET_SECTION, _("Persistent Settings"), §ion); - gp_widget_append (*window, section); - - /* Date */ - gp_widget_new (GP_WIDGET_DATE, _("Date and Time"), &widget); - gp_widget_append (section, widget); - gp_widget_set_value (widget, ×tamp); - - /* Auto Off Time */ - gp_widget_new (GP_WIDGET_RANGE, _("Auto Off Time"), &widget); - gp_widget_append (section, widget); - gp_widget_set_range (widget, 1, 255, 1); - value_float = ((buf[AUTO_OFF_PTR] << 8) + buf[AUTO_OFF_PTR+1]) / 60; - gp_widget_set_value (widget, &value_float); - - - /* Resolution */ - gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Low")); - gp_widget_add_choice (widget, _("Medium")); - gp_widget_add_choice (widget, _("High")); - switch (buf[RESOLUTION_PTR]) { - case 1: - gp_widget_set_value (widget, _("High")); - break; - case 2: - gp_widget_set_value (widget, _("Low")); - break; - case 0: - gp_widget_set_value (widget, _("Medium")); - break; - } - - /* LCD */ - gp_widget_new (GP_WIDGET_RADIO, _("LCD"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("On")); - gp_widget_add_choice (widget, _("Off")); - switch (buf[LCD_STATE_PTR]) { - case 0: - gp_widget_set_value (widget, _("On")); - break; - case 1: - gp_widget_set_value (widget, _("Off")); - break; - } - - /* Icons */ - gp_widget_new (GP_WIDGET_RADIO, _("Icons"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("On")); - gp_widget_add_choice (widget, _("Off")); - switch (buf[ICON_STATE_PTR]) { - case 0: - gp_widget_set_value (widget, _("On")); - break; - case 1: - gp_widget_set_value (widget, _("Off")); - break; - } - - /****************/ - /* Localization */ - /****************/ - gp_widget_new (GP_WIDGET_SECTION, _("Localization"), §ion); - gp_widget_append (*window, section); - - /* Date format */ - gp_widget_new (GP_WIDGET_MENU, _("Date Format"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Month/Day/Year")); - gp_widget_add_choice (widget, _("Day/Month/Year")); - gp_widget_add_choice (widget, _("Year/Month/Day")); + /************************/ + /* Persistent Settings */ + /************************/ + gp_widget_new (GP_WIDGET_SECTION, _("Persistent Settings"), §ion); + gp_widget_append (*window, section); + + /* Date */ + gp_widget_new (GP_WIDGET_DATE, _("Date and Time"), &widget); + gp_widget_append (section, widget); + gp_widget_set_value (widget, ×tamp); + + /* Auto Off Time */ + gp_widget_new (GP_WIDGET_RANGE, _("Auto Off Time"), &widget); + gp_widget_append (section, widget); + gp_widget_set_range (widget, 1, 255, 1); + value_float = ((buf[AUTO_OFF_PTR] << 8) + buf[AUTO_OFF_PTR+1]) / 60; + gp_widget_set_value (widget, &value_float); + + + /* Resolution */ + gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Low")); + gp_widget_add_choice (widget, _("Medium")); + gp_widget_add_choice (widget, _("High")); + switch (buf[RESOLUTION_PTR]) { + case 1: + gp_widget_set_value (widget, _("High")); + break; + case 2: + gp_widget_set_value (widget, _("Low")); + break; + case 0: + gp_widget_set_value (widget, _("Medium")); + break; + } + + /* LCD */ + gp_widget_new (GP_WIDGET_RADIO, _("LCD"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("On")); + gp_widget_add_choice (widget, _("Off")); + switch (buf[LCD_STATE_PTR]) { + case 0: + gp_widget_set_value (widget, _("On")); + break; + case 1: + gp_widget_set_value (widget, _("Off")); + break; + } + + /* Icons */ + gp_widget_new (GP_WIDGET_RADIO, _("Icons"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("On")); + gp_widget_add_choice (widget, _("Off")); + switch (buf[ICON_STATE_PTR]) { + case 0: + gp_widget_set_value (widget, _("On")); + break; + case 1: + gp_widget_set_value (widget, _("Off")); + break; + } + + /****************/ + /* Localization */ + /****************/ + gp_widget_new (GP_WIDGET_SECTION, _("Localization"), §ion); + gp_widget_append (*window, section); + + /* Date format */ + gp_widget_new (GP_WIDGET_MENU, _("Date Format"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Month/Day/Year")); + gp_widget_add_choice (widget, _("Day/Month/Year")); + gp_widget_add_choice (widget, _("Year/Month/Day")); switch (buf[DATE_FORMAT_PTR]) { - case 0: - gp_widget_set_value (widget, _("Month/Day/Year")); - break; - case 1: - gp_widget_set_value (widget, _("Day/Month/Year")); - break; - case 2: - gp_widget_set_value (widget, _("Year/Month/Day")); - break; + case 0: + gp_widget_set_value (widget, _("Month/Day/Year")); + break; + case 1: + gp_widget_set_value (widget, _("Day/Month/Year")); + break; + case 2: + gp_widget_set_value (widget, _("Year/Month/Day")); + break; } /********************************/ - /* Session-persistent Settings */ - /********************************/ - gp_widget_new (GP_WIDGET_SECTION, _("Session-persistent Settings"), - §ion); - gp_widget_append (*window, section); - - /* Flash */ - gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Off")); - gp_widget_add_choice (widget, _("On")); - gp_widget_add_choice (widget, _("On, red-eye reduction")); - gp_widget_add_choice (widget, _("Auto")); - gp_widget_add_choice (widget, _("Auto, red-eye reduction")); - switch (buf[FLASH_STATE_PTR]) { - case 2: - gp_widget_set_value (widget, _("Off")); - break; - case 1: - if (buf[RED_EYE_STATE_PTR] == 1) - gp_widget_set_value (widget, - _("On, red-eye reduction")); - else - gp_widget_set_value (widget, _("On")); - break; - case 0: - if (buf[RED_EYE_STATE_PTR] == 1) - gp_widget_set_value (widget, - _("Auto, red-eye reduction")); - else - gp_widget_set_value (widget, _("Auto")); - break; - } - - /* Exposure */ - gp_widget_new (GP_WIDGET_RANGE, _("Exposure"), &widget); - gp_widget_append (section, widget); - gp_widget_set_range (widget, -2, 2, 0.1); - switch(buf[EXPOSURE_TIME_PTR]) { - case 0: - value_float = 0; - break; - case 1: - value_float = 0.3; - break; - case 2: - value_float = 0.5; - break; - case 3: - value_float = 0.8; - break; - case 4: - value_float = 1.0; - break; - case 5: - value_float = 1.3; - break; - case 6: - value_float = 1.5; - break; - case 7: - value_float = 1.8; - break; - case 8: - value_float = 2.0; - break; - case 0xF8: - value_float = -2.0; - break; - case 0xF9: - value_float = -1.8; - break; - case 0xFA: - value_float = -1.5; - break; - case 0xFB: - value_float = -1.3; - break; - case 0xFC: - value_float = -1.0; - break; - case 0xFD: - value_float = -0.8; - break; - case 0xFE: - value_float = -0.5; - break; - case 0xFF: - value_float = -0.3; - break; + /* Session-persistent Settings */ + /********************************/ + gp_widget_new (GP_WIDGET_SECTION, _("Session-persistent Settings"), + §ion); + gp_widget_append (*window, section); + + /* Flash */ + gp_widget_new (GP_WIDGET_RADIO, _("Flash"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Off")); + gp_widget_add_choice (widget, _("On")); + gp_widget_add_choice (widget, _("On, red-eye reduction")); + gp_widget_add_choice (widget, _("Auto")); + gp_widget_add_choice (widget, _("Auto, red-eye reduction")); + switch (buf[FLASH_STATE_PTR]) { + case 2: + gp_widget_set_value (widget, _("Off")); + break; + case 1: + if (buf[RED_EYE_STATE_PTR] == 1) + gp_widget_set_value (widget, _("On, red-eye reduction")); + else + gp_widget_set_value (widget, _("On")); + break; + case 0: + if (buf[RED_EYE_STATE_PTR] == 1) + gp_widget_set_value (widget, _("Auto, red-eye reduction")); + else + gp_widget_set_value (widget, _("Auto")); + break; + } + + /* Exposure */ + gp_widget_new (GP_WIDGET_RANGE, _("Exposure"), &widget); + gp_widget_append (section, widget); + gp_widget_set_range (widget, -2, 2, 0.1); + switch (buf[EXPOSURE_TIME_PTR]) { + case 0: + value_float = 0; + break; + case 1: + value_float = 0.3; + break; + case 2: + value_float = 0.5; + break; + case 3: + value_float = 0.8; + break; + case 4: + value_float = 1.0; + break; + case 5: + value_float = 1.3; + break; + case 6: + value_float = 1.5; + break; + case 7: + value_float = 1.8; + break; + case 8: + value_float = 2.0; + break; + case 0xF8: + value_float = -2.0; + break; + case 0xF9: + value_float = -1.8; + break; + case 0xFA: + value_float = -1.5; + break; + case 0xFB: + value_float = -1.3; + break; + case 0xFC: + value_float = -1.0; + break; + case 0xFD: + value_float = -0.8; + break; + case 0xFE: + value_float = -0.5; + break; + case 0xFF: + value_float = -0.3; + break; } - gp_widget_set_value (widget, &value_float); + gp_widget_set_value (widget, &value_float); - /* Focus */ - gp_widget_new (GP_WIDGET_RADIO, _("Focus"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("2.0 m")); + /* Focus */ + gp_widget_new (GP_WIDGET_RADIO, _("Focus"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("2.0 m")); gp_widget_add_choice (widget, _("0.5 m")); gp_widget_add_choice (widget, _("0.1 m")); - gp_widget_add_choice (widget, _("Auto")); - switch (buf[FOCUS_PTR]) { - case 0: - gp_widget_set_value (widget, _("Auto")); - break; - case 1: - gp_widget_set_value (widget, _("2.0 m")); - break; - case 2: - gp_widget_set_value (widget, _("0.5 m")); - break; - case 3: - gp_widget_set_value (widget, _("0.1 m")); - break; - } - - /* white balance */ - gp_widget_new (GP_WIDGET_RADIO, _("White balance"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Office")); + gp_widget_add_choice (widget, _("Auto")); + switch (buf[FOCUS_PTR]) { + case 0: + gp_widget_set_value (widget, _("Auto")); + break; + case 1: + gp_widget_set_value (widget, _("2.0 m")); + break; + case 2: + gp_widget_set_value (widget, _("0.5 m")); + break; + case 3: + gp_widget_set_value (widget, _("0.1 m")); + break; + } + + /* white balance */ + gp_widget_new (GP_WIDGET_RADIO, _("White balance"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Office")); gp_widget_add_choice (widget, _("Daylight")); gp_widget_add_choice (widget, _("Auto")); - switch (buf[WHITE_BALANCE_PTR]) { - case 0: - gp_widget_set_value (widget, _("Auto")); - break; - case 1: - gp_widget_set_value (widget, _("Daylight")); - break; - case 2: - gp_widget_set_value (widget, _("Office")); - break; + switch (buf[WHITE_BALANCE_PTR]) { + case 0: + gp_widget_set_value (widget, _("Auto")); + break; + case 1: + gp_widget_set_value (widget, _("Daylight")); + break; + case 2: + gp_widget_set_value (widget, _("Office")); + break; } - /* Sharpness */ - gp_widget_new (GP_WIDGET_RADIO, _("Sharpness"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Sharp")); + /* Sharpness */ + gp_widget_new (GP_WIDGET_RADIO, _("Sharpness"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Sharp")); gp_widget_add_choice (widget, _("Soft")); gp_widget_add_choice (widget, _("Auto")); - switch (buf[SHARPNESS_PTR]) { - case 0: - gp_widget_set_value (widget, _("Auto")); - break; - case 1: - gp_widget_set_value (widget, _("Sharp")); - break; - case 2: - gp_widget_set_value (widget, _("Soft")); - break; + switch (buf[SHARPNESS_PTR]) { + case 0: + gp_widget_set_value (widget, _("Auto")); + break; + case 1: + gp_widget_set_value (widget, _("Sharp")); + break; + case 2: + gp_widget_set_value (widget, _("Soft")); + break; } - /* Color */ - gp_widget_new (GP_WIDGET_RADIO, _("Color"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Light")); + /* Color */ + gp_widget_new (GP_WIDGET_RADIO, _("Color"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Light")); gp_widget_add_choice (widget, _("Deep")); gp_widget_add_choice (widget, _("Black and White")); gp_widget_add_choice (widget, _("Sepia")); gp_widget_add_choice (widget, _("Auto")); - switch (buf[COLOR_PTR]) { - case 0: - gp_widget_set_value (widget, _("Auto")); - break; - case 1: - gp_widget_set_value (widget, _("Light")); - break; - case 2: - gp_widget_set_value (widget, _("Deep")); - break; - case 3: - gp_widget_set_value (widget, _("Black and White")); - break; - case 4: - gp_widget_set_value (widget, _("Sepia")); - break; + switch (buf[COLOR_PTR]) { + case 0: + gp_widget_set_value (widget, _("Auto")); + break; + case 1: + gp_widget_set_value (widget, _("Light")); + break; + case 2: + gp_widget_set_value (widget, _("Deep")); + break; + case 3: + gp_widget_set_value (widget, _("Black and White")); + break; + case 4: + gp_widget_set_value (widget, _("Sepia")); + break; } - /* Macro */ - gp_widget_new (GP_WIDGET_RADIO, _("Macro"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("On")); + /* Macro */ + gp_widget_new (GP_WIDGET_RADIO, _("Macro"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("Off")); - switch (buf[MACRO_PTR]) { - case 0: - gp_widget_set_value (widget, _("Off")); - break; - case 1: - gp_widget_set_value (widget, _("On")); - break; + switch (buf[MACRO_PTR]) { + case 0: + gp_widget_set_value (widget, _("Off")); + break; + case 1: + gp_widget_set_value (widget, _("On")); + break; } - /* Zoom */ - gp_widget_new (GP_WIDGET_RADIO, _("Zoom"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("On")); + /* Zoom */ + gp_widget_new (GP_WIDGET_RADIO, _("Zoom"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("On")); gp_widget_add_choice (widget, _("Off")); - switch (buf[ZOOM_PTR]) { - case 0: - gp_widget_set_value (widget, _("Off")); - break; - case 1: - gp_widget_set_value (widget, _("On")); - break; + switch (buf[ZOOM_PTR]) { + case 0: + gp_widget_set_value (widget, _("Off")); + break; + case 1: + gp_widget_set_value (widget, _("On")); + break; } - /* Capture */ - gp_widget_new (GP_WIDGET_RADIO, _("Capture"), &widget); - gp_widget_append (section, widget); + /* Capture */ + gp_widget_new (GP_WIDGET_RADIO, _("Capture"), &widget); + gp_widget_append (section, widget); gp_widget_add_choice (widget, _("Single")); gp_widget_add_choice (widget, _("Sequence 9")); - switch (buf[CAPTURE_TYPE_PTR]) { - case 0: - gp_widget_set_value (widget, _("Single")); - break; - case 1: - gp_widget_set_value (widget, _("Sequence 9")); - break; + switch (buf[CAPTURE_TYPE_PTR]) { + case 0: + gp_widget_set_value (widget, _("Single")); + break; + case 1: + gp_widget_set_value (widget, _("Sequence 9")); + break; } - /* Date display */ - gp_widget_new (GP_WIDGET_RADIO, _("Date display"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Anywhere")); + /* Date display */ + gp_widget_new (GP_WIDGET_RADIO, _("Date display"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Anywhere")); gp_widget_add_choice (widget, _("Play mode")); gp_widget_add_choice (widget, _("Record mode")); gp_widget_add_choice (widget, _("Everywhere")); - switch (buf[REC_DATE_DISP_PTR]) { - case 0: - if (buf[PLAY_DATE_DISP_PTR] == 0) - gp_widget_set_value (widget, _("Play mode")); - else - gp_widget_set_value (widget, _("Anywhere")); - break; - case 1: - if (buf[PLAY_DATE_DISP_PTR] == 0) - gp_widget_set_value (widget, _("Everywhere")); - else - gp_widget_set_value (widget, _("Record mode")); - break; + switch (buf[REC_DATE_DISP_PTR]) { + case 0: + if (buf[PLAY_DATE_DISP_PTR] == 0) + gp_widget_set_value (widget, _("Play mode")); + else + gp_widget_set_value (widget, _("Anywhere")); + break; + case 1: + if (buf[PLAY_DATE_DISP_PTR] == 0) + gp_widget_set_value (widget, _("Everywhere")); + else + gp_widget_set_value (widget, _("Record mode")); + break; } - /************************/ - /* Volatile Settings */ - /************************/ - gp_widget_new (GP_WIDGET_SECTION, _("Volatile Settings"), §ion); - gp_widget_append (*window, section); - - /* Self Timer */ - gp_widget_new (GP_WIDGET_RADIO, _("Self Timer"), &widget); - gp_widget_append (section, widget); - gp_widget_add_choice (widget, _("Self Timer (next picture only)")); - gp_widget_add_choice (widget, _("Normal")); - switch (buf[TIMER_PTR]) { - case 1: - gp_widget_set_value (widget, _("Self Timer (" - "next picture only)")); - break; - case 0: - gp_widget_set_value (widget, _("Normal")); - break; - } + /************************/ + /* Volatile Settings */ + /************************/ + gp_widget_new (GP_WIDGET_SECTION, _("Volatile Settings"), §ion); + gp_widget_append (*window, section); + + /* Self Timer */ + gp_widget_new (GP_WIDGET_RADIO, _("Self Timer"), &widget); + gp_widget_append (section, widget); + gp_widget_add_choice (widget, _("Self Timer (next picture only)")); + gp_widget_add_choice (widget, _("Normal")); + switch (buf[TIMER_PTR]) { + case 1: + gp_widget_set_value (widget, _("Self Timer (next picture only)")); + break; + case 0: + gp_widget_set_value (widget, _("Normal")); + break; + } return (GP_OK); } @@ -1153,18 +1150,18 @@ camera_summary (Camera *camera, CameraText *text, GPContext *context) timestamp = (unsigned int)timestamp + (8*365 + 2*366)*24*3600-3600; tmp = *localtime(×tamp); switch (buf[DATE_FORMAT_PTR]) { - case 1: - snprintf(date_disp,sizeof(date_disp),_("DD/MM/YYYY")); - strftime(date,sizeof(date),"%d/%m/%Y %H:%M",&tmp); - break; - case 2: - strftime(date,sizeof(date),"%Y/%m/%d %H:%M",&tmp); - snprintf(date_disp,sizeof(date_disp),_("YYYY/MM/DD")); - break; - default: - strftime(date,sizeof(date),"%m/%d/%Y %H:%M",&tmp); - snprintf(date_disp,sizeof(date_disp),_("MM/DD/YYYY")); - break; + case 1: + snprintf(date_disp, sizeof(date_disp), _("DD/MM/YYYY")); + strftime(date, sizeof(date), "%d/%m/%Y %H:%M", &tmp); + break; + case 2: + strftime(date, sizeof(date), "%Y/%m/%d %H:%M", &tmp); + snprintf(date_disp, sizeof(date_disp), _("YYYY/MM/DD")); + break; + default: + strftime(date, sizeof(date), "%m/%d/%Y %H:%M", &tmp); + snprintf(date_disp, sizeof(date_disp), _("MM/DD/YYYY")); + break; } snprintf(text->text, sizeof(text->text), _("Model: %s\n" @@ -1272,12 +1269,12 @@ camera_init (Camera *camera, GPContext *context) char cmd[3], buf[1]; /* First, set up all the function pointers. */ - camera->functions->capture = camera_capture; - camera->functions->about = camera_about; - camera->functions->get_config = camera_get_config; - camera->functions->set_config = camera_set_config; - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; + camera->functions->capture = camera_capture; + camera->functions->about = camera_about; + camera->functions->get_config = camera_get_config; + camera->functions->set_config = camera_set_config; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; /* Now, tell the filesystem where to get lists, files and info */ diff --git a/camlibs/largan/lmini/largan.c b/camlibs/largan/lmini/largan.c index cd42c57741..15cd02a333 100644 --- a/camlibs/largan/lmini/largan.c +++ b/camlibs/largan/lmini/largan.c @@ -255,10 +255,10 @@ camera_init (Camera *camera, GPContext *context) int ret; GPPortSettings settings; - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->capture = camera_capture; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->capture = camera_capture; + camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); diff --git a/camlibs/largan/lmini/lmini.c b/camlibs/largan/lmini/lmini.c index a5dc4745d8..9e957cacc5 100644 --- a/camlibs/largan/lmini/lmini.c +++ b/camlibs/largan/lmini/lmini.c @@ -109,15 +109,15 @@ int largan_open (Camera * camera) { int ret; - ret = largan_get_num_pict (camera); - if (ret < 0){ - ret = purge_camera (camera); - if (ret == GP_ERROR) { - return ret; - } - ret = wakeup_camera (camera); - } - return ret; /* here: number of pictures */ + ret = largan_get_num_pict (camera); + if (ret < 0) { + ret = purge_camera (camera); + if (ret == GP_ERROR) { + return ret; + } + ret = wakeup_camera (camera); + } + return ret; /* here: number of pictures */ } /* @@ -160,21 +160,21 @@ int largan_get_pict (Camera * camera, largan_pict_type type, uint32_t pict_size; /* size of the picture as returned by the camera */ switch (type) { - case LARGAN_PICT: - param = 0x01; - break; - case LARGAN_THUMBNAIL: - param = 0x00; - break; - default: - GP_DEBUG ("largan_get_pict(): wrong picture type requested !\n"); - return GP_ERROR; + case LARGAN_PICT: + param = 0x01; + break; + case LARGAN_THUMBNAIL: + param = 0x00; + break; + default: + GP_DEBUG ("largan_get_pict(): wrong picture type requested !\n"); + return GP_ERROR; } ret = largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index); if (ret < 0) { return ret; } - ret = largan_recv_reply (camera, &reply, &code, NULL); + ret = largan_recv_reply (camera, &reply, &code, NULL); /* here we have to receive 7 bytes back the 2nd contains 00 for thumbnail or 01 for original picture the 3rd contains the picturenumber for an original picture @@ -183,26 +183,26 @@ int largan_get_pict (Camera * camera, largan_pict_type type, bytes 4 5 6 7 contain the number of byte coming in the datastream */ /* the 1st and the 2nd byte are read here */ if (ret < 0) { - /* clean up and give it a 2nd chance */ - wakeup_camera (camera); - largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index); - GP_DEBUG ("largan_get_pict(): command sent 2nd time\n"); - ret = largan_recv_reply (camera, &reply, &code, NULL); - if (ret < 0) { - /* clean up and give it even a 3rd chance */ - wakeup_camera (camera); - sleep (5); - largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index); - GP_DEBUG ("largan_get_pict(): command sent 3rd time\n"); - ret = largan_recv_reply (camera, &reply, &code, NULL); - if (ret < 0) { - GP_DEBUG ("largan_get_pict(): timeout after command sent 3rd time\n"); - return ret; /* timeout after 3rd trial */ - } - } - } - if ((reply != LARGAN_GET_PICT_CMD) || ((code != 0x01) && (code != 0x00))) { - GP_DEBUG ("largan_get_pict(): code != 0x01 && 0x00\n"); + /* clean up and give it a 2nd chance */ + wakeup_camera (camera); + largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index); + GP_DEBUG ("largan_get_pict(): command sent 2nd time\n"); + ret = largan_recv_reply (camera, &reply, &code, NULL); + if (ret < 0) { + /* clean up and give it even a 3rd chance */ + wakeup_camera (camera); + sleep (5); + largan_send_command (camera, LARGAN_GET_PICT_CMD, param, index); + GP_DEBUG ("largan_get_pict(): command sent 3rd time\n"); + ret = largan_recv_reply (camera, &reply, &code, NULL); + if (ret < 0) { + GP_DEBUG ("largan_get_pict(): timeout after command sent 3rd time\n"); + return ret; /* timeout after 3rd trial */ + } + } + } + if ((reply != LARGAN_GET_PICT_CMD) || ((code != 0x01) && (code != 0x00))) { + GP_DEBUG ("largan_get_pict(): code != 0x01 && 0x00\n"); return GP_ERROR; } @@ -265,7 +265,7 @@ int largan_get_pict (Camera * camera, largan_pict_type type, } default: GP_DEBUG ("largan_get_pict(): type not LARGAN_PICT nor LARGAN_THUMBNAIL\n"); - return GP_ERROR; + return GP_ERROR; } return GP_OK; } diff --git a/camlibs/lg_gsm/lg_gsm.c b/camlibs/lg_gsm/lg_gsm.c index 4a2058cc21..b5c14eda17 100644 --- a/camlibs/lg_gsm/lg_gsm.c +++ b/camlibs/lg_gsm/lg_gsm.c @@ -72,13 +72,13 @@ int lg_gsm_init (GPPort *port, Model *model, Info *info) /*GP_DEBUG("info[20] = 0x%x\n", firmware[26]);*/ GP_DEBUG("Leaving lg_gsm_init\n"); - return GP_OK; + return GP_OK; } unsigned int lg_gsm_get_picture_size (GPPort *port, int pic) { - unsigned int size; + unsigned int size; /* example : list photos 2 & 3: 0x04000800000040000000 + 0100 : from + 0200 : to @@ -206,7 +206,7 @@ int lg_gsm_read_picture_data (GPPort *port, char *data, unsigned int datasize, u READ(port, oknok, 6); GP_DEBUG("Leaving lg_gsm_read_picture_data\n"); - return GP_OK; + return GP_OK; } int lg_gsm_list_files (GPPort *port, CameraList *list) @@ -270,5 +270,5 @@ int lg_gsm_list_files (GPPort *port, CameraList *list) GP_DEBUG("Leaving lg_gsm_list_files\n"); - return GP_OK; + return GP_OK; } diff --git a/camlibs/lg_gsm/library.c b/camlibs/lg_gsm/library.c index 4ef7bcc257..47a3ab6d54 100644 --- a/camlibs/lg_gsm/library.c +++ b/camlibs/lg_gsm/library.c @@ -51,20 +51,20 @@ struct _CameraPrivateLibrary { }; static struct { - char *name; + char *name; CameraDriverStatus status; - unsigned short idVendor; - unsigned short idProduct; + unsigned short idVendor; + unsigned short idProduct; } models[] = { - {"LG T5100", GP_DRIVER_STATUS_EXPERIMENTAL, 0x1004, 0x6005}, + {"LG T5100", GP_DRIVER_STATUS_EXPERIMENTAL, 0x1004, 0x6005}, {NULL,0,0,0} }; int camera_id (CameraText *id) { - strcpy (id->text, "LG GSM camera"); - return GP_OK; + strcpy (id->text, "LG GSM camera"); + return GP_OK; } int @@ -113,9 +113,9 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("LG GSM generic driver\n" - "Guillaume Bedot \n")); - return GP_OK; + strcpy (about->text, _("LG GSM generic driver\n" + "Guillaume Bedot \n")); + return GP_OK; } /*************** File and Downloading Functions *******************/ @@ -137,7 +137,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, { Camera *camera = user_data; - int k; + int k; char *data; unsigned int len; @@ -191,9 +191,9 @@ camera_init(Camera *camera, GPContext *context) int ret = 0; /* First, set up all the function pointers */ - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; - camera->functions->exit = camera_exit; + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; + camera->functions->exit = camera_exit; GP_DEBUG ("Initializing the camera\n"); ret = gp_port_get_settings(camera->port,&settings); @@ -201,17 +201,17 @@ camera_init(Camera *camera, GPContext *context) return ret; switch (camera->port->type) { - case GP_PORT_SERIAL: - return GP_ERROR; - case GP_PORT_USB: - settings.usb.config = 1; - settings.usb.altsetting = 0; - settings.usb.interface = 1; - settings.usb.inep = 0x81; - settings.usb.outep =0x02; - break; - default: - return GP_ERROR; + case GP_PORT_SERIAL: + return GP_ERROR; + case GP_PORT_USB: + settings.usb.config = 1; + settings.usb.altsetting = 0; + settings.usb.interface = 1; + settings.usb.inep = 0x81; + settings.usb.outep =0x02; + break; + default: + return GP_ERROR; } ret = gp_port_set_settings(camera->port,settings); @@ -222,7 +222,7 @@ camera_init(Camera *camera, GPContext *context) GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("outep = %x\n", settings.usb.outep); - /* Tell the CameraFilesystem where to get lists from */ + /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); diff --git a/camlibs/lumix/lumix.c b/camlibs/lumix/lumix.c index 27d8cd8c5c..ed28ea4e95 100644 --- a/camlibs/lumix/lumix.c +++ b/camlibs/lumix/lumix.c @@ -430,8 +430,8 @@ static void Set_ISO(Camera *camera,const char * ISOValue) { static char* generic_setting_getter(Camera *camera, char *type) { char *result, *s; - xmlDocPtr docin; - xmlNodePtr docroot, output; + xmlDocPtr docin; + xmlNodePtr docroot, output; xmlAttr *attr; char url[50]; @@ -725,8 +725,8 @@ static char* GetPixRange(Camera *camera, int start, int num) { long NumPix; int numreadint; - xmlDocPtr docin, docin2; - xmlNodePtr docroot, docroot2, output, output2, next; + xmlDocPtr docin, docin2; + xmlNodePtr docroot, docroot2, output, output2, next; xmlChar *xchar, *numread; char* SoapMsg; CURL *curl; @@ -1089,15 +1089,15 @@ static struct aperturemap { static int camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) { - CameraWidget *widget,*section; - int valset; - unsigned int i; + CameraWidget *widget,*section; + int valset; + unsigned int i; char *val; switchToRecMode (camera); - gp_widget_new (GP_WIDGET_WINDOW, _("Lumix Configuration"), window); - gp_widget_set_name (*window, "config"); + gp_widget_new (GP_WIDGET_WINDOW, _("Lumix Configuration"), window); + gp_widget_set_name (*window, "config"); gp_widget_new (GP_WIDGET_SECTION, _("Camera Settings"), §ion); gp_widget_set_name (section, "settings"); @@ -1367,14 +1367,14 @@ camera_config_set (Camera *camera, CameraWidget *window, GPContext *context) static int strend(const char *s, const char *t) { - size_t ls = strlen(s); // find length of s - size_t lt = strlen(t); // find length of t - if (ls >= lt) // check if t can fit in s - { - // point s to where t should start and compare the strings from there - return (0 == memcmp(t, s + (ls - lt), lt)); - } - return 0; // t was longer than s + size_t ls = strlen(s); // find length of s + size_t lt = strlen(t); // find length of t + if (ls >= lt) // check if t can fit in s + { + // point s to where t should start and compare the strings from there + return (0 == memcmp(t, s + (ls - lt), lt)); + } + return 0; // t was longer than s } static char* @@ -1383,33 +1383,33 @@ processNode(xmlTextReaderPtr reader) { char* lookupImgtag=""; switch (ReadoutMode) { - case 0 : //'jpg + case 0: //'jpg lookupImgtag = "CAM_RAW_JPG"; - break; - case 1 :// 'raw + break; + case 1:// 'raw lookupImgtag = "CAM_RAW"; - break; - case 2 ://'thumb + break; + case 2://'thumb lookupImgtag = "CAM_LRGTN"; - break; + break; } - const xmlChar *name; + const xmlChar *name; - name = xmlTextReaderConstName(reader); - if (name == NULL) - name = BAD_CAST "--"; + name = xmlTextReaderConstName(reader); + if (name == NULL) + name = BAD_CAST "--"; - if (xmlTextReaderNodeType(reader) == 1) { // Element - while (xmlTextReaderMoveToNextAttribute(reader)) { - if (strend((char*)xmlTextReaderConstValue(reader),lookupImgtag)) { - xmlTextReaderRead(reader); - ret = (char*)xmlTextReaderConstValue(reader); - printf("the image file is %s\n" ,ret); + if (xmlTextReaderNodeType(reader) == 1) { // Element + while (xmlTextReaderMoveToNextAttribute(reader)) { + if (strend((char*)xmlTextReaderConstValue(reader), lookupImgtag)) { + xmlTextReaderRead(reader); + ret = (char*)xmlTextReaderConstValue(reader); + printf("the image file is %s\n", ret); + } } } - } - return ret; + return ret; } /* @@ -1469,61 +1469,61 @@ case RAW: */ static int add_objectid_and_upload (Camera *camera, CameraFilePath *path, GPContext *context, char *ximage, size_t size) { - int ret; - CameraFile *file = NULL; - CameraFileInfo info; - - ret = gp_file_new(&file); - if (ret!=GP_OK) return ret; - gp_file_set_mtime (file, time(NULL)); - strcpy(info.file.type, GP_MIME_JPEG); - - GP_LOG_D ("setting size"); - ret = gp_file_set_data_and_size(file, ximage, size); - if (ret != GP_OK) { - gp_file_free (file); - return ret; - } - GP_LOG_D ("append to fs"); - ret = gp_filesystem_append(camera->fs, path->folder, path->name, context); - if (ret != GP_OK) { - gp_file_free (file); - return ret; - } - GP_LOG_D ("adding filedata to fs"); - ret = gp_filesystem_set_file_noop(camera->fs, path->folder, path->name, GP_FILE_TYPE_NORMAL, file, context); - if (ret != GP_OK) { - gp_file_free (file); - return ret; - } - - /* We have now handed over the file, disclaim responsibility by unref. */ - gp_file_unref (file); - - /* we also get the fs info for free, so just set it */ - info.file.fields = GP_FILE_INFO_TYPE | - /*GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |*/ - GP_FILE_INFO_SIZE /*| GP_FILE_INFO_MTIME */ ; - strcpy(info.file.type, GP_MIME_JPEG); - - info.preview.fields = 0; /* so far none */ -/* - info.file.width = oi->ImagePixWidth; - info.file.height = oi->ImagePixHeight; - info.file.size = oi->ObjectCompressedSize; - info.file.mtime = time(NULL); - - info.preview.fields = GP_FILE_INFO_TYPE | - GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | - GP_FILE_INFO_SIZE; - strcpy_mime (info.preview.type, params->deviceinfo.VendorExtensionID, oi->ThumbFormat); - info.preview.width = oi->ThumbPixWidth; - info.preview.height = oi->ThumbPixHeight; - info.preview.size = oi->ThumbCompressedSize; -*/ + int ret; + CameraFile *file = NULL; + CameraFileInfo info; - GP_LOG_D ("setting fileinfo in fs"); - return gp_filesystem_set_info_noop(camera->fs, path->folder, path->name, info, context); + ret = gp_file_new(&file); + if (ret!=GP_OK) return ret; + gp_file_set_mtime (file, time(NULL)); + strcpy(info.file.type, GP_MIME_JPEG); + + GP_LOG_D ("setting size"); + ret = gp_file_set_data_and_size(file, ximage, size); + if (ret != GP_OK) { + gp_file_free (file); + return ret; + } + GP_LOG_D ("append to fs"); + ret = gp_filesystem_append(camera->fs, path->folder, path->name, context); + if (ret != GP_OK) { + gp_file_free (file); + return ret; + } + GP_LOG_D ("adding filedata to fs"); + ret = gp_filesystem_set_file_noop(camera->fs, path->folder, path->name, GP_FILE_TYPE_NORMAL, file, context); + if (ret != GP_OK) { + gp_file_free (file); + return ret; + } + + /* We have now handed over the file, disclaim responsibility by unref. */ + gp_file_unref (file); + + /* we also get the fs info for free, so just set it */ + info.file.fields = GP_FILE_INFO_TYPE | + /*GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT |*/ + GP_FILE_INFO_SIZE /*| GP_FILE_INFO_MTIME */; + strcpy(info.file.type, GP_MIME_JPEG); + + info.preview.fields = 0; /* so far none */ + /* + info.file.width = oi->ImagePixWidth; + info.file.height = oi->ImagePixHeight; + info.file.size = oi->ObjectCompressedSize; + info.file.mtime = time(NULL); + + info.preview.fields = GP_FILE_INFO_TYPE | + GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | + GP_FILE_INFO_SIZE; + strcpy_mime (info.preview.type, params->deviceinfo.VendorExtensionID, oi->ThumbFormat); + info.preview.width = oi->ThumbPixWidth; + info.preview.height = oi->ThumbPixHeight; + info.preview.size = oi->ThumbCompressedSize; + */ + + GP_LOG_D ("setting fileinfo in fs"); + return gp_filesystem_set_info_noop(camera->fs, path->folder, path->name, info, context); } static int @@ -1540,10 +1540,10 @@ ReadImageFromCamera(Camera *camera, CameraFilePath *path, GPContext *context) { reader = xmlReaderForDoc((xmlChar*)GetPixRange(camera,NumberPix(camera)-1,1), NULL,"noname.xml", XML_PARSE_DTDATTR | /* default DTD attributes */ XML_PARSE_NOENT); ret = xmlTextReaderRead(reader); while (ret == 1) { - imageURL = processNode(reader); - if (strlen(imageURL)) - break; - ret = xmlTextReaderRead(reader); + imageURL = processNode(reader); + if (strlen(imageURL)) + break; + ret = xmlTextReaderRead(reader); } GP_DEBUG("the image URL is %s\n",imageURL); diff --git a/camlibs/mars/library.c b/camlibs/mars/library.c index 040600c010..c7c6463460 100644 --- a/camlibs/mars/library.c +++ b/camlibs/mars/library.c @@ -55,12 +55,12 @@ struct _CameraPrivateLibrary { }; static const struct { - char *name; + char *name; CameraDriverStatus status; - unsigned short idVendor; - unsigned short idProduct; + unsigned short idVendor; + unsigned short idProduct; } models[] = { - {"Aiptek PenCam VGA+", GP_DRIVER_STATUS_TESTING, 0x08ca, 0x0111}, + {"Aiptek PenCam VGA+", GP_DRIVER_STATUS_TESTING, 0x08ca, 0x0111}, {"Trust Spyc@m 100", GP_DRIVER_STATUS_TESTING, 0x08ca, 0x0110}, {"Emprex PCD3600", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, {"Vivitar Vivicam 55", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, @@ -86,34 +86,34 @@ static const struct { int camera_id (CameraText *id) { - strcpy (id->text, "Aiptek PenCam VGA+"); - return GP_OK; + strcpy (id->text, "Aiptek PenCam VGA+"); + return GP_OK; } int camera_abilities (CameraAbilitiesList *list) { - int i; - CameraAbilities a; - - for (i = 0; models[i].name; i++) { - memset (&a, 0, sizeof(a)); - strcpy (a.model, models[i].name); - a.status = models[i].status; - a.port = GP_PORT_USB; - a.speed[0] = 0; - a.usb_vendor = models[i].idVendor; - a.usb_product= models[i].idProduct; - if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) + int i; + CameraAbilities a; + + for (i = 0; models[i].name; i++) { + memset (&a, 0, sizeof(a)); + strcpy (a.model, models[i].name); + a.status = models[i].status; + a.port = GP_PORT_USB; + a.speed[0] = 0; + a.usb_vendor = models[i].idVendor; + a.usb_product= models[i].idProduct; + if (a.status == GP_DRIVER_STATUS_EXPERIMENTAL) a.operations = GP_OPERATION_NONE; else a.operations = GP_OPERATION_CAPTURE_IMAGE; - a.folder_operations = GP_FOLDER_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_PREVIEW - | GP_FILE_OPERATION_RAW; - gp_abilities_list_append (list, a); - } - return GP_OK; + a.folder_operations = GP_FOLDER_OPERATION_NONE; + a.file_operations = GP_FILE_OPERATION_PREVIEW + | GP_FILE_OPERATION_RAW; + gp_abilities_list_append (list, a); + } + return GP_OK; } static int @@ -121,20 +121,20 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) { int num_pics = mars_get_num_pics(camera->pl->info); - sprintf (summary->text,ngettext( + sprintf (summary->text, ngettext( "Mars MR97310 camera.\nThere is %i photo in it.\n", - "Mars MR97310 camera.\nThere are %i photos in it.\n", + "Mars MR97310 camera.\nThere are %i photos in it.\n", num_pics), num_pics ); - return GP_OK; + return GP_OK; } static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) { strcpy(manual->text, _( - "This driver supports cameras with Mars MR97310 chip (and direct\n" - "equivalents ??Pixart PACx07?\?).\n" + "This driver supports cameras with Mars MR97310 chip (and direct\n" + "equivalents ??Pixart PACx07?\?).\n" "These cameras do not support deletion of photos, nor uploading\n" "of data.\n" "Decoding of compressed photos may or may not work well\n" @@ -151,9 +151,9 @@ static int camera_manual (Camera *camera, CameraText *manual, GPContext *context static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("Mars MR97310 camera library\n" - "Theodore Kilgore \n")); - return GP_OK; + strcpy (about->text, _("Mars MR97310 camera library\n" + "Theodore Kilgore \n")); + return GP_OK; } /*************** File and Downloading Functions *******************/ @@ -162,7 +162,7 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; int i = 0, n; char name[30]; @@ -172,9 +172,9 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, sprintf (name, "mr%03isnd.wav", i+1); } else sprintf (name, "mr%03ipic.ppm", i+1); - gp_list_append (list, name, NULL); - } - return GP_OK; + gp_list_append (list, name, NULL); + } + return GP_OK; } static int @@ -192,10 +192,10 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileType type, CameraFile *file, void *user_data, GPContext *context) { - Camera *camera = user_data; - int w=0, h = 0, b = 0, k; - unsigned char *data; - unsigned char *ppm; + Camera *camera = user_data; + int w=0, h = 0, b = 0, k; + unsigned char *data; + unsigned char *ppm; unsigned char *p_data = NULL; unsigned char gtable[256], photo_code, res_code, compressed; unsigned char audio = 0; @@ -203,21 +203,21 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, int size = 0, raw_size = 0; float gamma_factor; - GP_DEBUG ("Downloading pictures!\n"); + GP_DEBUG ("Downloading pictures!\n"); /* These are cheap cameras. There ain't no EXIF data. */ if (GP_FILE_TYPE_EXIF == type) return GP_ERROR_FILE_EXISTS; - /* Get the number of the photo on the camera */ + /* Get the number of the photo on the camera */ k = gp_filesystem_number (camera->fs, "/", filename, context); - /* Determine the resolution setting from the PAT table */ + /* Determine the resolution setting from the PAT table */ photo_code = camera->pl->info[8*k]; res_code = photo_code & 0x0f; /* Compression presence or absence is seen here, and is given again * by the camera, in the header of raw data for each photo. */ - compressed = (photo_code >> 4) & 2; + compressed = (photo_code >> 4) & 2; switch (res_code) { case 0: w = 176; h = 144; break; case 1: audio = 1; break; @@ -235,30 +235,30 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, b = ((b+ 0x1b0)/0x2000 + 1) * 0x2000; if (w*h > b) { - GP_DEBUG ("w=%d, h=%d, w*h=%d, bytes read=%d\n", w,h,w*h,b); + GP_DEBUG ("w=%d, h=%d, w*h=%d, bytes read=%d\n", w, h, w*h, b); return GP_ERROR_CORRUPTED_DATA; } - data = calloc (b,1); + data = calloc (b, 1); if (!data) return GP_ERROR_NO_MEMORY; - GP_DEBUG ("buffersize= %i = 0x%x bytes\n", b,b); + GP_DEBUG ("buffersize= %i = 0x%x bytes\n", b, b); mars_read_picture_data (camera, camera->pl->info, - camera->port, (char *)data, b, k); + camera->port, (char *)data, b, k); /* The first 128 bytes are junk, so we toss them.*/ memmove(data, data+128, b - 128); if (audio) { p_data = malloc (raw_size+256); - if (!p_data) {free (data); return GP_ERROR_NO_MEMORY;} + if (!p_data) { free (data); return GP_ERROR_NO_MEMORY; } memset (p_data, 0, raw_size+256); - sprintf ((char *)p_data, "RIFF"); + sprintf ((char *)p_data, "RIFF"); p_data[4] = (raw_size+36)&0xff; p_data[5] = ((raw_size+36)>>8)&0xff; p_data[6] = ((raw_size+36)>>16)&0xff; p_data[7] = ((raw_size+36)>>24)&0xff; - sprintf ((char *)p_data+8, "WAVE");\ - sprintf ((char *)p_data+12, "fmt "); + sprintf ((char *)p_data+8, "WAVE"); + sprintf ((char *)p_data+12, "fmt "); p_data[16] = 0x10; p_data[20] = 1; p_data[22] = 1; @@ -268,14 +268,14 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, p_data[29] = 0x1F; p_data[32] = 1; p_data[34] = 8; - sprintf ((char *)p_data+36, "data"); + sprintf ((char *)p_data+36, "data"); p_data[40] = (raw_size)&0xff; p_data[41] = ((raw_size)>>8)&0xff; p_data[42] = ((raw_size)>>16)&0xff; p_data[43] = ((raw_size)>>24)&0xff; memcpy (p_data+44, data, raw_size); gp_file_set_mime_type(file, GP_MIME_WAV); - gp_file_set_data_and_size(file, (char *)p_data , raw_size+44); + gp_file_set_data_and_size(file, (char *)p_data, raw_size+44); return GP_OK; } @@ -314,7 +314,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, ppm = malloc (w * h * 3 + 256); /* Data + header */ if (!ppm) {free (p_data); return GP_ERROR_NO_MEMORY;} memset (ppm, 0, w * h * 3 + 256); - sprintf ((char *)ppm, + sprintf ((char *)ppm, "P6\n" "# CREATOR: gphoto2, Mars library\n" "%d %d\n" @@ -326,11 +326,11 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, gp_gamma_fill_table (gtable, gamma_factor ); gp_gamma_correct_single (gtable, ptr, w * h); mars_white_balance (ptr, w*h, 1.4, gamma_factor); - gp_file_set_mime_type (file, GP_MIME_PPM); + gp_file_set_mime_type (file, GP_MIME_PPM); gp_file_set_data_and_size (file, (char *)ppm, size); free (p_data); - return GP_OK; + return GP_OK; } /*************** Exit and Initialization Functions ******************/ @@ -360,7 +360,7 @@ camera_init(Camera *camera, GPContext *context) int ret = 0; /* First, set up all the function pointers */ - camera->functions->manual = camera_manual; + camera->functions->manual = camera_manual; camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->exit = camera_exit; @@ -370,19 +370,19 @@ camera_init(Camera *camera, GPContext *context) if (ret < 0) return ret; switch (camera->port->type) { - case GP_PORT_SERIAL: - return ( GP_ERROR ); - case GP_PORT_USB: - settings.usb.config = 1; - settings.usb.altsetting = 0; - settings.usb.interface = 0; + case GP_PORT_SERIAL: + return (GP_ERROR); + case GP_PORT_USB: + settings.usb.config = 1; + settings.usb.altsetting = 0; + settings.usb.interface = 0; /* settings.usb.inep = 0x82; */ /* inep 0x83 used for commands. Switch to 0x82 for data! */ - settings.usb.inep = 0x83; - settings.usb.outep = 0x04; - break; - default: - return ( GP_ERROR ); + settings.usb.inep = 0x83; + settings.usb.outep = 0x04; + break; + default: + return (GP_ERROR); } ret = gp_port_set_settings(camera->port,settings); @@ -392,7 +392,7 @@ camera_init(Camera *camera, GPContext *context) GP_DEBUG("inep = %x\n", settings.usb.inep); GP_DEBUG("outep = %x\n", settings.usb.outep); - /* Tell the CameraFilesystem where to get lists from */ + /* Tell the CameraFilesystem where to get lists from */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); camera->pl = malloc (sizeof (CameraPrivateLibrary)); diff --git a/camlibs/mars/mars.c b/camlibs/mars/mars.c index 754a0b8fba..06a28bc325 100644 --- a/camlibs/mars/mars.c +++ b/camlibs/mars/mars.c @@ -76,7 +76,7 @@ mars_init (Camera *camera, GPPort *port, Info *info) * camera reports 0x02 it is "jammed" and we must clear it. */ - m_read(port, c, 16); + m_read(port, c, 16); if (c[0] == 0x02) { gp_port_write(port, "\x19", 1); gp_port_read(port, c, 16); @@ -97,7 +97,7 @@ mars_init (Camera *camera, GPPort *port, Info *info) memmove(info, info + 144, 0x1f70); /* Saving config */ GP_DEBUG("Leaving mars_init\n"); - return GP_OK; + return GP_OK; } int @@ -123,7 +123,7 @@ mars_get_pic_data_size (Info *info, int n) } static int -set_usb_in_endpoint (Camera *camera, int inep) +set_usb_in_endpoint (Camera *camera, int inep) { GPPortSettings settings; gp_port_get_settings ( camera ->port, &settings); @@ -134,18 +134,18 @@ set_usb_in_endpoint (Camera *camera, int inep) static int -mars_read_data (GPPort *port, char *data, int size) +mars_read_data (GPPort *port, char *data, int size) { int MAX_BULK = 0x2000; int len = 0; while(size > 0) { len = (size>MAX_BULK)?MAX_BULK:size; - gp_port_read (port, data, len); + gp_port_read (port, data, len); data += len; size -= len; } - return 1; + return 1; } int @@ -247,63 +247,63 @@ int mars_decompress (unsigned char *inp, unsigned char *outp, int width, /* first two pixels in first two rows are stored as raw 8-bit */ if (row < 2) { - GET_CODE; - bitpos += 8; - *outp++ = code; + GET_CODE; + bitpos += 8; + *outp++ = code; - GET_CODE; - bitpos += 8; - *outp++ = code; + GET_CODE; + bitpos += 8; + *outp++ = code; - col += 2; + col += 2; } while (col < width) { - /* get bitcode */ - GET_CODE; - /* update bit position */ - bitpos += table[code].len; - - /* calculate pixel value */ - if (table[code].is_abs) { - /* get 5 more bits and use them as absolute value */ - GET_CODE; - val = (code & 0xF8); - bitpos += 5; - - }else { - /* value is relative to top or left pixel */ - val = table[code].val; - lp = outp[-2]; - if (row > 1) { - if (col > 1) - tlp = outp[-2*width-2]; - tp = outp[-2*width]; - if (col < width-2) - trp = outp[-2*width+2]; - } - if (row < 2) { - /* top row: relative to left pixel */ - val += lp; - }else if (col < 2) { - /* left column: relative to top pixel */ - /* initial estimate */ - val += (tp + trp)/2; - }else if (col > width - 3) { - /* left column: relative to top pixel */ - val += (tp + lp + tlp +1)/3; - /* main area: average of left and top pixel */ - }else { - /* initial estimate for predictor */ - tlp>>=1; - trp>>=1; - val += (lp + tp + tlp + trp +1)/3; - } - } - /* store pixel */ - *outp++ = CLAMP(val); - col++; + /* get bitcode */ + GET_CODE; + /* update bit position */ + bitpos += table[code].len; + + /* calculate pixel value */ + if (table[code].is_abs) { + /* get 5 more bits and use them as absolute value */ + GET_CODE; + val = (code & 0xF8); + bitpos += 5; + + } else { + /* value is relative to top or left pixel */ + val = table[code].val; + lp = outp[-2]; + if (row > 1) { + if (col > 1) + tlp = outp[-2*width-2]; + tp = outp[-2*width]; + if (col < width-2) + trp = outp[-2*width+2]; + } + if (row < 2) { + /* top row: relative to left pixel */ + val += lp; + } else if (col < 2) { + /* left column: relative to top pixel */ + /* initial estimate */ + val += (tp + trp)/2; + } else if (col > width - 3) { + /* left column: relative to top pixel */ + val += (tp + lp + tlp +1)/3; + /* main area: average of left and top pixel */ + } else { + /* initial estimate for predictor */ + tlp>>=1; + trp>>=1; + val += (lp + tp + tlp + trp +1)/3; + } } + /* store pixel */ + *outp++ = CLAMP(val); + col++; + } } return GP_OK; } @@ -342,7 +342,7 @@ mars_routine (Info *info, GPPort *port, char param, int n) memset(c,0,sizeof(c)); /*Routine used in initialization, photo download, and reset. */ - m_read(port, c, 16); + m_read(port, c, 16); m_command(port, start, 2, c); m_command(port, do_something, 2, c); m_command(port, address1, 2, c); @@ -350,8 +350,8 @@ mars_routine (Info *info, GPPort *port, char param, int n) c[0] = 0; gp_port_write(port, address2, 2); /* Moving the memory cursor to the given address? */ - while (( c[0] != 0xa) ) { - if (m_read(port, c, 16) < 16) + while ((c[0] != 0xa)) { + if (m_read(port, c, 16) < 16) break; } diff --git a/camlibs/minolta/dimagev/dimagev.c b/camlibs/minolta/dimagev/dimagev.c index cbe1c6c0c2..91d1c8eb15 100644 --- a/camlibs/minolta/dimagev/dimagev.c +++ b/camlibs/minolta/dimagev/dimagev.c @@ -429,13 +429,13 @@ int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->capture = camera_capture; - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->capture = camera_capture; + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; - GP_DEBUG( "initializing the camera"); + GP_DEBUG ("initializing the camera"); camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) @@ -444,35 +444,35 @@ int camera_init (Camera *camera, GPContext *context) camera->pl->dev = camera->port; /* Configure the port */ - gp_port_set_timeout(camera->port, 5000); + gp_port_set_timeout(camera->port, 5000); gp_port_get_settings(camera->port, &settings); - settings.serial.speed = 38400; - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits = 1; - gp_port_set_settings(camera->port, settings); - - if ( dimagev_get_camera_data(camera->pl) < GP_OK ) { - GP_DEBUG( "camera_init::unable to get current camera data"); + settings.serial.speed = 38400; + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits = 1; + gp_port_set_settings(camera->port, settings); + + if (dimagev_get_camera_data(camera->pl) < GP_OK) { + GP_DEBUG("camera_init::unable to get current camera data"); free (camera->pl); camera->pl = NULL; - return GP_ERROR_IO; - } + return GP_ERROR_IO; + } - if ( dimagev_get_camera_status(camera->pl) < GP_OK ) { - GP_DEBUG( "camera_init::unable to get current camera status"); + if (dimagev_get_camera_status(camera->pl) < GP_OK) { + GP_DEBUG("camera_init::unable to get current camera status"); free (camera->pl); camera->pl = NULL; - return GP_ERROR_IO; - } + return GP_ERROR_IO; + } /* Apparently, trying to set the clock now leaves the camera in an unstable state. Skipping it for now. */ - /* if ( dimagev_set_date(camera->pl) < GP_OK ) { - GP_DEBUG( "camera_init::unable to set camera to system time"); - } */ + /* if ( dimagev_set_date(camera->pl) < GP_OK ) { + GP_DEBUG( "camera_init::unable to set camera to system time"); + } */ - /* Set up the filesystem */ + /* Set up the filesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); - return GP_OK; + return GP_OK; } diff --git a/camlibs/mustek/io.c b/camlibs/mustek/io.c index 6045bc61f3..18b7d9ed2c 100644 --- a/camlibs/mustek/io.c +++ b/camlibs/mustek/io.c @@ -57,7 +57,7 @@ int mdc800_io_sendCommand_with_retry (GPPort *port,unsigned char* command, unsig while (try < maxtries) { - usleep(MDC800_DEFAULT_COMMAND_RETRY_DELAY*1000); + usleep(MDC800_DEFAULT_COMMAND_RETRY_DELAY*1000); if (port->type == GP_PORT_USB) ret=mdc800_usb_sendCommand(port,command, buffer, length ); else diff --git a/camlibs/mustek/mdc800.c b/camlibs/mustek/mdc800.c index 770685eafc..7dc454abc6 100644 --- a/camlibs/mustek/mdc800.c +++ b/camlibs/mustek/mdc800.c @@ -304,14 +304,14 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - /* First, set up all the function pointers */ - /* camera->functions->exit = camera_exit; */ - camera->functions->get_config = camera_config_get; - camera->functions->set_config = camera_config_set; - camera->functions->capture = camera_capture; - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + /* camera->functions->exit = camera_exit; */ + camera->functions->get_config = camera_config_get; + camera->functions->set_config = camera_config_set; + camera->functions->capture = camera_capture; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); @@ -319,13 +319,13 @@ camera_init (Camera *camera, GPContext *context) /* Configure port */ gp_port_set_timeout(camera->port,MDC800_DEFAULT_COMMAND_RETRY_DELAY); if (camera->port->type == GP_PORT_SERIAL) { - GPPortSettings settings; - gp_port_get_settings(camera->port, &settings); - settings.serial.speed = 57600; - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits= 1; - gp_port_set_settings(camera->port, settings); + GPPortSettings settings; + gp_port_get_settings(camera->port, &settings); + settings.serial.speed = 57600; + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits= 1; + gp_port_set_settings(camera->port, settings); } return mdc800_openCamera(camera); } diff --git a/camlibs/mustek/mustek-config.c b/camlibs/mustek/mustek-config.c index dcf98f4b8f..b32fc7b92e 100644 --- a/camlibs/mustek/mustek-config.c +++ b/camlibs/mustek/mustek-config.c @@ -263,11 +263,11 @@ void mdc800_createDialog (void ) /* done with the widgets */ - toggle = gtk_toggle_button_new(); + toggle = gtk_toggle_button_new(); gtk_widget_show(toggle); gtk_widget_hide(toggle); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mdc800_dialog.dialog)->action_area), - toggle, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mdc800_dialog.dialog)->action_area), + toggle, TRUE, TRUE, 0); mdc800_dialog.save_button = gtk_button_new_with_label("Save"); gtk_widget_show(mdc800_dialog.save_button); @@ -359,7 +359,7 @@ int mdc800_setupDialog (void) /* Baudrate */ if (!mdc800_io_using_usb) { int speed; - mdc800_getSpeed(camera,&speed); + mdc800_getSpeed (camera, &speed); mdc800_ComboBox_SetEntry (mdc800_dialog.baud, mdc800_baud_rate_string, speed); } @@ -408,12 +408,12 @@ int mdc800_setupConfig (void) value = mdc800_ComboBox_GetEntry (mdc800_dialog.light, mdc800_wb_string,4); switch (value) { - case 0: value=1; break; - case 1: value=2; break; - case 2: value=4; break; - case 3: value=8; break; - default: - return -1; + case 0: value=1; break; + case 1: value=2; break; + case 2: value=4; break; + case 3: value=8; break; + default: + return -1; } if (!mdc800_setWB (value)) return -1; @@ -422,9 +422,9 @@ int mdc800_setupConfig (void) /* Set LCD ON/OFF... */ if (GTK_WIDGET_STATE(mdc800_dialog.lcd_on) == GTK_STATE_ACTIVE) - mdc800_enableLCD (1); + mdc800_enableLCD (1); else - mdc800_enableLCD (0); + mdc800_enableLCD (0); update_progress(62); diff --git a/camlibs/panasonic/dc.c b/camlibs/panasonic/dc.c index a9a222a407..430c087247 100644 --- a/camlibs/panasonic/dc.c +++ b/camlibs/panasonic/dc.c @@ -49,193 +49,193 @@ static const char int dsc1_sendcmd(Camera *camera, uint8_t cmd, void *data, int size) { - int i; + int i; - DEBUG_PRINT_MEDIUM(("Sending command: 0x%02x, data size: %i.", cmd, size)); + DEBUG_PRINT_MEDIUM(("Sending command: 0x%02x, data size: %i.", cmd, size)); - memset(camera->pl->buf, 0, DSC_BUFSIZE); + memset(camera->pl->buf, 0, DSC_BUFSIZE); - memcpy(camera->pl->buf, c_prefix, 12); + memcpy(camera->pl->buf, c_prefix, 12); - for (i = 0; i < 4; i++) - camera->pl->buf[DSC1_BUF_SIZE + i] = (uint8_t)(size >> 8*(3 - i)); + for (i = 0; i < 4; i++) + camera->pl->buf[DSC1_BUF_SIZE + i] = (uint8_t)(size >> 8*(3 - i)); - camera->pl->buf[DSC1_BUF_CMD] = cmd; + camera->pl->buf[DSC1_BUF_CMD] = cmd; - if (DSC_BUFSIZE - DSC1_BUF_DATA <= size) { - RETURN_ERROR(EDSCOVERFL) - /* overflow */ - } + if (DSC_BUFSIZE - DSC1_BUF_DATA <= size) { + RETURN_ERROR(EDSCOVERFL) + /* overflow */ + } - if (data && 0 < size) - memcpy(&camera->pl->buf[DSC1_BUF_DATA], data, size); + if (data && 0 < size) + memcpy(&camera->pl->buf[DSC1_BUF_DATA], data, size); - return gp_port_write(camera->port, camera->pl->buf, 17 + size); + return gp_port_write(camera->port, camera->pl->buf, 17 + size); } int dsc1_retrcmd(Camera *camera) { - int result = GP_ERROR; - int s; + int result = GP_ERROR; + int s; - if ((s = gp_port_read(camera->port, camera->pl->buf, 17)) == GP_ERROR) - return GP_ERROR; + if ((s = gp_port_read(camera->port, camera->pl->buf, 17)) == GP_ERROR) + return GP_ERROR; /* Make sense in debug only. Done on gp_port level. - if (0 < s) - dsc_dumpmem(camera->pl->buf, s); + if (0 < s) + dsc_dumpmem(camera->pl->buf, s); */ - if (s != 17 || memcmp(camera->pl->buf, r_prefix, 12) != 0 ) - RETURN_ERROR(EDSCBADRSP) - /* bad response */ - else - result = camera->pl->buf[DSC1_BUF_CMD]; + if (s != 17 || memcmp(camera->pl->buf, r_prefix, 12) != 0 ) + RETURN_ERROR(EDSCBADRSP) + /* bad response */ + else + result = camera->pl->buf[DSC1_BUF_CMD]; - camera->pl->size = - (uint32_t)camera->pl->buf[DSC1_BUF_SIZE + 3] | - ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE + 2] << 8) | - ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE + 1] << 16) | - ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE] << 24); + camera->pl->size = + (uint32_t)camera->pl->buf[DSC1_BUF_SIZE + 3] | + ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE + 2] << 8) | + ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE + 1] << 16) | + ((uint8_t)camera->pl->buf[DSC1_BUF_SIZE] << 24); - if (DSC_BUFSIZE < camera->pl->size) { - RETURN_ERROR(EDSCOVERFL); - /* overflow */ - } + if (DSC_BUFSIZE < camera->pl->size) { + RETURN_ERROR(EDSCOVERFL); + /* overflow */ + } - if (gp_port_read(camera->port, camera->pl->buf, camera->pl->size) != camera->pl->size) - return GP_ERROR; + if (gp_port_read(camera->port, camera->pl->buf, camera->pl->size) != camera->pl->size) + return GP_ERROR; - DEBUG_PRINT_MEDIUM(("Retrieved command: %i.", result)); + DEBUG_PRINT_MEDIUM(("Retrieved command: %i.", result)); - return result; + return result; } int dsc1_setbaudrate(Camera *camera, int speed) { GPPortSettings settings; - uint8_t s_bps; - int result; + uint8_t s_bps; + int result; - DEBUG_PRINT_MEDIUM(("Setting baud rate to: %i.", speed)); + DEBUG_PRINT_MEDIUM(("Setting baud rate to: %i.", speed)); - switch (speed) { + switch (speed) { - case 9600: - s_bps = 0x02; - break; + case 9600: + s_bps = 0x02; + break; - case 19200: - s_bps = 0x0d; - break; + case 19200: + s_bps = 0x0d; + break; - case 38400: - s_bps = 0x01; - break; + case 38400: + s_bps = 0x01; + break; - case 57600: - s_bps = 0x03; - break; + case 57600: + s_bps = 0x03; + break; - case 115200: - s_bps = 0x00; - break; + case 115200: + s_bps = 0x00; + break; - default: - RETURN_ERROR(EDSCBPSRNG); - } + default: + RETURN_ERROR(EDSCBPSRNG); + } - if (dsc1_sendcmd(camera, DSC1_CMD_SET_BAUD, &s_bps, 1) != GP_OK) - return GP_ERROR; + if (dsc1_sendcmd(camera, DSC1_CMD_SET_BAUD, &s_bps, 1) != GP_OK) + return GP_ERROR; - if (dsc1_retrcmd(camera) != DSC1_RSP_OK) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc1_retrcmd(camera) != DSC1_RSP_OK) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - sleep(DSC_PAUSE/2); + sleep(DSC_PAUSE/2); CHECK (gp_port_get_settings(camera->port, &settings)); settings.serial.speed = speed; - CHECK (gp_port_set_settings(camera->port, settings)); + CHECK (gp_port_set_settings(camera->port, settings)); - DEBUG_PRINT_MEDIUM(("Baudrate set to: %i.", speed)); + DEBUG_PRINT_MEDIUM(("Baudrate set to: %i.", speed)); - return GP_OK; + return GP_OK; } int dsc1_getmodel(Camera *camera) { - static const char response[3] = { 'D', 'S', 'C' }; + static const char response[3] = { 'D', 'S', 'C' }; - DEBUG_PRINT_MEDIUM(("Getting camera model.")); + DEBUG_PRINT_MEDIUM(("Getting camera model.")); - if (dsc1_sendcmd(camera, DSC1_CMD_GET_MODEL, NULL, 0) != GP_OK) - return GP_ERROR; + if (dsc1_sendcmd(camera, DSC1_CMD_GET_MODEL, NULL, 0) != GP_OK) + return GP_ERROR; - if (dsc1_retrcmd(camera) != DSC1_RSP_MODEL || - memcmp(camera->pl->buf, response, 3) != 0) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc1_retrcmd(camera) != DSC1_RSP_MODEL || + memcmp(camera->pl->buf, response, 3) != 0) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - DEBUG_PRINT_MEDIUM(("Camera model is: %c.", camera->pl->buf[3])); + DEBUG_PRINT_MEDIUM(("Camera model is: %c.", camera->pl->buf[3])); - switch (camera->pl->buf[3]) { - case '1': - return DSC1; + switch (camera->pl->buf[3]) { + case '1': + return DSC1; - case '2': - return DSC2; + case '2': + return DSC2; - default: - return 0; - } - return GP_ERROR; + default: + return 0; + } + return GP_ERROR; } void dsc_dumpmem(void *buf, int size) { - int i; - - fprintf(stderr, "\nMemory dump: size: %i, contents:\n", size); - for (i = 0; i < size; i ++) - fprintf( - stderr, - *((char*)buf + i) >= 32 && - *((char*)buf + i) < 127 ? "%c" : "\\x%02x", - (uint8_t)*((char*)buf + i) - ); - fprintf(stderr, "\n\n"); + int i; + + fprintf(stderr, "\nMemory dump: size: %i, contents:\n", size); + for (i = 0; i < size; i++) + fprintf( + stderr, + *((char*)buf + i) >= 32 && + *((char*)buf + i) < 127 ? "%c" : "\\x%02x", + (uint8_t)*((char*)buf + i) + ); + fprintf(stderr, "\n\n"); } const char *dsc_strerror(int error) { - static const char * const errorlist[] = { - "Unknown error code", - "Baud rate out of range", - "Bad image number", - "Bad response", - "Bad camera model", - "Overflow" - }; + static const char * const errorlist[] = { + "Unknown error code", + "Baud rate out of range", + "Bad image number", + "Bad response", + "Bad camera model", + "Overflow" + }; - if (error == EDSCSERRNO) - return strerror(errno); + if (error == EDSCSERRNO) + return strerror(errno); - if (error < 1 || EDSCMAXERR < error) - return errorlist[EDSCUNKNWN]; + if (error < 1 || EDSCMAXERR < error) + return errorlist[EDSCUNKNWN]; - return errorlist[error]; + return errorlist[error]; } char *dsc_msgprintf(char *format, ...) { - va_list pvar; - static char msg[512]; + va_list pvar; + static char msg[512]; - va_start(pvar, format); - vsprintf(msg, format, pvar); - va_end(pvar); - return msg; + va_start(pvar, format); + vsprintf(msg, format, pvar); + va_end(pvar); + return msg; } void dsc_errorprint(int error, char *file, int line) { diff --git a/camlibs/panasonic/dc.h b/camlibs/panasonic/dc.h index 7937e9d7a8..23195bbf6a 100644 --- a/camlibs/panasonic/dc.h +++ b/camlibs/panasonic/dc.h @@ -95,24 +95,24 @@ void dsc_errorprint(int error, char *file, int line); /* Pre-procesor macros for verbose messaging and debugging */ #define DEBUG_PRINT_LOW(ARGS) \ - GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); + GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); #define DEBUG_PRINT_MEDIUM(ARGS) \ - GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); + GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); #define DEBUG_PRINT_HIGH(ARGS) \ - GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); + GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); #define RETURN_ERROR(ERROR) { \ - dsc_errorprint(ERROR, __FILE__, __LINE__); \ - return GP_ERROR; \ - } + dsc_errorprint(ERROR, __FILE__, __LINE__); \ + return GP_ERROR; \ + } #define CHECK(OPERATION) \ - if ((result = OPERATION) < 0) { \ - dsc_errorprint(EDSCSERRNO, __FILE__, __LINE__); \ - return result; \ - } + if ((result = OPERATION) < 0) { \ + dsc_errorprint(EDSCSERRNO, __FILE__, __LINE__); \ + return result; \ + } /* End of dc.h */ diff --git a/camlibs/panasonic/dc1000.c b/camlibs/panasonic/dc1000.c index 0e2daa92dd..0c34c871a7 100644 --- a/camlibs/panasonic/dc1000.c +++ b/camlibs/panasonic/dc1000.c @@ -138,7 +138,7 @@ static int dsc1_delete(Camera *camera, uint8_t index) { static int dsc1_selectimage(Camera *camera, uint8_t index) { - int size = 0; + int size = 0; DEBUG_PRINT_MEDIUM(("Selecting image: %i.", index)); @@ -332,7 +332,7 @@ int camera_id (CameraText *id) { int camera_abilities (CameraAbilitiesList *list) { CameraAbilities a; - int result; + int result; memset (&a, 0, sizeof(a)); strcpy(a.model, "Panasonic:DC1000"); @@ -486,7 +486,7 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder, /* index is the 0-based image number on the camera */ CHECK (index = gp_filesystem_number (camera->fs, folder, filename, context)); - index++; + index++; return dsc1_delete(camera, index); } @@ -511,12 +511,12 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - int ret, selected_speed; + int ret, selected_speed; GPPortSettings settings; - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->about = camera_about; camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) @@ -529,14 +529,14 @@ int camera_init (Camera *camera, GPContext *context) { } /* Configure the port (remember the selected speed) */ - gp_port_set_timeout(camera->port, 5000); + gp_port_set_timeout(camera->port, 5000); gp_port_get_settings(camera->port, &settings); selected_speed = settings.serial.speed; - settings.serial.speed = 9600; /* hand shake speed */ - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits = 1; - gp_port_set_settings(camera->port, settings); + settings.serial.speed = 9600; /* hand shake speed */ + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits = 1; + gp_port_set_settings(camera->port, settings); /* Set up the filesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); diff --git a/camlibs/panasonic/dc1580.c b/camlibs/panasonic/dc1580.c index 5cf3493c9c..797e4c90c6 100644 --- a/camlibs/panasonic/dc1580.c +++ b/camlibs/panasonic/dc1580.c @@ -50,221 +50,221 @@ static uint8_t dsc2_checksum(char *buffer, int size) { - int checksum = 0; - int i; + int checksum = 0; + int i; - for (i = 1; i < size - 2; i++) { - checksum += buffer[i]; - checksum %= 0x100; - } + for (i = 1; i < size - 2; i++) { + checksum += buffer[i]; + checksum %= 0x100; + } - return checksum; + return checksum; } /* dsc2_sendcmd - send command with data to DSC */ static int dsc2_sendcmd(Camera *camera, uint8_t cmd, long int data, uint8_t sequence) { - unsigned int i; + unsigned int i; - DEBUG_PRINT_MEDIUM(("Sending command: 0x%02x, data: %i, sequence: %i.", cmd, data, sequence)); + DEBUG_PRINT_MEDIUM(("Sending command: 0x%02x, data: %i, sequence: %i.", cmd, data, sequence)); - memset(camera->pl->buf, 0, 16); + memset(camera->pl->buf, 0, 16); - camera->pl->buf[0] = 0x08; - camera->pl->buf[1] = sequence; - camera->pl->buf[2] = 0xff - sequence; - camera->pl->buf[3] = cmd; + camera->pl->buf[0] = 0x08; + camera->pl->buf[1] = sequence; + camera->pl->buf[2] = 0xff - sequence; + camera->pl->buf[3] = cmd; - for (i = 0; i < sizeof(data); i++) - camera->pl->buf[4 + i] = (uint8_t)(data >> 8*i); + for (i = 0; i < sizeof(data); i++) + camera->pl->buf[4 + i] = (uint8_t)(data >> 8*i); - camera->pl->buf[14] = dsc2_checksum(camera->pl->buf, 16); + camera->pl->buf[14] = dsc2_checksum(camera->pl->buf, 16); - return gp_port_write(camera->port, camera->pl->buf, 16); + return gp_port_write(camera->port, camera->pl->buf, 16); } /* dsc2_retrcmd - retrieve command and its data from DSC */ static int dsc2_retrcmd(Camera *camera) { - int result = GP_ERROR; - int s; + int result = GP_ERROR; + int s; - if ((s = gp_port_read(camera->port, camera->pl->buf, 16)) == GP_ERROR) - return GP_ERROR; + if ((s = gp_port_read(camera->port, camera->pl->buf, 16)) == GP_ERROR) + return GP_ERROR; /* Make sense in debug only. Done on gp_port level. - if (0 < s) - dsc_dumpmem(camera->pl->buf, s); + if (0 < s) + dsc_dumpmem(camera->pl->buf, s); */ - if (s != 16 || camera->pl->buf[DSC2_BUF_BASE] != 0x08 || - camera->pl->buf[DSC2_BUF_SEQ] != 0xff - (uint8_t)camera->pl->buf[DSC2_BUF_SEQC]) { - RETURN_ERROR(EDSCBADRSP); - /* bad response */ - } - else - result = camera->pl->buf[DSC2_BUF_CMD]; + if (s != 16 || camera->pl->buf[DSC2_BUF_BASE] != 0x08 || + camera->pl->buf[DSC2_BUF_SEQ] != 0xff - (uint8_t)camera->pl->buf[DSC2_BUF_SEQC]) { + RETURN_ERROR(EDSCBADRSP); + /* bad response */ + } + else + result = camera->pl->buf[DSC2_BUF_CMD]; - DEBUG_PRINT_MEDIUM(("Retrieved command: %i.", result)); + DEBUG_PRINT_MEDIUM(("Retrieved command: %i.", result)); - return result; + return result; } /* dsc2_connect - try hand shake with camera and establish connection */ static int dsc2_connect(Camera *camera, int speed) { - DEBUG_PRINT_MEDIUM(("Connecting camera with speed: %i.", speed)); + DEBUG_PRINT_MEDIUM(("Connecting camera with speed: %i.", speed)); - if (dsc1_setbaudrate(camera, speed) != GP_OK) - return GP_ERROR; + if (dsc1_setbaudrate(camera, speed) != GP_OK) + return GP_ERROR; - if (dsc1_getmodel(camera) != DSC2) - RETURN_ERROR(EDSCBADDSC); - /* bad camera model */ + if (dsc1_getmodel(camera) != DSC2) + RETURN_ERROR(EDSCBADDSC); + /* bad camera model */ - if (dsc2_sendcmd(camera, DSC2_CMD_CONNECT, 0, 0) != GP_OK) - return GP_ERROR; + if (dsc2_sendcmd(camera, DSC2_CMD_CONNECT, 0, 0) != GP_OK) + return GP_ERROR; - if (dsc2_retrcmd(camera) != DSC2_RSP_OK) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc2_retrcmd(camera) != DSC2_RSP_OK) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - DEBUG_PRINT_MEDIUM(("Camera connected successfully.")); + DEBUG_PRINT_MEDIUM(("Camera connected successfully.")); - return GP_OK; + return GP_OK; } /* dsc2_disconnect - reset camera, free buffers and close files */ static int dsc2_disconnect(Camera *camera) { - DEBUG_PRINT_MEDIUM(("Disconnecting the camera.")); + DEBUG_PRINT_MEDIUM(("Disconnecting the camera.")); - if (dsc2_sendcmd(camera, DSC2_CMD_RESET, 0, 0) != GP_OK) - return GP_ERROR; + if (dsc2_sendcmd(camera, DSC2_CMD_RESET, 0, 0) != GP_OK) + return GP_ERROR; - if (dsc2_retrcmd(camera) != DSC2_RSP_OK) - RETURN_ERROR(EDSCBADRSP) - /* bad response */ - else - sleep(DSC_PAUSE); /* let camera to redraw its screen */ + if (dsc2_retrcmd(camera) != DSC2_RSP_OK) + RETURN_ERROR(EDSCBADRSP) + /* bad response */ + else + sleep(DSC_PAUSE); /* let camera to redraw its screen */ - DEBUG_PRINT_MEDIUM(("Camera disconnected.")); + DEBUG_PRINT_MEDIUM(("Camera disconnected.")); - return GP_OK; + return GP_OK; } /* dsc2_getindex - retrieve the number of images stored in camera memory */ static int dsc2_getindex(Camera *camera) { - int result = GP_ERROR; + int result = GP_ERROR; - DEBUG_PRINT_MEDIUM(("Retrieving the number of images.")); + DEBUG_PRINT_MEDIUM(("Retrieving the number of images.")); - if (dsc2_sendcmd(camera, DSC2_CMD_GET_INDEX, 0, 0) != GP_OK) - return GP_ERROR; + if (dsc2_sendcmd(camera, DSC2_CMD_GET_INDEX, 0, 0) != GP_OK) + return GP_ERROR; - if (dsc2_retrcmd(camera) == DSC2_RSP_INDEX) - result = - ((uint32_t)camera->pl->buf[DSC2_BUF_DATA]) | - ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 1] << 8) | - ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 2] << 16) | - ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 3] << 24); - else - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc2_retrcmd(camera) == DSC2_RSP_INDEX) + result = + ((uint32_t)camera->pl->buf[DSC2_BUF_DATA]) | + ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 1] << 8) | + ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 2] << 16) | + ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 3] << 24); + else + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - DEBUG_PRINT_MEDIUM(("Number of images: %i", result)); + DEBUG_PRINT_MEDIUM(("Number of images: %i", result)); - return result; + return result; } /* dsc2_delete - delete image #index from camera memory */ static int dsc2_delete(Camera *camera, int index) { - DEBUG_PRINT_MEDIUM(("Deleting image: %i.", index)); + DEBUG_PRINT_MEDIUM(("Deleting image: %i.", index)); - if (index < 1) - RETURN_ERROR(EDSCBADNUM); - /* bad image number */ + if (index < 1) + RETURN_ERROR(EDSCBADNUM); + /* bad image number */ - if (dsc2_sendcmd(camera, DSC2_CMD_DELETE, index, 0) != GP_OK) - return GP_ERROR; + if (dsc2_sendcmd(camera, DSC2_CMD_DELETE, index, 0) != GP_OK) + return GP_ERROR; - if (dsc2_retrcmd(camera) != DSC2_RSP_OK) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc2_retrcmd(camera) != DSC2_RSP_OK) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - DEBUG_PRINT_MEDIUM(("Image: %i deleted.", index)); - return GP_OK; + DEBUG_PRINT_MEDIUM(("Image: %i deleted.", index)); + return GP_OK; } /* dsc2_selectimage - select image to download, return its size */ static int dsc2_selectimage(Camera *camera, int index, int thumbnail) { - int size = 0; + int size = 0; - DEBUG_PRINT_MEDIUM(("Selecting image: %i, thumbnail: %i.", index, thumbnail)); + DEBUG_PRINT_MEDIUM(("Selecting image: %i, thumbnail: %i.", index, thumbnail)); - if (index < 1) - RETURN_ERROR(EDSCBADNUM); - /* bad image number */ + if (index < 1) + RETURN_ERROR(EDSCBADNUM); + /* bad image number */ - if (thumbnail == DSC_THUMBNAIL) { - if (dsc2_sendcmd(camera, DSC2_CMD_THUMB, index, 0) != GP_OK) - return GP_ERROR; - } else { - if (dsc2_sendcmd(camera, DSC2_CMD_SELECT, index, 0) != GP_OK) - return GP_ERROR; - } + if (thumbnail == DSC_THUMBNAIL) { + if (dsc2_sendcmd(camera, DSC2_CMD_THUMB, index, 0) != GP_OK) + return GP_ERROR; + } else { + if (dsc2_sendcmd(camera, DSC2_CMD_SELECT, index, 0) != GP_OK) + return GP_ERROR; + } - if (dsc2_retrcmd(camera) != DSC2_RSP_IMGSIZE) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc2_retrcmd(camera) != DSC2_RSP_IMGSIZE) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - size = ((uint32_t)camera->pl->buf[DSC2_BUF_DATA]) | - ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 1] << 8) | - ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 2] << 16) | - ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 3] << 24); + size = ((uint32_t)camera->pl->buf[DSC2_BUF_DATA]) | + ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 1] << 8) | + ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 2] << 16) | + ((uint8_t)camera->pl->buf[DSC2_BUF_DATA + 3] << 24); - DEBUG_PRINT_MEDIUM(("Selected image: %i, thumbnail: %i, size: %i.", index, thumbnail, size)); + DEBUG_PRINT_MEDIUM(("Selected image: %i, thumbnail: %i, size: %i.", index, thumbnail, size)); - return size; + return size; } /* gp_port_readimageblock - read #block block (1024 bytes) of an image into buf */ static int dsc2_readimageblock(Camera *camera, int block, char *buffer) { - DEBUG_PRINT_MEDIUM(("Reading image block: %i.", block)); + DEBUG_PRINT_MEDIUM(("Reading image block: %i.", block)); - if (dsc2_sendcmd(camera, DSC2_CMD_GET_DATA, block, block) != GP_OK) - return GP_ERROR; + if (dsc2_sendcmd(camera, DSC2_CMD_GET_DATA, block, block) != GP_OK) + return GP_ERROR; - if (gp_port_read(camera->port, camera->pl->buf, DSC_BUFSIZE) != DSC_BUFSIZE) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (gp_port_read(camera->port, camera->pl->buf, DSC_BUFSIZE) != DSC_BUFSIZE) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - if ((uint8_t)camera->pl->buf[0] != 1 || - (uint8_t)camera->pl->buf[1] != block || - (uint8_t)camera->pl->buf[2] != 0xff - block || - (uint8_t)camera->pl->buf[3] != DSC2_RSP_DATA || - (uint8_t)camera->pl->buf[DSC_BUFSIZE - 2] != dsc2_checksum(camera->pl->buf, DSC_BUFSIZE)) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if ((uint8_t)camera->pl->buf[0] != 1 || + (uint8_t)camera->pl->buf[1] != block || + (uint8_t)camera->pl->buf[2] != 0xff - block || + (uint8_t)camera->pl->buf[3] != DSC2_RSP_DATA || + (uint8_t)camera->pl->buf[DSC_BUFSIZE - 2] != dsc2_checksum(camera->pl->buf, DSC_BUFSIZE)) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - if (buffer) - memcpy(buffer, &camera->pl->buf[4], DSC_BLOCKSIZE); + if (buffer) + memcpy(buffer, &camera->pl->buf[4], DSC_BLOCKSIZE); - DEBUG_PRINT_MEDIUM(("Block: %i read in.", block)); + DEBUG_PRINT_MEDIUM(("Block: %i read in.", block)); - return DSC_BLOCKSIZE; + return DSC_BLOCKSIZE; } /* dsc2_readimage - read #index image or thumbnail and return its contents */ @@ -272,38 +272,38 @@ static int dsc2_readimageblock(Camera *camera, int block, char *buffer) { #if 0 static char *dsc2_readimage(Camera *camera, int index, int thumbnail, int *size) { - char kind[16]; - int blocks, i; - char *buffer = NULL; + char kind[16]; + int blocks, i; + char *buffer = NULL; - DEBUG_PRINT_MEDIUM(("Reading image: %i, thumbnail: %i.", index, thumbnail)); + DEBUG_PRINT_MEDIUM(("Reading image: %i, thumbnail: %i.", index, thumbnail)); - if ((*size = dsc2_selectimage(camera, index, thumbnail)) < 0) - return NULL; + if ((*size = dsc2_selectimage(camera, index, thumbnail)) < 0) + return NULL; - if (thumbnail == DSC_THUMBNAIL) - strcpy(kind, "thumbnail"); - else - strcpy(kind, "image"); + if (thumbnail == DSC_THUMBNAIL) + strcpy(kind, "thumbnail"); + else + strcpy(kind, "image"); - if (!(buffer = (char*)malloc(*size))) { - DEBUG_PRINT_MEDIUM(("Failed to allocate memory for %s data.", kind)); - return NULL; - } + if (!(buffer = (char*)malloc(*size))) { + DEBUG_PRINT_MEDIUM(("Failed to allocate memory for %s data.", kind)); + return NULL; + } - blocks = (*size - 1)/DSC_BLOCKSIZE + 1; + blocks = (*size - 1)/DSC_BLOCKSIZE + 1; - for (i = 0; i < blocks; i++) { - if (dsc2_readimageblock(camera, i, &buffer[i*DSC_BLOCKSIZE]) == GP_ERROR) { - DEBUG_PRINT_MEDIUM(("Error during %s transfer.", kind)); - free(buffer); - return NULL; - } - } + for (i = 0; i < blocks; i++) { + if (dsc2_readimageblock(camera, i, &buffer[i*DSC_BLOCKSIZE]) == GP_ERROR) { + DEBUG_PRINT_MEDIUM(("Error during %s transfer.", kind)); + free(buffer); + return NULL; + } + } - DEBUG_PRINT_MEDIUM(("Image: %i read in.", index)); + DEBUG_PRINT_MEDIUM(("Image: %i read in.", index)); - return buffer; + return buffer; } #endif @@ -311,50 +311,50 @@ static char *dsc2_readimage(Camera *camera, int index, int thumbnail, int *size) static int dsc2_setimagesize(Camera *camera, int size) { - DEBUG_PRINT_MEDIUM(("Setting image size to: %i.", size)); + DEBUG_PRINT_MEDIUM(("Setting image size to: %i.", size)); - if (dsc2_sendcmd(camera, DSC2_CMD_SET_SIZE, size, 0) != GP_OK) - return GP_ERROR; + if (dsc2_sendcmd(camera, DSC2_CMD_SET_SIZE, size, 0) != GP_OK) + return GP_ERROR; - if (dsc2_retrcmd(camera) != DSC2_RSP_OK) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc2_retrcmd(camera) != DSC2_RSP_OK) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - DEBUG_PRINT_MEDIUM(("Image size set to: %i.", size)); + DEBUG_PRINT_MEDIUM(("Image size set to: %i.", size)); - return GP_OK; + return GP_OK; } /* gp_port_writeimageblock - write size bytes from buffer rounded to 1024 bytes to camera */ static int dsc2_writeimageblock(Camera *camera, int block, char *buffer, int size) { - DEBUG_PRINT_MEDIUM(("Writing image block: %i.", block)); + DEBUG_PRINT_MEDIUM(("Writing image block: %i.", block)); - memset(camera->pl->buf, 0, DSC_BUFSIZE); + memset(camera->pl->buf, 0, DSC_BUFSIZE); - camera->pl->buf[0] = 0x01; - camera->pl->buf[1] = block; - camera->pl->buf[2] = 0xff - block; - camera->pl->buf[3] = DSC2_CMD_SEND_DATA; + camera->pl->buf[0] = 0x01; + camera->pl->buf[1] = block; + camera->pl->buf[2] = 0xff - block; + camera->pl->buf[3] = DSC2_CMD_SEND_DATA; - if (DSC_BLOCKSIZE < size) - size = DSC_BLOCKSIZE; + if (DSC_BLOCKSIZE < size) + size = DSC_BLOCKSIZE; - memcpy(&camera->pl->buf[4], buffer, size); + memcpy(&camera->pl->buf[4], buffer, size); - camera->pl->buf[DSC_BUFSIZE - 2] = dsc2_checksum(camera->pl->buf, DSC_BUFSIZE); + camera->pl->buf[DSC_BUFSIZE - 2] = dsc2_checksum(camera->pl->buf, DSC_BUFSIZE); - if (gp_port_write(camera->port, camera->pl->buf, DSC_BUFSIZE) != GP_OK) - return GP_ERROR; + if (gp_port_write(camera->port, camera->pl->buf, DSC_BUFSIZE) != GP_OK) + return GP_ERROR; - if (dsc2_retrcmd(camera) != DSC2_RSP_OK) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc2_retrcmd(camera) != DSC2_RSP_OK) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - DEBUG_PRINT_MEDIUM(("Block: %i of size: %i written.", block, size)); + DEBUG_PRINT_MEDIUM(("Block: %i of size: %i written.", block, size)); - return GP_OK; + return GP_OK; } /* dsc2_writeimage - write an image to camera memory, size bytes at buffer */ @@ -362,28 +362,28 @@ static int dsc2_writeimageblock(Camera *camera, int block, char *buffer, int siz #if 0 static int dsc2_writeimage(Camera *camera, char *buffer, int size) { - int blocks, blocksize, i; + int blocks, blocksize, i; - DEBUG_PRINT_MEDIUM(("Writing an image of size: %i.", size)); + DEBUG_PRINT_MEDIUM(("Writing an image of size: %i.", size)); - if ((dsc2_setimagesize(camera, size)) != GP_OK) - return GP_ERROR; + if ((dsc2_setimagesize(camera, size)) != GP_OK) + return GP_ERROR; - blocks = (size - 1)/DSC_BLOCKSIZE + 1; + blocks = (size - 1)/DSC_BLOCKSIZE + 1; - for (i = 0; i < blocks; i++) { - blocksize = size - i*DSC_BLOCKSIZE; - if (DSC_BLOCKSIZE < blocksize) - blocksize = DSC_BLOCKSIZE; - if (dsc2_writeimageblock(camera, i, &buffer[i*DSC_BLOCKSIZE], blocksize) != GP_OK) { - DEBUG_PRINT_MEDIUM(("Error during image transfer.")); - return GP_ERROR; - } - } + for (i = 0; i < blocks; i++) { + blocksize = size - i*DSC_BLOCKSIZE; + if (DSC_BLOCKSIZE < blocksize) + blocksize = DSC_BLOCKSIZE; + if (dsc2_writeimageblock(camera, i, &buffer[i*DSC_BLOCKSIZE], blocksize) != GP_OK) { + DEBUG_PRINT_MEDIUM(("Error during image transfer.")); + return GP_ERROR; + } + } - DEBUG_PRINT_MEDIUM(("Image written successfully.")); + DEBUG_PRINT_MEDIUM(("Image written successfully.")); - return GP_OK; + return GP_OK; } #endif @@ -392,18 +392,18 @@ static int dsc2_writeimage(Camera *camera, char *buffer, int size) { #if 0 static int dsc2_preview(Camera *camera, int index) { - if (index < 1) - RETURN_ERROR(EDSCBADNUM); - /* bad image number */ + if (index < 1) + RETURN_ERROR(EDSCBADNUM); + /* bad image number */ - if (dsc2_sendcmd(camera, DSC2_CMD_PREVIEW, index, 0) != GP_OK) - return GP_ERROR; + if (dsc2_sendcmd(camera, DSC2_CMD_PREVIEW, index, 0) != GP_OK) + return GP_ERROR; - if (dsc2_retrcmd(camera) != DSC2_RSP_OK) - RETURN_ERROR(EDSCBADRSP); - /* bad response */ + if (dsc2_retrcmd(camera) != DSC2_RSP_OK) + RETURN_ERROR(EDSCBADRSP); + /* bad response */ - return GP_OK; + return GP_OK; } #endif @@ -413,86 +413,86 @@ static int dsc2_preview(Camera *camera, int index) { int camera_id (CameraText *id) { - strcpy(id->text, "panasonic-dc1580"); + strcpy(id->text, "panasonic-dc1580"); - return (GP_OK); + return (GP_OK); } int camera_abilities (CameraAbilitiesList *list) { - CameraAbilities a; - char *models[] = { - "Panasonic:DC1580", - "Nikon:CoolPix 600", - NULL }; - int i = 0, result; + CameraAbilities a; + char *models[] = { + "Panasonic:DC1580", + "Nikon:CoolPix 600", + NULL }; + int i = 0, result; - while (models[i]) { + while (models[i]) { memset(&a, 0, sizeof(a)); a.status = GP_DRIVER_STATUS_PRODUCTION; - strcpy(a.model, models[i]); - a.port = GP_PORT_SERIAL; - a.speed[0] = 9600; - a.speed[1] = 19200; - a.speed[2] = 38400; - a.speed[3] = 57600; - a.speed[4] = 115200; - a.speed[5] = 0; - a.operations = GP_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_DELETE | + strcpy(a.model, models[i]); + a.port = GP_PORT_SERIAL; + a.speed[0] = 9600; + a.speed[1] = 19200; + a.speed[2] = 38400; + a.speed[3] = 57600; + a.speed[4] = 115200; + a.speed[5] = 0; + a.operations = GP_OPERATION_NONE; + a.file_operations = GP_FILE_OPERATION_DELETE | GP_FILE_OPERATION_PREVIEW; - a.folder_operations = GP_FOLDER_OPERATION_PUT_FILE; + a.folder_operations = GP_FOLDER_OPERATION_PUT_FILE; - CHECK (gp_abilities_list_append(list, a)); - i++; - } + CHECK (gp_abilities_list_append(list, a)); + i++; + } - return GP_OK; + return GP_OK; } static int camera_exit (Camera *camera, GPContext *context) { - gp_context_status(context, _("Disconnecting camera.")); - dsc2_disconnect(camera); - free (camera->pl->buf); - camera->pl->buf = NULL; + gp_context_status(context, _("Disconnecting camera.")); + dsc2_disconnect(camera); + free (camera->pl->buf); + camera->pl->buf = NULL; free (camera->pl); camera->pl = NULL; - return (GP_OK); + return (GP_OK); } static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { - Camera *camera = data; - int count, result; + Camera *camera = data; + int count, result; CHECK (count = dsc2_getindex(camera)); - CHECK (gp_list_populate(list, DSC_FILENAMEFMT, count)); + CHECK (gp_list_populate(list, DSC_FILENAMEFMT, count)); - return GP_OK; + return GP_OK; } static int get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo *info, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; int index, result; - /* index is the 0-based image number on the camera */ - CHECK (index = gp_filesystem_number(camera->fs, folder, filename, context)); - index++; + /* index is the 0-based image number on the camera */ + CHECK (index = gp_filesystem_number(camera->fs, folder, filename, context)); + index++; info->file.fields = GP_FILE_INFO_TYPE | GP_FILE_INFO_SIZE; strcpy(info->file.type, GP_MIME_JPEG); - info->file.size = dsc2_selectimage(camera, index, DSC_FULLIMAGE); + info->file.size = dsc2_selectimage(camera, index, DSC_FULLIMAGE); info->preview.fields = GP_FILE_INFO_TYPE | GP_FILE_INFO_SIZE; strcpy(info->preview.type, GP_MIME_JPEG); - info->preview.size = dsc2_selectimage(camera, index, DSC_THUMBNAIL); + info->preview.size = dsc2_selectimage(camera, index, DSC_THUMBNAIL); - return GP_OK; + return GP_OK; } static int get_file_func (CameraFilesystem *fs, const char *folder, @@ -500,14 +500,14 @@ static int get_file_func (CameraFilesystem *fs, const char *folder, CameraFile *file, void *data, GPContext *context) { Camera *camera = data; - int index, i, size, blocks, result; + int index, i, size, blocks, result; unsigned int id; - gp_context_status(context, _("Downloading %s."), filename); + gp_context_status(context, _("Downloading %s."), filename); - /* index is the 0-based image number on the camera */ - CHECK (index = gp_filesystem_number(camera->fs, folder, filename, context)); - index++; + /* index is the 0-based image number on the camera */ + CHECK (index = gp_filesystem_number(camera->fs, folder, filename, context)); + index++; switch (type) { case GP_FILE_TYPE_PREVIEW: @@ -524,19 +524,19 @@ static int get_file_func (CameraFilesystem *fs, const char *folder, CHECK (gp_file_set_mime_type(file, GP_MIME_JPEG)); - blocks = (size - 1)/DSC_BLOCKSIZE + 1; + blocks = (size - 1)/DSC_BLOCKSIZE + 1; id = gp_context_progress_start (context, blocks, _("Getting data...")); - for (i = 0; i < blocks; i++) { + for (i = 0; i < blocks; i++) { CHECK (dsc2_readimageblock(camera, i, NULL)); - CHECK (gp_file_append(file, &camera->pl->buf[4], DSC_BLOCKSIZE)); + CHECK (gp_file_append(file, &camera->pl->buf[4], DSC_BLOCKSIZE)); gp_context_progress_update (context, id, i + 1); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) return (GP_ERROR_CANCEL); - } + } gp_context_progress_stop (context, id); - return GP_OK; + return GP_OK; } static int put_file_func (CameraFilesystem *fs, const char *folder, const char *name, @@ -544,38 +544,38 @@ static int put_file_func (CameraFilesystem *fs, const char *folder, const char * GPContext *context) { Camera *camera = user_data; - int blocks, blocksize, i, result; + int blocks, blocksize, i, result; const char *data; long unsigned int size; unsigned int id; - gp_context_status(context, _("Uploading image: %s."), name); + gp_context_status(context, _("Uploading image: %s."), name); /* We can not figure out file type, at least by now. (? curious, mime type -Marcus) - if (strcmp(file->type, "image/jpg") != 0) { - dsc_print_message(camera, "JPEG image format allowed only."); - return GP_ERROR; - } + if (strcmp(file->type, "image/jpg") != 0) { + dsc_print_message(camera, "JPEG image format allowed only."); + return GP_ERROR; + } */ gp_file_get_data_and_size (file, &data, &size); - if (size > DSC_MAXIMAGESIZE) { - gp_context_message (context, _("File size is %ld bytes. " + if (size > DSC_MAXIMAGESIZE) { + gp_context_message (context, _("File size is %ld bytes. " "The size of the largest file possible to " "upload is: %i bytes."), size, DSC_MAXIMAGESIZE); - return GP_ERROR; - } + return GP_ERROR; + } if ((result = dsc2_setimagesize(camera, size)) != GP_OK) return result; - blocks = (size - 1)/DSC_BLOCKSIZE + 1; + blocks = (size - 1)/DSC_BLOCKSIZE + 1; id = gp_context_progress_start (context, blocks, _("Uploading...")); - for (i = 0; i < blocks; i++) { - blocksize = size - i*DSC_BLOCKSIZE; - if (DSC_BLOCKSIZE < blocksize) - blocksize = DSC_BLOCKSIZE; + for (i = 0; i < blocks; i++) { + blocksize = size - i*DSC_BLOCKSIZE; + if (DSC_BLOCKSIZE < blocksize) + blocksize = DSC_BLOCKSIZE; result = dsc2_writeimageblock(camera, i, (char*)&data[i*DSC_BLOCKSIZE], blocksize); @@ -584,10 +584,10 @@ static int put_file_func (CameraFilesystem *fs, const char *folder, const char * gp_context_progress_update (context, id, i + 1); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) return (GP_ERROR_CANCEL); - } + } gp_context_progress_stop (context, id); - return GP_OK; + return GP_OK; } static int delete_file_func (CameraFilesystem *fs, const char *folder, @@ -595,26 +595,26 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder, GPContext *context) { Camera *camera = data; - int index, result; + int index, result; - gp_context_status(context, _("Deleting image %s."), filename); + gp_context_status(context, _("Deleting image %s."), filename); - /* index is the 0-based image number on the camera */ + /* index is the 0-based image number on the camera */ CHECK (index = gp_filesystem_number (camera->fs, folder, filename, context)); - index++; + index++; - return dsc2_delete(camera, index); + return dsc2_delete(camera, index); } static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy(about->text, - _("Panasonic DC1580 gPhoto2 library\n" - "Mariusz Zynel \n\n" - "Based on dc1000 program written by\n" - "Fredrik Roubert and\n" - "Galen Brooks .")); - return (GP_OK); + strcpy(about->text, + _("Panasonic DC1580 gPhoto2 library\n" + "Mariusz Zynel \n\n" + "Based on dc1000 program written by\n" + "Fredrik Roubert and\n" + "Galen Brooks .")); + return (GP_OK); } static CameraFilesystemFuncs fsfuncs = { @@ -627,12 +627,12 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - GPPortSettings settings; - int result, selected_speed; + GPPortSettings settings; + int result, selected_speed; - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->about = camera_about; camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) @@ -649,15 +649,15 @@ int camera_init (Camera *camera, GPContext *context) /* Configure the port (and remember the speed) */ CHECK (gp_port_get_settings (camera->port, &settings)); selected_speed = settings.serial.speed; - settings.serial.speed = 9600; /* hand shake speed */ - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits = 1; - CHECK (gp_port_set_settings (camera->port, settings)); + settings.serial.speed = 9600; /* hand shake speed */ + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits = 1; + CHECK (gp_port_set_settings (camera->port, settings)); - CHECK (gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); + CHECK (gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); /* Connect with the selected speed */ - return dsc2_connect(camera, selected_speed); + return dsc2_connect(camera, selected_speed); } /* End of dc1580.c */ diff --git a/camlibs/panasonic/l859/l859.c b/camlibs/panasonic/l859/l859.c index 8cb6301972..cc5f1683cc 100644 --- a/camlibs/panasonic/l859/l859.c +++ b/camlibs/panasonic/l859/l859.c @@ -142,7 +142,7 @@ static int l859_disconnect(Camera *camera) { if (l859_sendcmd(camera, L859_CMD_RESET) != GP_OK) return GP_ERROR; if (gp_port_read(camera->port, camera->pl->buf, 1) == GP_ERROR) - return GP_ERROR; + return GP_ERROR; GP_DEBUG ("Camera disconnected."); @@ -614,13 +614,13 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - int ret; + int ret; GPPortSettings settings; - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; camera->functions->about = camera_about; /* Allocate memory for a read/write buffer */ @@ -628,19 +628,19 @@ int camera_init (Camera *camera, GPContext *context) { if (!camera->pl) return (GP_ERROR_NO_MEMORY); - gp_port_set_timeout (camera->port, 2000); + gp_port_set_timeout (camera->port, 2000); gp_port_get_settings(camera->port, &settings); camera->pl->speed = settings.serial.speed; settings.serial.speed = 9600; /* hand shake speed */ settings.serial.bits = 8; settings.serial.parity = 0; settings.serial.stopbits = 1; - gp_port_set_settings(camera->port, settings); + gp_port_set_settings(camera->port, settings); /* Set up the filesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); - ret = l859_connect (camera); + ret = l859_connect (camera); if (ret < 0) { free (camera->pl); camera->pl = NULL; diff --git a/camlibs/pentax/library.c b/camlibs/pentax/library.c index 3904ea1d6d..a4b08a0dde 100644 --- a/camlibs/pentax/library.c +++ b/camlibs/pentax/library.c @@ -115,53 +115,53 @@ camera_abilities (CameraAbilitiesList *list) strcpy (a.model, "Pentax:K30"); a.usb_vendor = 0x25fb; - a.usb_product = 0x0132; - if (GP_OK != (ret = gp_abilities_list_append (list, a))) - return ret; + a.usb_product = 0x0132; + if (GP_OK != (ret = gp_abilities_list_append (list, a))) + return ret; - strcpy (a.model, "Pentax:K5II"); + strcpy (a.model, "Pentax:K5II"); a.usb_vendor = 0x25fb; - a.usb_product = 0x0148; - if (GP_OK != (ret = gp_abilities_list_append (list, a))) - return ret; + a.usb_product = 0x0148; + if (GP_OK != (ret = gp_abilities_list_append (list, a))) + return ret; /* TommyLimKW @ Twitter */ - strcpy (a.model, "Pentax:K5IIs"); + strcpy (a.model, "Pentax:K5IIs"); a.usb_vendor = 0x25fb; - a.usb_product = 0x014a; - if (GP_OK != (ret = gp_abilities_list_append (list, a))) - return ret; + a.usb_product = 0x014a; + if (GP_OK != (ret = gp_abilities_list_append (list, a))) + return ret; - strcpy (a.model, "Pentax:K3"); + strcpy (a.model, "Pentax:K3"); a.usb_vendor = 0x25fb; - a.usb_product = 0x0164; - if (GP_OK != (ret = gp_abilities_list_append (list, a))) - return ret; + a.usb_product = 0x0164; + if (GP_OK != (ret = gp_abilities_list_append (list, a))) + return ret; - strcpy (a.model, "Pentax:K1"); + strcpy (a.model, "Pentax:K1"); a.usb_vendor = 0x25fb; - a.usb_product = 0x0178; - if (GP_OK != (ret = gp_abilities_list_append (list, a))) - return ret; + a.usb_product = 0x0178; + if (GP_OK != (ret = gp_abilities_list_append (list, a))) + return ret; - strcpy (a.model, "Pentax:K3II"); + strcpy (a.model, "Pentax:K3II"); a.usb_vendor = 0x25fb; - a.usb_product = 0x017a; - if (GP_OK != (ret = gp_abilities_list_append (list, a))) - return ret; + a.usb_product = 0x017a; + if (GP_OK != (ret = gp_abilities_list_append (list, a))) + return ret; /* Keld Henningsen */ - strcpy (a.model, "Pentax:K70"); + strcpy (a.model, "Pentax:K70"); a.usb_vendor = 0x25fb; - a.usb_product = 0x017c; - if (GP_OK != (ret = gp_abilities_list_append (list, a))) - return ret; + a.usb_product = 0x017c; + if (GP_OK != (ret = gp_abilities_list_append (list, a))) + return ret; /* fifu7fi@gmail.com */ - strcpy (a.model, "Pentax:KP"); + strcpy (a.model, "Pentax:KP"); a.usb_vendor = 0x25fb; - a.usb_product = 0x017e; - if (GP_OK != (ret = gp_abilities_list_append (list, a))) - return ret; + a.usb_product = 0x017e; + if (GP_OK != (ret = gp_abilities_list_append (list, a))) + return ret; /* https://github.com/asalamon74/pktriggercord/issues/21 */ strcpy (a.model, "Pentax:K1II"); @@ -181,25 +181,25 @@ camera_abilities (CameraAbilitiesList *list) int scsi_write(GPPort *port, uint8_t *cmd, uint32_t cmdLen, uint8_t *buf, uint32_t bufLen) { - int ret; - char sense_buffer[32]; + int ret; + char sense_buffer[32]; - ret = gp_port_send_scsi_cmd (port, 1, (char*)cmd, cmdLen, - sense_buffer, sizeof(sense_buffer), (char*)buf, bufLen); - if (ret == GP_OK) return PSLR_OK; - return PSLR_SCSI_ERROR; + ret = gp_port_send_scsi_cmd (port, 1, (char*)cmd, cmdLen, + sense_buffer, sizeof(sense_buffer), (char*)buf, bufLen); + if (ret == GP_OK) return PSLR_OK; + return PSLR_SCSI_ERROR; } int scsi_read(GPPort *port, uint8_t *cmd, uint32_t cmdLen, uint8_t *buf, uint32_t bufLen) { - int ret; - char sense_buffer[32]; + int ret; + char sense_buffer[32]; - ret = gp_port_send_scsi_cmd (port, 0, (char*)cmd, cmdLen, - sense_buffer, sizeof(sense_buffer), (char*)buf, bufLen); - if (ret == GP_OK) return bufLen; - return -PSLR_SCSI_ERROR; + ret = gp_port_send_scsi_cmd (port, 0, (char*)cmd, cmdLen, + sense_buffer, sizeof(sense_buffer), (char*)buf, bufLen); + if (ret == GP_OK) return bufLen; + return -PSLR_SCSI_ERROR; } void close_drive(GPPort **port) { @@ -328,7 +328,7 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, const char *mimes[2]; int buftypes[2], jpegres[2], nrofdownloads = 1; char *fns[2], *lastfn = NULL; - struct timeval event_start; + struct timeval event_start; gp_log (GP_LOG_DEBUG, "pentax", "camera_capture"); @@ -471,7 +471,7 @@ static int camera_wait_for_event (Camera *camera, int timeout, CameraEventType *eventtype, void **eventdata, GPContext *context) { - struct timeval event_start; + struct timeval event_start; CameraFilePath *path; pslr_handle_t p = &camera->pl->pslr; int ret, length; @@ -829,12 +829,12 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) int i, resolution = -1; int *valid_resolutions; - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); valid_resolutions = pslr_get_model_jpeg_resolutions (&camera->pl->pslr); gp_widget_get_value (w, &sval); for (i = 0; i < MAX_RESOLUTION_SIZE; i++) - { + { int foo; sscanf(sval, "%d", &foo); @@ -854,7 +854,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) if ((ret == GP_OK) && gp_widget_changed (w)) { pslr_exposure_mode_t exposuremode; - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &sval); exposuremode = PSLR_EXPOSURE_MODE_MAX; @@ -879,7 +879,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) if ((ret == GP_OK) && gp_widget_changed (w)) { int iso; - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &sval); if (sscanf(sval, "%d", &iso)) { /* pslr_set_iso(&camera->pl->pslr, iso); */ @@ -910,7 +910,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) /* FIXME: decoding is strange. the UI shows number of stars * on k20d: 4 stars = 3, 3 stars = 0, 2 stars = 1, 1 star = 2 */ - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &sval); if (sscanf(sval, "%d", &qual)) { pslr_set_jpeg_stars (&camera->pl->pslr, qual); @@ -923,7 +923,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) if ((ret == GP_OK) && gp_widget_changed (w)) { pslr_rational_t speed; - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &sval); if (sscanf(sval, "%d/%d", &speed.nom, &speed.denom)) { pslr_set_shutter(&camera->pl->pslr, speed); @@ -946,7 +946,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) pslr_rational_t aperture; int apt1,apt2; - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &sval); if (sscanf(sval, "%d.%d", &apt1, &apt2)) { if (apt1<11) { @@ -983,7 +983,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) return GP_ERROR; } - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); gp_widget_get_value (w, &bulb); pslr_bulb (&camera->pl->pslr, bulb); diff --git a/camlibs/polaroid/pdc320.c b/camlibs/polaroid/pdc320.c index 257d13f24c..9221e5187d 100644 --- a/camlibs/polaroid/pdc320.c +++ b/camlibs/polaroid/pdc320.c @@ -504,9 +504,9 @@ camera_init (Camera *camera, GPContext *context) CameraAbilities abilities; int result; - /* First, set up all the function pointers */ + /* First, set up all the function pointers */ camera->functions->exit = camera_exit; - camera->functions->about = camera_about; + camera->functions->about = camera_about; camera->functions->summary = camera_summary; /* Now, tell the filesystem where to get lists and info */ diff --git a/camlibs/polaroid/pdc640.c b/camlibs/polaroid/pdc640.c index d25efd26c3..e48dc2b91b 100644 --- a/camlibs/polaroid/pdc640.c +++ b/camlibs/polaroid/pdc640.c @@ -912,13 +912,13 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, return (GP_ERROR); /* Set the filename */ - sprintf (path->name, camera->pl->filespec, num); - strcpy (path->folder, "/"); + sprintf (path->name, camera->pl->filespec, num); + strcpy (path->folder, "/"); CHECK_RESULT (gp_filesystem_append (camera->fs, "/", path->name, - context)); + context)); - return (GP_OK); + return (GP_OK); } static int diff --git a/camlibs/polaroid/pdc700.c b/camlibs/polaroid/pdc700.c index 5707686ee7..2eb8c3aa09 100644 --- a/camlibs/polaroid/pdc700.c +++ b/camlibs/polaroid/pdc700.c @@ -636,16 +636,16 @@ pdc700_set_date (Camera *camera, time_t time, GPContext *context) static int pdc700_capture (Camera *camera, GPContext *context) { - unsigned char cmd[5], buf[1024]; - unsigned int buf_len = 0; + unsigned char cmd[5], buf[1024]; + unsigned int buf_len = 0; int r = 0; int try; PDCInfo info; - cmd[3] = PDC700_CAPTURE; + cmd[3] = PDC700_CAPTURE; cmd[4] = 0; - CR (pdc700_transmit (camera, cmd, 5, buf, &buf_len, context)); + CR (pdc700_transmit (camera, cmd, 5, buf, &buf_len, context)); /* * This is rather hackish. The camera needs a little time to recover @@ -654,10 +654,10 @@ pdc700_capture (Camera *camera, GPContext *context) * I'm leaving this ugly-but-works junk here for now. */ for (try = 0; try < 10; try++) - if ((r = pdc700_info(camera, &info, context)) == GP_OK) - break; + if ((r = pdc700_info(camera, &info, context)) == GP_OK) + break; - return r; + return r; }; static int @@ -746,7 +746,7 @@ camera_abilities (CameraAbilitiesList *list) a.speed[3] = 57600; a.speed[4] = 115200; a.operations = GP_OPERATION_CAPTURE_IMAGE | - GP_OPERATION_CONFIG; + GP_OPERATION_CONFIG; a.file_operations = GP_FILE_OPERATION_DELETE | GP_FILE_OPERATION_PREVIEW; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; @@ -1182,10 +1182,10 @@ camera_init (Camera *camera, GPContext *context) GPPortSettings settings; int speeds[] = {115200, 9600, 57600, 19200, 38400}; - /* First, set up all the function pointers */ + /* First, set up all the function pointers */ camera->functions->capture = camera_capture; camera->functions->summary = camera_summary; - camera->functions->about = camera_about; + camera->functions->about = camera_about; camera->functions->get_config = camera_get_config; camera->functions->set_config = camera_set_config; diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index 78e219d4e3..f17fcc9912 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -10678,7 +10678,7 @@ _put_nikon_create_wifi_profile (CONFIG_PUT_ARGS) if (!gp_widget_changed (subwidget)) continue; - gp_widget_set_changed (subwidget, FALSE); + gp_widget_set_changed (subwidget, FALSE); ret = cursub->putfunc (camera, subwidget, NULL, NULL, NULL); } diff --git a/camlibs/ptp2/ptp-pack.c b/camlibs/ptp2/ptp-pack.c index aab02e4f1b..305180c901 100644 --- a/camlibs/ptp2/ptp-pack.c +++ b/camlibs/ptp2/ptp-pack.c @@ -1451,7 +1451,7 @@ ptp_pack_OPL (PTPParams *params, MTPProperties *props, int nrofprops, unsigned c packedpropstypes[noitems]= propitr->datatype; totalsize += sizeof(uint16_t); /* Add each property to be sent. */ - packedpropslens[noitems] = ptp_pack_DPV (params, &propitr->propval, &packedprops[noitems], propitr->datatype); + packedpropslens[noitems] = ptp_pack_DPV (params, &propitr->propval, &packedprops[noitems], propitr->datatype); totalsize += packedpropslens[noitems]; noitems ++; propitr ++; diff --git a/camlibs/ptp2/ptp.h b/camlibs/ptp2/ptp.h index ee2cfcda3d..2791b48c22 100644 --- a/camlibs/ptp2/ptp.h +++ b/camlibs/ptp2/ptp.h @@ -3706,11 +3706,11 @@ typedef struct _PTPParams PTPParams; typedef uint16_t (* PTPDataGetFunc) (PTPParams* params, void*priv, unsigned long wantlen, - unsigned char *data, unsigned long *gotlen); + unsigned char *data, unsigned long *gotlen); typedef uint16_t (* PTPDataPutFunc) (PTPParams* params, void*priv, unsigned long sendlen, - unsigned char *data); + unsigned char *data); typedef struct _PTPDataHandler { PTPDataGetFunc getfunc; PTPDataPutFunc putfunc; @@ -3727,7 +3727,7 @@ typedef uint16_t (* PTPIOSendData) (PTPParams* params, PTPContainer* ptp, typedef uint16_t (* PTPIOGetResp) (PTPParams* params, PTPContainer* resp); typedef uint16_t (* PTPIOGetData) (PTPParams* params, PTPContainer* ptp, - PTPDataHandler *putter); + PTPDataHandler *putter); typedef uint16_t (* PTPIOCancelReq) (PTPParams* params, uint32_t transaction_id); typedef uint16_t (* PTPIODevStatReq) (PTPParams* params); @@ -3923,7 +3923,7 @@ uint16_t ptp_usb_senddata (PTPParams* params, PTPContainer* ptp, uint64_t size, PTPDataHandler *handler); uint16_t ptp_usb_getresp (PTPParams* params, PTPContainer* resp); uint16_t ptp_usb_getdata (PTPParams* params, PTPContainer* ptp, - PTPDataHandler *handler); + PTPDataHandler *handler); uint16_t ptp_usb_event_async (PTPParams *params, PTPEventCbFn cb, void *user_data); uint16_t ptp_usb_event_wait (PTPParams* params, PTPContainer* event); uint16_t ptp_usb_event_check (PTPParams* params, PTPContainer* event); @@ -3943,7 +3943,7 @@ uint16_t ptp_ptpip_senddata (PTPParams* params, PTPContainer* ptp, uint64_t size, PTPDataHandler *handler); uint16_t ptp_ptpip_getresp (PTPParams* params, PTPContainer* resp); uint16_t ptp_ptpip_getdata (PTPParams* params, PTPContainer* ptp, - PTPDataHandler *handler); + PTPDataHandler *handler); uint16_t ptp_ptpip_event_wait (PTPParams* params, PTPContainer* event); uint16_t ptp_ptpip_event_check (PTPParams* params, PTPContainer* event); uint16_t ptp_ptpip_event_check_queue (PTPParams* params, PTPContainer* event); @@ -3955,7 +3955,7 @@ uint16_t ptp_fujiptpip_senddata (PTPParams* params, PTPContainer* ptp, uint64_t size, PTPDataHandler *handler); uint16_t ptp_fujiptpip_getresp (PTPParams* params, PTPContainer* resp); uint16_t ptp_fujiptpip_getdata (PTPParams* params, PTPContainer* ptp, - PTPDataHandler *handler); + PTPDataHandler *handler); uint16_t ptp_fujiptpip_event_wait (PTPParams* params, PTPContainer* event); uint16_t ptp_fujiptpip_event_check (PTPParams* params, PTPContainer* event); uint16_t ptp_fujiptpip_event_check_queue(PTPParams* params, PTPContainer* event); diff --git a/camlibs/ricoh/g3.c b/camlibs/ricoh/g3.c index 2d53356e11..8bb2b90dc1 100644 --- a/camlibs/ricoh/g3.c +++ b/camlibs/ricoh/g3.c @@ -378,10 +378,10 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, break; case GP_FILE_TYPE_EXIF: msg = _("Downloading EXIF data..."); - if (!strstr(filename,".JPG") && !strstr(filename,".jpg")) { - gp_context_error (context,_("No EXIF data available for %s."), - filename); - ret = GP_ERROR_FILE_NOT_FOUND; + if (!strstr(filename, ".JPG") && !strstr(filename, ".jpg")) { + gp_context_error (context, _("No EXIF data available for %s."), + filename); + ret = GP_ERROR_FILE_NOT_FOUND; goto out; } cmd = aprintf("-SRET %s", filename); @@ -397,9 +397,9 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, if (seek == -2) { /* FIXME: pretty bad, the camera has some time out problems * if this happens */ - gp_context_error (context,_("No EXIF data available for %s."), - filename); - ret = GP_ERROR_FILE_NOT_FOUND; + gp_context_error (context, _("No EXIF data available for %s."), + filename); + ret = GP_ERROR_FILE_NOT_FOUND; g3_channel_read(camera->port, &channel, &reply, &len); /* reply */ goto out; } @@ -844,7 +844,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, time = (ubuf[n*32+14]) | (ubuf[n*32+15]<<8); /* from kernel fs/fat/, time_dos2unix. */ - month = ((date >> 5) - 1) & 15; + month = ((date >> 5) - 1) & 15; year = date >> 9; info.file.mtime = (time & 31)*2+60*((time >> 5) & 63)+ @@ -885,18 +885,18 @@ camera_init (Camera *camera, GPContext *context) /*char *buf;*/ GPPortSettings settings; - /* First, set up all the needed function pointers */ - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; + /* First, set up all the needed function pointers */ + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); - gp_port_get_settings(camera->port, &settings); + gp_port_get_settings(camera->port, &settings); settings.usb.inep = 0x81; settings.usb.outep = 0x02; settings.usb.intep = 0x83; - gp_port_set_settings(camera->port, settings); + gp_port_set_settings(camera->port, settings); /* * The port is already provided with camera->port (and * already open). You just have to use functions like diff --git a/camlibs/ricoh/library.c b/camlibs/ricoh/library.c index 345a289bda..e3b86e62ff 100644 --- a/camlibs/ricoh/library.c +++ b/camlibs/ricoh/library.c @@ -117,7 +117,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, static int get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, - CameraFileInfo *info, void *data, GPContext *context) + CameraFileInfo *info, void *data, GPContext *context) { Camera *camera = data; int n; @@ -234,7 +234,7 @@ camera_summary (Camera *camera, CameraText *about, GPContext *context) camera->pl->model); sprintf (about->text, _("Model: %s\n" - "Memory: %d byte(s) of %d available"), + "Memory: %d byte(s) of %d available"), model, avail_mem, total_mem); return (GP_OK); @@ -392,9 +392,9 @@ static struct { const char *__v = NULL; \ unsigned int __i; \ \ - CR (gp_widget_get_child_by_name (wi, Name, &__w)); \ + CR (gp_widget_get_child_by_name (wi, Name, &__w)); \ if (gp_widget_changed (__w)) { \ - gp_widget_set_changed (__w, 0); \ + gp_widget_set_changed (__w, 0); \ CR (gp_widget_get_value (__w, &__v)); \ for (__i = 0; __i < N_ELEMENTS (ricoh_##n##s); __i++) \ if (!strcmp (__v, _(ricoh_##n##s[__i].name))) { \ @@ -465,7 +465,7 @@ camera_set_config (Camera *c, CameraWidget *window, GPContext *co) /* Copyright */ CR (gp_widget_get_child_by_name (window, "copyright", &w)); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); CR (gp_widget_get_value (w, &v_char)); CR (ricoh_set_copyright (c, co, v_char)); } @@ -473,7 +473,7 @@ camera_set_config (Camera *c, CameraWidget *window, GPContext *co) /* Date */ CR (gp_widget_get_child_by_name (window, "date", &w)); if (gp_widget_changed (w)) { - gp_widget_set_changed (w, 0); + gp_widget_set_changed (w, 0); CR (gp_widget_get_value (w, &time)); CR (ricoh_set_date (c, co, time)); } diff --git a/camlibs/ricoh/ricoh.c b/camlibs/ricoh/ricoh.c index bc9814a4d9..f8a1ea572a 100644 --- a/camlibs/ricoh/ricoh.c +++ b/camlibs/ricoh/ricoh.c @@ -147,7 +147,7 @@ static int ricoh_recv (Camera *camera, GPContext *context, unsigned char *cmd, unsigned char *number, unsigned char *data, unsigned char *len) { - unsigned char buf[6]; + unsigned char buf[6]; unsigned char r, i, ii, last_dle; unsigned int crc = 0; @@ -269,13 +269,13 @@ ricoh_transmit (Camera *camera, GPContext *context, unsigned char cmd, const unsigned char *data, unsigned char len, unsigned char *ret_data, unsigned char *ret_len) { - unsigned char ret_cmd; + unsigned char ret_cmd; unsigned int r = 0; int result; - while (1) { - CR (ricoh_send (camera, context, cmd, 0, data, len)); - result = ricoh_recv (camera, context, &ret_cmd, NULL, + while (1) { + CR (ricoh_send (camera, context, cmd, 0, data, len)); + result = ricoh_recv (camera, context, &ret_cmd, NULL, ret_data, ret_len); switch (result) { case GP_ERROR_TIMEOUT: @@ -352,14 +352,14 @@ ricoh_transmit (Camera *camera, GPContext *context, unsigned char cmd, gp_context_error (context, _("An unknown error occurred. " "Please contact %s."), MAIL_GPHOTO_DEVEL); return (GP_ERROR); - } + } /* Success! We don't need the first two bytes any more. */ *ret_len -= 2; if (*ret_len > 0) memmove (ret_data, ret_data + 2, *ret_len); - return (GP_OK); + return (GP_OK); } int diff --git a/camlibs/ricoh/ricoh.h b/camlibs/ricoh/ricoh.h index 6b5c546acb..f426be3db7 100644 --- a/camlibs/ricoh/ricoh.h +++ b/camlibs/ricoh/ricoh.h @@ -99,7 +99,7 @@ int ricoh_get_cam_mem (Camera *camera, GPContext *context, int *mem); int ricoh_get_cam_amem (Camera *camera, GPContext *context, int *mem); int ricoh_get_copyright (Camera *camera, GPContext *context, - const char **copyright); + const char **copyright); int ricoh_set_copyright (Camera *camera, GPContext *context, const char *copyright); diff --git a/camlibs/samsung/samsung.c b/camlibs/samsung/samsung.c index 494988bc67..1d62928d08 100644 --- a/camlibs/samsung/samsung.c +++ b/camlibs/samsung/samsung.c @@ -177,18 +177,18 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CHECK_RESULT (SDSC_send (camera->port, SDSC_NEXT)); CHECK_RESULT (SDSC_send (camera->port, SDSC_START)); CHECK_RESULT (SDSC_receive (camera->port, buffer, SDSC_INFOSIZE)); - if (!strcmp((char*)buffer,filename)) - break; + if (!strcmp((char*)buffer, filename)) + break; if (is_null(buffer)) { /* skipped to the end of the camera? */ - /* Since we start at a random position, we wrap around. */ - continue; - } + /* Since we start at a random position, we wrap around. */ + continue; + } /* We are at the first item again, so break. */ - if (havefirst && !strcmp((char*)first,(char*)buffer)) + if (havefirst && !strcmp((char*)first, (char*)buffer)) return GP_ERROR_BAD_PARAMETERS; if (!havefirst) { havefirst = 1; - strcpy((char*)first,(char*)buffer); + strcpy((char*)first, (char*)buffer); } } /* The buffer header has @@ -214,9 +214,9 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, return result; gp_file_append(file,(char *)buffer,SDSC_BLOCKSIZE); curread += SDSC_BLOCKSIZE; - gp_context_progress_update(context, pid, curread); + gp_context_progress_update(context, pid, curread); if (gp_context_cancel(context) == GP_CONTEXT_FEEDBACK_CANCEL) - return GP_ERROR_CANCEL; + return GP_ERROR_CANCEL; CHECK_RESULT (SDSC_send (camera->port, SDSC_BINARY)); } gp_context_progress_stop(context, pid); @@ -289,7 +289,7 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, strcpy(info->file.type,GP_MIME_JPEG); sscanf((char *)buffer+12,"%lld",(long long int *)&info->file.size); return GP_OK; - } + } /* We are at the first item again */ if (havefirst && !strcmp((char*)first,(char*)buffer)) break; @@ -312,8 +312,8 @@ camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; - /* First, set up all the function pointers */ - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); diff --git a/camlibs/sierra/library.c b/camlibs/sierra/library.c index e4b758d9cf..f1395b4df4 100644 --- a/camlibs/sierra/library.c +++ b/camlibs/sierra/library.c @@ -459,26 +459,25 @@ sierra_write_packet (Camera *camera, char *packet, GPContext *context) static int sierra_clear_usb_halt(Camera *camera) { - - if ( (camera->port->type == GP_PORT_USB) && - !(camera->pl->flags & SIERRA_WRAP_USB_MASK) && - !(camera->pl->flags & SIERRA_NO_USB_CLEAR) ) + if ((camera->port->type == GP_PORT_USB) && + !(camera->pl->flags & SIERRA_WRAP_USB_MASK) && + !(camera->pl->flags & SIERRA_NO_USB_CLEAR)) gp_port_usb_clear_halt(camera->port, GP_PORT_USB_ENDPOINT_IN); - return (GP_OK); + return (GP_OK); } static int sierra_write_nak (Camera *camera, GPContext *context) { - char buf[4096]; - int ret; + char buf[4096]; + int ret; - GP_DEBUG ("* sierra_write_nack"); + GP_DEBUG ("* sierra_write_nack"); - buf[0] = SIERRA_PACKET_NAK; - ret = sierra_write_packet (camera, buf, context); + buf[0] = SIERRA_PACKET_NAK; + ret = sierra_write_packet (camera, buf, context); sierra_clear_usb_halt(camera); - return (ret); + return (ret); } /** @@ -798,10 +797,10 @@ sierra_transmit_ack (Camera *camera, char *packet, GPContext *context) } /* - * The camera has ended this session and - * reverted the speed back to 19200. Reinitialize + * The camera has ended this session and + * reverted the speed back to 19200. Reinitialize * the connection. - */ + */ CHECK (sierra_init (camera, context)); CHECK (sierra_set_speed (camera, SIERRA_SPEED_19200, context)); @@ -931,15 +930,15 @@ sierra_init (Camera *camera, GPContext *context) } static struct { - SierraSpeed speed; - int bit_rate; + SierraSpeed speed; + int bit_rate; } SierraSpeeds[] = { - {SIERRA_SPEED_9600 , 9600}, - {SIERRA_SPEED_19200 , 19200}, - {SIERRA_SPEED_38400 , 38400}, - {SIERRA_SPEED_57600 , 57600}, - {SIERRA_SPEED_115200, 115200}, - {0, 0} + {SIERRA_SPEED_9600 , 9600}, + {SIERRA_SPEED_19200 , 19200}, + {SIERRA_SPEED_38400 , 38400}, + {SIERRA_SPEED_57600 , 57600}, + {SIERRA_SPEED_115200, 115200}, + {0, 0} }; int @@ -1204,7 +1203,7 @@ sierra_set_string_register (Camera *camera, int reg, const char *s, } int sierra_get_string_register (Camera *camera, int reg, int fnumber, - CameraFile *file, unsigned char *b, + CameraFile *file, unsigned char *b, unsigned int *b_len, GPContext *context) { unsigned char p[34816]; diff --git a/camlibs/sierra/sierra-desc.c b/camlibs/sierra/sierra-desc.c index e713752ceb..56b66defc1 100644 --- a/camlibs/sierra/sierra-desc.c +++ b/camlibs/sierra/sierra-desc.c @@ -137,7 +137,7 @@ camera_cam_desc_get_widget (Camera *camera, CameraRegisterType *reg_p, return (GP_ERROR); } GP_DEBUG ("... '%s'.", gp_result_as_string (ret)); - if (ret < 0) { + if (ret < 0) { return (ret); } @@ -170,7 +170,7 @@ camera_cam_desc_get_widget (Camera *camera, CameraRegisterType *reg_p, if (((reg_desc_p->reg_widget_type == GP_WIDGET_RADIO) || (reg_desc_p->reg_widget_type == GP_WIDGET_MENU)) && !gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); sprintf (buff, _("%lld (unknown)"), (long long)reg_p->reg_value); gp_widget_add_choice (child, buff); gp_widget_set_value (child, buff); @@ -366,10 +366,9 @@ camera_cam_desc_set_widget (Camera *camera, CameraRegisterType *reg_p, if ((gp_widget_get_child_by_label (window, _(reg_desc_p->regs_long_name), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value_in); - for (vind = 0; vind < reg_desc_p->reg_val_name_cnt; - vind++) { + for (vind = 0; vind < reg_desc_p->reg_val_name_cnt; vind++) { ret = camera_cam_desc_set_value (camera, reg_p, reg_desc_p, ®_desc_p->regs_value_names[vind], @@ -422,8 +421,8 @@ camera_set_config_cam_desc (Camera *camera, CameraWidget *window, GP_DEBUG ("%s registers", cam_desc->regset[wind].window_name); for (rind = 0; rind < cam_desc->regset[wind].reg_cnt; rind++) { camera_cam_desc_set_widget (camera, - &cam_desc->regset[wind].regs[rind], window, - context); + &cam_desc->regset[wind].regs[rind], window, + context); } } return (GP_OK); diff --git a/camlibs/sierra/sierra.c b/camlibs/sierra/sierra.c index e03bf4a3e0..867de9368d 100644 --- a/camlibs/sierra/sierra.c +++ b/camlibs/sierra/sierra.c @@ -269,10 +269,10 @@ int camera_abilities (CameraAbilitiesList *list) #ifdef linux /* The USB SCSI generic passthrough driver only works on Linux currently */ if (sierra_cameras[x].flags & (SIERRA_WRAP_USB_OLYMPUS|SIERRA_WRAP_USB_PENTAX|SIERRA_WRAP_USB_NIKON)) - a.port |= GP_PORT_USB_SCSI; - else + a.port |= GP_PORT_USB_SCSI; + else #endif - a.port |= GP_PORT_USB; + a.port |= GP_PORT_USB; } a.speed[0] = 9600; a.speed[1] = 19200; @@ -294,7 +294,7 @@ int camera_abilities (CameraAbilitiesList *list) a.speed[5] = 0; } } - a.operations = GP_OPERATION_CAPTURE_IMAGE | + a.operations = GP_OPERATION_CAPTURE_IMAGE | GP_OPERATION_CAPTURE_PREVIEW | GP_OPERATION_CONFIG; a.file_operations = GP_FILE_OPERATION_DELETE | @@ -520,7 +520,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, GPContext *context) { Camera *camera = user_data; - int regd, n; + int regd, n; char *jpeg_data = NULL; int jpeg_size; const char *data, *mime_type; @@ -904,7 +904,7 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con GP_DEBUG ("Resolution..."); ret = sierra_get_int_register (camera, 1, &value, context); GP_DEBUG ("... '%s'.", gp_result_as_string (ret)); - if (ret >= 0) { + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &child); gp_widget_add_choice (child, _("Auto")); @@ -912,26 +912,26 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con gp_widget_add_choice (child, _("High")); gp_widget_add_choice (child, _("Best")); - switch (value) { + switch (value) { case 0: strcpy (t, _("Auto")); break; - case 1: strcpy (t, _("Standard")); - break; - case 2: strcpy (t, _("High")); - break; - case 3: strcpy (t, _("Best")); - break; - default: - sprintf (t, _("%i (unknown)"), value); + case 1: strcpy (t, _("Standard")); + break; + case 2: strcpy (t, _("High")); + break; + case 3: strcpy (t, _("Best")); + break; + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Shutter Speed */ - ret = sierra_get_int_register (camera, 3, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 3, &value, context); + if (ret >= 0) { gp_widget_new (GP_WIDGET_RANGE, _("Shutter Speed (microseconds, 0 auto)"), @@ -940,11 +940,11 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con float_value = value; gp_widget_set_value (child, &float_value); gp_widget_append (section, child); - } + } /* Aperture */ - ret = sierra_get_int_register (camera, 5, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 5, &value, context); + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Aperture"), &child); gp_widget_add_choice (child, _("Auto")); @@ -952,26 +952,26 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con gp_widget_add_choice (child, _("Medium")); gp_widget_add_choice (child, _("High")); - switch (value) { + switch (value) { case 0: strcpy (t, _("Auto")); break; - case 1: strcpy (t, _("Low")); - break; - case 2: strcpy (t, _("Medium")); - break; - case 3: strcpy (t, _("High")); - break; - default: - sprintf(t, _("%i (unknown)"), value); + case 1: strcpy (t, _("Low")); + break; + case 2: strcpy (t, _("Medium")); + break; + case 3: strcpy (t, _("High")); + break; + default: + sprintf(t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Color Mode */ - ret = sierra_get_int_register (camera, 6, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 6, &value, context); + if (ret >= 0) { /* * Those values are for a C-2020 Z. If your model differs, * we have to distinguish models here. @@ -983,28 +983,28 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con gp_widget_add_choice (child, _("White Board")); gp_widget_add_choice (child, _("Black Board")); - switch (value) { + switch (value) { case 0: strcpy (t, _("Normal")); break; - case 1: strcpy (t, _("Black/White")); - break; - case 2: strcpy (t, _("Sepia")); - break; + case 1: strcpy (t, _("Black/White")); + break; + case 2: strcpy (t, _("Sepia")); + break; case 3: strcpy (t, _("White Board")); break; case 4: strcpy (t, _("Black Board")); break; - default: - sprintf (t, _("%i (unknown)"), value); + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Flash Mode */ ret = sierra_get_int_register (camera, 7, &value, context); - if (ret >= 0) { + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Flash Mode"), &child); gp_widget_add_choice (child, _("Auto")); @@ -1013,28 +1013,28 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con gp_widget_add_choice (child, _("Red-eye Reduction")); gp_widget_add_choice (child, _("Slow Sync")); - switch (value) { - case 0: strcpy (t, _("Auto")); - break; - case 1: strcpy (t, _("Force")); - break; - case 2: strcpy (t, _("Off")); - break; - case 3: strcpy (t, _("Red-eye Reduction")); - break; - case 4: strcpy (t, _("Slow Sync")); - break; - default: - sprintf (t, _("%i (unknown)"), value); + switch (value) { + case 0: strcpy (t, _("Auto")); + break; + case 1: strcpy (t, _("Force")); + break; + case 2: strcpy (t, _("Off")); + break; + case 3: strcpy (t, _("Red-eye Reduction")); + break; + case 4: strcpy (t, _("Slow Sync")); + break; + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Brightness/Contrast */ - ret = sierra_get_int_register (camera, 19, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 19, &value, context); + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Brightness/Contrast"), &child); @@ -1044,28 +1044,28 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con gp_widget_add_choice (child, _("Contrast+")); gp_widget_add_choice (child, _("Contrast-")); - switch (value) { - case 0: strcpy (t, _("Normal")); - break; - case 1: strcpy (t, _("Bright+")); - break; - case 2: strcpy (t, _("Bright-")); - break; - case 3: strcpy (t, _("Contrast+")); - break; - case 4: strcpy (t, _("Contrast-")); - break; - default: - sprintf (t, _("%i (unknown)"), value); + switch (value) { + case 0: strcpy (t, _("Normal")); + break; + case 1: strcpy (t, _("Bright+")); + break; + case 2: strcpy (t, _("Bright-")); + break; + case 3: strcpy (t, _("Contrast+")); + break; + case 4: strcpy (t, _("Contrast-")); + break; + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* White Balance */ - ret = sierra_get_int_register (camera, 20, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 20, &value, context); + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("White Balance"), &child); gp_widget_add_choice (child, _("Auto")); @@ -1074,49 +1074,49 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con gp_widget_add_choice (child, _("Tungsten")); gp_widget_add_choice (child, _("Cloudy")); - switch (value) { - case 0: strcpy (t, _("Auto")); - break; - case 1: strcpy (t, _("Skylight")); - break; - case 2: strcpy (t, _("Fluorescent")); - break; - case 3: strcpy (t, _("Tungsten")); - break; - case 255: - strcpy (t, _("Cloudy")); - break; - default: - sprintf (t, _("%i (unknown)"), value); + switch (value) { + case 0: strcpy (t, _("Auto")); + break; + case 1: strcpy (t, _("Skylight")); + break; + case 2: strcpy (t, _("Fluorescent")); + break; + case 3: strcpy (t, _("Tungsten")); + break; + case 255: + strcpy (t, _("Cloudy")); + break; + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Lens Mode */ - ret = sierra_get_int_register (camera, 33, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 33, &value, context); + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Lens Mode"), &child); gp_widget_add_choice (child, _("Macro")); gp_widget_add_choice (child, _("Normal")); gp_widget_add_choice (child, _("Infinity/Fish-eye")); - switch (value) { - case 1: strcpy (t, _("Macro")); - break; - case 2: strcpy (t, _("Normal")); - break; - case 3: strcpy (t, _("Infinity/Fish-eye")); - break; - default: - sprintf (t, _("%i (unknown)"), value); + switch (value) { + case 1: strcpy (t, _("Macro")); + break; + case 2: strcpy (t, _("Normal")); + break; + case 3: strcpy (t, _("Infinity/Fish-eye")); + break; + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Spot Metering Mode */ ret = sierra_get_int_register (camera, 70, &value, context); @@ -1241,7 +1241,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Resolution"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Auto")) == 0) { i = 0; @@ -1261,7 +1261,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Shutter Speed (microseconds, 0 auto)"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &float_value); i = float_value; CHECK_STOP (camera, sierra_set_int_register (camera, 3, i, context)); @@ -1272,7 +1272,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Aperture"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Auto")) == 0) { i = 0; @@ -1292,7 +1292,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Color Mode"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Normal")) == 0) { i = 0; @@ -1314,7 +1314,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Flash Mode"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Auto")) == 0) { i = 0; @@ -1337,7 +1337,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Brightness/Contrast"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Normal")) == 0) { i = 0; @@ -1359,7 +1359,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("White Balance"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Auto")) == 0) { i = 0; @@ -1381,9 +1381,9 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Lens Mode"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); - if (strcmp (value, _("Macro")) == 0) { + if (strcmp (value, _("Macro")) == 0) { i = 1; } else if (strcmp (value, _("Normal")) == 0) { i = 2; @@ -1392,7 +1392,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } else return (GP_ERROR_NOT_SUPPORTED); CHECK_STOP (camera, sierra_set_int_register (camera, 33, i, context)); - } + } /* Spot Metering Mode */ GP_DEBUG ( @@ -1400,7 +1400,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Spot Metering Mode"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("On")) == 0) { i = 3; @@ -1416,7 +1416,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont if ((gp_widget_get_child_by_label (window, _("Zoom"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, "1x") == 0) { i = 0; @@ -1431,46 +1431,46 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont CHECK_STOP (camera, sierra_set_int_register (camera, 72, i, context)); } - /* Auto Off (host) */ + /* Auto Off (host) */ GP_DEBUG ("*** setting auto off (host)"); if ((gp_widget_get_child_by_label (window, _("Auto Off (host) " "(in seconds)"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &i); - CHECK_STOP (camera, sierra_set_int_register (camera, 23, i, context)); - } + CHECK_STOP (camera, sierra_set_int_register (camera, 23, i, context)); + } - /* Auto Off (field) */ + /* Auto Off (field) */ GP_DEBUG ( "*** setting auto off (field)"); if ((gp_widget_get_child_by_label (window, _("Auto Off (field) " "(in seconds)"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &i); CHECK_STOP (camera, sierra_set_int_register (camera, 24, i, context)); } - /* LCD Brightness */ + /* LCD Brightness */ GP_DEBUG ("*** setting lcd brightness"); if ((gp_widget_get_child_by_label (window, _("LCD Brightness"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &i); CHECK_STOP (camera, sierra_set_int_register (camera, 35, i, context)); } - /* LCD Auto Off */ + /* LCD Auto Off */ GP_DEBUG ("*** setting lcd auto off"); if ((gp_widget_get_child_by_label (window, _("LCD Auto Off (in seconds)"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &i); CHECK_STOP (camera, sierra_set_int_register (camera, 38, i, context)); - } + } return (camera_stop (camera, context)); } @@ -1494,8 +1494,8 @@ camera_get_config_epson (Camera *camera, CameraWidget **window, GPContext *conte gp_widget_append (*window, section); /* Aperture */ - ret = sierra_get_int_register (camera, 5, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 5, &value, context); + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Aperture"), &child); gp_widget_add_choice (child, _("F2")); gp_widget_add_choice (child, _("F2.3")); @@ -1504,14 +1504,14 @@ camera_get_config_epson (Camera *camera, CameraWidget **window, GPContext *conte gp_widget_add_choice (child, _("F5.6")); gp_widget_add_choice (child, _("F8")); gp_widget_add_choice (child, _("auto")); - switch (value) { + switch (value) { case 0: strcpy (t, _("F2")); break; - case 1: strcpy (t, _("F2.3")); + case 1: strcpy (t, _("F2.3")); break; - case 2: strcpy (t, _("F2.8")); + case 2: strcpy (t, _("F2.8")); break; - case 3: strcpy (t, _("F4")); + case 3: strcpy (t, _("F4")); break; case 4: strcpy (t, _("F5.6")); break; @@ -1519,112 +1519,112 @@ camera_get_config_epson (Camera *camera, CameraWidget **window, GPContext *conte break; case 6: strcpy (t, _("auto")); break; - default: + default: sprintf(t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Flash Mode */ ret = sierra_get_int_register (camera, 7, &value, context); - if (ret >= 0) { + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Flash Mode"), &child); gp_widget_add_choice (child, _("Auto")); gp_widget_add_choice (child, _("Force")); gp_widget_add_choice (child, _("Off")); gp_widget_add_choice (child, _("Red-eye Reduction")); gp_widget_add_choice (child, _("Slow Sync")); - switch (value) { - case 0: strcpy (t, _("Auto")); - break; - case 1: strcpy (t, _("Force")); - break; - case 2: strcpy (t, _("Off")); - break; - case 3: strcpy (t, _("Red-eye Reduction")); - break; - case 4: strcpy (t, _("Slow Sync")); - break; - default: - sprintf (t, _("%i (unknown)"), value); + switch (value) { + case 0: strcpy (t, _("Auto")); + break; + case 1: strcpy (t, _("Force")); + break; + case 2: strcpy (t, _("Off")); + break; + case 3: strcpy (t, _("Red-eye Reduction")); + break; + case 4: strcpy (t, _("Slow Sync")); + break; + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* White Balance */ - ret = sierra_get_int_register (camera, 20, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 20, &value, context); + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("White Balance"), &child); gp_widget_add_choice (child, _("Auto")); gp_widget_add_choice (child, _("Fixed")); gp_widget_add_choice (child, _("Custom")); - switch (value) { - case 0: strcpy (t, _("Auto")); - break; - case 1: strcpy (t, _("Fixed")); - break; - case 225: strcpy (t, _("Custom")); - break; - default: - sprintf (t, _("%i (unknown)"), value); + switch (value) { + case 0: strcpy (t, _("Auto")); + break; + case 1: strcpy (t, _("Fixed")); + break; + case 225: strcpy (t, _("Custom")); + break; + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } gp_widget_new (GP_WIDGET_SECTION, _("Picture Settings"), §ion); gp_widget_append (*window, section); /* Lens Mode */ - ret = sierra_get_int_register (camera, 33, &value, context); - if (ret >= 0) { + ret = sierra_get_int_register (camera, 33, &value, context); + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Lens Mode"), &child); gp_widget_add_choice (child, _("Macro")); gp_widget_add_choice (child, _("Normal")); - switch (value) { - case 1: strcpy (t, _("Macro")); - break; - case 2: strcpy (t, _("Normal")); - break; - default: - sprintf (t, _("%i (unknown)"), value); + switch (value) { + case 1: strcpy (t, _("Macro")); + break; + case 2: strcpy (t, _("Normal")); + break; + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Resolution */ ret = sierra_get_int_register (camera, 1, &value, context); - if (ret >= 0) { + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Resolution"), &child); gp_widget_add_choice (child, _("standard")); gp_widget_add_choice (child, _("fine")); gp_widget_add_choice (child, _("superfine")); gp_widget_add_choice (child, _("HyPict")); - switch (value) { + switch (value) { case 1: strcpy (t, _("standard")); break; - case 2: strcpy (t, _("fine")); + case 2: strcpy (t, _("fine")); break; - case 3: strcpy (t, _("superfine")); + case 3: strcpy (t, _("superfine")); break; - case 34: strcpy (t, _("HyPict")); + case 34: strcpy (t, _("HyPict")); break; - default: + default: sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Color Mode */ ret = sierra_get_int_register (camera, 6, &value, context); @@ -1678,7 +1678,7 @@ camera_get_config_epson (Camera *camera, CameraWidget **window, GPContext *conte /* Language */ ret = sierra_get_int_register (camera, 53, &value, context); - if (ret >= 0) { + if (ret >= 0) { gp_widget_new (GP_WIDGET_RADIO, _("Language"), &child); gp_widget_add_choice (child, _("Korean")); gp_widget_add_choice (child, _("English")); @@ -1688,30 +1688,30 @@ camera_get_config_epson (Camera *camera, CameraWidget **window, GPContext *conte gp_widget_add_choice (child, _("Japanese")); gp_widget_add_choice (child, _("Spanish")); gp_widget_add_choice (child, _("Portuguese")); - switch (value) { - case 1: strcpy (t, _("Korean")); - break; - case 3: strcpy (t, _("English")); - break; - case 4: strcpy (t, _("French")); - break; - case 5: strcpy (t, _("German")); - break; - case 6: strcpy (t, _("Italian")); - break; + switch (value) { + case 1: strcpy (t, _("Korean")); + break; + case 3: strcpy (t, _("English")); + break; + case 4: strcpy (t, _("French")); + break; + case 5: strcpy (t, _("German")); + break; + case 6: strcpy (t, _("Italian")); + break; case 7: strcpy (t, _("Japanese")); break; case 8: strcpy (t, _("Spanish")); break; case 9: strcpy (t, _("Portuguese")); break; - default: - sprintf (t, _("%i (unknown)"), value); + default: + sprintf (t, _("%i (unknown)"), value); gp_widget_add_choice (child, t); - } + } gp_widget_set_value (child, t); gp_widget_append (section, child); - } + } /* Date & Time */ ret = sierra_get_int_register (camera, 2, &value, context); @@ -1739,7 +1739,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex GP_DEBUG ("*** setting aperture"); if ((gp_widget_get_child_by_label (window, _("Aperture"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("F2")) == 0) { i = 0; @@ -1764,7 +1764,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex GP_DEBUG ("*** setting flash mode"); if ((gp_widget_get_child_by_label (window, _("Flash Mode"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Auto")) == 0) { i = 0; @@ -1785,7 +1785,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex GP_DEBUG ("*** setting white balance"); if ((gp_widget_get_child_by_label (window, _("White Balance"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Auto")) == 0) { i = 0; @@ -1803,22 +1803,22 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex if ((gp_widget_get_child_by_label (window, _("Lens Mode"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); - if (strcmp (value, _("Macro")) == 0) { + if (strcmp (value, _("Macro")) == 0) { i = 1; } else if (strcmp (value, _("Normal")) == 0) { i = 2; } else return (GP_ERROR_NOT_SUPPORTED); CHECK_STOP (camera, sierra_set_int_register (camera, 33, i, context)); - } + } /* Resolution */ GP_DEBUG ("*** setting resolution"); if ((gp_widget_get_child_by_label (window, _("Resolution"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("standard")) == 0) { i = 1; @@ -1837,7 +1837,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex GP_DEBUG ("*** setting color mode"); if ((gp_widget_get_child_by_label (window, _("Color Mode"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("color")) == 0) { i = 1; @@ -1848,23 +1848,23 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex CHECK_STOP (camera, sierra_set_int_register (camera, 6, i, context)); } - /* Auto Off (host) */ + /* Auto Off (host) */ GP_DEBUG ("*** setting auto off (host)"); if ((gp_widget_get_child_by_label (window, _("Auto Off (host) " "(in seconds)"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &i); - CHECK_STOP (camera, sierra_set_int_register (camera, 23, i, context)); - } + CHECK_STOP (camera, sierra_set_int_register (camera, 23, i, context)); + } - /* Auto Off (field) */ + /* Auto Off (field) */ GP_DEBUG ( "*** setting auto off (field)"); if ((gp_widget_get_child_by_label (window, _("Auto Off (field) " "(in seconds)"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &i); CHECK_STOP (camera, sierra_set_int_register (camera, 24, i, context)); } @@ -1873,7 +1873,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex GP_DEBUG ("*** setting language"); if ((gp_widget_get_child_by_label (window, _("Language"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &value); if (strcmp (value, _("Korean")) == 0) { i = 1; @@ -1901,7 +1901,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex if ((gp_widget_get_child_by_label (window, _("Date & Time"), &child) >= 0) && gp_widget_changed (child)) { - gp_widget_set_changed (child, FALSE); + gp_widget_set_changed (child, FALSE); gp_widget_get_value (child, &i); CHECK_STOP (camera, sierra_set_int_register (camera, 2, i, context)); } @@ -1996,12 +1996,12 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *c) static int storage_info_func (CameraFilesystem *fs, - CameraStorageInformation **sinfos, - int *nrofsinfos, - void *data, GPContext *c + CameraStorageInformation **sinfos, + int *nrofsinfos, + void *data, GPContext *c ) { - Camera *camera = data; - CameraStorageInformation*sif; + Camera *camera = data; + CameraStorageInformation*sif; int v; char t[1024]; @@ -2164,18 +2164,18 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - int x = 0, ret, value; - int vendor=0; + int x = 0, ret, value; + int vendor=0; GPPortSettings s; CameraAbilities a; - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->capture_preview = camera_capture_preview; - camera->functions->capture = camera_capture; - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->capture_preview = camera_capture_preview; + camera->functions->capture = camera_capture; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; camera->pl = calloc (1, sizeof (CameraPrivateLibrary)); if (!camera->pl) @@ -2197,7 +2197,7 @@ camera_init (Camera *camera, GPContext *context) camera->pl->flags = sierra_cameras[x].flags; camera->pl->cam_desc = sierra_cameras[x].cam_desc; break; - } + } } switch (camera->pl->model) { @@ -2212,7 +2212,7 @@ camera_init (Camera *camera, GPContext *context) case SIERRA_MODEL_CAM_DESC: if (camera->pl->cam_desc == NULL) { GP_DEBUG ("*** sierra cam_desc NULL"); - return (GP_ERROR_MODEL_NOT_FOUND); + return (GP_ERROR_MODEL_NOT_FOUND); } camera->pl->flags |= camera->pl->cam_desc->flags; camera->functions->get_config = camera_get_config_cam_desc; @@ -2224,8 +2224,8 @@ camera_init (Camera *camera, GPContext *context) break; } CHECK_FREE (camera, gp_port_get_settings (camera->port, &s)); - switch (camera->port->type) { - case GP_PORT_SERIAL: + switch (camera->port->type) { + case GP_PORT_SERIAL: s.serial.bits = 8; s.serial.parity = 0; @@ -2255,31 +2255,31 @@ camera_init (Camera *camera, GPContext *context) } /* The camera defaults to 19200. */ - s.serial.speed = 19200; + s.serial.speed = 19200; - break; + break; - case GP_PORT_USB: - case GP_PORT_USB_SCSI: + case GP_PORT_USB: + case GP_PORT_USB_SCSI: - /* Test if we have usb information */ - if (vendor == 0) { - free (camera->pl); - camera->pl = NULL; - return (GP_ERROR_MODEL_NOT_FOUND); - } + /* Test if we have usb information */ + if (vendor == 0) { + free (camera->pl); + camera->pl = NULL; + return (GP_ERROR_MODEL_NOT_FOUND); + } /* Use the defaults the core parsed */ - break; + break; - default: + default: - free (camera->pl); - camera->pl = NULL; - return (GP_ERROR_UNKNOWN_PORT); - } + free (camera->pl); + camera->pl = NULL; + return (GP_ERROR_UNKNOWN_PORT); + } - CHECK_FREE (camera, gp_port_set_settings (camera->port, s)); - CHECK_FREE (camera, gp_port_set_timeout (camera->port, TIMEOUT)); + CHECK_FREE (camera, gp_port_set_settings (camera->port, s)); + CHECK_FREE (camera, gp_port_set_timeout (camera->port, TIMEOUT)); /* * Send initialization sequence unless otherwise flagged. (The @@ -2289,10 +2289,10 @@ camera_init (Camera *camera, GPContext *context) if (!(camera->pl->flags & SIERRA_SKIP_INIT)) CHECK (sierra_init (camera, context)); - /* Establish a connection */ - CHECK_FREE (camera, camera_start (camera, context)); + /* Establish a connection */ + CHECK_FREE (camera, camera_start (camera, context)); - /* + /* * USB cameras seem to need this request. If we don't request the * contents of this register and directly proceed with checking for * folder support, the camera doesn't send anything. @@ -2320,31 +2320,31 @@ camera_init (Camera *camera, GPContext *context) sierra_get_int_register (camera, 1, &value, NULL); #if 0 - /* FIXME??? What's that for? "Resetting folder system"? */ + /* FIXME??? What's that for? "Resetting folder system"? */ sierra_set_int_register (camera, 83, -1, NULL); #endif /* How to switch the coolpix 2500 between RAW / NORMAL return dsc->SetStr(0x16, raw_enabled ? "DIAG RAW" : "NIKON DIGITAL CAMERA" ); - ret = sierra_set_string_register (camera, 0x16, "NIKON DIGITAL CAMERA", strlen("NIKON DIGITAL CAMERA"), NULL); + ret = sierra_set_string_register (camera, 0x16, "NIKON DIGITAL CAMERA", strlen("NIKON DIGITAL CAMERA"), NULL); */ - /* Folder support? */ + /* Folder support? */ CHECK_STOP_FREE (camera, gp_port_set_timeout (camera->port, 50)); - ret = sierra_set_string_register (camera, 84, "\\", 1, NULL); - if (ret != GP_OK) { - camera->pl->folders = 0; - GP_DEBUG ("*** folder support: no"); - } else { + ret = sierra_set_string_register (camera, 84, "\\", 1, NULL); + if (ret != GP_OK) { + camera->pl->folders = 0; + GP_DEBUG ("*** folder support: no"); + } else { camera->pl->folders = 1; - GP_DEBUG ("*** folder support: yes"); - } - CHECK_STOP_FREE (camera, gp_port_set_timeout (camera->port, TIMEOUT)); + GP_DEBUG ("*** folder support: yes"); + } + CHECK_STOP_FREE (camera, gp_port_set_timeout (camera->port, TIMEOUT)); - /* We start off not knowing where we are */ - strcpy (camera->pl->folder, ""); - CHECK_STOP_FREE (camera, gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); + /* We start off not knowing where we are */ + strcpy (camera->pl->folder, ""); + CHECK_STOP_FREE (camera, gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera)); - CHECK (camera_stop (camera, context)); + CHECK (camera_stop (camera, context)); GP_DEBUG ("****************** sierra initialization OK"); return (GP_OK); diff --git a/camlibs/sipix/blink.c b/camlibs/sipix/blink.c index 6cc30844e8..38778b04f0 100644 --- a/camlibs/sipix/blink.c +++ b/camlibs/sipix/blink.c @@ -738,18 +738,18 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, unsigned char *xdata, *ydata; - if (strcmp(folder,"/")) - return GP_ERROR_BAD_PARAMETERS; - image_no = gp_filesystem_number(fs, folder, filename, context); + if (strcmp(folder, "/")) + return GP_ERROR_BAD_PARAMETERS; + image_no = gp_filesystem_number(fs, folder, filename, context); - /* size */ + /* size */ do { gp_port_usb_msg_read (camera->port, 1, image_no , 1, reply, 8); } while(reply[0]!=0); picsize = reply[1] | (reply[2] << 8) | ( reply[3] << 16); /* Setup bulk transfer */ - do { + do { gp_port_usb_msg_read (camera->port, 2, image_no , 0, reply, 6); } while(reply[0]!=0); diff --git a/camlibs/sipix/blink2.c b/camlibs/sipix/blink2.c index 4450c6f9dc..3c8c3a060b 100644 --- a/camlibs/sipix/blink2.c +++ b/camlibs/sipix/blink2.c @@ -45,19 +45,17 @@ #define BLINK2_GET_FIRMWARE_ID 0x18 static int -blink2_getnumpics( - GPPort *port, GPContext *context, unsigned int *numpics -) { - unsigned char buf[2]; - int ret; - - ret = gp_port_usb_msg_read(port, BLINK2_GET_NUMPICS, 0x03, 0, (char*)buf, 2); - if (ret < GP_OK) - return ret; - gp_log(GP_LOG_DEBUG, "blink2","ret is %d", ret); - if (ret < 2) return GP_ERROR_IO_READ; - *numpics = (buf[0]<<8) | buf[1]; - return GP_OK; +blink2_getnumpics (GPPort *port, GPContext *context, unsigned int *numpics) { + unsigned char buf[2]; + int ret; + + ret = gp_port_usb_msg_read(port, BLINK2_GET_NUMPICS, 0x03, 0, (char*)buf, 2); + if (ret < GP_OK) + return ret; + gp_log(GP_LOG_DEBUG, "blink2", "ret is %d", ret); + if (ret < 2) return GP_ERROR_IO_READ; + *numpics = (buf[0]<<8) | buf[1]; + return GP_OK; } #ifdef HAVE_LIBJPEG @@ -65,17 +63,17 @@ blink2_getnumpics( static void _jpeg_init_source(j_decompress_ptr cinfo) { } static boolean _jpeg_fill_input_buffer(j_decompress_ptr cinfo) { - fprintf(stderr,"(), should not get here.\n"); - return FALSE; + fprintf(stderr, "(), should not get here.\n"); + return FALSE; } -static void _jpeg_skip_input_data(j_decompress_ptr cinfo,long num_bytes) { - fprintf(stderr,"(%ld), should not get here.\n",num_bytes); +static void _jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes) { + fprintf(stderr, "(%ld), should not get here.\n", num_bytes); } static boolean _jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired) { - fprintf(stderr,"(desired=%d), should not get here.\n",desired); - return FALSE; + fprintf(stderr, "(desired=%d), should not get here.\n", desired); + return FALSE; } static void _jpeg_term_source(j_decompress_ptr cinfo) { } #endif @@ -182,18 +180,18 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, } free(xbuf); - image_no = gp_filesystem_number(fs, folder, filename, context); - if(image_no < 0) { + image_no = gp_filesystem_number(fs, folder, filename, context); + if(image_no < 0) { free(addrs); - return image_no; + return image_no; } if (image_no < 0 || (unsigned int)image_no >= numpics) { free(addrs); gp_log(GP_LOG_DEBUG, "blink2","image %d requested, but only %d pics on camera?", image_no, numpics); - return GP_ERROR; + return GP_ERROR; } - switch (type) { - case GP_FILE_TYPE_NORMAL: + switch (type) { + case GP_FILE_TYPE_NORMAL: #ifdef HAVE_LIBJPEG { char *convline,*convline2,*rawline; @@ -205,9 +203,9 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, memset( buf, 0, sizeof(buf)); if (addrs[image_no].type) - gp_file_set_mime_type (file, GP_MIME_AVI); + gp_file_set_mime_type (file, GP_MIME_AVI); else - gp_file_set_mime_type (file, GP_MIME_JPEG); + gp_file_set_mime_type (file, GP_MIME_JPEG); start = addrs[image_no].start; len = addrs[image_no].len; @@ -302,23 +300,23 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, free(convline); free(rawline); free(jpegdata); - gp_file_set_mime_type (file, GP_MIME_PPM); + gp_file_set_mime_type (file, GP_MIME_PPM); jpeg_destroy_decompress(&dinfo); break; } #else /* fall through to raw mode if no libjpeg */ #endif - case GP_FILE_TYPE_RAW: { + case GP_FILE_TYPE_RAW: { char buf2[4096]; unsigned int start, len; unsigned int curread; memset( buf, 0, sizeof(buf)); if (addrs[image_no].type) - gp_file_set_mime_type (file, GP_MIME_AVI); + gp_file_set_mime_type (file, GP_MIME_AVI); else - gp_file_set_mime_type (file, GP_MIME_JPEG); + gp_file_set_mime_type (file, GP_MIME_JPEG); start = addrs[image_no].start; len = addrs[image_no].len; @@ -329,7 +327,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, buf[4] = (len >> 24) & 0xff; buf[5] = (len >> 16) & 0xff; buf[6] = (len >> 8) & 0xff; - buf[7] = len & 0xff; + buf[7] = len & 0xff; result = gp_port_usb_msg_write(camera->port,BLINK2_GET_MEMORY,0x03,0,(char*)buf,8); if (result < GP_OK) break; @@ -349,21 +347,20 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, if (result < GP_OK) break; } while (len>0); - break; - } + break; + } default: - result = GP_ERROR_NOT_SUPPORTED; + result = GP_ERROR_NOT_SUPPORTED; break; - } + } free(addrs); - if (result < 0) - return result; - return (GP_OK); + if (result < 0) + return result; + return (GP_OK); } static int -delete_all_func (CameraFilesystem *fs, const char *folder, void *data, - GPContext *context) +delete_all_func (CameraFilesystem *fs, const char *folder, void *data, GPContext *context) { Camera *camera = data; int ret; @@ -373,12 +370,11 @@ delete_all_func (CameraFilesystem *fs, const char *folder, void *data, if (ret < GP_OK) return ret; if (ret < 1) return GP_ERROR_IO_READ; - return GP_OK; + return GP_OK; } static int -camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, - GPContext *context) +camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, GPContext *context) { int ret; unsigned int oldnumpics, numpics; @@ -405,9 +401,9 @@ camera_capture (Camera *camera, CameraCaptureType type, CameraFilePath *path, return ret; if (numpics == oldnumpics) return (GP_ERROR); - strcpy (path->folder,"/"); - sprintf (path->name,"image%04d.pnm",numpics-1); - return (GP_OK); + strcpy (path->folder, "/"); + sprintf (path->name, "image%04d.pnm", numpics-1); + return (GP_OK); } @@ -459,7 +455,7 @@ camera_init (Camera *camera, GPContext *context) int ret; GPPortSettings settings; - camera->functions->capture = camera_capture; + camera->functions->capture = camera_capture; gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); gp_port_get_settings( camera->port, &settings); diff --git a/camlibs/sipix/web2.c b/camlibs/sipix/web2.c index a9f14d8643..3041dee6b5 100644 --- a/camlibs/sipix/web2.c +++ b/camlibs/sipix/web2.c @@ -678,8 +678,8 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - camera->functions->exit = camera_exit; - camera->functions->about = camera_about; + camera->functions->exit = camera_exit; + camera->functions->about = camera_about; gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); return web2_init(camera->port, context); } diff --git a/camlibs/smal/smal.c b/camlibs/smal/smal.c index 649230c61e..b1aae6a0be 100644 --- a/camlibs/smal/smal.c +++ b/camlibs/smal/smal.c @@ -61,7 +61,7 @@ static const struct smal_cameras { { "Fuji:Axia Eyeplate", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_ULTRAPOCKET }, { "Logitech:Pocket Digital", USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_POCKETDIGITAL }, { "SMaL:Ultra-Pocket", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_ULTRAPOCKET }, - { "Radioshack:Flatfoto", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_FLATFOTO }, + { "Radioshack:Flatfoto", USB_VENDOR_ID_SMAL, USB_DEVICE_ID_FLATFOTO }, { "Creative:CardCam", USB_VENDOR_ID_CREATIVE, USB_DEVICE_ID_CARDCAM }, { NULL, 0, 0 } }; @@ -69,118 +69,117 @@ static const struct smal_cameras { int camera_abilities (CameraAbilitiesList *list) { - CameraAbilities a; - int i; - - memset(&a, 0, sizeof(a)); - a.status = GP_DRIVER_STATUS_EXPERIMENTAL; /* highly! */ - a.port = GP_PORT_USB; - a.speed[0] = 0; - a.operations = GP_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_DELETE; - a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; - for (i = 0; smal_cameras[i].name; i++) { - strcpy(a.model, smal_cameras[i].name); - a.usb_vendor = smal_cameras[i].idVendor; - a.usb_product = smal_cameras[i].idProduct; - gp_abilities_list_append(list, a); - } - return (GP_OK); + CameraAbilities a; + int i; + + memset(&a, 0, sizeof(a)); + a.status = GP_DRIVER_STATUS_EXPERIMENTAL; /* highly! */ + a.port = GP_PORT_USB; + a.speed[0] = 0; + a.operations = GP_OPERATION_NONE; + a.file_operations = GP_FILE_OPERATION_DELETE; + a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; + for (i = 0; smal_cameras[i].name; i++) { + strcpy(a.model, smal_cameras[i].name); + a.usb_vendor = smal_cameras[i].idVendor; + a.usb_product = smal_cameras[i].idProduct; + gp_abilities_list_append(list, a); + } + return (GP_OK); } static int camera_exit (Camera *camera, GPContext *context) { - if (camera->pl) { - free(camera->pl); - camera->pl = NULL; - } - return ultrapocket_exit(camera->port, context); + if (camera->pl) { + free(camera->pl); + camera->pl = NULL; + } + return ultrapocket_exit(camera->port, context); } static int get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, - CameraFileType type, CameraFile *file, void *user_data, - GPContext *context) + CameraFileType type, CameraFile *file, void *user_data, + GPContext *context) { - Camera *camera = user_data; - int size,image_no,result; - unsigned char *data; - - image_no = gp_filesystem_number(fs, folder, filename, context); - if (image_no < GP_OK) - return image_no; - - switch (type) { - case GP_FILE_TYPE_NORMAL: - result = ultrapocket_getpicture(camera,context,&data,&size,filename); - gp_file_set_mime_type (file, GP_MIME_PPM); - break; - case GP_FILE_TYPE_RAW: - result = ultrapocket_getrawpicture(camera, context, - &data, &size, filename); - gp_file_set_mime_type (file, GP_MIME_PPM); - break; - case GP_FILE_TYPE_PREVIEW: - default: - return (GP_ERROR_NOT_SUPPORTED); - } - if (result < 0) - return result; - - CHECK_RESULT(gp_file_set_data_and_size (file, (char *)data, size)); - - return (GP_OK); + Camera *camera = user_data; + int size, image_no, result; + unsigned char *data; + + image_no = gp_filesystem_number(fs, folder, filename, context); + if (image_no < GP_OK) + return image_no; + + switch (type) { + case GP_FILE_TYPE_NORMAL: + result = ultrapocket_getpicture(camera, context, &data, &size, filename); + gp_file_set_mime_type (file, GP_MIME_PPM); + break; + case GP_FILE_TYPE_RAW: + result = ultrapocket_getrawpicture(camera, context, + &data, &size, filename); + gp_file_set_mime_type (file, GP_MIME_PPM); + break; + case GP_FILE_TYPE_PREVIEW: + default: + return (GP_ERROR_NOT_SUPPORTED); + } + if (result < 0) + return result; + + CHECK_RESULT(gp_file_set_data_and_size (file, (char *)data, size)); + + return (GP_OK); } static int delete_file_func (CameraFilesystem *fs, const char *folder, const char *filename, void *data, GPContext *context) { - Camera *camera = data; - int image_no; + Camera *camera = data; + int image_no; - image_no = gp_filesystem_number(fs, folder, filename, context); - if (image_no < GP_OK) - return image_no; + image_no = gp_filesystem_number(fs, folder, filename, context); + if (image_no < GP_OK) + return image_no; - CHECK_RESULT(ultrapocket_deletefile(camera, filename)); + CHECK_RESULT(ultrapocket_deletefile(camera, filename)); - return (GP_OK); + return (GP_OK); } static int -delete_all_func (CameraFilesystem *fs, const char* folder, void *data, - GPContext *context) +delete_all_func (CameraFilesystem *fs, const char* folder, void *data, GPContext *context) { - Camera *camera = data; - if (strcmp (folder, "/")) - return (GP_ERROR_DIRECTORY_NOT_FOUND); - return ultrapocket_deleteall(camera); + Camera *camera = data; + if (strcmp (folder, "/")) + return (GP_ERROR_DIRECTORY_NOT_FOUND); + return ultrapocket_deleteall(camera); } static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - strcpy (about->text, _("Smal Ultrapocket\n" + strcpy (about->text, _("Smal Ultrapocket\n" "Lee Benfield \n" "Driver for accessing the Smal Ultrapocket camera, and OEM versions (slimshot)")); - return (GP_OK); + return (GP_OK); } static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { - Camera *camera = data; - int count, result; + Camera *camera = data; + int count, result; - result = ultrapocket_getpicsoverview(camera, context, &count, list); - if (result != GP_OK) - return result; + result = ultrapocket_getpicsoverview(camera, context, &count, list); + if (result != GP_OK) + return result; - return (GP_OK); + return (GP_OK); } static CameraFilesystemFuncs fsfuncs = { @@ -193,55 +192,55 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - CameraAbilities cab; - up_badge_type badge; - - camera->functions->exit = camera_exit; - camera->functions->about = camera_about; - gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); - badge = BADGE_UNKNOWN; - gp_camera_get_abilities(camera, &cab); - switch (cab.usb_vendor) { - case USB_VENDOR_ID_SMAL: - case USB_VENDOR_ID_CREATIVE: - switch (cab.usb_product) { - case USB_DEVICE_ID_ULTRAPOCKET: - /* could be an axia eyeplate or a slimshot - * figure it out later, when we get the image - * catalogue. - */ - badge = BADGE_GENERIC; - break; - case USB_DEVICE_ID_FLATFOTO: - badge = BADGE_FLATFOTO; - break; - case USB_DEVICE_ID_CARDCAM: - badge = BADGE_CARDCAM; - break; - default: - break; + CameraAbilities cab; + up_badge_type badge; + + camera->functions->exit = camera_exit; + camera->functions->about = camera_about; + gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); + badge = BADGE_UNKNOWN; + gp_camera_get_abilities(camera, &cab); + switch (cab.usb_vendor) { + case USB_VENDOR_ID_SMAL: + case USB_VENDOR_ID_CREATIVE: + switch (cab.usb_product) { + case USB_DEVICE_ID_ULTRAPOCKET: + /* could be an axia eyeplate or a slimshot + * figure it out later, when we get the image + * catalogue. + */ + badge = BADGE_GENERIC; + break; + case USB_DEVICE_ID_FLATFOTO: + badge = BADGE_FLATFOTO; + break; + case USB_DEVICE_ID_CARDCAM: + badge = BADGE_CARDCAM; + break; + default: + break; + } + break; + case USB_VENDOR_ID_LOGITECH: + switch (cab.usb_product) { + case USB_DEVICE_ID_POCKETDIGITAL: + badge = BADGE_LOGITECH_PD; + break; + default: + break; + } + break; + default: + break; } - break; - case USB_VENDOR_ID_LOGITECH: - switch (cab.usb_product) { - case USB_DEVICE_ID_POCKETDIGITAL: - badge = BADGE_LOGITECH_PD; - break; - default: - break; + + if (badge == BADGE_UNKNOWN) { + /* can't happen. Otherwise, how'd we get to camera_init, neh? */ + return GP_ERROR; } - break; - default: - break; - } - - if (badge == BADGE_UNKNOWN) { - /* can't happen. Otherwise, how'd we get to camera_init, neh? */ - return GP_ERROR; - } - - camera->pl = malloc (sizeof (CameraPrivateLibrary)); - camera->pl->up_type = badge; - /* don't need to do any exciting init stuff until we get pic numbers */ - return GP_OK; + + camera->pl = malloc (sizeof (CameraPrivateLibrary)); + camera->pl->up_type = badge; + /* don't need to do any exciting init stuff until we get pic numbers */ + return GP_OK; } diff --git a/camlibs/sonix/library.c b/camlibs/sonix/library.c index d3e5e760b9..8c8de1af24 100644 --- a/camlibs/sonix/library.c +++ b/camlibs/sonix/library.c @@ -160,7 +160,7 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; int i = 0; char name[16]; int(avitype); @@ -366,25 +366,25 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, sonix_decode (frame_data, data+offset+CAM_OFFSET, w, h); sonix_cols_reverse(frame_data, w, h); - gp_ahd_decode(frame_data, w, h, ptr+ - SAKAR_AVI_FRAME_HEADER_LENGTH, - BAYER_TILE_GBRG); + gp_ahd_decode(frame_data, w, h, ptr+ + SAKAR_AVI_FRAME_HEADER_LENGTH, + BAYER_TILE_GBRG); break; case DECOMP: sonix_decode (frame_data, - data+offset+CAM_OFFSET, w, h); + data+offset+CAM_OFFSET, w, h); sonix_rows_reverse(frame_data, w, h); - gp_ahd_decode(frame_data, w, h, ptr+ - SAKAR_AVI_FRAME_HEADER_LENGTH, - BAYER_TILE_GRBG); + gp_ahd_decode(frame_data, w, h, ptr+ + SAKAR_AVI_FRAME_HEADER_LENGTH, + BAYER_TILE_GRBG); break; default: memcpy(frame_data, data + offset - +CAM_OFFSET, frame_size); + +CAM_OFFSET, frame_size); sonix_rows_reverse(frame_data, w, h); - gp_ahd_decode(frame_data, w, h, ptr+ - SAKAR_AVI_FRAME_HEADER_LENGTH, - BAYER_TILE_GRBG); + gp_ahd_decode(frame_data, w, h, ptr+ + SAKAR_AVI_FRAME_HEADER_LENGTH, + BAYER_TILE_GRBG); } white_balance(ptr+SAKAR_AVI_FRAME_HEADER_LENGTH, w * h, 1.2); @@ -431,15 +431,15 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, if (camera->pl->post&REVERSE) { sonix_decode (p_data, data+CAM_OFFSET, w, h); sonix_byte_reverse(p_data, w*h); - gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_BGGR); + gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_BGGR); break; case DECOMP: sonix_decode (p_data, data+CAM_OFFSET, w, h); - gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_RGGB); + gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_RGGB); break; default: memcpy (p_data, data+CAM_OFFSET, w*h); - gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_RGGB); + gp_ahd_decode(p_data, w, h, ptr, BAYER_TILE_RGGB); } free (p_data); white_balance(ptr, w * h, 1.2); @@ -458,7 +458,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, free(data); return GP_ERROR_NOT_SUPPORTED; } - return GP_OK; + return GP_OK; } static int @@ -567,8 +567,8 @@ camera_init(Camera *camera, GPContext *context) GP_DEBUG("product number is 0x%x\n", abilities.usb_product); /* First, set up all the function pointers */ - camera->functions->capture = camera_capture; - camera->functions->manual = camera_manual; + camera->functions->capture = camera_capture; + camera->functions->manual = camera_manual; camera->functions->summary = camera_summary; camera->functions->about = camera_about; camera->functions->exit = camera_exit; diff --git a/camlibs/sonix/sonix.c b/camlibs/sonix/sonix.c index f08afbbdc1..55e360c487 100644 --- a/camlibs/sonix/sonix.c +++ b/camlibs/sonix/sonix.c @@ -515,8 +515,8 @@ white_balance (unsigned char *data, unsigned int size, float saturation) x += htable_g[r]; x += htable_b[r]; } - gamma = sqrt((double) (x ) / (double) (size * 2)); - GP_DEBUG("Provisional gamma correction = %1.2f\n", gamma); + gamma = sqrt((double) (x ) / (double) (size * 2)); + GP_DEBUG("Provisional gamma correction = %1.2f\n", gamma); if(gamma < .1) { new_gamma = .50; @@ -526,8 +526,8 @@ white_balance (unsigned char *data, unsigned int size, float saturation) new_gamma = 0.60; else new_gamma = gamma; - if (new_gamma > 1.2) new_gamma = 1.2; - GP_DEBUG("Gamma correction = %1.2f\n", new_gamma); + if (new_gamma > 1.2) new_gamma = 1.2; + GP_DEBUG("Gamma correction = %1.2f\n", new_gamma); gp_gamma_fill_table(gtable, new_gamma); gp_gamma_correct_single(gtable,data,size); diff --git a/camlibs/sonydscf55/camera.c b/camlibs/sonydscf55/camera.c index 5d9771e97a..62db724c3e 100644 --- a/camlibs/sonydscf55/camera.c +++ b/camlibs/sonydscf55/camera.c @@ -202,7 +202,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, case GP_FILE_TYPE_NORMAL: if (file_type == SONY_FILE_MPEG) { rc = sony_mpeg_get(camera, num, file, context); - } + } else { rc = sony_image_get(camera, num, file, context); } diff --git a/camlibs/sonydscf55/sony.c b/camlibs/sonydscf55/sony.c index 6537e13247..4cc02f32d1 100644 --- a/camlibs/sonydscf55/sony.c +++ b/camlibs/sonydscf55/sony.c @@ -308,7 +308,7 @@ sony_packet_write(Camera * camera, Packet * p) GP_DEBUG( "sony_packet_write()"); - /** + /** * This usleep is necessary when using (relatively) fast CPUs, * as P4 2Ghz. Without it gphoto2 stops with a segmentation fault * and the --debug message sony_packet_validate: invalid sequence diff --git a/camlibs/soundvision/commands.h b/camlibs/soundvision/commands.h index eae760242f..ffae0f253d 100644 --- a/camlibs/soundvision/commands.h +++ b/camlibs/soundvision/commands.h @@ -20,11 +20,9 @@ #define CAMLIBS_SOUNDVISION_COMMANDS_H -int32_t soundvision_send_command(uint32_t command, uint32_t argument, - CameraPrivateLibrary *dev); +int32_t soundvision_send_command(uint32_t command, uint32_t argument, CameraPrivateLibrary *dev); -int32_t soundvision_send_file_command(const char *filename, - CameraPrivateLibrary *dev); +int32_t soundvision_send_file_command(const char *filename, CameraPrivateLibrary *dev); int32_t soundvision_read(CameraPrivateLibrary *dev, void *buffer, int len); diff --git a/camlibs/soundvision/soundvision.h b/camlibs/soundvision/soundvision.h index 30c4c78f3f..8e7d068246 100644 --- a/camlibs/soundvision/soundvision.h +++ b/camlibs/soundvision/soundvision.h @@ -57,16 +57,15 @@ struct _CameraPrivateLibrary { GPPort *gpdev; - int device_type; - int reset_times,odd_command; + int device_type; + int reset_times, odd_command; int num_pictures; char *file_list; }; /* commands.c */ -int32_t soundvision_send_command(uint32_t command, uint32_t argument, - CameraPrivateLibrary *dev); +int32_t soundvision_send_command(uint32_t command, uint32_t argument, CameraPrivateLibrary *dev); int soundvision_reset(CameraPrivateLibrary *dev, char *revision, char *status); int soundvision_get_revision(CameraPrivateLibrary *dev,char *revision); @@ -93,10 +92,10 @@ int agfa_capture(CameraPrivateLibrary *dev, CameraFilePath *path); int agfa_delete_picture(CameraPrivateLibrary *dev, const char *filename); int agfa_get_file_list(CameraPrivateLibrary *dev); int agfa_get_pic(CameraPrivateLibrary *dev, const char *filename, - unsigned char *data,int size); + unsigned char *data,int size); int agfa_get_pic_size(CameraPrivateLibrary *dev, const char *filename); int agfa_get_thumb(CameraPrivateLibrary *dev, const char *filename, - unsigned char *data,int size); + unsigned char *data,int size); int agfa_get_thumb_size(CameraPrivateLibrary *dev, const char *filename); @@ -113,10 +112,10 @@ int tiger_capture(CameraPrivateLibrary *dev, CameraFilePath *path); int tiger_get_mem(CameraPrivateLibrary *dev, int *num_pics, int *mem_total, int *mem_free); int tiger_get_file_list(CameraPrivateLibrary *dev); int tiger_get_pic(CameraPrivateLibrary *dev, const char *filename, - unsigned char *data,int size); + unsigned char *data,int size); int tiger_get_pic_size(CameraPrivateLibrary *dev, const char *filename); int tiger_get_thumb(CameraPrivateLibrary *dev, const char *filename, - unsigned char *data,int size); + unsigned char *data,int size); int tiger_get_thumb_size(CameraPrivateLibrary *dev, const char *filename); #endif /* !defined(CAMLIBS_SOUNDVISION_SOUNDVISION_H) */ diff --git a/camlibs/spca50x/library.c b/camlibs/spca50x/library.c index a0497914c0..7fe7980880 100644 --- a/camlibs/spca50x/library.c +++ b/camlibs/spca50x/library.c @@ -105,14 +105,14 @@ models[] = {"Aiptek:Smart Megacam", 0x04fc, 0x504b, BRIDGE_SPCA504, 0 }, {"Benq:DC1300", 0x04a5, 0x3003, - BRIDGE_SPCA504, 0 }, + BRIDGE_SPCA504, 0 }, /* Some other 500a cams with flash */ {"Trust:Familycam 300", 0x084d, 0x0003, BRIDGE_SPCA500, SPCA50X_FLASH}, {"D-Link:DSC 350+", 0x084d, 0x0003, BRIDGE_SPCA500, SPCA50X_FLASH}, - {"Minton:S-Cam F5", 0x084d, 0x0003, - BRIDGE_SPCA500, SPCA50X_FLASH}, + {"Minton:S-Cam F5", 0x084d, 0x0003, + BRIDGE_SPCA500, SPCA50X_FLASH}, {"PureDigital:Ritz Disposable", 0x04fc, 0xffff, BRIDGE_SPCA504B_PD, SPCA50X_FLASH}, {NULL, 0, 0, 0, 0} @@ -141,7 +141,7 @@ camera_abilities (CameraAbilitiesList *list) a.status = GP_DRIVER_STATUS_TESTING; a.file_operations = GP_FILE_OPERATION_PREVIEW - | GP_FILE_OPERATION_DELETE; + | GP_FILE_OPERATION_DELETE; a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; @@ -155,8 +155,8 @@ camera_abilities (CameraAbilitiesList *list) a.operations = GP_OPERATION_CAPTURE_IMAGE; } if (models[x].bridge == BRIDGE_SPCA504B_PD) { - a.operations = GP_OPERATION_CAPTURE_IMAGE; - } + a.operations = GP_OPERATION_CAPTURE_IMAGE; + } if (models[x].bridge == BRIDGE_SPCA500) { /* TEST enable capture for the DSC-350 style cams */ if (a.usb_vendor == 0x084d) { diff --git a/camlibs/spca50x/spca50x-flash.c b/camlibs/spca50x/spca50x-flash.c index 52599746ad..06227bf40f 100644 --- a/camlibs/spca50x/spca50x-flash.c +++ b/camlibs/spca50x/spca50x-flash.c @@ -345,7 +345,7 @@ spca50x_flash_get_file_name (CameraPrivateLibrary *pl, int index, char *name) memset (p, 0, sizeof(p)); /* dsc350 - get the file info, so we can set the file type - correctly */ + correctly */ spca500_flash_84D_get_file_info (pl, index, &w, &h, &type, &size); if (type < 3){ /* for single images */ snprintf (p, sizeof(p), "Img%03d.jpg", (index + 1)); diff --git a/camlibs/spca50x/spca50x-sdram.c b/camlibs/spca50x/spca50x-sdram.c index 13939128d6..6b9500f151 100644 --- a/camlibs/spca50x/spca50x-sdram.c +++ b/camlibs/spca50x/spca50x-sdram.c @@ -50,8 +50,8 @@ static int spca50x_mode_set_download (CameraPrivateLibrary * lib); static int spca50x_download_data (CameraPrivateLibrary * lib, uint32_t start, unsigned int size, uint8_t * buf); static int spca50x_get_FATs (CameraPrivateLibrary * lib, int dramtype); -static int spca50x_sdram_get_file_count_and_fat_count - (CameraPrivateLibrary * lib, int dramtype); +static int spca50x_sdram_get_file_count_and_fat_count ( + CameraPrivateLibrary * lib, int dramtype); static int spca50x_get_avi_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, unsigned int *len, struct SPCA50xFile *g_file); @@ -67,7 +67,7 @@ static inline uint8_t *put_dword (uint8_t * ptr, uint32_t value); static int spca50x_sdram_get_fat_page (CameraPrivateLibrary * lib, int index, - int dramtype, uint8_t *p) + int dramtype, uint8_t *p) { switch (dramtype) { case 4: /* 128 Mbit */ @@ -92,7 +92,7 @@ spca50x_sdram_get_fat_page (CameraPrivateLibrary * lib, int index, static int spca50x_sdram_get_file_count_and_fat_count (CameraPrivateLibrary * lib, - int dramtype) + int dramtype) { uint8_t theFat[256]; @@ -128,7 +128,7 @@ spca50x_sdram_get_file_count_and_fat_count (CameraPrivateLibrary * lib, } else { while (1) { CHECK (spca50x_sdram_get_fat_page (lib, lib->num_fats, - dramtype, theFat)); + dramtype, theFat)); if (theFat[0] == 0xFF) break; diff --git a/camlibs/spca50x/spca50x.c b/camlibs/spca50x/spca50x.c index 16848037bb..ea4123029b 100644 --- a/camlibs/spca50x/spca50x.c +++ b/camlibs/spca50x/spca50x.c @@ -180,7 +180,7 @@ spca50x_capture (CameraPrivateLibrary * lib) #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION sleep (2); #endif - CHECK (gp_port_usb_msg_write + CHECK (gp_port_usb_msg_write (lib->gpdev, 0x06, 0x0000, 0x0003, NULL, 0)); #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION sleep (3); diff --git a/camlibs/sq905/library.c b/camlibs/sq905/library.c index f8a5e28c00..87c69efbc3 100644 --- a/camlibs/sq905/library.c +++ b/camlibs/sq905/library.c @@ -73,9 +73,9 @@ static const struct { {"Precision Mini Digital Camera", GP_DRIVER_STATUS_PRODUCTION , 0x2770 , 0x9120}, {"iConcepts digital camera" , - GP_DRIVER_STATUS_PRODUCTION , 0x2770 , 0x9120}, - {"Sakar Kidz Cam 86379", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, - 0x9120}, + GP_DRIVER_STATUS_PRODUCTION , 0x2770 , 0x9120}, + {"Sakar Kidz Cam 86379", + GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120}, {"ViviCam3350", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120}, {"ViviCam5B", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120}, {"DC-N130ta", GP_DRIVER_STATUS_EXPERIMENTAL, 0x2770, 0x9120}, @@ -140,8 +140,8 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) return GP_OK; } -static int camera_manual (Camera *camera, CameraText *manual, - GPContext *context) +static int +camera_manual (Camera *camera, CameraText *manual, GPContext *context) { strcpy(manual->text, _( @@ -184,7 +184,7 @@ camera_about (Camera *camera, CameraText *about, GPContext *context) static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, - void *data, GPContext *context) + void *data, GPContext *context) { Camera *camera = data; int i,n; @@ -212,7 +212,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, static int folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, - void *data, GPContext *context) + void *data, GPContext *context) { Camera *camera = data; int i,n; @@ -229,7 +229,7 @@ folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, static int get_info_func (CameraFilesystem *fs, const char *folder, const char *file, - CameraFileInfo *info, void *data, GPContext *context) + CameraFileInfo *info, void *data, GPContext *context) { memset (info, 0, sizeof(CameraFileInfo)); /* FIXME: fill in some stuff? */ @@ -413,7 +413,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, memcpy (rawdata, frame_data, size); memcpy (rawdata+size,camera->pl->catalog+16*entry,16); gp_file_set_mime_type (file, GP_MIME_RAW); - gp_file_set_data_and_size (file, (char *)rawdata, size+16); + gp_file_set_data_and_size (file, (char *)rawdata, size+16); } /* Reset camera when done, for more graceful exit. */ if ((!(is_in_clip)&&(entry +1 == camera->pl->nb_entries)) @@ -424,8 +424,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, } static int -delete_all_func (CameraFilesystem *fs, const char *folder, void *data, - GPContext *context) +delete_all_func (CameraFilesystem *fs, const char *folder, void *data, GPContext *context) { Camera *camera = data; @@ -452,7 +451,7 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context) return GP_ERROR_NO_MEMORY; } - sq_access_reg(camera->port, CAPTURE); + sq_access_reg(camera->port, CAPTURE); sq_read_picture_data (camera->port, camera->pl->last_fetched_data, b); frame_data = camera->pl->last_fetched_data + 0x40; sq_preprocess(camera->pl->model, 1, 0, frame_data, w, h); @@ -490,7 +489,7 @@ camera_capture_preview (Camera *camera, CameraFile *file, GPContext *context) gp_file_set_data_and_size (file, (char *)ppm, size); sq_reset(camera->port); - sq_access_reg(camera->port, CAPTURE); + sq_access_reg(camera->port, CAPTURE); sq_reset(camera->port); return (GP_OK); diff --git a/camlibs/sq905/postprocess.c b/camlibs/sq905/postprocess.c index ae35ba4743..e74a3c827a 100644 --- a/camlibs/sq905/postprocess.c +++ b/camlibs/sq905/postprocess.c @@ -44,7 +44,7 @@ static int decode_panel (unsigned char *panel_out, unsigned char *panel, - int panelwidth, int height, int color); + int panelwidth, int height, int color); int sq_decompress (SQModel model, unsigned char *output, unsigned char *data, @@ -107,13 +107,13 @@ sq_decompress (SQModel model, unsigned char *output, unsigned char *data, switch(model) { case(SQ_MODEL_MAGPIX): case(SQ_MODEL_POCK_CAM): - for (i = 0; i < h; i++) { - for (m = 0 ; m < w/2; m++) { - temp = output[w*i +m]; - output[w*i + m] = output[w*i + w -1 -m]; - output[w*i + w - 1 - m] = temp; - } - } + for (i = 0; i < h; i++) { + for (m = 0; m < w/2; m++) { + temp = output[w*i +m]; + output[w*i + m] = output[w*i + w -1 -m]; + output[w*i + w - 1 - m] = temp; + } + } break; default: ; /* default is "do nothing" */ } @@ -163,7 +163,7 @@ int decode_panel (unsigned char *panel_out, unsigned char *panel, tempval = (temp_line[2*i]) + diff; else tempval = (temp_line[2*i] - + panel_out[m*panelwidth+2*i-1])/2 + diff; + + panel_out[m*panelwidth+2*i-1])/2 + diff; tempval = MIN(tempval, 0xff); tempval = MAX(tempval, 0); panel_out[m*panelwidth+2*i] = tempval; @@ -193,7 +193,7 @@ int decode_panel (unsigned char *panel_out, unsigned char *panel, tempval = (temp_line[0]+temp_line[1])/2 + diff; else tempval = (temp_line[2*i+1] - + panel_out[2*m*panelwidth+2*i-1])/2 + diff; + + panel_out[2*m*panelwidth+2*i-1])/2 + diff; tempval = MIN(tempval, 0xff); tempval = MAX(tempval, 0); panel_out[2*m*panelwidth+2*i] = tempval; diff --git a/camlibs/sq905/sq905.c b/camlibs/sq905/sq905.c index ddbc50b66e..9ba05b7916 100644 --- a/camlibs/sq905/sq905.c +++ b/camlibs/sq905/sq905.c @@ -254,25 +254,25 @@ sq_preprocess (SQModel model, int comp_ratio, unsigned char is_in_clip, if (!is_in_clip) { /* Turning the picture right-side up. */ - for (i = 0; i < b/2; ++i) { - temp = data[i]; - data[i] = data[b -1 -i]; - data[b - 1 - i] = temp; - } + for (i = 0; i < b/2; ++i) { + temp = data[i]; + data[i] = data[b -1 -i]; + data[b - 1 - i] = temp; + } /* But clip frames are already right-side-up */ - } + } /* * POCK_CAM needs de-mirror-imaging, too. But if a photo is * compressed we de-mirror after decompression, so not here. */ if ((model == SQ_MODEL_POCK_CAM) && (comp_ratio == 1)) { - for (i = 0; i < h; i++) { - for (m = 0 ; m < w/2; m++) { - temp = data[w*i +m]; + for (i = 0; i < h; i++) { + for (m = 0; m < w/2; m++) { + temp = data[w*i +m]; data[w*i + m] = data[w*i + w -1 -m]; data[w*i + w - 1 - m] = temp; } - } + } } return GP_OK; } diff --git a/camlibs/st2205/st2205.c b/camlibs/st2205/st2205.c index 6603ed42d3..6b339790a2 100644 --- a/camlibs/st2205/st2205.c +++ b/camlibs/st2205/st2205.c @@ -830,9 +830,9 @@ st2205_init(Camera *camera) { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, } }; const int uncompressed_firmware_checksums[] = { - 0x00ab02fc, /* Frame 96x64 from blokker (Netherlands) */ - 0x00aa8060, /* Blokker frame with picframe hacked firmware */ - 0 }; + 0x00ab02fc, /* Frame 96x64 from blokker (Netherlands) */ + 0x00aa8060, /* Blokker frame with picframe hacked firmware */ + 0 }; GP_DEBUG ("st2205_init called"); diff --git a/camlibs/stv0674/stv0674.c b/camlibs/stv0674/stv0674.c index 9cc00bcf3a..8d6273b2c5 100644 --- a/camlibs/stv0674/stv0674.c +++ b/camlibs/stv0674/stv0674.c @@ -200,7 +200,7 @@ static int delete_all_func (CameraFilesystem *fs, const char* folder, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; if (strcmp (folder, "/")) return (GP_ERROR_DIRECTORY_NOT_FOUND); return stv0674_delete_all(camera->port); @@ -214,38 +214,38 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - GPPortSettings settings; - int ret; - - /* First, set up all the function pointers */ - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; - camera->functions->capture_preview = camera_capture_preview; - camera->functions->capture = camera_capture; - - gp_port_get_settings(camera->port, &settings); - switch(camera->port->type) { - case GP_PORT_USB: - /* Modify the default settings the core parsed */ - settings.usb.altsetting=1;/* we need to use interface 0 setting 1 */ - settings.usb.inep=2; - settings.usb.intep=3; - settings.usb.outep=5; - - /* Use the defaults the core parsed */ - break; - default: - return (GP_ERROR_UNKNOWN_PORT); - break; - } + GPPortSettings settings; + int ret; + + /* First, set up all the function pointers */ + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; + camera->functions->capture_preview = camera_capture_preview; + camera->functions->capture = camera_capture; + + gp_port_get_settings(camera->port, &settings); + switch (camera->port->type) { + case GP_PORT_USB: + /* Modify the default settings the core parsed */ + settings.usb.altsetting=1;/* we need to use interface 0 setting 1 */ + settings.usb.inep=2; + settings.usb.intep=3; + settings.usb.outep=5; + + /* Use the defaults the core parsed */ + break; + default: + return (GP_ERROR_UNKNOWN_PORT); + break; + } - ret = gp_port_set_settings (camera->port, settings); - if (ret != GP_OK) { - gp_context_error (context, _("Could not apply USB settings")); - return ret; - } - /* Set up the filesystem */ - gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); - /* test camera */ - return stv0674_ping(camera->port); + ret = gp_port_set_settings (camera->port, settings); + if (ret != GP_OK) { + gp_context_error (context, _("Could not apply USB settings")); + return ret; + } + /* Set up the filesystem */ + gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); + /* test camera */ + return stv0674_ping(camera->port); } diff --git a/camlibs/stv0680/sharpen.c b/camlibs/stv0680/sharpen.c index 333386747a..680210559a 100644 --- a/camlibs/stv0680/sharpen.c +++ b/camlibs/stv0680/sharpen.c @@ -38,84 +38,84 @@ #define new(ctype, ccount) calloc(ccount, sizeof(ctype)) static void -compute_luts (int sharpen_percent, int *pos_lut, int *neg_lut ) +compute_luts (int sharpen_percent, int *pos_lut, int *neg_lut) { - int i; /* Looping var */ - int fact; /* 1 - sharpness */ - - fact = 100 - sharpen_percent; - if (fact < 1) - fact = 1; - - for (i = 0; i < 256; i ++) - { - pos_lut[i] = (800 * i) / fact; - neg_lut[i] = (4 + pos_lut[i] - (i << 3)) >> 3; - }; + int i; /* Looping var */ + int fact; /* 1 - sharpness */ + + fact = 100 - sharpen_percent; + if (fact < 1) + fact = 1; + + for (i = 0; i < 256; i++) + { + pos_lut[i] = (800 * i) / fact; + neg_lut[i] = (4 + pos_lut[i] - (i << 3)) >> 3; + }; } /** 'rgb_filter()' - Sharpen RGB pixels. **/ static void rgb_filter (int width, /* I - Width of line in pixels */ - int *pos_lut, - int *neg_lut, - unsigned char *src, /* I - Source line */ - unsigned char *dst, /* O - Destination line */ - long int *neg0, /* I - Top negative coefficient line */ - long int *neg1, /* I - Middle negative coefficient line */ - long int *neg2) /* I - Bottom negative coefficient line */ + int *pos_lut, + int *neg_lut, + unsigned char *src, /* I - Source line */ + unsigned char *dst, /* O - Destination line */ + long int *neg0, /* I - Top negative coefficient line */ + long int *neg1, /* I - Middle negative coefficient line */ + long int *neg2) /* I - Bottom negative coefficient line */ { - long int pixel; /* New pixel value */ - - *dst++ = *src++; - *dst++ = *src++; - *dst++ = *src++; - width -= 2; - - while (width > 0) - { - pixel = (pos_lut[*src++] - neg0[-3] - neg0[0] - neg0[3] - - neg1[-3] - neg1[3] - - neg2[-3] - neg2[0] - neg2[3]); - pixel = (pixel + 4) >> 3; - if (pixel < 0) - *dst++ = 0; - else if (pixel < 255) - *dst++ = pixel; - else - *dst++ = 255; - - pixel = (pos_lut[*src++] - neg0[-2] - neg0[1] - neg0[4] - - neg1[-2] - neg1[4] - - neg2[-2] - neg2[1] - neg2[4]); - pixel = (pixel + 4) >> 3; - if (pixel < 0) - *dst++ = 0; - else if (pixel < 255) - *dst++ = pixel; - else - *dst++ = 255; - - pixel = (pos_lut[*src++] - neg0[-1] - neg0[2] - neg0[5] - - neg1[-1] - neg1[5] - - neg2[-1] - neg2[2] - neg2[5]); - pixel = (pixel + 4) >> 3; - if (pixel < 0) - *dst++ = 0; - else if (pixel < 255) - *dst++ = pixel; - else - *dst++ = 255; - - neg0 += 3; - neg1 += 3; - neg2 += 3; - width --; - }; - - *dst++ = *src++; - *dst++ = *src++; - *dst++ = *src++; + long int pixel; /* New pixel value */ + + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; + width -= 2; + + while (width > 0) + { + pixel = (pos_lut[*src++] - neg0[-3] - neg0[0] - neg0[3] - + neg1[-3] - neg1[3] - + neg2[-3] - neg2[0] - neg2[3]); + pixel = (pixel + 4) >> 3; + if (pixel < 0) + *dst++ = 0; + else if (pixel < 255) + *dst++ = pixel; + else + *dst++ = 255; + + pixel = (pos_lut[*src++] - neg0[-2] - neg0[1] - neg0[4] - + neg1[-2] - neg1[4] - + neg2[-2] - neg2[1] - neg2[4]); + pixel = (pixel + 4) >> 3; + if (pixel < 0) + *dst++ = 0; + else if (pixel < 255) + *dst++ = pixel; + else + *dst++ = 255; + + pixel = (pos_lut[*src++] - neg0[-1] - neg0[2] - neg0[5] - + neg1[-1] - neg1[5] - + neg2[-1] - neg2[2] - neg2[5]); + pixel = (pixel + 4) >> 3; + if (pixel < 0) + *dst++ = 0; + else if (pixel < 255) + *dst++ = pixel; + else + *dst++ = 255; + + neg0 += 3; + neg1 += 3; + neg2 += 3; + width--; + }; + + *dst++ = *src++; + *dst++ = *src++; + *dst++ = *src++; } /** 'sharpen()' - Sharpen an image using a convolution filter. **/ @@ -123,94 +123,92 @@ void sharpen(int width, int height, unsigned char *src_region, unsigned char *dest_region, int sharpen_percent ) { - unsigned char *src_rows[4], /* Source pixel rows */ - *src_ptr, /* Current source pixel */ - *dst_row; /* Destination pixel row */ - long int *neg_rows[4], /* Negative coefficient rows */ + unsigned char *src_rows[4], /* Source pixel rows */ + *src_ptr, /* Current source pixel */ + *dst_row; /* Destination pixel row */ + long int *neg_rows[4], /* Negative coefficient rows */ *neg_ptr; /* Current negative coefficient */ - int i, /* Looping vars */ + int i, /* Looping vars */ y, /* Current location in image */ row, /* Current row in src_rows */ count, /* Current number of filled src_rows */ pitch; /* Byte width of the image */ - int img_bpp=3; /* Bytes-per-pixel in image */ - int neg_lut[256]; /* Negative coefficient LUT */ - int pos_lut[256]; /* Positive coefficient LUT */ - - compute_luts (sharpen_percent,pos_lut,neg_lut); - pitch = width * img_bpp; - - for (row = 0; row < 4; row ++) - { - src_rows[row] = new (unsigned char, pitch); - neg_rows[row] = new (long int, pitch); - } + int img_bpp=3; /* Bytes-per-pixel in image */ + int neg_lut[256]; /* Negative coefficient LUT */ + int pos_lut[256]; /* Positive coefficient LUT */ - dst_row = new (unsigned char, pitch); + compute_luts (sharpen_percent, pos_lut, neg_lut); + pitch = width * img_bpp; - /** Pre-load the first row for the filter... **/ - memcpy(src_rows[0], src_region, pitch); + for (row = 0; row < 4; row++) + { + src_rows[row] = new (unsigned char, pitch); + neg_rows[row] = new (long int, pitch); + } - for (i = pitch, src_ptr = src_rows[0], neg_ptr = neg_rows[0]; - i > 0; i --, src_ptr ++, neg_ptr ++) - *neg_ptr = neg_lut[*src_ptr]; + dst_row = new (unsigned char, pitch); - row = 1; - count = 1; + /** Pre-load the first row for the filter... **/ + memcpy(src_rows[0], src_region, pitch); - /** Sharpen... **/ + for (i = pitch, src_ptr = src_rows[0], neg_ptr = neg_rows[0]; + i > 0; i--, src_ptr++, neg_ptr++) + *neg_ptr = neg_lut[*src_ptr]; - for (y = 0; y < height; y ++) - { - /** Load the next pixel row... **/ - if ((y + 1) < height) - { - /** Check to see if our src_rows[] array is overflowing yet... **/ - if (count >= 3) - count --; - - /** Grab the next row... **/ - memcpy(src_rows[row], (src_region + pitch*(y+1)), pitch); - - for (i = pitch, src_ptr = src_rows[row], neg_ptr = neg_rows[row]; - i > 0; i --, src_ptr ++, neg_ptr ++) - *neg_ptr = neg_lut[*src_ptr]; - count ++; - row = (row + 1) & 3; - } - else - { - /** No more pixels at the bottom... Drop the oldest samples... **/ - count --; - } + row = 1; + count = 1; - /** Now sharpen pixels and save the results... **/ + /** Sharpen... **/ - if (count == 3) + for (y = 0; y < height; y++) { - rgb_filter(width, pos_lut, neg_lut, - src_rows[(row + 2) & 3], dst_row, - neg_rows[(row + 1) & 3] + img_bpp, - neg_rows[(row + 2) & 3] + img_bpp, - neg_rows[(row + 3) & 3] + img_bpp); - - /** Set the row... **/ - memcpy((dest_region + pitch*y), dst_row, pitch); - } - else if (count == 2) + /** Load the next pixel row... **/ + if ((y + 1) < height) + { + /** Check to see if our src_rows[] array is overflowing yet... **/ + if (count >= 3) + count--; + + /** Grab the next row... **/ + memcpy(src_rows[row], (src_region + pitch*(y+1)), pitch); + + for (i = pitch, src_ptr = src_rows[row], neg_ptr = neg_rows[row]; + i > 0; i--, src_ptr++, neg_ptr++) + *neg_ptr = neg_lut[*src_ptr]; + count++; + row = (row + 1) & 3; + } else + { + /** No more pixels at the bottom... Drop the oldest samples... **/ + count--; + } + + /** Now sharpen pixels and save the results... **/ + + if (count == 3) + { + rgb_filter(width, pos_lut, neg_lut, + src_rows[(row + 2) & 3], dst_row, + neg_rows[(row + 1) & 3] + img_bpp, + neg_rows[(row + 2) & 3] + img_bpp, + neg_rows[(row + 3) & 3] + img_bpp); + + /** Set the row... **/ + memcpy((dest_region + pitch*y), dst_row, pitch); + } else if (count == 2) + { + if (y == 0) /* first row */ + memcpy((dest_region), src_rows[0], pitch); + else /* last row */ + memcpy((dest_region + pitch*(y)), src_rows[(height-1)&3], pitch); + } + } /* for */ + + /** OK, we're done. Free all memory used... **/ + for (row = 0; row < 4; row++) { - if (y == 0) /* first row */ - memcpy((dest_region), src_rows[0], pitch); - else /* last row */ - memcpy((dest_region + pitch*(y)), src_rows[(height-1)&3], pitch); + free (src_rows[row]); + free (neg_rows[row]); } - } /* for */ - - /** OK, we're done. Free all memory used... **/ - for (row = 0; row < 4; row ++) - { - free (src_rows[row]); - free (neg_rows[row]); - } - free (dst_row); + free (dst_row); } diff --git a/camlibs/stv0680/stv0680-bayer.c b/camlibs/stv0680/stv0680-bayer.c index fed5322c34..5125bebde2 100644 --- a/camlibs/stv0680/stv0680-bayer.c +++ b/camlibs/stv0680/stv0680-bayer.c @@ -28,26 +28,26 @@ void bayer_unshuffle_preview(unsigned int w, unsigned int h, unsigned int scale, unsigned char *raw, unsigned char *output) { - int x, y, nx, ny; - int colour; int rgb[3]; - int nw = w >> scale; - int nh = h >> scale; - int incr = 1<>1) + ((x&1)? 0: (w>>1))]; + int x, y, nx, ny; + int colour; int rgb[3]; + int nw = w >> scale; + int nh = h >> scale; + int incr = 1<>1) + ((x&1) ? 0 : (w>>1))]; + } + } + output[0] = rgb[0]>>(2*scale-2); + output[1] = rgb[1]>>(2*scale-1); + output[2] = rgb[2]>>(2*scale-2); } - } - output[0] = rgb[0]>>(2*scale-2); - output[1] = rgb[1]>>(2*scale-1); - output[2] = rgb[2]>>(2*scale-2); } - } } /****** gamma correction from trans[], plus hardcoded white balance */ @@ -100,100 +100,100 @@ static const rgbgamma gampar[6][3] = { void light_enhance(unsigned int vw, unsigned int vh, unsigned int coarse, unsigned int fine, unsigned char avg_pix, unsigned char *output) { - unsigned long int i; - int lt=3; /* 3 is auto */ - /* float wb[3][3]; */ - unsigned char trans[3][256]; - unsigned char col; - /* int tmp1, tmp2, tmp3, whitex=20, whitey=20, j, k; */ + unsigned long int i; + int lt=3; /* 3 is auto */ + /* float wb[3][3]; */ + unsigned char trans[3][256]; + unsigned char col; + /* int tmp1, tmp2, tmp3, whitex=20, whitey=20, j, k; */ - double brightness = 1.00; /* FIXME: configurable? */ + double brightness = 1.00; /* FIXME: configurable? */ - /* fprintf(stderr, "(FineExp=%i CoarseExp=%i => filter=", fine, coarse); */ + /* fprintf(stderr, "(FineExp=%i CoarseExp=%i => filter=", fine, coarse); */ #if 0 - if (fine >= (coarse<<1)) { - lt = 0; - /* fprintf(stderr, "natural)\n"); */ - } else if (((fine<<1) < coarse) && (coarse < 400)) { - lt = 2; - /* fprintf(stderr, "incandescent)\n"); */ - } else { - lt = 1; - /* fprintf(stderr, "fluorescent)\n"); */ - } - wb[0][0] = 1.08 * x; wb[0][1] = 1.00 * x; wb[0][2] = 0.95 * x; /* natural */ - wb[1][0] = 1.00 * x; wb[1][1] = 1.00 * x; wb[1][2] = 1.00 * x; /* fluorescent */ - wb[2][0] = 0.90 * x; wb[2][1] = 1.00 * x; wb[2][2] = 1.11 * x; /* incandescent */ + if (fine >= (coarse<<1)) { + lt = 0; + /* fprintf(stderr, "natural)\n"); */ + } else if (((fine<<1) < coarse) && (coarse < 400)) { + lt = 2; + /* fprintf(stderr, "incandescent)\n"); */ + } else { + lt = 1; + /* fprintf(stderr, "fluorescent)\n"); */ + } + wb[0][0] = 1.08 * x; wb[0][1] = 1.00 * x; wb[0][2] = 0.95 * x; /* natural */ + wb[1][0] = 1.00 * x; wb[1][1] = 1.00 * x; wb[1][2] = 1.00 * x; /* fluorescent */ + wb[2][0] = 0.90 * x; wb[2][1] = 1.00 * x; wb[2][2] = 1.11 * x; /* incandescent */ #else - if (fine > coarse) { - lt = 0; /* fprintf (stderr, "cold)\n"); */ - } else if (coarse < 100) { - lt = 1; /* fprintf (stderr, "coldish)\n"); */ - } else if (coarse < 200) { - lt = 2; /* fprintf (stderr, "mid)\n"); */ - } else if (coarse < 400) { - lt = 3; /* fprintf (stderr, "warmish)\n"); */ - } else if (avg_pix < 94) { - lt = 4; /* fprintf (stderr, "warm)\n"); */ - } else { - lt = 5; /* fprintf (stderr, "warm, bright)\n"); */ - } + if (fine > coarse) { + lt = 0; /* fprintf (stderr, "cold)\n"); */ + } else if (coarse < 100) { + lt = 1; /* fprintf (stderr, "coldish)\n"); */ + } else if (coarse < 200) { + lt = 2; /* fprintf (stderr, "mid)\n"); */ + } else if (coarse < 400) { + lt = 3; /* fprintf (stderr, "warmish)\n"); */ + } else if (avg_pix < 94) { + lt = 4; /* fprintf (stderr, "warm)\n"); */ + } else { + lt = 5; /* fprintf (stderr, "warm, bright)\n"); */ + } #endif #if 0 - /* find white pixel */ - for (j=0;j=160)) { - whitex = k; whitey = j; - break; - } + for (k=0; k=160)) { + whitex = k; whitey = j; + break; + } + } } - } #endif - for (col = 0; col < 3; col++) { - double y; - const rgbgamma *gp = gampar[lt] + col; - for(i=0; i<256; ++i) { - if (i < ZERO0) - y = 0; - else if (i < ZERO1) - y = 1; - else - y = brightness * gp->ampl * (2 + pow((i-ZERO1)/((double)254-ZERO1),gp->gamma) * 253.5); - if (y > 255.0) - y = 255.0; - trans[col][i] = (unsigned char) y; - } - } - - for (i=0;i<(vw*vh*3);i+=3) - { - int r,g,b; - r = *(output+i); - g = *(output+i+1); - b = *(output+i+2); - /* this (adjusting white) isn't quite right yet, so I turned it off */ - if ( 0 && (abs(r-g) < 8) && - (abs(r-b) < 8) && - (abs(b-g) < 8)) { - int v = trans[1][(r+b+g+1)/3]; - *(output+i) = (unsigned char) (v); - *(output+i+1) = (unsigned char) (v); - *(output+i+2) = (unsigned char) (v); - fprintf(stderr,"Adjusting white\n"); - } else { /* this is OK */ - *(output+i) = trans[0][r]; - *(output+i+1) = trans[1][g]; - *(output+i+2) = trans[2][b]; + for (col = 0; col < 3; col++) { + double y; + const rgbgamma *gp = gampar[lt] + col; + for (i=0; i<256; ++i) { + if (i < ZERO0) + y = 0; + else if (i < ZERO1) + y = 1; + else + y = brightness * gp->ampl * (2 + pow((i-ZERO1)/((double)254-ZERO1), gp->gamma) * 253.5); + if (y > 255.0) + y = 255.0; + trans[col][i] = (unsigned char)y; + } } - } /* for */ + + for (i=0;i<(vw*vh*3);i+=3) + { + int r, g, b; + r = *(output+i); + g = *(output+i+1); + b = *(output+i+2); + /* this (adjusting white) isn't quite right yet, so I turned it off */ + if (0 && (abs(r-g) < 8) && + (abs(r-b) < 8) && + (abs(b-g) < 8)) { + int v = trans[1][(r+b+g+1)/3]; + *(output+i) = (unsigned char)(v); + *(output+i+1) = (unsigned char)(v); + *(output+i+2) = (unsigned char)(v); + fprintf(stderr, "Adjusting white\n"); + } else { /* this is OK */ + *(output+i) = trans[0][r]; + *(output+i+1) = trans[1][g]; + *(output+i+2) = trans[2][b]; + } + } /* for */ } /* light_enhance */ diff --git a/camlibs/stv0680/stv0680.c b/camlibs/stv0680/stv0680.c index c495b81e27..1a2fbbbabb 100644 --- a/camlibs/stv0680/stv0680.c +++ b/camlibs/stv0680/stv0680.c @@ -41,7 +41,7 @@ static const struct camera_to_usb { unsigned short idProduct; int serial; } camera_to_usb[] = { - /* http://www.vvl.co.uk/products/co-processors/680/680.htm */ + /* http://www.vvl.co.uk/products/co-processors/680/680.htm */ { "STM:USB Dual-mode camera", 0x0553, 0x0202, 1 }, { "STV0680", 0x0553, 0x0202, 1 }, @@ -270,61 +270,59 @@ static int delete_all_func (CameraFilesystem *fs, const char* folder, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; if (strcmp (folder, "/")) return (GP_ERROR_DIRECTORY_NOT_FOUND); return stv0680_delete_all(camera->port); } static int -storage_info_func (CameraFilesystem *fs, - CameraStorageInformation **sinfos, - int *nrofsinfos, - void *data, GPContext *context -) { - Camera *camera = (Camera*)data; - GPPort *port = camera->port; - struct stv680_camera_info caminfo; - struct stv680_image_info imginfo; - int ret; - CameraStorageInformation *sinfo; - - /* Get Camera Information */ - if ((ret = stv0680_try_cmd(port, CMDID_GET_CAMERA_INFO, - 0, (void*)&caminfo, sizeof(caminfo)) < 0)) - return ret; - - sinfo = malloc(sizeof(CameraStorageInformation)); - if (!sinfo) return GP_ERROR_NO_MEMORY; - - *sinfos = sinfo; - *nrofsinfos = 1; - - sinfo->fields = GP_STORAGEINFO_BASE; - strcpy(sinfo->basedir, "/"); - - sinfo->fields |= GP_STORAGEINFO_ACCESS; - sinfo->access = GP_STORAGEINFO_AC_READONLY_WITH_DELETE; - sinfo->fields |= GP_STORAGEINFO_STORAGETYPE; - sinfo->type = GP_STORAGEINFO_ST_FIXED_RAM; - sinfo->fields |= GP_STORAGEINFO_FILESYSTEMTYPE; - sinfo->fstype = GP_STORAGEINFO_FST_GENERICFLAT; - - sinfo->fields |= GP_STORAGEINFO_MAXCAPACITY; - if (caminfo.hardware_config & HWCONFIG_MEMSIZE_16MBIT) - sinfo->capacitykbytes = 16*1024/8; - else - sinfo->capacitykbytes = 64*1024/8; - - if ((ret = stv0680_try_cmd(port, CMDID_GET_IMAGE_INFO, 0, - (void*)&imginfo, sizeof(imginfo))!=GP_OK)) - return ret; - - sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES; - sinfo->freeimages = - ((imginfo.maximages[0]<<8)|imginfo.maximages[1]) - - ((imginfo.index[0]<<8)|imginfo.index[1]); - return GP_OK; +storage_info_func (CameraFilesystem *fs, CameraStorageInformation **sinfos, + int *nrofsinfos, void *data, GPContext *context) +{ + Camera *camera = (Camera*)data; + GPPort *port = camera->port; + struct stv680_camera_info caminfo; + struct stv680_image_info imginfo; + int ret; + CameraStorageInformation *sinfo; + + /* Get Camera Information */ + if ((ret = stv0680_try_cmd(port, CMDID_GET_CAMERA_INFO, + 0, (void*)&caminfo, sizeof(caminfo)) < 0)) + return ret; + + sinfo = malloc(sizeof(CameraStorageInformation)); + if (!sinfo) return GP_ERROR_NO_MEMORY; + + *sinfos = sinfo; + *nrofsinfos = 1; + + sinfo->fields = GP_STORAGEINFO_BASE; + strcpy(sinfo->basedir, "/"); + + sinfo->fields |= GP_STORAGEINFO_ACCESS; + sinfo->access = GP_STORAGEINFO_AC_READONLY_WITH_DELETE; + sinfo->fields |= GP_STORAGEINFO_STORAGETYPE; + sinfo->type = GP_STORAGEINFO_ST_FIXED_RAM; + sinfo->fields |= GP_STORAGEINFO_FILESYSTEMTYPE; + sinfo->fstype = GP_STORAGEINFO_FST_GENERICFLAT; + + sinfo->fields |= GP_STORAGEINFO_MAXCAPACITY; + if (caminfo.hardware_config & HWCONFIG_MEMSIZE_16MBIT) + sinfo->capacitykbytes = 16*1024/8; + else + sinfo->capacitykbytes = 64*1024/8; + + if ((ret = stv0680_try_cmd(port, CMDID_GET_IMAGE_INFO, 0, + (void*)&imginfo, sizeof(imginfo))!=GP_OK)) + return ret; + + sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES; + sinfo->freeimages = + ((imginfo.maximages[0]<<8)|imginfo.maximages[1]) - + ((imginfo.index[0]<<8)|imginfo.index[1]); + return GP_OK; } @@ -339,20 +337,20 @@ int camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; - /* First, set up all the function pointers */ - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; camera->functions->capture_preview = camera_capture_preview; camera->functions->capture = camera_capture; gp_port_get_settings(camera->port, &settings); switch(camera->port->type) { case GP_PORT_SERIAL: - gp_port_set_timeout(camera->port, 1000); + gp_port_set_timeout(camera->port, 1000); settings.serial.speed = 115200; - settings.serial.bits = 8; - settings.serial.parity = 0; - settings.serial.stopbits = 1; + settings.serial.bits = 8; + settings.serial.parity = 0; + settings.serial.stopbits = 1; break; case GP_PORT_USB: /* Use the defaults the core parsed */ @@ -366,6 +364,6 @@ int camera_init (Camera *camera, GPContext *context) /* Set up the filesystem */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); - /* test camera */ - return stv0680_ping(camera->port); + /* test camera */ + return stv0680_ping(camera->port); } diff --git a/camlibs/stv0680/stv0680.h b/camlibs/stv0680/stv0680.h index 9955a1a574..92cd377fdd 100644 --- a/camlibs/stv0680/stv0680.h +++ b/camlibs/stv0680/stv0680.h @@ -167,8 +167,8 @@ struct stv680_user_info { #define STV0680_VGA_HEIGHT 484 int stv0680_try_cmd(GPPort *port, unsigned char cmd, - unsigned short data, - unsigned char *response, unsigned char response_len); + unsigned short data, + unsigned char *response, unsigned char response_len); #endif /* !defined(CAMLIBS_STV0680_STV0680_H) */ diff --git a/camlibs/sx330z/library.c b/camlibs/sx330z/library.c index 95b5ac4634..e4c9228f98 100644 --- a/camlibs/sx330z/library.c +++ b/camlibs/sx330z/library.c @@ -50,23 +50,23 @@ static const struct { - char *model; - int usb_vendor; - int usb_product; + char *model; + int usb_vendor; + int usb_product; } models[]= { - {"Traveler:SX330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, - {"Maginon:SX330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, - {"Skanhex:SX-330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, - {"Medion:MD 9700",USB_VENDOR_TRAVELER,USB_PRODUCT_MD9700}, - {"Jenoptik:JD-3300z3",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, - - {"Traveler:SX410z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, - {"Concord:EyeQ 4330",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, - {"Jenoptik:JD-4100z3",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, - {"Medion:MD 6000",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, - {"Maginon SX-410z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, - {"Lifetec:LT 5995",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, - {NULL,0,0} + {"Traveler:SX330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, + {"Maginon:SX330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, + {"Skanhex:SX-330z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, + {"Medion:MD 9700",USB_VENDOR_TRAVELER,USB_PRODUCT_MD9700}, + {"Jenoptik:JD-3300z3",USB_VENDOR_TRAVELER,USB_PRODUCT_SX330Z}, + + {"Traveler:SX410z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, + {"Concord:EyeQ 4330",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, + {"Jenoptik:JD-4100z3",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, + {"Medion:MD 6000",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, + {"Maginon SX-410z",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, + {"Lifetec:LT 5995",USB_VENDOR_TRAVELER,USB_PRODUCT_SX410Z}, + {NULL,0,0} }; @@ -76,25 +76,25 @@ static const struct int camera_abilities (CameraAbilitiesList *list) { - int i; - CameraAbilities a; - for(i=0;models[i].model;i++) - { - memset(&a,0,sizeof(CameraAbilities)); - strcpy(a.model,models[i].model); - a.usb_vendor = models[i].usb_vendor; - a.usb_product = models[i].usb_product; - a.status = GP_DRIVER_STATUS_EXPERIMENTAL; - a.port = GP_PORT_USB; - a.speed[0] = 0; - a.operations = GP_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_PREVIEW| - GP_FILE_OPERATION_DELETE| - GP_FILE_OPERATION_EXIF; - a.folder_operations = GP_FOLDER_OPERATION_NONE; - CR(gp_abilities_list_append(list,a)); - } /* all models... */ - return(GP_OK); + int i; + CameraAbilities a; + for (i=0;models[i].model;i++) + { + memset(&a, 0, sizeof(CameraAbilities)); + strcpy(a.model, models[i].model); + a.usb_vendor = models[i].usb_vendor; + a.usb_product = models[i].usb_product; + a.status = GP_DRIVER_STATUS_EXPERIMENTAL; + a.port = GP_PORT_USB; + a.speed[0] = 0; + a.operations = GP_OPERATION_NONE; + a.file_operations = GP_FILE_OPERATION_PREVIEW| + GP_FILE_OPERATION_DELETE| + GP_FILE_OPERATION_EXIF; + a.folder_operations = GP_FOLDER_OPERATION_NONE; + CR(gp_abilities_list_append(list, a)); + } /* all models... */ + return(GP_OK); } /* camera_abilities */ @@ -190,14 +190,14 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, * Delete file function (working ..) */ static int -del_file_func(CameraFilesystem *fs,const char *folder,const char *filename, - void *user_data,GPContext *context) +del_file_func(CameraFilesystem *fs, const char *folder, const char *filename, + void *user_data, GPContext *context) { - Camera *camera=user_data; - /*int id;*/ - if (strcmp(folder,"/")) return(GP_ERROR_DIRECTORY_NOT_FOUND); - GP_DEBUG("Deleting : %s",filename); - return(sx330z_delete_file(camera,context,filename)); + Camera *camera=user_data; + /*int id;*/ + if (strcmp(folder, "/")) return(GP_ERROR_DIRECTORY_NOT_FOUND); + GP_DEBUG("Deleting : %s", filename); + return(sx330z_delete_file(camera, context, filename)); } /* delete file func */ @@ -207,24 +207,21 @@ del_file_func(CameraFilesystem *fs,const char *folder,const char *filename, int camera_id(CameraText *id) { - strcpy(id->text,"Traveler SX330z"); - return (GP_OK); + strcpy(id->text, "Traveler SX330z"); + return (GP_OK); } /* camera id */ - - - /* * Camera about */ static int -camera_about(Camera *camera,CameraText *about,GPContext *context) +camera_about(Camera *camera, CameraText *about, GPContext *context) { - strcpy(about->text,_("(Traveler) SX330z Library (And other Aldi-cams).\n" - "Even other Vendors like Jenoptik, Skanhex, Maginon should work.\n" - "Please send bugreports and comments.\n" - "Dominik Kuhlen \n")); - return(GP_OK); + strcpy(about->text, _("(Traveler) SX330z Library (And other Aldi-cams).\n" + "Even other Vendors like Jenoptik, Skanhex, Maginon should work.\n" + "Please send bugreports and comments.\n" + "Dominik Kuhlen \n")); + return(GP_OK); } /* camera about */ @@ -235,9 +232,9 @@ camera_about(Camera *camera,CameraText *about,GPContext *context) int camera_exit(Camera *camera, GPContext *context) { - if (camera->pl) - free(camera->pl); - return(GP_OK); + if (camera->pl) + free(camera->pl); + return(GP_OK); } @@ -251,35 +248,35 @@ static CameraFilesystemFuncs fsfuncs = { * OK, lets get serious ! */ int -camera_init(Camera *camera,GPContext *context) +camera_init(Camera *camera, GPContext *context) { - GPPortSettings settings; - CameraAbilities abilities; - /* try to contact the camera ...*/ - /*CR(gp_port_get_settings(camera->port,&settings));*/ - - camera->functions->about=camera_about; - camera->functions->exit=camera_exit; - gp_port_get_settings(camera->port,&settings); - if (camera->port->type!=GP_PORT_USB) - { - gp_context_error(context,_("sx330z is USB only")); - return(GP_ERROR_UNKNOWN_PORT); - } -/* GP_DEBUG("camera_init : in = %x",camera->port->settings.usb.inep);*/ - CR(gp_port_set_settings(camera->port,settings)); - CR(gp_port_set_timeout(camera->port,TIMEOUT)); - - CR(gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera)); - - camera->pl=malloc(sizeof(CameraPrivateLibrary)); - if (!camera->pl) - return(GP_ERROR_NO_MEMORY); - - CR(gp_camera_get_abilities(camera, &abilities)); - camera->pl->usb_product=abilities.usb_product; /* some models differ in Thumbnail size */ -/* GP_DEBUG("sx330z Camera_init : sx init %04x",camera->pl->usb_product); */ - return(sx330z_init(camera,context)); + GPPortSettings settings; + CameraAbilities abilities; + /* try to contact the camera ...*/ + /*CR(gp_port_get_settings(camera->port,&settings));*/ + + camera->functions->about=camera_about; + camera->functions->exit=camera_exit; + gp_port_get_settings(camera->port, &settings); + if (camera->port->type!=GP_PORT_USB) + { + gp_context_error(context, _("sx330z is USB only")); + return(GP_ERROR_UNKNOWN_PORT); + } + /* GP_DEBUG("camera_init : in = %x",camera->port->settings.usb.inep);*/ + CR(gp_port_set_settings(camera->port, settings)); + CR(gp_port_set_timeout(camera->port, TIMEOUT)); + + CR(gp_filesystem_set_funcs(camera->fs, &fsfuncs, camera)); + + camera->pl=malloc(sizeof(CameraPrivateLibrary)); + if (!camera->pl) + return(GP_ERROR_NO_MEMORY); + + CR(gp_camera_get_abilities(camera, &abilities)); + camera->pl->usb_product=abilities.usb_product; /* some models differ in Thumbnail size */ + /* GP_DEBUG("sx330z Camera_init : sx init %04x",camera->pl->usb_product); */ + return(sx330z_init(camera, context)); } /* camera init */ diff --git a/camlibs/template/template.c b/camlibs/template/template.c index d3caae51d2..c55f7f37ed 100644 --- a/camlibs/template/template.c +++ b/camlibs/template/template.c @@ -503,15 +503,15 @@ CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->get_config = camera_config_get; - camera->functions->set_config = camera_config_set; - camera->functions->capture = camera_capture; - camera->functions->capture_preview = camera_capture_preview; - camera->functions->summary = camera_summary; - camera->functions->manual = camera_manual; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->get_config = camera_config_get; + camera->functions->set_config = camera_config_set; + camera->functions->capture = camera_capture; + camera->functions->capture_preview = camera_capture_preview; + camera->functions->summary = camera_summary; + camera->functions->manual = camera_manual; + camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); diff --git a/camlibs/topfield/crc16.c b/camlibs/topfield/crc16.c index 8668c29194..7b0eba6657 100644 --- a/camlibs/topfield/crc16.c +++ b/camlibs/topfield/crc16.c @@ -27,49 +27,49 @@ #include "crc16.h" static unsigned short crc_16_table[256] = { - 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, - 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, - 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, - 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, - 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, - 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, - 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, - 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, - 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, - 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, - 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, - 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, - 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, - 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, - 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, - 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, - 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, - 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, - 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, - 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, - 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, - 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, - 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, - 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, - 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, - 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, - 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, - 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, - 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, - 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, - 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, - 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040 + 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, + 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, + 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, + 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, + 0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40, + 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41, + 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, + 0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040, + 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240, + 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, + 0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41, + 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840, + 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, + 0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40, + 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640, + 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, + 0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240, + 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441, + 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, + 0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840, + 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41, + 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, + 0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640, + 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041, + 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, + 0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440, + 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40, + 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, + 0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40, + 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41, + 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, + 0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040 }; unsigned short crc16_ansi(const void *data, size_t size) { - unsigned short crc = 0; - const unsigned char *d = data; + unsigned short crc = 0; + const unsigned char *d = data; - while(size--) - { - crc = crc_16_table[(crc ^ *d++) & 0xff] ^ (crc >> 8); - } + while (size--) + { + crc = crc_16_table[(crc ^ *d++) & 0xff] ^ (crc >> 8); + } - return crc; + return crc; } diff --git a/camlibs/topfield/puppy.c b/camlibs/topfield/puppy.c index 04892a0032..c9244172bc 100644 --- a/camlibs/topfield/puppy.c +++ b/camlibs/topfield/puppy.c @@ -238,7 +238,7 @@ do_cmd_turbo(Camera *camera, char *state, GPContext *context) char buf[1024]; /* check if we want to use turbo mode. Default is YES */ - if (GP_OK == gp_setting_get("topfield","turbo", buf)) + if (GP_OK == gp_setting_get("topfield","turbo", buf)) if (!strcmp(buf,"no")) return GP_OK; @@ -391,12 +391,12 @@ decode_dir(Camera *camera, struct tf_packet *p, int listdirs, CameraList *list) } #if 0 - /* This makes the assumption that the timezone of the Toppy and the system - * that puppy runs on are the same. Given the limitations on the length of - * USB cables, this condition is likely to be satisfied. */ - timestamp = tfdt_to_time(&entries[i].stamp); - printf("%c %20llu %24.24s %s\n", type, get_u64(&entries[i].size), - ctime(×tamp), entries[i].name); + /* This makes the assumption that the timezone of the Toppy and the system + * that puppy runs on are the same. Given the limitations on the length of + * USB cables, this condition is likely to be satisfied. */ + timestamp = tfdt_to_time(&entries[i].stamp); + printf("%c %20llu %24.24s %s\n", type, get_u64(&entries[i].size), + ctime(×tamp), entries[i].name); #endif } } @@ -440,12 +440,12 @@ decode_and_get_info(Camera *camera, const char *folder, struct tf_packet *p, con break; } #if 0 - /* This makes the assumption that the timezone of the Toppy and the system - * that puppy runs on are the same. Given the limitations on the length of - * USB cables, this condition is likely to be satisfied. */ - timestamp = tfdt_to_time(&entries[i].stamp); - printf("%c %20llu %24.24s %s\n", type, get_u64(&entries[i].size), - ctime(×tamp), entries[i].name); + /* This makes the assumption that the timezone of the Toppy and the system + * that puppy runs on are the same. Given the limitations on the length of + * USB cables, this condition is likely to be satisfied. */ + timestamp = tfdt_to_time(&entries[i].stamp); + printf("%c %20llu %24.24s %s\n", type, get_u64(&entries[i].size), + ctime(×tamp), entries[i].name); #endif } } @@ -482,71 +482,71 @@ do_hdd_rename(Camera *camera, char *srcPath, char *dstPath, GPContext *context) static void progressStats(uint64_t totalSize, uint64_t bytes, time_t startTime) { - int delta = time(NULL) - startTime; - - if(quiet) - return; - - if(delta > 0) - { - double rate = bytes / delta; - int eta = (totalSize - bytes) / rate; - - fprintf(stderr, - "\r%6.2f%%, %5.2f Mbits/s, %02d:%02d:%02d elapsed, %02d:%02d:%02d remaining", - 100.0 * ((double) (bytes) / (double) totalSize), - ((bytes * 8.0) / delta) / (1000 * 1000), delta / (60 * 60), - (delta / 60) % 60, delta % 60, eta / (60 * 60), - (eta / 60) % 60, eta % 60); - } + int delta = time(NULL) - startTime; + + if (quiet) + return; + + if (delta > 0) + { + double rate = bytes / delta; + int eta = (totalSize - bytes) / rate; + + fprintf(stderr, + "\r%6.2f%%, %5.2f Mbits/s, %02d:%02d:%02d elapsed, %02d:%02d:%02d remaining", + 100.0 * ((double)(bytes) / (double)totalSize), + ((bytes * 8.0) / delta) / (1000 * 1000), delta / (60 * 60), + (delta / 60) % 60, delta % 60, eta / (60 * 60), + (eta / 60) % 60, eta % 60); + } } static void finalStats(uint64_t bytes, time_t startTime) { - int delta = time(NULL) - startTime; + int delta = time(NULL) - startTime; - if(quiet) - return; + if (quiet) + return; - if(delta > 0) - { - fprintf(stderr, "\n%.2f Mbytes in %02d:%02d:%02d (%.2f Mbits/s)\n", - (double) bytes / (1000.0 * 1000.0), - delta / (60 * 60), (delta / 60) % 60, delta % 60, - ((bytes * 8.0) / delta) / (1000.0 * 1000.0)); - } + if (delta > 0) + { + fprintf(stderr, "\n%.2f Mbytes in %02d:%02d:%02d (%.2f Mbits/s)\n", + (double)bytes / (1000.0 * 1000.0), + delta / (60 * 60), (delta / 60) % 60, delta % 60, + ((bytes * 8.0) / delta) / (1000.0 * 1000.0)); + } } #endif static int camera_config_get (Camera *camera, CameraWidget **window, GPContext *context) { - CameraWidget *section, *turbo; + CameraWidget *section, *turbo; char buf[1024]; int val; - gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); - gp_widget_set_name (*window, "config"); + gp_widget_new (GP_WIDGET_WINDOW, _("Camera Configuration"), window); + gp_widget_set_name (*window, "config"); - gp_widget_new (GP_WIDGET_SECTION, _("Driver Settings"), §ion); + gp_widget_new (GP_WIDGET_SECTION, _("Driver Settings"), §ion); gp_widget_set_name (section, "driver"); - gp_widget_append (*window, section); + gp_widget_append (*window, section); gp_widget_new (GP_WIDGET_RADIO, _("Turbo mode"), &turbo); - gp_widget_set_name (turbo, "turbo"); - gp_widget_add_choice (turbo,_("On")); - gp_widget_add_choice (turbo,_("Off")); - gp_widget_append (section, turbo); + gp_widget_set_name (turbo, "turbo"); + gp_widget_add_choice (turbo, _("On")); + gp_widget_add_choice (turbo, _("Off")); + gp_widget_append (section, turbo); - if (GP_OK == gp_setting_get("topfield","turbo", buf)) { - if (!strcmp(buf,"no")) + if (GP_OK == gp_setting_get("topfield", "turbo", buf)) { + if (!strcmp(buf, "no")) val = 0; else val = 1; } else { val = 1; /* enabled by default */ } - gp_widget_set_value ( turbo, val?_("On"):_("Off")); + gp_widget_set_value (turbo, val ? _("On") : _("Off")); return GP_OK; } @@ -566,7 +566,7 @@ camera_config_set (Camera *camera, CameraWidget *window, GPContext *context) const char* val; int ival; - gp_widget_set_changed (turbo, FALSE); + gp_widget_set_changed (turbo, FALSE); ret = gp_widget_get_value (turbo, &val); if (ret == GP_OK) { ival = !strcmp (val, _("On")); @@ -1078,7 +1078,7 @@ storage_info_func (CameraFilesystem *fs, sif->access = GP_STORAGEINFO_AC_READWRITE; sif->fields |= GP_STORAGEINFO_FILESYSTEMTYPE; sif->fstype = GP_STORAGEINFO_FST_GENERICHIERARCHICAL; - sif->fields |= GP_STORAGEINFO_MAXCAPACITY; + sif->fields |= GP_STORAGEINFO_MAXCAPACITY; sif->capacitykbytes = totalk / 1024; sif->fields |= GP_STORAGEINFO_FREESPACEKBYTES; sif->freekbytes = freek / 1024; @@ -1101,7 +1101,7 @@ static int make_dir_func (CameraFilesystem *fs, const char *folder, const char *foldername, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; char *path = get_path (camera, folder, foldername); struct tf_packet reply; int r; diff --git a/camlibs/toshiba/pdrm11/library.c b/camlibs/toshiba/pdrm11/library.c index 142002a67f..9d7b25cbb1 100644 --- a/camlibs/toshiba/pdrm11/library.c +++ b/camlibs/toshiba/pdrm11/library.c @@ -129,9 +129,9 @@ static CameraFilesystemFuncs fsfuncs = { int camera_init (Camera *camera, GPContext *context) { - /* First, set up all the function pointers */ - camera->functions->exit = camera_exit; - camera->functions->about = camera_about; + /* First, set up all the function pointers */ + camera->functions->exit = camera_exit; + camera->functions->about = camera_about; /* Now, tell the filesystem where to get lists, files and info */ gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); return pdrm11_init(camera->port); diff --git a/camlibs/tp6801/library.c b/camlibs/tp6801/library.c index 6575c2f7ec..69e1024232 100644 --- a/camlibs/tp6801/library.c +++ b/camlibs/tp6801/library.c @@ -168,8 +168,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, CHECK (tp6801_read_raw_file (camera, idx, &raw)) gp_file_set_mime_type (file, GP_MIME_RAW); gp_file_set_name (file, filename); - gp_file_set_data_and_size (file, raw, - tp6801_filesize (camera)); + gp_file_set_data_and_size (file, raw, tp6801_filesize (camera)); return GP_OK; } @@ -398,8 +397,8 @@ storage_info_func (CameraFilesystem *fs, imagesize = tp6801_filesize (camera); if (imagesize) { - sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES; - sinfo->freeimages = free / imagesize; + sinfo->fields |= GP_STORAGEINFO_FREESPACEIMAGES; + sinfo->freeimages = free / imagesize; } return GP_OK; diff --git a/coverity-model.c b/coverity-model.c index a56e2739a3..b4638ff403 100644 --- a/coverity-model.c +++ b/coverity-model.c @@ -47,9 +47,10 @@ int gp_port_usb_msg_class_read (GPPort *port, int request, int value, int ind } int gp_port_send_scsi_cmd (GPPort *port, int to_dev, - char *cmd, int cmd_size, - char *sense, int sense_size, - char *data, int data_size) { + char *cmd, int cmd_size, + char *sense, int sense_size, + char *data, int data_size) +{ if (!to_dev) { __coverity_tainted_data_argument__(data); __coverity_tainted_data_argument__(sense); @@ -62,8 +63,8 @@ void gp_log_data (const char *domain, const char *data, unsigned int size, const uint16_t ptp_transaction (PTPParams* params, PTPContainer* ptp, - uint16_t flags, uint64_t sendlen, - unsigned char **data, unsigned int *recvlen) { + uint16_t flags, uint64_t sendlen, + unsigned char** data, unsigned int* recvlen) { if ((flags & 0xff) == 0x2) { __coverity_tainted_data_argument__(data); __coverity_tainted_data_argument__(recvlen); diff --git a/examples/sample-capture.c b/examples/sample-capture.c index e0d627b7c1..7f81a80f7b 100644 --- a/examples/sample-capture.c +++ b/examples/sample-capture.c @@ -23,9 +23,9 @@ #include "samples.h" -static void errordumper(GPLogLevel level, const char *domain, const char *str, - void *data) { - fprintf(stdout, "%s\n", str); +static void +errordumper(GPLogLevel level, const char *domain, const char *str, void *data) { + fprintf(stdout, "%s\n", str); } static void diff --git a/examples/sample-justfocus.c b/examples/sample-justfocus.c index 3b5b06beae..9021443eec 100644 --- a/examples/sample-justfocus.c +++ b/examples/sample-justfocus.c @@ -10,20 +10,20 @@ #include "samples.h" int main(int argc, char *argv[]){ - Camera *camera; - GPContext *context = gp_context_new(); - int retval; + Camera *camera; + GPContext *context = gp_context_new(); + int retval; CameraEventType evttype; void *evtdata; CameraFile *file; - gp_camera_new(&camera); + gp_camera_new(&camera); retval = gp_camera_init(camera, context); - if(retval != GP_OK) - { - printf("Error: %s\n", gp_result_as_string(retval)); - return 1; - } + if (retval != GP_OK) + { + printf("Error: %s\n", gp_result_as_string(retval)); + return 1; + } do { retval = gp_camera_wait_for_event (camera, 10, &evttype, &evtdata, context); @@ -41,23 +41,21 @@ int main(int argc, char *argv[]){ } gp_file_free (file); - if(argc == 1) - { - retval = camera_auto_focus(camera, context, 1); + if (argc == 1) + { + retval = camera_auto_focus(camera, context, 1); if(retval != GP_OK) { printf("Error: %s\n", gp_result_as_string(retval)); return 1; } - } - else if(argc == 2) - { - int value = atoi(argv[1]); - retval = camera_manual_focus(camera, value, context); - if(retval != GP_OK) { + } else if (argc == 2) { + int value = atoi(argv[1]); + retval = camera_manual_focus(camera, value, context); + if (retval != GP_OK) { printf("Error: %s\n", gp_result_as_string(retval)); return 1; } - } + } do { retval = gp_camera_wait_for_event (camera, 10, &evttype, &evtdata, context); } while ((retval == GP_OK) && (evttype != GP_EVENT_TIMEOUT)); @@ -68,6 +66,6 @@ int main(int argc, char *argv[]){ return 1; } - gp_camera_exit(camera, context); - return 0; + gp_camera_exit(camera, context); + return 0; } diff --git a/examples/sample-libfuzz.c b/examples/sample-libfuzz.c index f2aef159bf..2facde2b47 100644 --- a/examples/sample-libfuzz.c +++ b/examples/sample-libfuzz.c @@ -32,8 +32,7 @@ * */ -void errordumper(GPLogLevel level, const char *domain, const char *str, - void *data) { +void errordumper(GPLogLevel level, const char *domain, const char *str, void *data) { /* Do not log ... but let it appear here so we discover debug paths */ //fprintf(stderr, "%s:%s\n", domain, str); } @@ -173,7 +172,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { /*CameraFilePath path;*/ CameraList *list; - gp_log_add_func(GP_LOG_DEBUG, errordumper, NULL); + gp_log_add_func(GP_LOG_DEBUG, errordumper, NULL); if (!gpinfolist) { gp_port_info_list_new (&gpinfolist); diff --git a/examples/sample-multi-detect.c b/examples/sample-multi-detect.c index 4f82186376..55665fae4f 100644 --- a/examples/sample-multi-detect.c +++ b/examples/sample-multi-detect.c @@ -33,25 +33,25 @@ int main(int argc, char **argv) { /* Now open all cameras we autodected for usage */ printf("Number of cameras: %d\n", count); cams = calloc (count, sizeof (Camera*)); - for (i = 0; i < count; i++) { - gp_list_get_name (list, i, &name); - gp_list_get_value (list, i, &value); + for (i = 0; i < count; i++) { + gp_list_get_name (list, i, &name); + gp_list_get_value (list, i, &value); ret = sample_open_camera (&cams[i], name, value, context); - if (ret < GP_OK) fprintf(stderr,"Camera %s on port %s failed to open\n", name, value); - } + if (ret < GP_OK) fprintf(stderr, "Camera %s on port %s failed to open\n", name, value); + } /* Now call a simple function in each of those cameras. */ for (i = 0; i < count; i++) { CameraText text; char *owner; - ret = gp_camera_get_summary (cams[i], &text, context); + ret = gp_camera_get_summary (cams[i], &text, context); if (ret < GP_OK) { fprintf (stderr, "Failed to get summary.\n"); continue; } - gp_list_get_name (list, i, &name); - gp_list_get_value (list, i, &value); - printf("%-30s %-16s\n", name, value); + gp_list_get_name (list, i, &name); + gp_list_get_value (list, i, &value); + printf("%-30s %-16s\n", name, value); printf("Summary:\n%s\n", text.text); /* Query a simple string configuration variable. */ diff --git a/examples/sample-tether.c b/examples/sample-tether.c index 683f006c88..eb5d11fc93 100644 --- a/examples/sample-tether.c +++ b/examples/sample-tether.c @@ -17,9 +17,9 @@ #include "samples.h" -static void errordumper(GPLogLevel level, const char *domain, const char *str, - void *data) { - fprintf(stdout, "%s\n", str); +static void +errordumper(GPLogLevel level, const char *domain, const char *str, void *data) { + fprintf(stdout, "%s\n", str); } static void diff --git a/examples/sample-trigger-capture.c b/examples/sample-trigger-capture.c index fb2c063c58..455caf6b65 100644 --- a/examples/sample-trigger-capture.c +++ b/examples/sample-trigger-capture.c @@ -34,9 +34,9 @@ wait_event_and_download (Camera *camera, int waittime, GPContext *context) { CameraFilePath *path; void *data; int retval; - struct timeval start, curtime; + struct timeval start, curtime; - gettimeofday (&start, NULL); + gettimeofday (&start, NULL); data = NULL; if (nrofqueue) waittime = 10; /* just drain the event queue */ @@ -44,7 +44,7 @@ wait_event_and_download (Camera *camera, int waittime, GPContext *context) { while (1) { int timediff; - gettimeofday (&curtime, NULL); + gettimeofday (&curtime, NULL); timediff = ((curtime.tv_sec - start.tv_sec)*1000)+((curtime.tv_usec - start.tv_usec)/1000); if (timediff >= waittime) diff --git a/libgphoto2/ahd_bayer.c b/libgphoto2/ahd_bayer.c index 1039f941bc..47d6998c86 100644 --- a/libgphoto2/ahd_bayer.c +++ b/libgphoto2/ahd_bayer.c @@ -147,10 +147,10 @@ int do_rb_ctr_row(unsigned char *image_h, unsigned char *image_v, int w, } if (x < w-1 && y < h-1) { value += image_h[AD(x+1,2,w)+color] - -image_h[AD(x+1,2,w)+GREEN]; + -image_h[AD(x+1,2,w)+GREEN]; value2+= image_v[AD(x+1,2,w)+color] -image_v[AD(x+1,2,w)+GREEN]; - div++; + div++; } image_h[AD(x,1,w)+color]= CLAMP( @@ -168,7 +168,7 @@ int do_rb_ctr_row(unsigned char *image_h, unsigned char *image_v, int w, -image_h[AD(x,0,w)+GREEN]; value2+= image_v[AD(x,0,w)+color] -image_v[AD(x,0,w)+GREEN]; - div++; + div++; } if (y < h-1) { value += image_h[AD(x,2,w)+color] diff --git a/libgphoto2_port/disk/disk.c b/libgphoto2_port/disk/disk.c index 807718c8c3..ee3d5fc3a5 100644 --- a/libgphoto2_port/disk/disk.c +++ b/libgphoto2_port/disk/disk.c @@ -63,7 +63,7 @@ struct _GPPortPrivateLibrary { GPPortType gp_port_library_type (void) { - return GP_PORT_DISK; + return GP_PORT_DISK; } int @@ -92,14 +92,14 @@ gp_port_library_list (GPPortInfoList *list) (NULL != strstr(mntent->mnt_fsname,"afs")) || (NULL != strstr(mntent->mnt_fsname,"davfs"))|| (NULL != strstr(mntent->mnt_fsname,"autofs"))|| - (NULL != strstr(mntent->mnt_fsname,"cgroup"))|| - (NULL != strstr(mntent->mnt_fsname,"systemd"))|| - (NULL != strstr(mntent->mnt_fsname,"mqueue"))|| - (NULL != strstr(mntent->mnt_fsname,"securityfs"))|| - (NULL != strstr(mntent->mnt_fsname,"proc"))|| - (NULL != strstr(mntent->mnt_fsname,"devtmpfs"))|| - (NULL != strstr(mntent->mnt_fsname,"devpts"))|| - (NULL != strstr(mntent->mnt_fsname,"sysfs"))|| + (NULL != strstr(mntent->mnt_fsname,"cgroup"))|| + (NULL != strstr(mntent->mnt_fsname,"systemd"))|| + (NULL != strstr(mntent->mnt_fsname,"mqueue"))|| + (NULL != strstr(mntent->mnt_fsname,"securityfs"))|| + (NULL != strstr(mntent->mnt_fsname,"proc"))|| + (NULL != strstr(mntent->mnt_fsname,"devtmpfs"))|| + (NULL != strstr(mntent->mnt_fsname,"devpts"))|| + (NULL != strstr(mntent->mnt_fsname,"sysfs"))|| (NULL != strstr(mntent->mnt_fsname,"gphotofs"))|| /* fstype based */ (NULL != strstr(mntent->mnt_type,"autofs")) || @@ -164,14 +164,14 @@ gp_port_library_list (GPPortInfoList *list) (NULL != strstr(mntent->mnt_fsname,"afs")) || (NULL != strstr(mntent->mnt_fsname,"autofs"))|| (NULL != strstr(mntent->mnt_fsname,"davfs"))|| - (NULL != strstr(mntent->mnt_fsname,"cgroup"))|| - (NULL != strstr(mntent->mnt_fsname,"systemd"))|| - (NULL != strstr(mntent->mnt_fsname,"mqueue"))|| - (NULL != strstr(mntent->mnt_fsname,"securityfs"))|| - (NULL != strstr(mntent->mnt_fsname,"proc"))|| - (NULL != strstr(mntent->mnt_fsname,"devtmpfs"))|| - (NULL != strstr(mntent->mnt_fsname,"devpts"))|| - (NULL != strstr(mntent->mnt_fsname,"sysfs"))|| + (NULL != strstr(mntent->mnt_fsname,"cgroup"))|| + (NULL != strstr(mntent->mnt_fsname,"systemd"))|| + (NULL != strstr(mntent->mnt_fsname,"mqueue"))|| + (NULL != strstr(mntent->mnt_fsname,"securityfs"))|| + (NULL != strstr(mntent->mnt_fsname,"proc"))|| + (NULL != strstr(mntent->mnt_fsname,"devtmpfs"))|| + (NULL != strstr(mntent->mnt_fsname,"devpts"))|| + (NULL != strstr(mntent->mnt_fsname,"sysfs"))|| (NULL != strstr(mntent->mnt_fsname,"gphotofs"))|| /* fstype based */ (NULL != strstr(mntent->mnt_type,"autofs")) || @@ -323,13 +323,13 @@ gp_port_disk_close (GPPort *port) static int gp_port_disk_write (GPPort *port, const char *bytes, int size) { - return GP_OK; + return GP_OK; } static int gp_port_disk_read(GPPort *port, char *bytes, int size) { - return GP_OK; + return GP_OK; } GPPortOperations * diff --git a/libgphoto2_port/gphoto2/gphoto2-port-library.h b/libgphoto2_port/gphoto2/gphoto2-port-library.h index 146c8d76b3..e534349763 100644 --- a/libgphoto2_port/gphoto2/gphoto2-port-library.h +++ b/libgphoto2_port/gphoto2/gphoto2-port-library.h @@ -37,40 +37,40 @@ * gp_port_read() and gp_port_write(). */ typedef struct _GPPortOperations { - int (*init) (GPPort *); - int (*exit) (GPPort *); - int (*open) (GPPort *); - int (*close) (GPPort *); - int (*read) (GPPort *, char *, int); - int (*check_int)(GPPort *, char *, int, int); - int (*write) (GPPort *, const char *, int); - int (*update) (GPPort *); - - /* Pointers to devices. Please note these are stubbed so there is - no need to #ifdef GP_PORT_* anymore. */ - - /* for serial devices */ - int (*get_pin) (GPPort *, GPPin, GPLevel*); - int (*set_pin) (GPPort *, GPPin, GPLevel); - int (*send_break)(GPPort *, int); - int (*flush) (GPPort *, int); - - /* for USB devices */ - int (*find_device)(GPPort * dev, int idvendor, int idproduct); - int (*find_device_by_class)(GPPort * dev, int class, int subclass, int protocol); - int (*clear_halt) (GPPort * dev, int ep); - int (*msg_write) (GPPort * dev, int request, int value, int index, - char *bytes, int size); - int (*msg_read) (GPPort * dev, int request, int value, int index, - char *bytes, int size); - int (*msg_interface_write) (GPPort * dev, int request, - int value, int index, char *bytes, int size); - int (*msg_interface_read) (GPPort * dev, int request, - int value, int index, char *bytes, int size); - int (*msg_class_write) (GPPort * dev, int request, - int value, int index, char *bytes, int size); - int (*msg_class_read) (GPPort * dev, int request, - int value, int index, char *bytes, int size); + int (*init) (GPPort *); + int (*exit) (GPPort *); + int (*open) (GPPort *); + int (*close) (GPPort *); + int (*read) (GPPort *, char *, int); + int (*check_int)(GPPort *, char *, int, int); + int (*write) (GPPort *, const char *, int); + int (*update) (GPPort *); + + /* Pointers to devices. Please note these are stubbed so there is + no need to #ifdef GP_PORT_* anymore. */ + + /* for serial devices */ + int (*get_pin) (GPPort *, GPPin, GPLevel*); + int (*set_pin) (GPPort *, GPPin, GPLevel); + int (*send_break)(GPPort *, int); + int (*flush) (GPPort *, int); + + /* for USB devices */ + int (*find_device)(GPPort * dev, int idvendor, int idproduct); + int (*find_device_by_class)(GPPort * dev, int class, int subclass, int protocol); + int (*clear_halt) (GPPort * dev, int ep); + int (*msg_write) (GPPort * dev, int request, int value, int index, + char *bytes, int size); + int (*msg_read) (GPPort * dev, int request, int value, int index, + char *bytes, int size); + int (*msg_interface_write) (GPPort * dev, int request, + int value, int index, char *bytes, int size); + int (*msg_interface_read) (GPPort * dev, int request, + int value, int index, char *bytes, int size); + int (*msg_class_write) (GPPort * dev, int request, + int value, int index, char *bytes, int size); + int (*msg_class_read) (GPPort * dev, int request, + int value, int index, char *bytes, int size); /* For USB disk direct IO devices */ int (*seek) (GPPort * dev, int offset, int whence); @@ -81,7 +81,7 @@ typedef struct _GPPortOperations { char *sense, int sense_size, char *data, int data_size); - int (*reset) (GPPort *); + int (*reset) (GPPort *); } GPPortOperations; diff --git a/libgphoto2_port/gphoto2/gphoto2-port-log.h b/libgphoto2_port/gphoto2/gphoto2-port-log.h index c3b20c0c47..57deb0fa95 100644 --- a/libgphoto2_port/gphoto2/gphoto2-port-log.h +++ b/libgphoto2_port/gphoto2/gphoto2-port-log.h @@ -110,7 +110,7 @@ __attribute__((__format__(printf,4,5))) #ifdef _GPHOTO2_INTERNAL_CODE #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define GP_DEBUG(...) \ - gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, __VA_ARGS__) + gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, __VA_ARGS__) /* * GP_LOG_D/E: @@ -123,7 +123,7 @@ __attribute__((__format__(printf,4,5))) #elif defined(__GNUC__) && __GNUC__ >= 2 #define GP_DEBUG(msg, params...) \ - gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, msg, ##params) + gp_log(GP_LOG_DEBUG, GP_MODULE "/" __FILE__, msg, ##params) /* * GP_LOG_D/E: * simple helper macros for convenient and consistent logging of error diff --git a/libgphoto2_port/gphoto2/gphoto2-port.h b/libgphoto2_port/gphoto2/gphoto2-port.h index fedac44286..6cfcf9c3c4 100644 --- a/libgphoto2_port/gphoto2/gphoto2-port.h +++ b/libgphoto2_port/gphoto2/gphoto2-port.h @@ -115,9 +115,9 @@ typedef union _GPPortSettings { } GPPortSettings; enum { - GP_PORT_USB_ENDPOINT_IN, /**< \brief USB bulk IN ep */ - GP_PORT_USB_ENDPOINT_OUT, /**< \brief USB bulk OUT ep */ - GP_PORT_USB_ENDPOINT_INT /**< \brief USB Interrupt ep */ + GP_PORT_USB_ENDPOINT_IN, /**< \brief USB bulk IN ep */ + GP_PORT_USB_ENDPOINT_OUT, /**< \brief USB bulk OUT ep */ + GP_PORT_USB_ENDPOINT_INT /**< \brief USB Interrupt ep */ }; typedef struct _GPPortPrivateLibrary GPPortPrivateLibrary; @@ -141,9 +141,9 @@ typedef struct _GPPort { GPPortType type; /**< \brief Actual type of this port */ GPPortSettings settings; /**< \brief Current port settings. */ - GPPortSettings settings_pending;/**< \brief Settings to be committed. */ + GPPortSettings settings_pending;/**< \brief Settings to be committed. */ - int timeout; /**< \brief Port timeout in milliseconds. */ + int timeout; /**< \brief Port timeout in milliseconds. */ GPPortPrivateLibrary *pl; /**< \brief Camera driver private data pointer. */ GPPortPrivateCore *pc; /**< \brief Port library private data pointer. */ diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c index 7a9be8a96b..507e934b9d 100644 --- a/libgphoto2_port/libusb1/libusb1.c +++ b/libgphoto2_port/libusb1/libusb1.c @@ -118,27 +118,27 @@ struct _PrivateIrqCompleted { #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE static struct _GPPortExternalSysDevice { - /* some more may be used in future */ - libusb_device_handle *h; - libusb_device *d; - libusb_context *ctx; - libusb_device *dl[1]; + /* some more may be used in future */ + libusb_device_handle *h; + libusb_device *d; + libusb_context *ctx; + libusb_device *dl[1]; } external_sys_device = { NULL, NULL, NULL, { NULL } }; static int has_external_fd() { - if(gp_port_usb_get_sys_device() == -1) - return 0; - if(external_sys_device.h) - return 1; + if (gp_port_usb_get_sys_device() == -1) + return 0; + if (external_sys_device.h) + return 1; #ifdef HAVE_LIBUSB_OPTION_NO_DEVICE_DISCOVERY - libusb_set_option(NULL,LIBUSB_OPTION_NO_DEVICE_DISCOVERY,NULL); + libusb_set_option(NULL, LIBUSB_OPTION_NO_DEVICE_DISCOVERY, NULL); #endif - C_LIBUSB (libusb_init (&external_sys_device.ctx), GP_ERROR_IO); - LOG_ON_LIBUSB_E(libusb_wrap_sys_device(external_sys_device.ctx,gp_port_usb_get_sys_device(),&external_sys_device.h)); - external_sys_device.d = libusb_get_device(external_sys_device.h); - external_sys_device.dl[0] = external_sys_device.d; - return 1; + C_LIBUSB (libusb_init (&external_sys_device.ctx), GP_ERROR_IO); + LOG_ON_LIBUSB_E(libusb_wrap_sys_device(external_sys_device.ctx, gp_port_usb_get_sys_device(), &external_sys_device.h)); + external_sys_device.d = libusb_get_device(external_sys_device.h); + external_sys_device.dl[0] = external_sys_device.d; + return 1; } @@ -185,27 +185,27 @@ load_devicelist (GPPortPrivateLibrary *pl) { time(&xtime); #if HAVE_LIBUSB_WRAP_SYS_DEVICE - if(!has_external_fd()) /* when external device present no need to research for Android */ + if (!has_external_fd()) /* when external device present no need to research for Android */ #endif - { - if (xtime != pl->devslastchecked) { - if (pl->nrofdevs) - libusb_free_device_list (pl->devs, 1); - free (pl->descs); - pl->nrofdevs = 0; - pl->devs = NULL; - pl->descs = NULL; + { + if (xtime != pl->devslastchecked) { + if (pl->nrofdevs) + libusb_free_device_list (pl->devs, 1); + free (pl->descs); + pl->nrofdevs = 0; + pl->devs = NULL; + pl->descs = NULL; + } } - } - #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - if(has_external_fd()) { - pl->nrofdevs = 1; - pl->devs = external_sys_device.dl; - C_MEM (pl->descs = calloc (1, sizeof(pl->descs[0]))); - LOG_ON_LIBUSB_E (libusb_get_device_descriptor(pl->devs[0], &pl->descs[0])); - } - #endif +#ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE + if (has_external_fd()) { + pl->nrofdevs = 1; + pl->devs = external_sys_device.dl; + C_MEM (pl->descs = calloc (1, sizeof(pl->descs[0]))); + LOG_ON_LIBUSB_E (libusb_get_device_descriptor(pl->devs[0], &pl->descs[0])); + } +#endif if (!pl->nrofdevs) { int i; @@ -230,14 +230,13 @@ gp_port_library_list (GPPortInfoList *list) struct libusb_device_descriptor *descs; #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - if(has_external_fd()) { - ctx = external_sys_device.ctx; - } - else { - C_LIBUSB (libusb_init (&ctx), GP_ERROR_IO); - } + if (has_external_fd()) { + ctx = external_sys_device.ctx; + } else { + C_LIBUSB (libusb_init (&ctx), GP_ERROR_IO); + } #else - C_LIBUSB (libusb_init (&ctx), GP_ERROR_IO); + C_LIBUSB (libusb_init (&ctx), GP_ERROR_IO); #endif /* TODO: make sure libusb_exit gets called in all error paths inside this function */ @@ -250,19 +249,18 @@ gp_port_library_list (GPPortInfoList *list) gp_port_info_list_append (list, info); /* do not check return value, it might be -1 */ #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - if(has_external_fd()) { - nrofdevs = 1; - devs = external_sys_device.dl; - } - else + if (has_external_fd()) { + nrofdevs = 1; + devs = external_sys_device.dl; + } else #endif - { - nrofdevs = libusb_get_device_list (ctx, &devs); - if (!nrofdevs) { - libusb_exit (ctx); /* should free all stuff above */ - goto nodevices; + { + nrofdevs = libusb_get_device_list (ctx, &devs); + if (!nrofdevs) { + libusb_exit (ctx); /* should free all stuff above */ + goto nodevices; + } } - } C_MEM (descs = calloc (nrofdevs, sizeof(descs[0]))); for (i=0;ipl->config = port->pl->interface = port->pl->altsetting = -1; #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - if(has_external_fd()) { - port->pl->ctx = external_sys_device.ctx; - } - else + if (has_external_fd()) { + port->pl->ctx = external_sys_device.ctx; + } else #endif - { - if (LOG_ON_LIBUSB_E (libusb_init (&port->pl->ctx))) { - free (port->pl); - port->pl = NULL; - return GP_ERROR_IO; + { + if (LOG_ON_LIBUSB_E (libusb_init (&port->pl->ctx))) { + free (port->pl); + port->pl = NULL; + return GP_ERROR_IO; + } } - } #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION unlink("usblog.raw"); port->pl->logfd = open("usblog.raw",O_CREAT|O_WRONLY,0644); @@ -428,22 +425,22 @@ gp_libusb1_exit (GPPort *port) if (port->pl) { free (port->pl->descs); #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - if (port->pl->logfd >=0 ) close (port->pl->logfd); + if (port->pl->logfd >=0) close (port->pl->logfd); #endif - if (port->pl->nrofdevs) { + if (port->pl->nrofdevs) { #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - if(!has_external_fd()) + if (!has_external_fd()) #endif - { - libusb_free_device_list (port->pl->devs, 1); - } - } + { + libusb_free_device_list (port->pl->devs, 1); + } + } #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - if(!has_external_fd()) + if (!has_external_fd()) #endif - { - libusb_exit (port->pl->ctx); - } + { + libusb_exit (port->pl->ctx); + } free (port->pl); port->pl = NULL; } @@ -466,19 +463,18 @@ gp_libusb1_open (GPPort *port) } #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - if(gp_port_usb_get_sys_device() != -1) { - if(!external_sys_device.h) { - LOG_ON_LIBUSB_E(libusb_wrap_sys_device(port->pl->ctx,gp_port_usb_get_sys_device(),&external_sys_device.h)); - libusb_ref_device(libusb_get_device(external_sys_device.h)); - } - port->pl->dh = external_sys_device.h; - port->pl->d = libusb_get_device(external_sys_device.h); - } - else + if (gp_port_usb_get_sys_device() != -1) { + if (!external_sys_device.h) { + LOG_ON_LIBUSB_E(libusb_wrap_sys_device(port->pl->ctx, gp_port_usb_get_sys_device(), &external_sys_device.h)); + libusb_ref_device(libusb_get_device(external_sys_device.h)); + } + port->pl->dh = external_sys_device.h; + port->pl->d = libusb_get_device(external_sys_device.h); + } else #endif - { - C_LIBUSB (libusb_open (port->pl->d, &port->pl->dh), GP_ERROR_IO); - } + { + C_LIBUSB (libusb_open (port->pl->d, &port->pl->dh), GP_ERROR_IO); + } if (!port->pl->dh) { int saved_errno = errno; gp_port_set_error (port, _("Could not open USB device (%s)."), @@ -675,15 +671,15 @@ gp_libusb1_clear_halt_lib(GPPort *port, int ep) static int gp_libusb1_write (GPPort *port, const char *bytes, int size) { - int curwritten; + int curwritten; C_PARAMS (port && port->pl->dh); C_LIBUSB (libusb_bulk_transfer (port->pl->dh, port->settings.usb.outep, - (unsigned char*)bytes, size, &curwritten, port->timeout), - GP_ERROR_IO_WRITE); + (unsigned char*)bytes, size, &curwritten, port->timeout), + GP_ERROR_IO_WRITE); - return curwritten; + return curwritten; } static int @@ -700,7 +696,7 @@ gp_libusb1_read(GPPort *port, char *bytes, int size) #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION write(port->pl->logfd, bytes, curread); #endif - return curread; + return curread; } static int @@ -877,7 +873,7 @@ gp_libusb1_check_int (GPPort *port, char *bytes, int size, int timeout) while ((irq_cur->next) && (irq_cur->next->status != LIBUSB_TRANSFER_COMPLETED) && (irq_cur->next->status != LIBUSB_TRANSFER_NO_DEVICE) - ) { + ) { port->pl->irqs_head = irq_cur->next; free(irq_cur->data); free(irq_cur); diff --git a/libgphoto2_port/ptpip/ptpip.c b/libgphoto2_port/ptpip/ptpip.c index ff9df9da55..6872311b9c 100644 --- a/libgphoto2_port/ptpip/ptpip.c +++ b/libgphoto2_port/ptpip/ptpip.c @@ -52,7 +52,7 @@ struct _GPPortPrivateLibrary { GPPortType gp_port_library_type (void) { - return GP_PORT_PTPIP; + return GP_PORT_PTPIP; } /* thanks to Avahi this makes more trouble than its worth */ @@ -236,13 +236,13 @@ gp_port_ptpip_close (GPPort *port) static int gp_port_ptpip_write (GPPort *port, const char *bytes, int size) { - return GP_OK; + return GP_OK; } static int gp_port_ptpip_read(GPPort *port, char *bytes, int size) { - return GP_OK; + return GP_OK; } static int diff --git a/libgphoto2_port/serial/unix.c b/libgphoto2_port/serial/unix.c index 05131d4642..27f1f6d3ff 100644 --- a/libgphoto2_port/serial/unix.c +++ b/libgphoto2_port/serial/unix.c @@ -192,7 +192,7 @@ static int gp_port_serial_check_speed (GPPort *dev); GPPortType gp_port_library_type () { - return (GP_PORT_SERIAL); + return (GP_PORT_SERIAL); } static int @@ -421,8 +421,8 @@ gp_port_serial_close (GPPort *dev) "'%s' (%s)."), dev->settings.serial.port, strerror(saved_errno)); - return GP_ERROR_IO; - } + return GP_ERROR_IO; + } dev->pl->fd = 0; } @@ -458,7 +458,7 @@ gp_port_serial_write (GPPort *dev, const char *bytes, int size) CHECK (gp_port_serial_check_speed (dev)); len = 0; - while (len < size) { + while (len < size) { /* * Make sure we write all data while handling @@ -470,34 +470,34 @@ gp_port_serial_write (GPPort *dev, const char *bytes, int size) switch (saved_errno) { case EAGAIN: case EINTR: - ret = 0; - break; - default: + ret = 0; + break; + default: gp_port_set_error (dev, _("Could not write " "to port (%s)"), strerror(saved_errno)); - return GP_ERROR_IO_WRITE; - } + return GP_ERROR_IO_WRITE; + } } len += ret; - } + } - /* wait till all bytes are really sent */ + /* wait till all bytes are really sent */ #ifdef HAVE_TERMIOS_H - tcdrain (dev->pl->fd); + tcdrain (dev->pl->fd); #else - ioctl (dev->pl->fd, TCDRAIN, 0); + ioctl (dev->pl->fd, TCDRAIN, 0); #endif - return len; + return len; } static int gp_port_serial_read (GPPort *dev, char *bytes, int size) { - struct timeval timeout; - fd_set readfs; /* file descriptor set */ - int readen = 0, now; + struct timeval timeout; + fd_set readfs; /* file descriptor set */ + int readen = 0, now; C_PARAMS (dev); @@ -508,18 +508,18 @@ gp_port_serial_read (GPPort *dev, char *bytes, int size) /* Make sure we are operating at the specified speed */ CHECK (gp_port_serial_check_speed (dev)); - FD_ZERO (&readfs); - FD_SET (dev->pl->fd, &readfs); + FD_ZERO (&readfs); + FD_SET (dev->pl->fd, &readfs); - while (readen < size) { + while (readen < size) { /* Set timeout value within input loop */ - timeout.tv_usec = (dev->timeout % 1000) * 1000; - timeout.tv_sec = (dev->timeout / 1000); + timeout.tv_usec = (dev->timeout % 1000) * 1000; + timeout.tv_sec = (dev->timeout / 1000); /* Any data available? */ - if (!select (dev->pl->fd + 1, &readfs, NULL, NULL, &timeout)) - return GP_ERROR_TIMEOUT; + if (!select (dev->pl->fd + 1, &readfs, NULL, NULL, &timeout)) + return GP_ERROR_TIMEOUT; if (!FD_ISSET (dev->pl->fd, &readfs)) return (GP_ERROR_TIMEOUT); @@ -566,38 +566,38 @@ gp_port_serial_read (GPPort *dev, char *bytes, int size) } bytes += now; readen += now; - } + } - return readen; + return readen; } #ifdef HAVE_TERMIOS_H static int get_termios_bit (GPPort *dev, GPPin pin, int *bit) { - switch (pin) { - case GP_PIN_RTS: - *bit = TIOCM_RTS; - break; - case GP_PIN_DTR: - *bit = TIOCM_DTR; - break; - case GP_PIN_CTS: - *bit = TIOCM_CTS; - break; - case GP_PIN_DSR: - *bit = TIOCM_DSR; - break; - case GP_PIN_CD: - *bit = TIOCM_CD; - break; - case GP_PIN_RING: - *bit = TIOCM_RNG; - break; - default: - gp_port_set_error (dev, _("Unknown pin %i."), pin); - return GP_ERROR_IO; - } + switch (pin) { + case GP_PIN_RTS: + *bit = TIOCM_RTS; + break; + case GP_PIN_DTR: + *bit = TIOCM_DTR; + break; + case GP_PIN_CTS: + *bit = TIOCM_CTS; + break; + case GP_PIN_DSR: + *bit = TIOCM_DSR; + break; + case GP_PIN_CD: + *bit = TIOCM_CD; + break; + case GP_PIN_RING: + *bit = TIOCM_RNG; + break; + default: + gp_port_set_error (dev, _("Unknown pin %i."), pin); + return GP_ERROR_IO; + } return (GP_OK); } #endif @@ -615,43 +615,43 @@ gp_port_serial_get_pin (GPPort *dev, GPPin pin, GPLevel *level) #ifdef HAVE_TERMIOS_H CHECK (get_termios_bit (dev, pin, &bit)); - if (ioctl (dev->pl->fd, TIOCMGET, &j) < 0) { + if (ioctl (dev->pl->fd, TIOCMGET, &j) < 0) { int saved_errno = errno; gp_port_set_error (dev, _("Could not get level of pin %i " - "(%s)."), - pin, strerror(saved_errno)); - return GP_ERROR_IO; - } - *level = j & bit; + "(%s)."), + pin, strerror(saved_errno)); + return GP_ERROR_IO; + } + *level = j & bit; #else # ifdef __GCC__ -# warning ACCESSING PINS IS NOT IMPLEMENTED FOR NON-TERMIOS SYSTEMS! + # warning ACCESSING PINS IS NOT IMPLEMENTED FOR NON-TERMIOS SYSTEMS! # endif #endif - return (GP_OK); + return (GP_OK); } static int gp_port_serial_set_pin (GPPort *dev, GPPin pin, GPLevel level) { #ifdef HAVE_TERMIOS_H - int bit, request; + int bit, request; #endif C_PARAMS (dev); #ifdef HAVE_TERMIOS_H CHECK (get_termios_bit (dev, pin, &bit)); - switch (level) { + switch (level) { case GP_LEVEL_LOW: request = TIOCMBIS; break; default: request = TIOCMBIC; break; - } - if (ioctl (dev->pl->fd, request, &bit) < 0) { + } + if (ioctl (dev->pl->fd, request, &bit) < 0) { int saved_errno = errno; gp_port_set_error (dev, _("Could not set level of pin %i to " "%i (%s)."), @@ -664,7 +664,7 @@ gp_port_serial_set_pin (GPPort *dev, GPPin pin, GPLevel level) # endif #endif - return GP_OK; + return GP_OK; } static int @@ -698,53 +698,53 @@ static speed_t gp_port_serial_baudconv (int baudrate) { #define BAUDCASE(x) case (x): { ret = B##x; break; } - speed_t ret; - - switch (baudrate) { - - /* POSIX defined baudrates */ - BAUDCASE(0); - BAUDCASE(50); - BAUDCASE(75); - BAUDCASE(110); - BAUDCASE(134); - BAUDCASE(150); - BAUDCASE(200); - BAUDCASE(300); - BAUDCASE(600); - BAUDCASE(1200); - BAUDCASE(1800); - BAUDCASE(2400); - BAUDCASE(4800); - BAUDCASE(9600); - BAUDCASE(19200); - BAUDCASE(38400); - - /* non POSIX values */ + speed_t ret; + + switch (baudrate) { + + /* POSIX defined baudrates */ + BAUDCASE(0); + BAUDCASE(50); + BAUDCASE(75); + BAUDCASE(110); + BAUDCASE(134); + BAUDCASE(150); + BAUDCASE(200); + BAUDCASE(300); + BAUDCASE(600); + BAUDCASE(1200); + BAUDCASE(1800); + BAUDCASE(2400); + BAUDCASE(4800); + BAUDCASE(9600); + BAUDCASE(19200); + BAUDCASE(38400); + + /* non POSIX values */ #ifdef B7200 - BAUDCASE(7200); + BAUDCASE(7200); #endif #ifdef B14400 - BAUDCASE(14400); + BAUDCASE(14400); #endif #ifdef B28800 - BAUDCASE(28800); + BAUDCASE(28800); #endif #ifdef B57600 - BAUDCASE(57600); + BAUDCASE(57600); #endif #ifdef B115200 - BAUDCASE(115200); + BAUDCASE(115200); #endif #ifdef B230400 - BAUDCASE(230400); + BAUDCASE(230400); #endif - default: + default: ret = (speed_t) baudrate; GP_LOG_D ("Baudrate %d unknown - using as is", baudrate); - } + } - return ret; + return ret; #undef BAUDCASE } @@ -774,28 +774,28 @@ gp_port_serial_check_speed (GPPort *dev) speed = gp_port_serial_baudconv (dev->settings.serial.speed); #ifdef HAVE_TERMIOS_H - if (tcgetattr(dev->pl->fd, &tio) < 0) { + if (tcgetattr(dev->pl->fd, &tio) < 0) { gp_port_set_error (dev, _("Could not set the baudrate to %d"), dev->settings.serial.speed); - return GP_ERROR_IO_SERIAL_SPEED; - } - tio.c_cflag = (tio.c_cflag & ~CSIZE) | CS8; + return GP_ERROR_IO_SERIAL_SPEED; + } + tio.c_cflag = (tio.c_cflag & ~CSIZE) | CS8; - /* Set into raw, no echo mode */ - tio.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | - IXANY | IXON | IXOFF | INPCK | ISTRIP); + /* Set into raw, no echo mode */ + tio.c_iflag &= ~(IGNBRK | IGNCR | INLCR | ICRNL | + IXANY | IXON | IXOFF | INPCK | ISTRIP); #ifdef IUCLC - tio.c_iflag &= ~IUCLC; + tio.c_iflag &= ~IUCLC; #endif - tio.c_iflag |= (BRKINT | IGNPAR); - tio.c_oflag &= ~OPOST; - tio.c_lflag &= ~(ICANON | ISIG | ECHO | ECHONL | ECHOE | - ECHOK | IEXTEN); - tio.c_cflag &= ~(CRTSCTS | PARENB | PARODD); - tio.c_cflag |= CLOCAL | CREAD; + tio.c_iflag |= (BRKINT | IGNPAR); + tio.c_oflag &= ~OPOST; + tio.c_lflag &= ~(ICANON | ISIG | ECHO | ECHONL | ECHOE | + ECHOK | IEXTEN); + tio.c_cflag &= ~(CRTSCTS | PARENB | PARODD); + tio.c_cflag |= CLOCAL | CREAD; - tio.c_cc[VMIN] = 1; - tio.c_cc[VTIME] = 0; + tio.c_cc[VMIN] = 1; + tio.c_cc[VTIME] = 0; if (dev->settings.serial.parity != GP_PORT_SERIAL_PARITY_OFF) { GP_LOG_D ("Setting parity to %s...", dev->settings.serial.parity == GP_PORT_SERIAL_PARITY_ODD?"odd":"even"); @@ -809,16 +809,16 @@ gp_port_serial_check_speed (GPPort *dev) /* Set the new speed. */ cfsetispeed (&tio, speed); cfsetospeed (&tio, speed); - if (tcsetattr (dev->pl->fd, TCSANOW, &tio) < 0) { + if (tcsetattr (dev->pl->fd, TCSANOW, &tio) < 0) { GP_LOG_E ("Error on 'tcsetattr'."); - return GP_ERROR_IO_SERIAL_SPEED; - } + return GP_ERROR_IO_SERIAL_SPEED; + } /* Clear O_NONBLOCK. */ - if (fcntl (dev->pl->fd, F_SETFL, 0) < 0) { + if (fcntl (dev->pl->fd, F_SETFL, 0) < 0) { GP_LOG_E ("Error on 'fcntl'."); - return GP_ERROR_IO_SERIAL_SPEED; - } + return GP_ERROR_IO_SERIAL_SPEED; + } /* * Verify if the speed change has been successful. @@ -841,23 +841,23 @@ gp_port_serial_check_speed (GPPort *dev) } #else /* !HAVE_TERMIOS_H */ - if (ioctl (dev->pl->fd, TIOCGETP, &ttyb) < 0) { - perror("ioctl(TIOCGETP)"); - return GP_ERROR_IO_SERIAL_SPEED; - } - ttyb.sg_ispeed = dev->settings.serial.speed; - ttyb.sg_ospeed = dev->settings.serial.speed; - ttyb.sg_flags = 0; + if (ioctl (dev->pl->fd, TIOCGETP, &ttyb) < 0) { + perror("ioctl(TIOCGETP)"); + return GP_ERROR_IO_SERIAL_SPEED; + } + ttyb.sg_ispeed = dev->settings.serial.speed; + ttyb.sg_ospeed = dev->settings.serial.speed; + ttyb.sg_flags = 0; - if (ioctl (dev->pl->fd, TIOCSETP, &ttyb) < 0) { - perror("ioctl(TIOCSETP)"); - return GP_ERROR_IO_SERIAL_SPEED; - } + if (ioctl (dev->pl->fd, TIOCSETP, &ttyb) < 0) { + perror("ioctl(TIOCSETP)"); + return GP_ERROR_IO_SERIAL_SPEED; + } #endif dev->pl->baudrate = dev->settings.serial.speed; dev->pl->parity = dev->settings.serial.parity; - return GP_OK; + return GP_OK; } static int @@ -880,17 +880,17 @@ gp_port_serial_send_break (GPPort *dev, int duration) /* Make sure we are operating at the specified speed */ CHECK (gp_port_serial_check_speed (dev)); - /* Duration is in milliseconds */ + /* Duration is in milliseconds */ #ifdef HAVE_TERMIOS_H - tcsendbreak (dev->pl->fd, duration / 310); - tcdrain (dev->pl->fd); + tcsendbreak (dev->pl->fd, duration / 310); + tcdrain (dev->pl->fd); #else # ifdef __GCC__ # warning SEND BREAK NOT IMPLEMENTED FOR NON TERMIOS SYSTEMS! # endif #endif - return GP_OK; + return GP_OK; } GPPortOperations * @@ -898,22 +898,22 @@ gp_port_library_operations () { GPPortOperations *ops; - ops = malloc (sizeof (GPPortOperations)); + ops = malloc (sizeof (GPPortOperations)); if (!ops) return (NULL); - memset (ops, 0, sizeof (GPPortOperations)); - - ops->init = gp_port_serial_init; - ops->exit = gp_port_serial_exit; - ops->open = gp_port_serial_open; - ops->close = gp_port_serial_close; - ops->read = gp_port_serial_read; - ops->write = gp_port_serial_write; - ops->update = gp_port_serial_update; - ops->get_pin = gp_port_serial_get_pin; - ops->set_pin = gp_port_serial_set_pin; - ops->send_break = gp_port_serial_send_break; - ops->flush = gp_port_serial_flush; - - return (ops); + memset (ops, 0, sizeof (GPPortOperations)); + + ops->init = gp_port_serial_init; + ops->exit = gp_port_serial_exit; + ops->open = gp_port_serial_open; + ops->close = gp_port_serial_close; + ops->read = gp_port_serial_read; + ops->write = gp_port_serial_write; + ops->update = gp_port_serial_update; + ops->get_pin = gp_port_serial_get_pin; + ops->set_pin = gp_port_serial_set_pin; + ops->send_break = gp_port_serial_send_break; + ops->flush = gp_port_serial_flush; + + return (ops); } diff --git a/libgphoto2_port/usb/libusb.c b/libgphoto2_port/usb/libusb.c index ab0a854f41..7bbd17be74 100644 --- a/libgphoto2_port/usb/libusb.c +++ b/libgphoto2_port/usb/libusb.c @@ -238,7 +238,7 @@ gp_port_usb_open (GPPort *port) C_PARAMS (port->pl->d); } - /* + /* * Open the device using the previous usb_handle returned by * find_device */ @@ -394,16 +394,16 @@ gp_port_usb_clear_halt_lib(GPPort *port, int ep) static int gp_port_usb_write (GPPort *port, const char *bytes, int size) { - int ret; + int ret; - C_PARAMS (port && port->pl->dh); + C_PARAMS (port && port->pl->dh); ret = usb_bulk_write (port->pl->dh, port->settings.usb.outep, - (char *) bytes, size, port->timeout); - if (ret < 0) + (char *) bytes, size, port->timeout); + if (ret < 0) return (GP_ERROR_IO_WRITE); - return (ret); + return (ret); } static int @@ -415,10 +415,10 @@ gp_port_usb_read(GPPort *port, char *bytes, int size) ret = usb_bulk_read(port->pl->dh, port->settings.usb.inep, bytes, size, port->timeout); - if (ret < 0) + if (ret < 0) return GP_ERROR_IO_READ; - return ret; + return ret; } static int @@ -430,11 +430,11 @@ gp_port_usb_reset(GPPort *port) C_PARAMS (port && port->pl->dh); ret = usb_reset(port->pl->dh); - if (ret < 0) { + if (ret < 0) { GP_LOG_E ("gp_port_reset: %d", ret); return GP_ERROR_IO_READ; } - return GP_OK; + return GP_OK; } static int @@ -447,12 +447,12 @@ gp_port_usb_check_int (GPPort *port, char *bytes, int size, int timeout) /* 0 timeout is okish ... libusb 0.x it will do 1 poll though */ ret = usb_interrupt_read(port->pl->dh, port->settings.usb.intep, bytes, size, timeout); - if (ret < 0) { + if (ret < 0) { if ((errno == EAGAIN) || (errno == ETIMEDOUT)) return GP_ERROR_TIMEOUT; return GP_ERROR_IO_READ; } - return ret; + return ret; } static int diff --git a/libgphoto2_port/vusb/vcamera.c b/libgphoto2_port/vusb/vcamera.c index 0ac97d912b..86b8659dd4 100644 --- a/libgphoto2_port/vusb/vcamera.c +++ b/libgphoto2_port/vusb/vcamera.c @@ -197,8 +197,8 @@ ptp_response(vcamera *cam, uint16_t code, int nparams, ...) { #define PTP_RC_OK 0x2001 #define PTP_RC_GeneralError 0x2002 -#define PTP_RC_SessionNotOpen 0x2003 -#define PTP_RC_OperationNotSupported 0x2005 +#define PTP_RC_SessionNotOpen 0x2003 +#define PTP_RC_OperationNotSupported 0x2005 #define PTP_RC_InvalidStorageId 0x2008 #define PTP_RC_InvalidObjectHandle 0x2009 #define PTP_RC_DevicePropNotSupported 0x200A @@ -209,11 +209,11 @@ ptp_response(vcamera *cam, uint16_t code, int nparams, ...) { #define PTP_RC_AccessDenied 0x200F #define PTP_RC_NoThumbnailPresent 0x2010 #define PTP_RC_StoreNotAvailable 0x2013 -#define PTP_RC_SpecificationByFormatUnsupported 0x2014 +#define PTP_RC_SpecificationByFormatUnsupported 0x2014 #define PTP_RC_InvalidParentObject 0x201A #define PTP_RC_InvalidDevicePropFormat 0x201B #define PTP_RC_InvalidParameter 0x201D -#define PTP_RC_SessionAlreadyOpened 0x201E +#define PTP_RC_SessionAlreadyOpened 0x201E #define CHECK_PARAM_COUNT(x) \ if (ptp->nparams != x) { \ @@ -310,33 +310,33 @@ typedef union _PTPPropertyValue { } PTPPropertyValue; struct _PTPPropDescRangeForm { - PTPPropertyValue MinimumValue; - PTPPropertyValue MaximumValue; - PTPPropertyValue StepSize; + PTPPropertyValue MinimumValue; + PTPPropertyValue MaximumValue; + PTPPropertyValue StepSize; }; typedef struct _PTPPropDescRangeForm PTPPropDescRangeForm; /* Property Describing Dataset, Enum Form */ struct _PTPPropDescEnumForm { - uint16_t NumberOfValues; - PTPPropertyValue *SupportedValue; /* malloced */ + uint16_t NumberOfValues; + PTPPropertyValue *SupportedValue; /* malloced */ }; typedef struct _PTPPropDescEnumForm PTPPropDescEnumForm; /* Device Property Describing Dataset (DevicePropDesc) */ struct _PTPDevicePropDesc { - uint16_t DevicePropertyCode; - uint16_t DataType; - uint8_t GetSet; - PTPPropertyValue FactoryDefaultValue; - PTPPropertyValue CurrentValue; - uint8_t FormFlag; - union { - PTPPropDescEnumForm Enum; - PTPPropDescRangeForm Range; - } FORM; + uint16_t DevicePropertyCode; + uint16_t DataType; + uint8_t GetSet; + PTPPropertyValue FactoryDefaultValue; + PTPPropertyValue CurrentValue; + uint8_t FormFlag; + union { + PTPPropDescEnumForm Enum; + PTPPropDescRangeForm Range; + } FORM; }; typedef struct _PTPDevicePropDesc PTPDevicePropDesc; @@ -1033,7 +1033,7 @@ ptp_getthumb_write(vcamera *cam, ptpcontainer *ptp) { unsigned char *data; struct ptp_dirent *cur; #ifdef HAVE_LIBEXIF - ExifData *ed; + ExifData *ed; #endif CHECK_SEQUENCE_NUMBER(); @@ -1568,7 +1568,7 @@ ptp_battery_getdesc (vcamera* cam, PTPDevicePropDesc *desc) { desc->GetSet = 0; /* Get only */ desc->FactoryDefaultValue.u8 = 50; desc->CurrentValue.u8 = 50; - desc->FormFlag = 0x01; /* range */ + desc->FormFlag = 0x01; /* range */ desc->FORM.Range.MinimumValue.u8= 0; desc->FORM.Range.MaximumValue.u8= 100; desc->FORM.Range.StepSize.u8 = 1; @@ -1590,7 +1590,7 @@ ptp_imagesize_getdesc (vcamera* cam, PTPDevicePropDesc *desc) { desc->GetSet = 0; /* Get only */ desc->FactoryDefaultValue.str = strdup("640x480"); desc->CurrentValue.str = strdup("640x480"); - desc->FormFlag = 0x02; /* enum */ + desc->FormFlag = 0x02; /* enum */ desc->FORM.Enum.NumberOfValues = 3; desc->FORM.Enum.SupportedValue = malloc(3*sizeof(desc->FORM.Enum.SupportedValue[0])); desc->FORM.Enum.SupportedValue[0].str = strdup("640x480"); @@ -1616,7 +1616,7 @@ ptp_shutterspeed_getdesc (vcamera* cam, PTPDevicePropDesc *desc) { if (!cam->shutterspeed) cam->shutterspeed = 100; /* 1/100 * 10000 */ desc->FactoryDefaultValue.u32 = cam->shutterspeed; desc->CurrentValue.u32 = cam->shutterspeed; - desc->FormFlag = 0x02; /* enum */ + desc->FormFlag = 0x02; /* enum */ desc->FORM.Enum.NumberOfValues = 9; desc->FORM.Enum.SupportedValue = malloc(desc->FORM.Enum.NumberOfValues*sizeof(desc->FORM.Enum.SupportedValue[0])); desc->FORM.Enum.SupportedValue[0].u32 = 10000; @@ -1656,7 +1656,7 @@ ptp_fnumber_getdesc (vcamera* cam, PTPDevicePropDesc *desc) { if (!cam->fnumber) cam->fnumber = 280; /* 2.8 * 100 */ desc->FactoryDefaultValue.u16 = cam->fnumber; desc->CurrentValue.u16 = cam->fnumber; - desc->FormFlag = 0x02; /* enum */ + desc->FormFlag = 0x02; /* enum */ desc->FORM.Enum.NumberOfValues = 18; desc->FORM.Enum.SupportedValue = malloc(desc->FORM.Enum.NumberOfValues*sizeof(desc->FORM.Enum.SupportedValue[0])); desc->FORM.Enum.SupportedValue[0].u16 = 280; @@ -1705,7 +1705,7 @@ ptp_exposurebias_getdesc (vcamera* cam, PTPDevicePropDesc *desc) { if (!cam->exposurebias) cam->exposurebias = 0; /* 0.0 */ desc->FactoryDefaultValue.i16 = cam->exposurebias; desc->CurrentValue.i16 = cam->exposurebias; - desc->FormFlag = 0x02; /* enum */ + desc->FormFlag = 0x02; /* enum */ desc->FORM.Enum.NumberOfValues = 13; desc->FORM.Enum.SupportedValue = malloc(desc->FORM.Enum.NumberOfValues*sizeof(desc->FORM.Enum.SupportedValue[0])); desc->FORM.Enum.SupportedValue[0].i16 = -3000; @@ -1756,7 +1756,7 @@ ptp_datetime_getdesc (vcamera* cam, PTPDevicePropDesc *desc) { sprintf(xdate,"%04d%02d%02dT%02d%02d%02d",tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec); desc->FactoryDefaultValue.str = strdup (xdate); desc->CurrentValue.str = strdup (xdate); - desc->FormFlag = 0; /* no form */ + desc->FormFlag = 0; /* no form */ /*ptp_inject_interrupt (cam, 1000, 0x4006, 1, 0x5011, 0xffffffff);*/ return 1; } diff --git a/libgphoto2_port/vusb/vusb.c b/libgphoto2_port/vusb/vusb.c index a711a8460f..3fba79a6ac 100644 --- a/libgphoto2_port/vusb/vusb.c +++ b/libgphoto2_port/vusb/vusb.c @@ -52,7 +52,7 @@ GPPortType gp_port_library_type (void) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"()"); - return GP_PORT_USB; + return GP_PORT_USB; } int @@ -176,16 +176,16 @@ static int gp_port_vusb_reset(GPPort *port) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"()"); - C_PARAMS (port && port->pl); + C_PARAMS (port && port->pl); - return GP_OK; + return GP_OK; } static int gp_port_vusb_check_int (GPPort *port, char *bytes, int size, int timeout) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"()"); - C_PARAMS (port && port->pl && timeout >= 0); + C_PARAMS (port && port->pl && timeout >= 0); return port->pl->vcamera->readint(port->pl->vcamera, (unsigned char*)bytes, size, timeout); } @@ -200,28 +200,28 @@ gp_port_vusb_update (GPPort *port) static int gp_port_vusb_clear_halt_lib(GPPort *port, int ep) { - unsigned char internal_ep; + unsigned char internal_ep; gp_log(GP_LOG_DEBUG,__FUNCTION__,"()"); - C_PARAMS (port && port->pl); - - switch (ep) { - case GP_PORT_USB_ENDPOINT_IN : - internal_ep = port->settings.usb.inep; - break; - case GP_PORT_USB_ENDPOINT_OUT : - internal_ep = port->settings.usb.outep; - break; - case GP_PORT_USB_ENDPOINT_INT : - internal_ep = port->settings.usb.intep; - break; - default: - gp_port_set_error (port, "Bad EndPoint argument 0x%x", ep); - return GP_ERROR_BAD_PARAMETERS; - } + C_PARAMS (port && port->pl); + + switch (ep) { + case GP_PORT_USB_ENDPOINT_IN : + internal_ep = port->settings.usb.inep; + break; + case GP_PORT_USB_ENDPOINT_OUT : + internal_ep = port->settings.usb.outep; + break; + case GP_PORT_USB_ENDPOINT_INT : + internal_ep = port->settings.usb.intep; + break; + default: + gp_port_set_error (port, "Bad EndPoint argument 0x%x", ep); + return GP_ERROR_BAD_PARAMETERS; + } gp_log(GP_LOG_DEBUG,"gp_port_vusb_clear_halt_lib","clearing halt on ep 0x%x", internal_ep); /* now clear halt */ - return GP_OK; + return GP_OK; } /* The next two functions support the nonstandard request types 0x41 (write) @@ -229,16 +229,16 @@ gp_port_vusb_clear_halt_lib(GPPort *port, int ep) */ static int gp_port_vusb_msg_interface_write_lib(GPPort *port, int request, - int value, int index, char *bytes, int size) + int value, int index, char *bytes, int size) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"()"); - return GP_OK; + return GP_OK; } static int gp_port_vusb_msg_interface_read_lib(GPPort *port, int request, - int value, int index, char *bytes, int size) + int value, int index, char *bytes, int size) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"(req=%x, value=%x, index=%d, size=%d)", request, value, index, size); return port->pl->vcamera->read(port->pl->vcamera, 0x81, (unsigned char*)bytes, size); @@ -250,7 +250,7 @@ gp_port_vusb_msg_interface_read_lib(GPPort *port, int request, */ static int gp_port_vusb_msg_class_write_lib(GPPort *port, int request, - int value, int index, char *bytes, int size) + int value, int index, char *bytes, int size) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"()"); return GP_OK; @@ -260,16 +260,16 @@ gp_port_vusb_msg_class_write_lib(GPPort *port, int request, static int gp_port_vusb_msg_class_read_lib(GPPort *port, int request, - int value, int index, char *bytes, int size) + int value, int index, char *bytes, int size) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"()"); - return GP_OK; /* or bytes */ + return GP_OK; /* or bytes */ } static int gp_port_vusb_msg_write_lib(GPPort *port, int request, int value, int index, - char *bytes, int size) + char *bytes, int size) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"()"); return GP_OK; @@ -277,7 +277,7 @@ gp_port_vusb_msg_write_lib(GPPort *port, int request, int value, int index, static int gp_port_vusb_msg_read_lib(GPPort *port, int request, int value, int index, - char *bytes, int size) + char *bytes, int size) { gp_log(GP_LOG_DEBUG,__FUNCTION__,"(req=%x, value=%x, index=%x, size=%d)", request, value, index, size); return port->pl->vcamera->read(port->pl->vcamera, index, (unsigned char*)bytes, size); @@ -321,18 +321,18 @@ gp_port_vusb_find_device_lib(GPPort *port, int idvendor, int idproduct) if ((idvendor == vendor) && (idproduct == product)) { #endif - port->settings.usb.config = 1; - port->settings.usb.interface = 1; - port->settings.usb.altsetting = 1; - - port->settings.usb.inep = 0x81; - port->settings.usb.outep = 0x02; - port->settings.usb.intep = 0x83; - port->settings.usb.maxpacketsize = 512; + port->settings.usb.config = 1; + port->settings.usb.interface = 1; + port->settings.usb.altsetting = 1; + + port->settings.usb.inep = 0x81; + port->settings.usb.outep = 0x02; + port->settings.usb.intep = 0x83; + port->settings.usb.maxpacketsize = 512; return GP_OK; } gp_log(GP_LOG_DEBUG,__FUNCTION__,"(0x%04x,0x%04x)", idvendor, idproduct); - return GP_ERROR_IO_USB_FIND; + return GP_ERROR_IO_USB_FIND; } static int @@ -342,18 +342,18 @@ gp_port_vusb_find_device_by_class_lib(GPPort *port, int class, int subclass, int #ifdef FUZZ_PTP if ((class == 6) && (subclass == 1) && (protocol == 1)) { - port->settings.usb.config = 1; - port->settings.usb.interface = 1; - port->settings.usb.altsetting = 1; - - port->settings.usb.inep = 0x81; - port->settings.usb.outep = 0x02; - port->settings.usb.intep = 0x83; - port->settings.usb.maxpacketsize = 512; + port->settings.usb.config = 1; + port->settings.usb.interface = 1; + port->settings.usb.altsetting = 1; + + port->settings.usb.inep = 0x81; + port->settings.usb.outep = 0x02; + port->settings.usb.intep = 0x83; + port->settings.usb.maxpacketsize = 512; return GP_OK; } #endif - return GP_ERROR_IO_USB_FIND; + return GP_ERROR_IO_USB_FIND; } @@ -376,20 +376,20 @@ gp_port_library_operations (void) ops->write = gp_port_vusb_write; ops->reset = gp_port_vusb_reset; - ops->check_int = gp_port_vusb_check_int; - ops->update = gp_port_vusb_update; - ops->clear_halt = gp_port_vusb_clear_halt_lib; - ops->msg_write = gp_port_vusb_msg_write_lib; - ops->msg_read = gp_port_vusb_msg_read_lib; - - ops->msg_interface_write = gp_port_vusb_msg_interface_write_lib; - ops->msg_interface_read = gp_port_vusb_msg_interface_read_lib; - ops->msg_class_write = gp_port_vusb_msg_class_write_lib; - ops->msg_class_read = gp_port_vusb_msg_class_read_lib; - ops->send_scsi_cmd = gp_port_vusb_send_scsi_cmd; - ops->seek = gp_port_vusb_seek; - - ops->find_device = gp_port_vusb_find_device_lib; - ops->find_device_by_class = gp_port_vusb_find_device_by_class_lib; + ops->check_int = gp_port_vusb_check_int; + ops->update = gp_port_vusb_update; + ops->clear_halt = gp_port_vusb_clear_halt_lib; + ops->msg_write = gp_port_vusb_msg_write_lib; + ops->msg_read = gp_port_vusb_msg_read_lib; + + ops->msg_interface_write = gp_port_vusb_msg_interface_write_lib; + ops->msg_interface_read = gp_port_vusb_msg_interface_read_lib; + ops->msg_class_write = gp_port_vusb_msg_class_write_lib; + ops->msg_class_read = gp_port_vusb_msg_class_read_lib; + ops->send_scsi_cmd = gp_port_vusb_send_scsi_cmd; + ops->seek = gp_port_vusb_seek; + + ops->find_device = gp_port_vusb_find_device_lib; + ops->find_device_by_class = gp_port_vusb_find_device_by_class_lib; return ops; } diff --git a/tests/test-i18n.c b/tests/test-i18n.c index 90b27a0be2..7c4d11598b 100644 --- a/tests/test-i18n.c +++ b/tests/test-i18n.c @@ -62,10 +62,10 @@ void print_locale_list(const size_t list_count, char *locale = setlocale(LC_ALL, list[i]); if (locale) { printf("Translated empty string to '%s' (%s):\n", - list[i], locale); - indented_print(" ", - dgettext(GETTEXT_PACKAGE_LIBGPHOTO2, - "")); + list[i], locale); + indented_print(" ", + dgettext(GETTEXT_PACKAGE_LIBGPHOTO2, + "")); setlocale(LC_ALL, "C"); } else { printf("Skipping locale: '%s'\n", list[i]);