diff --git a/camlibs/ax203/ax203.c b/camlibs/ax203/ax203.c index 0670bbd58..62f572686 100644 --- a/camlibs/ax203/ax203.c +++ b/camlibs/ax203/ax203.c @@ -1279,7 +1279,7 @@ static int ax203_defrag_memory(Camera *camera) { char **raw_pictures; - struct ax203_fileinfo *fileinfo; + struct ax203_fileinfo *fileinfo; int i, count, ret = GP_OK; count = ax203_read_filecount (camera); @@ -1399,7 +1399,7 @@ static int ax203_build_used_mem_table(Camera *camera, struct ax203_fileinfo *table) { int i, count, found = 0; - struct ax203_fileinfo fileinfo; + struct ax203_fileinfo fileinfo; count = ax203_read_filecount (camera); if (count < 0) return count; diff --git a/camlibs/ax203/ax203_decode_yuv_delta.c b/camlibs/ax203/ax203_decode_yuv_delta.c index 43779cef6..3bb99e4b3 100644 --- a/camlibs/ax203/ax203_decode_yuv_delta.c +++ b/camlibs/ax203/ax203_decode_yuv_delta.c @@ -62,7 +62,7 @@ ax203_decode_component_values(char *src, char *dest) { int i, table, corr; dest[0] = src[0] & ~0x07; - table = (src[0] >> 1) & 3; + table = (src[0] >> 1) & 3; for (i = 1; i < 4; i++) { switch (i) { diff --git a/camlibs/ax203/library.c b/camlibs/ax203/library.c index 31760dc31..db039ef33 100644 --- a/camlibs/ax203/library.c +++ b/camlibs/ax203/library.c @@ -474,9 +474,9 @@ camera_exit (Camera *camera, GPContext *context) int camera_init (Camera *camera, GPContext *context) { - CameraAbilities a; - int i, ret; - char *dump, buf[256]; + CameraAbilities a; + int i, ret; + char *dump, buf[256]; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; diff --git a/camlibs/canon/library.c b/camlibs/canon/library.c index 02fe91e7b..18b894b2f 100644 --- a/camlibs/canon/library.c +++ b/camlibs/canon/library.c @@ -1248,15 +1248,15 @@ get_last_file (Camera *camera, char *directory, char *destname, static int get_last_picture (Camera *camera, char *directory, char *destname, GPContext* context) { - GP_DEBUG ("get_last_picture()"); - return get_last_file(camera, directory, destname, context, 0, destname); + GP_DEBUG ("get_last_picture()"); + return get_last_file(camera, directory, destname, context, 0, destname); } static int get_last_dir (Camera *camera, char *directory, char *destname, GPContext* context) { - GP_DEBUG ("get_last_dir()"); - return get_last_file(camera, directory, destname, context, 1, destname); + GP_DEBUG ("get_last_dir()"); + return get_last_file(camera, directory, destname, context, 1, destname); } /* @@ -1267,21 +1267,20 @@ get_last_dir (Camera *camera, char *directory, char *destname, GPContext* contex static void convert_filename_to_8_3(const char* filename, char* dest) { - char*c; - GP_DEBUG ("convert_filename_to_8_3()"); - c = strchr(filename, '.'); - if(!c) { - sprintf(dest, "%.8s", filename); - } - else { - int l = c-filename; - if(l>8) - l=8; - memcpy(dest, filename, l); - dest[l]=0; - strcat(dest, c); - dest[l+4]=0; - } + char*c; + GP_DEBUG ("convert_filename_to_8_3()"); + c = strchr(filename, '.'); + if (!c) { + sprintf(dest, "%.8s", filename); + } else { + int l = c-filename; + if (l>8) + l=8; + memcpy(dest, filename, l); + dest[l]=0; + strcat(dest, c); + dest[l+4]=0; + } } diff --git a/camlibs/canon/ps350/ps350chk.c b/camlibs/canon/ps350/ps350chk.c index fd893689b..254c46128 100644 --- a/camlibs/canon/ps350/ps350chk.c +++ b/camlibs/canon/ps350/ps350chk.c @@ -62,97 +62,97 @@ void main (void) { - long datalen = 296; /* number of data bytes. Always 296. */ + long datalen = 296; /* number of data bytes. Always 296. */ - char data[] = - {0x05, 0x03, 0x04, 0x00, 0x01, -/* this is a EOT packet, count=5. The checksum is "87 3F" (LSByte-first!) */ + char data[] = + { + 0x05, 0x03, 0x04, 0x00, 0x01, + /* this is a EOT packet, count=5. The checksum is "87 3F" (LSByte-first!) */ -/* a few 0's to fill up the packet (far too much 0's actually, but that's - no problem) */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + /* a few 0's to fill up the packet (far too much 0's actually, but that's no problem) */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; -/* from a serial snoop: jut some arbitrary packet from a JPG download. */ -/* rename this to `data' and the original `data' to `data1' to try it. */ - char data1[] = - { - /* 0x3f1e */ /* 0xC0, */ 0x05, - /* 0x3f20 */ 0x10, 0x24, 0x81, 0x4d, 0xf6, 0xa7, 0x52, 0xbd, - /* 0x3f28 */ 0x83, 0xec, 0xe9, 0x88, 0xbc, 0xcc, 0x0f, 0x90, - /* 0x3f30 */ 0xf4, 0x99, 0x97, 0xb0, 0xf6, 0xae, 0xa3, 0x9b, - /* 0x3f38 */ 0x99, 0x98, 0xb6, 0xf7, 0xfb, 0x55, 0x8b, 0xbe, - /* 0x3f40 */ 0x23, 0x68, 0xf3, 0xc7, 0xad, 0x72, 0xe6, 0xf2, - /* 0x3f48 */ 0x1b, 0x88, 0xdf, 0x9c, 0x1e, 0xb4, 0xa3, 0x1d, - /* 0x3f50 */ 0x59, 0xac, 0xe5, 0xa9, 0xdd, 0xe8, 0x97, 0x65, - /* 0x3f58 */ 0x63, 0xd9, 0xe6, 0x7c, 0xb8, 0xad, 0x2b, 0x8b, - /* 0x3f60 */ 0xce, 0x3f, 0xa5, 0x73, 0x3d, 0xcd, 0x8c, 0xc9, - /* 0x3f68 */ 0x65, 0xbb, 0xfb, 0x3f, 0x99, 0x1d, 0xc4, 0xa0, - /* 0x3f70 */ 0x15, 0x3c, 0x29, 0xf4, 0xc7, 0xbf, 0xbd, 0x32, - /* 0x3f78 */ 0xfa, 0xd6, 0xf6, 0xde, 0x29, 0x0f, 0xf6, 0x9d, - /* 0x3f80 */ 0xe4, 0xbf, 0x7b, 0xfd, 0x58, 0x27, 0xa2, 0xb3, - /* 0x3f88 */ 0x7f, 0x7b, 0xfd, 0x9f, 0xd6, 0xb7, 0x80, 0x4a, - /* 0x3f90 */ 0x71, 0xb6, 0xa8, 0xdd, 0xd1, 0xe0, 0x31, 0xe8, - /* 0x3f98 */ 0x0c, 0xc3, 0xed, 0xb7, 0x33, 0xc2, 0x0b, 0x71, - /* 0x3fa0 */ 0xbb, 0xe6, 0xff, 0x00, 0x67, 0x83, 0xd6, 0x9d, - /* 0x3fa8 */ 0xb0, 0xde, 0x68, 0xcf, 0x25, 0xd5, 0xbd, 0xf5, - /* 0x3fb0 */ 0x85, 0xc4, 0xaa, 0x53, 0x6c, 0x9b, 0xb3, 0x1f, - /* 0x3fb8 */ 0xd7, 0x35, 0xc9, 0x3d, 0x64, 0xf5, 0x34, 0x53, - /* 0x3fc0 */ 0x56, 0x5a, 0x1c, 0xb4, 0x30, 0x6a, 0x37, 0x1c, - /* 0x3fc8 */ 0x0d, 0x52, 0xfa, 0x3c, 0x7f, 0x7f, 0x23, 0xbb, - /* 0x3fd0 */ 0x8f, 0xef, 0x7f, 0xb2, 0x7f, 0xef, 0xaa, 0x82, - /* 0x3fd8 */ 0xe1, 0x6f, 0xfc, 0xdb, 0x88, 0x5f, 0x52, 0xbb, - /* 0x3fe0 */ 0xf9, 0x37, 0x7c, 0xcc, 0x4e, 0x1b, 0x0e, 0x57, - /* 0x3fe8 */ 0xfb, 0xde, 0xd5, 0xe8, 0x9c, 0x7e, 0xd2, 0x1d, - /* 0x3ff0 */ 0x8e, 0x46, 0x6b, 0xc9, 0x3e, 0x62, 0x64, 0xce, - /* 0x3ff8 */ 0x17, 0xb9, 0xed, 0x5c, 0xaa, 0xdc, 0xb8, 0x47, - /* 0x4000 */ 0x22, 0xba, 0x60, 0x8c, 0x31, 0x0e, 0xcc, 0xf4, - /* 0x4008 */ 0x5d, 0x2e, 0xf0, 0x06, 0x45, 0xdd, 0xc7, 0x7a, - /* 0x4010 */ 0xda, 0xbb, 0xbb, 0xc4, 0x13, 0x30, 0x2c, 0xc5, - /* 0x4018 */ 0x57, 0x27, 0x00, 0xf1, 0x9e, 0x95, 0xc1, 0x34, - /* 0x4020 */ 0x74, 0xa6, 0x32, 0xea, 0xfa, 0xca, 0x4d, 0x21, - /* 0x4028 */ 0x55, 0x65, 0x5f, 0x33, 0x04, 0x00, 0x47, 0x5e, - /* 0x4030 */ 0x63, 0xcf, 0x24, 0x7b, 0x51, 0xa8, 0x6b, 0x16, - /* 0x4038 */ 0xf7, 0x31, 0x4b, 0x1d, 0xad, 0xc2, 0x33, 0x37, - /* 0x4040 */ 0x98, 0xa7, 0x2c, 0x07, 0x58, 0x9c, 0x77, 0x6e, - /* 0x4048 */ 0xc7, 0xc1}; -/* note: last 3 bytes are chksum and trailer */ + /* from a serial snoop: jut some arbitrary packet from a JPG download. */ + /* rename this to `data' and the original `data' to `data1' to try it. */ + char data1[] = + { + /* 0x3f1e */ /* 0xC0, */ 0x05, + /* 0x3f20 */ 0x10, 0x24, 0x81, 0x4d, 0xf6, 0xa7, 0x52, 0xbd, + /* 0x3f28 */ 0x83, 0xec, 0xe9, 0x88, 0xbc, 0xcc, 0x0f, 0x90, + /* 0x3f30 */ 0xf4, 0x99, 0x97, 0xb0, 0xf6, 0xae, 0xa3, 0x9b, + /* 0x3f38 */ 0x99, 0x98, 0xb6, 0xf7, 0xfb, 0x55, 0x8b, 0xbe, + /* 0x3f40 */ 0x23, 0x68, 0xf3, 0xc7, 0xad, 0x72, 0xe6, 0xf2, + /* 0x3f48 */ 0x1b, 0x88, 0xdf, 0x9c, 0x1e, 0xb4, 0xa3, 0x1d, + /* 0x3f50 */ 0x59, 0xac, 0xe5, 0xa9, 0xdd, 0xe8, 0x97, 0x65, + /* 0x3f58 */ 0x63, 0xd9, 0xe6, 0x7c, 0xb8, 0xad, 0x2b, 0x8b, + /* 0x3f60 */ 0xce, 0x3f, 0xa5, 0x73, 0x3d, 0xcd, 0x8c, 0xc9, + /* 0x3f68 */ 0x65, 0xbb, 0xfb, 0x3f, 0x99, 0x1d, 0xc4, 0xa0, + /* 0x3f70 */ 0x15, 0x3c, 0x29, 0xf4, 0xc7, 0xbf, 0xbd, 0x32, + /* 0x3f78 */ 0xfa, 0xd6, 0xf6, 0xde, 0x29, 0x0f, 0xf6, 0x9d, + /* 0x3f80 */ 0xe4, 0xbf, 0x7b, 0xfd, 0x58, 0x27, 0xa2, 0xb3, + /* 0x3f88 */ 0x7f, 0x7b, 0xfd, 0x9f, 0xd6, 0xb7, 0x80, 0x4a, + /* 0x3f90 */ 0x71, 0xb6, 0xa8, 0xdd, 0xd1, 0xe0, 0x31, 0xe8, + /* 0x3f98 */ 0x0c, 0xc3, 0xed, 0xb7, 0x33, 0xc2, 0x0b, 0x71, + /* 0x3fa0 */ 0xbb, 0xe6, 0xff, 0x00, 0x67, 0x83, 0xd6, 0x9d, + /* 0x3fa8 */ 0xb0, 0xde, 0x68, 0xcf, 0x25, 0xd5, 0xbd, 0xf5, + /* 0x3fb0 */ 0x85, 0xc4, 0xaa, 0x53, 0x6c, 0x9b, 0xb3, 0x1f, + /* 0x3fb8 */ 0xd7, 0x35, 0xc9, 0x3d, 0x64, 0xf5, 0x34, 0x53, + /* 0x3fc0 */ 0x56, 0x5a, 0x1c, 0xb4, 0x30, 0x6a, 0x37, 0x1c, + /* 0x3fc8 */ 0x0d, 0x52, 0xfa, 0x3c, 0x7f, 0x7f, 0x23, 0xbb, + /* 0x3fd0 */ 0x8f, 0xef, 0x7f, 0xb2, 0x7f, 0xef, 0xaa, 0x82, + /* 0x3fd8 */ 0xe1, 0x6f, 0xfc, 0xdb, 0x88, 0x5f, 0x52, 0xbb, + /* 0x3fe0 */ 0xf9, 0x37, 0x7c, 0xcc, 0x4e, 0x1b, 0x0e, 0x57, + /* 0x3fe8 */ 0xfb, 0xde, 0xd5, 0xe8, 0x9c, 0x7e, 0xd2, 0x1d, + /* 0x3ff0 */ 0x8e, 0x46, 0x6b, 0xc9, 0x3e, 0x62, 0x64, 0xce, + /* 0x3ff8 */ 0x17, 0xb9, 0xed, 0x5c, 0xaa, 0xdc, 0xb8, 0x47, + /* 0x4000 */ 0x22, 0xba, 0x60, 0x8c, 0x31, 0x0e, 0xcc, 0xf4, + /* 0x4008 */ 0x5d, 0x2e, 0xf0, 0x06, 0x45, 0xdd, 0xc7, 0x7a, + /* 0x4010 */ 0xda, 0xbb, 0xbb, 0xc4, 0x13, 0x30, 0x2c, 0xc5, + /* 0x4018 */ 0x57, 0x27, 0x00, 0xf1, 0x9e, 0x95, 0xc1, 0x34, + /* 0x4020 */ 0x74, 0xa6, 0x32, 0xea, 0xfa, 0xca, 0x4d, 0x21, + /* 0x4028 */ 0x55, 0x65, 0x5f, 0x33, 0x04, 0x00, 0x47, 0x5e, + /* 0x4030 */ 0x63, 0xcf, 0x24, 0x7b, 0x51, 0xa8, 0x6b, 0x16, + /* 0x4038 */ 0xf7, 0x31, 0x4b, 0x1d, 0xad, 0xc2, 0x33, 0x37, + /* 0x4040 */ 0x98, 0xa7, 0x2c, 0x07, 0x58, 0x9c, 0x77, 0x6e, + /* 0x4048 */ 0xc7, 0xc1 }; + /* note: last 3 bytes are chksum and trailer */ - char bits[] = - {1, 2, 4, 8, 16, 32, 64, 128}; - long chksum = 0; - long i, j; - int inputbit, lastbit, xorbit; + char bits[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; + long chksum = 0; + long i, j; + int inputbit, lastbit, xorbit; -/* calculate checksum */ - for (i = 0; i < datalen; i++) - for (j = 0; j <= 7; j++) - { - lastbit = chksum & 0x0001; /* remember if last bit was 1 */ - chksum >>= 1; /* shift 1 place */ - inputbit = data[i] & bits[j] ? 1 : 0; /* the In bit */ - xorbit = inputbit ^ lastbit; /* output of upper XOR gate */ - if (xorbit) /* XOR if needed */ - chksum ^= 0x8408; - } + /* calculate checksum */ + for (i = 0; i < datalen; i++) + for (j = 0; j <= 7; j++) + { + lastbit = chksum & 0x0001; /* remember if last bit was 1 */ + chksum >>= 1; /* shift 1 place */ + inputbit = data[i] & bits[j] ? 1 : 0; /* the In bit */ + xorbit = inputbit ^ lastbit; /* output of upper XOR gate */ + if (xorbit) /* XOR if needed */ + chksum ^= 0x8408; + } -/* display checksum */ - printf ("Checksum: 0x%lX\n", chksum); + /* display checksum */ + printf ("Checksum: 0x%lX\n", chksum); } diff --git a/camlibs/canon/ps350/renamejpg.c b/camlibs/canon/ps350/renamejpg.c index 43f9520bf..b3128d544 100644 --- a/camlibs/canon/ps350/renamejpg.c +++ b/camlibs/canon/ps350/renamejpg.c @@ -7,68 +7,68 @@ void main (int argc, char **argv) { - FILE *jpgfile; - time_t time; - struct tm *temptm; - unsigned char buffer[4]; - char timestring[200]; - char tempstring[300]; - char newname[300]; - int i; - struct stat statbuf; - struct stat statbuf2; - int newnamecounter; + FILE *jpgfile; + time_t time; + struct tm *temptm; + unsigned char buffer[4]; + char timestring[200]; + char tempstring[300]; + char newname[300]; + int i; + struct stat statbuf; + struct stat statbuf2; + int newnamecounter; - if (argc < 2) - { - fprintf (stderr, "Usage: renamejpg [filename(s)]\n\n"); - exit(1); - } - - for (i=1; i %s\n", argv[i], statbuf.st_size, - timestring, newname); + for (i=1; i %s\n", argv[i], statbuf.st_size, + timestring, newname); + + fclose(jpgfile); + + rename(argv[i], newname); + } } diff --git a/camlibs/canon/usb.c b/camlibs/canon/usb.c index b134b9704..9e2777ff7 100644 --- a/camlibs/canon/usb.c +++ b/camlibs/canon/usb.c @@ -451,7 +451,7 @@ canon_usb_init (Camera *camera, GPContext *context) #if 0 /* FIXME: as raspberry user confirmed the need for those... - * I am currently not sure why I added them. + * I am currently not sure why I added them. */ gp_port_usb_clear_halt (camera->port, GP_PORT_USB_ENDPOINT_IN); gp_port_usb_clear_halt (camera->port, GP_PORT_USB_ENDPOINT_OUT); @@ -887,7 +887,7 @@ static int canon_usb_poll_interrupt_pipe ( Camera *camera, unsigned char *buf, u /* Either some real data, or failure */ if ( status != 0 && status != GP_ERROR_TIMEOUT) break; - gettimeofday ( &cur, NULL ); + gettimeofday (&cur, NULL); curduration = (cur.tv_sec-start.tv_sec)*1000 + (cur.tv_usec-start.tv_usec)/1000; if (curduration >= timeout) { diff --git a/camlibs/clicksmart310/clicksmart.h b/camlibs/clicksmart310/clicksmart.h index 797c75a5d..bd48c0370 100644 --- a/camlibs/clicksmart310/clicksmart.h +++ b/camlibs/clicksmart310/clicksmart.h @@ -36,7 +36,7 @@ int clicksmart_init (GPPort *port, CameraPrivateLibrary *priv); int clicksmart_get_res_setting (CameraPrivateLibrary *priv, int n); int clicksmart_read_pic_data (CameraPrivateLibrary *priv, GPPort *port, unsigned char **data, - int n); + int n); int clicksmart_delete_all_pics (GPPort *port); int clicksmart_reset (GPPort *port); diff --git a/camlibs/clicksmart310/spca50x-jpeg-header.h b/camlibs/clicksmart310/spca50x-jpeg-header.h index 3fbe30891..34aa9168e 100644 --- a/camlibs/clicksmart310/spca50x-jpeg-header.h +++ b/camlibs/clicksmart310/spca50x-jpeg-header.h @@ -105,13 +105,13 @@ static unsigned char SPCA50xQTable[20][64]= { /* index 0, Q50 */ { 16, 11, 12, 14, 12, 10, 16, 14, 13, 14, 18, 17, 16, 19, 24, 40, - 26, 24, 22, 22, 24, 49, 35, 37, 29, 40, 58, 51, 61, 60, 57, 51, - 56, 55, 64, 72, 92, 78, 64, 68, 87, 69, 55, 56, 80,109, 81, 87, - 95, 98,103,104,103, 62, 77,113,121,112,100,120, 92,101,103, 99 }, + 26, 24, 22, 22, 24, 49, 35, 37, 29, 40, 58, 51, 61, 60, 57, 51, + 56, 55, 64, 72, 92, 78, 64, 68, 87, 69, 55, 56, 80,109, 81, 87, + 95, 98,103,104,103, 62, 77,113,121,112,100,120, 92,101,103, 99 }, { 17, 18, 18, 24, 21, 24, 47, 26, 26, 47, 99, 66, 56, 66, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, - 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99 }, /* index 1, Q70 */ { 10, 7, 7, 8, 7, 6, 10, 8, 8, 8, 11, 10, 10, 11, 14, 24, diff --git a/camlibs/digigr8/digi_postprocess.c b/camlibs/digigr8/digi_postprocess.c index 12693a6c3..f6c35e047 100644 --- a/camlibs/digigr8/digi_postprocess.c +++ b/camlibs/digigr8/digi_postprocess.c @@ -40,7 +40,7 @@ static int digi_first_decompress (unsigned char *output, unsigned char *input, - unsigned int outputsize) + unsigned int outputsize) { unsigned char parity = 0; unsigned char nibble_to_keep[2]; @@ -111,7 +111,7 @@ digi_first_decompress (unsigned char *output, unsigned char *input, static int digi_second_decompress (unsigned char *uncomp, unsigned char *in, - int width, int height) + int width, int height) { int diff = 0; int tempval = 0; @@ -129,7 +129,7 @@ digi_second_decompress (unsigned char *uncomp, unsigned char *in, return GP_ERROR_NO_MEMORY; } for(i=0; i < width; i++) - templine_red[i] = 0x80; + templine_red[i] = 0x80; templine_green = malloc(width); if (!templine_green) { @@ -161,8 +161,8 @@ digi_second_decompress (unsigned char *uncomp, unsigned char *in, tempval = templine_red[0] + diff; else tempval = (templine_red[i] - + uncomp[2 *m * width + 2 * i - 2]) / 2 - + diff; + + uncomp[2 *m * width + 2 * i - 2]) / 2 + + diff; tempval = MIN(tempval, 0xff); tempval = MAX(tempval, 0); uncomp[2 * m * width + 2 * i] = tempval; @@ -173,12 +173,12 @@ digi_second_decompress (unsigned char *uncomp, unsigned char *in, tempval = templine_green[1] + diff; else if (2 * i == width - 2 ) tempval = (templine_green[i] - + uncomp[2 * m * width + 2 * i -1]) / 2 - + diff; + + uncomp[2 * m * width + 2 * i -1]) / 2 + + diff; else tempval = (templine_green[i + 1] - + uncomp[2 * m * width + 2 * i - 1]) / 2 - + diff; + + uncomp[2 * m * width + 2 * i - 1]) / 2 + + diff; tempval = MIN(tempval, 0xff); tempval = MAX(tempval, 0); uncomp[2 * m * width + 2 * i + 1] = tempval; @@ -195,8 +195,8 @@ digi_second_decompress (unsigned char *uncomp, unsigned char *in, tempval = templine_green[0] + diff; else tempval = (templine_green[i] - + uncomp[(2 * m + 1) * width - + 2 * i - 2]) / 2 + diff; + + uncomp[(2 * m + 1) * width + + 2 * i - 2]) / 2 + diff; tempval = MIN(tempval, 0xff); tempval = MAX(tempval, 0); uncomp[(2 * m + 1) * width + 2 * i] = tempval; @@ -207,8 +207,8 @@ digi_second_decompress (unsigned char *uncomp, unsigned char *in, tempval = templine_blue[0] + diff; else tempval = (templine_blue[i] - + uncomp[(2 * m + 1) * width - + 2 * i - 1]) / 2 + diff; + + uncomp[(2 * m + 1) * width + + 2 * i - 1]) / 2 + diff; tempval = MIN(tempval, 0xff); tempval = MAX(tempval, 0); uncomp[(2 * m + 1) * width + 2 * i + 1] = tempval; @@ -331,7 +331,7 @@ digi_postprocess(int width, int height, static int histogram (unsigned char *data, unsigned int size, int *htable_r, - int *htable_g, int *htable_b) + int *htable_g, int *htable_b) { unsigned int x; /* Initializations */ diff --git a/camlibs/digigr8/digigr8.h b/camlibs/digigr8/digigr8.h index 8201984d9..108ffcbde 100644 --- a/camlibs/digigr8/digigr8.h +++ b/camlibs/digigr8/digigr8.h @@ -32,7 +32,7 @@ int digi_reset (GPPort *); int digi_init (GPPort *, CameraPrivateLibrary *); int digi_rewind (GPPort *port, CameraPrivateLibrary *priv); int digi_read_picture_data (GPPort *, unsigned char *data, - unsigned int size, int n); + unsigned int size, int n); /* Those functions don't need data transfer with the camera */ int digi_get_num_frames (CameraPrivateLibrary *, int entry); @@ -40,8 +40,7 @@ unsigned int digi_get_comp_ratio (CameraPrivateLibrary *, int entry); unsigned int digi_get_data_size (CameraPrivateLibrary *, int entry); unsigned int digi_get_picture_width (CameraPrivateLibrary *, int entry); int digi_is_clip (CameraPrivateLibrary *, int entry); -int digi_decompress (unsigned char *out_data, unsigned char *data, - int w, int h); +int digi_decompress (unsigned char *out_data, unsigned char *data, int w, int h); int digi_postprocess (int width, int height, unsigned char* rgb); int digi_delete_all (GPPort *, CameraPrivateLibrary *priv); diff --git a/camlibs/digigr8/library.c b/camlibs/digigr8/library.c index 6b0f7a486..9b65c1895 100644 --- a/camlibs/digigr8/library.c +++ b/camlibs/digigr8/library.c @@ -217,8 +217,8 @@ get_file_func(CameraFilesystem *fs, const char *folder, const char *filename, if (GP_FILE_TYPE_EXIF ==type) return GP_ERROR_FILE_EXISTS; - if (GP_FILE_TYPE_RAW!=type && GP_FILE_TYPE_NORMAL - != type && GP_FILE_TYPE_PREVIEW != type) { + if (GP_FILE_TYPE_RAW != type + && GP_FILE_TYPE_NORMAL != type && GP_FILE_TYPE_PREVIEW != type) { return GP_ERROR_NOT_SUPPORTED; } diff --git a/camlibs/dimera/dimera3500.c b/camlibs/dimera/dimera3500.c index 9e0fe04d1..128804813 100644 --- a/camlibs/dimera/dimera3500.c +++ b/camlibs/dimera/dimera3500.c @@ -340,11 +340,11 @@ static int get_info_func (CameraFilesystem *fs, const char *folder, const char * info->file.permissions = GP_FILE_PERM_READ; if (std_res) { - info->file.width = 320; - info->file.height = 240; + info->file.width = 320; + info->file.height = 240; } else { - info->file.width = 640; - info->file.height = 480; + info->file.width = 640; + info->file.height = 480; } info->file.size = info->file.height*info->file.width*3 + sizeof( Dimera_finehdr ) - 1; diff --git a/camlibs/docupen/docupen.h b/camlibs/docupen/docupen.h index 3b9c44603..c9fd3c238 100644 --- a/camlibs/docupen/docupen.h +++ b/camlibs/docupen/docupen.h @@ -82,7 +82,7 @@ struct _CameraPrivateLibrary { }; struct lut { - unsigned char data[256]; + unsigned char data[256]; }; bool dp_cmd(GPPort *port, const char *cmd); diff --git a/camlibs/fuji/fuji.c b/camlibs/fuji/fuji.c index a6cdaaeea..a1c87e703 100644 --- a/camlibs/fuji/fuji.c +++ b/camlibs/fuji/fuji.c @@ -937,10 +937,10 @@ static int download_picture(int n,int thumb,CameraFile *file,CameraPrivateLibrar fuji_count * CLK_TCK / (int)(t2-t1)); if (fjd->has_cmd[17]&&!thumb){ - if (!thumb&&(fuji_count != fuji_size)){ - /* gp_frontend_status(NULL,"Short picture file--disk full or quota exceeded\n"); */ - return(GP_ERROR); - }; + if (!thumb&&(fuji_count != fuji_size)) { + /* gp_frontend_status(NULL,"Short picture file--disk full or quota exceeded\n"); */ + return(GP_ERROR); + }; }; return(GP_OK); diff --git a/camlibs/iclick/iclick.c b/camlibs/iclick/iclick.c index e1af9c04e..71c87ae69 100644 --- a/camlibs/iclick/iclick.c +++ b/camlibs/iclick/iclick.c @@ -155,7 +155,7 @@ icl_reset (GPPort *port) { icl_access_reg(port, CLEAR); /* Release current register */ - return GP_OK; + return GP_OK; } int @@ -171,7 +171,7 @@ icl_read_picture_data (GPPort *port, unsigned char *data, int size ) if (remainder) gp_port_read (port, (char *)data + offset, remainder); - return GP_OK; + return GP_OK; } diff --git a/camlibs/jd11/decomp.c b/camlibs/jd11/decomp.c index 51fe15c7b..a1b3c06fb 100644 --- a/camlibs/jd11/decomp.c +++ b/camlibs/jd11/decomp.c @@ -26,14 +26,16 @@ #include "decomp.h" -struct chain { int left,val,right; }; +struct chain { + int left,val,right; +}; struct compstate { - unsigned char curmask; - unsigned char bytebuf; - unsigned char *byteptr; + unsigned char curmask; + unsigned char bytebuf; + unsigned char *byteptr; - struct chain cl[200]; - int stackstart; + struct chain cl[200]; + int stackstart; }; /* FLOAT_QUERY: 0.860000 1.030000 1.150000. */ @@ -43,13 +45,13 @@ struct compstate { /********************************************************/ static inline int jd11_getbit(struct compstate *cs) { - int ret; - if (cs->curmask == 0x80) - cs->bytebuf = *cs->byteptr++; - ret = cs->curmask & cs->bytebuf; - cs->curmask >>=1; - if (!cs->curmask) cs->curmask = 0x80; - return !!ret; + int ret; + if (cs->curmask == 0x80) + cs->bytebuf = *cs->byteptr++; + ret = cs->curmask & cs->bytebuf; + cs->curmask >>=1; + if (!cs->curmask) cs->curmask = 0x80; + return !!ret; } /********************************************************/ @@ -57,17 +59,17 @@ jd11_getbit(struct compstate *cs) { /********************************************************/ static int decomp_1byte(struct compstate *cs) { - int xcs = cs->stackstart; - int xbit; + int xcs = cs->stackstart; + int xbit; - while ((cs->cl[xcs].left>=0) && (cs->cl[xcs].right>=0)) { - xbit = jd11_getbit(cs); - if (xbit) - xcs = cs->cl[xcs].left; - else - xcs = cs->cl[xcs].right; - } - return cs->cl[xcs].val; + while ((cs->cl[xcs].left>=0) && (cs->cl[xcs].right>=0)) { + xbit = jd11_getbit(cs); + if (xbit) + xcs = cs->cl[xcs].left; + else + xcs = cs->cl[xcs].right; + } + return cs->cl[xcs].val; } static void diff --git a/camlibs/jd11/jd11.c b/camlibs/jd11/jd11.c index 015084811..8153240ab 100644 --- a/camlibs/jd11/jd11.c +++ b/camlibs/jd11/jd11.c @@ -136,10 +136,10 @@ static int 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 jd11_erase_all(camera->port); + Camera *camera = data; + if (strcmp (folder, "/")) + return (GP_ERROR_DIRECTORY_NOT_FOUND); + return jd11_erase_all(camera->port); } static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) @@ -179,7 +179,7 @@ static int camera_config_get (Camera *camera, CameraWidget **window, gp_widget_set_name (section, "othersettings"); gp_widget_append (*window, section); - /* Bulb Exposure Time */ + /* Bulb Exposure Time */ gp_widget_new (GP_WIDGET_RANGE, _("Bulb Exposure Time"), &widget); gp_widget_set_name (widget, "exposuretime"); gp_widget_append (section, widget); @@ -194,7 +194,7 @@ static int camera_config_get (Camera *camera, CameraWidget **window, ret = jd11_get_rgb(camera->port,&red,&green,&blue); if (ret < GP_OK) - return ret; + return ret; gp_widget_new (GP_WIDGET_RANGE, _("Red"), &widget); gp_widget_append (section, widget); gp_widget_set_name (widget, "red"); @@ -235,7 +235,7 @@ static int camera_config_set (Camera *camera, CameraWidget *window, gp_widget_set_changed (widget, 0); ret = jd11_set_bulb_exposure(camera->port,(int)f); if (ret < GP_OK) - return ret; + return ret; } gp_widget_get_child_by_label (window, _("Color Settings"), §ion); @@ -260,7 +260,7 @@ static int camera_config_set (Camera *camera, CameraWidget *window, ret = GP_OK; if (changed) - ret =jd11_set_rgb(camera->port,red,green,blue); + ret =jd11_set_rgb(camera->port, red, green, blue); return ret; } diff --git a/camlibs/jd11/serial.c b/camlibs/jd11/serial.c index 97cd6d1e2..05ba9b52d 100644 --- a/camlibs/jd11/serial.c +++ b/camlibs/jd11/serial.c @@ -86,13 +86,13 @@ static int _read_cmd(GPPort *port,unsigned short *xcmd) { 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; - } + if (1==READ(port, buf+1, 1)) { + *xcmd = (buf[0] << 8)| buf[1]; + return GP_OK; + } } } else { - return ret; + return ret; } } while (i++<10); return GP_ERROR_IO; diff --git a/camlibs/jl2005a/jl2005a.c b/camlibs/jl2005a/jl2005a.c index 8094e5be6..13dd2c76e 100644 --- a/camlibs/jl2005a/jl2005a.c +++ b/camlibs/jl2005a/jl2005a.c @@ -173,7 +173,7 @@ jl2005a_reset (Camera *camera, GPPort *port) for (i=0; i < 4; i++) jl2005a_shortquery(port, 0x1d); /* Supposed to get something like 0x01, 0x01, 0x01, 0x00 */ - return GP_OK; + return GP_OK; } int jl2005a_read_info_byte(GPPort *port, int n) diff --git a/camlibs/jl2005a/jl2005a.h b/camlibs/jl2005a/jl2005a.h index c9ad4d71f..27945743f 100644 --- a/camlibs/jl2005a/jl2005a.h +++ b/camlibs/jl2005a/jl2005a.h @@ -38,7 +38,7 @@ struct _CameraPrivateLibrary { int jl2005a_init (Camera *camera, GPPort *port, - CameraPrivateLibrary *priv); + CameraPrivateLibrary *priv); int jl2005a_get_pic_data_size (GPPort *port, int n); int jl2005a_get_pic_width (GPPort *port); int jl2005a_get_pic_height (GPPort *port); diff --git a/camlibs/jl2005a/library.c b/camlibs/jl2005a/library.c index fbde6badf..33579b2dd 100644 --- a/camlibs/jl2005a/library.c +++ b/camlibs/jl2005a/library.c @@ -57,7 +57,7 @@ struct { unsigned short idProduct; } models[] = { {"American Idol Keychain Camera", GP_DRIVER_STATUS_TESTING, - 0x0979, 0x0224}, + 0x0979, 0x0224}, {"NogaNet TDC-15", GP_DRIVER_STATUS_TESTING, 0x0979, 0x0224}, {"Cobra DC125", GP_DRIVER_STATUS_EXPERIMENTAL, 0x0979, 0x0224}, {NULL,0,0,0} diff --git a/camlibs/jl2005c/jl2005c.c b/camlibs/jl2005c/jl2005c.c index b4ab334bd..c447a2300 100644 --- a/camlibs/jl2005c/jl2005c.c +++ b/camlibs/jl2005c/jl2005c.c @@ -248,18 +248,18 @@ int jl2005c_reset (Camera *camera, GPPort *port) * dumped before exit. If that is not yet done, then do it now! */ if(camera->pl->data_reg_opened) { while (camera->pl->bytes_read_from_camera < - camera->pl->total_data_in_camera ) { + camera->pl->total_data_in_camera ) { if (!camera->pl->data_cache ) camera->pl->data_cache = malloc (MAX_DLSIZE); downloadsize = MAX_DLSIZE; if (camera->pl->bytes_read_from_camera + MAX_DLSIZE >= - camera->pl->total_data_in_camera ) + camera->pl->total_data_in_camera ) downloadsize = camera->pl->total_data_in_camera - camera->pl->bytes_read_from_camera; if (downloadsize) jl2005c_read_data (camera->port, - (char *) camera->pl->data_cache, - downloadsize); + (char *) camera->pl->data_cache, + downloadsize); camera->pl->bytes_read_from_camera += downloadsize; } } diff --git a/camlibs/kodak/dc120/dc120.c b/camlibs/kodak/dc120/dc120.c index a0b65021d..4a9f5a7ed 100644 --- a/camlibs/kodak/dc120/dc120.c +++ b/camlibs/kodak/dc120/dc120.c @@ -77,125 +77,118 @@ int camera_abilities (CameraAbilitiesList *list) { static int find_folder( Camera *camera, const char *folder, int *from_card, int *folder_nr, GPContext *context) { - CameraList *albums = NULL; - const char* album_name; - size_t folder_len; - int i; - char *dc120_folder_card = _("CompactFlash Card"); + CameraList *albums = NULL; + const char* album_name; + size_t folder_len; + int i; + char *dc120_folder_card = _("CompactFlash Card"); - if( folder[0] != '/' ) { - return (GP_ERROR); - } - - folder++; - - if( folder[0] == '\0') { - /* From memory */ - *from_card = FALSE; - *folder_nr = 0; - return (GP_OK); - } - else if( strncmp(folder, dc120_folder_card, strlen(dc120_folder_card) )==0) { - /* From card */ - *from_card = TRUE; - folder += strlen(dc120_folder_card); - } - else { - /* Subfolder in memory */ - *from_card = FALSE; - folder--; /* step back to slash */ - } - - if ( (folder[0] == 0) || - (folder[0] == '/' && folder[1] == 0) ) { /* ok, finished */ - *folder_nr = 0; - return (GP_OK); - } - else if( folder[0] != '/' ) - return (GP_ERROR); - - folder++; /* remove slash */ - - /* Have trailing slash */ - folder_len = strlen(folder); - if (folder[folder_len-1] == '/') { - folder_len--; - } - - /* ok, now we have a album. first get all albums */ - if( gp_list_new( &albums ) != (GP_OK) ) { - return (GP_ERROR); - } - - if( dc120_get_albums(camera, *from_card, albums, context) != (GP_OK) ) { - gp_list_free( albums ); - return (GP_ERROR); - } - - /* no check if such a album exist */ - for( i = 0; i3 ) { - strcpy( dot+1, "ppm"); + strcpy( dot+1, "ppm"); } } return (dc120_file_action(camera, action, from_card, folder_nr, picnum+1, file, context)); diff --git a/camlibs/kodak/dc120/library.c b/camlibs/kodak/dc120/library.c index 848096667..3b9875a36 100644 --- a/camlibs/kodak/dc120/library.c +++ b/camlibs/kodak/dc120/library.c @@ -288,7 +288,7 @@ int dc120_get_status (Camera *camera, Kodak_dc120_status *status, GPContext *con CameraFile *file; char *p = dc120_packet_new(0x7F); int i; - int retval; + int retval; int size; gp_file_new (&file); diff --git a/camlibs/kodak/dc120/library.h b/camlibs/kodak/dc120/library.h index dc64eea82..1c8c0a883 100644 --- a/camlibs/kodak/dc120/library.h +++ b/camlibs/kodak/dc120/library.h @@ -31,34 +31,34 @@ /* Status structure. Copied from dc210, thus may not fit. */ typedef struct { - char camera_type_id; /* 1 */ - char firmware_major; /* 2 */ - char firmware_minor; /* 3 */ - char batteryStatusId; /* 8 battery status */ - char acStatusId; /* 9 */ - unsigned long time; /* 12-15 */ - char af_mode; /* 16 */ - char zoom_mode; /* 16 */ - char flash_charged; /* 18 */ - char compression_mode_id; /* 19 */ - char flash_mode; /* 20 */ - char exposure_compensation; /* 21 */ - char light_value; /* 22 measured light */ - char manual_exposure; /* 23 */ - unsigned long exposure_time; /* 24-27*/ - char shutter_delay; /* 29 */ - char memory_card; /* 30 */ - char front_cover; /* 31 */ - char date_format; /* 32 */ - char time_format; /* 33 */ - char distance_format; /* 34 */ - unsigned short taken_pict_mem; /* 36-37 */ - unsigned short remaining_pic_mem[4]; /* 46-53 */ - unsigned short taken_pict_card; /* 56-57 */ - unsigned short remaining_pic_card[4]; /* 66-73 */ - unsigned long album_count; /* 122-125 */ - char card_id[32]; /* 77-88 */ - char camera_id[32]; /* 90-122 */ + char camera_type_id; /* 1 */ + char firmware_major; /* 2 */ + char firmware_minor; /* 3 */ + char batteryStatusId; /* 8 battery status */ + char acStatusId; /* 9 */ + unsigned long time; /* 12-15 */ + char af_mode; /* 16 */ + char zoom_mode; /* 16 */ + char flash_charged; /* 18 */ + char compression_mode_id; /* 19 */ + char flash_mode; /* 20 */ + char exposure_compensation; /* 21 */ + char light_value; /* 22 measured light */ + char manual_exposure; /* 23 */ + unsigned long exposure_time; /* 24-27*/ + char shutter_delay; /* 29 */ + char memory_card; /* 30 */ + char front_cover; /* 31 */ + char date_format; /* 32 */ + char time_format; /* 33 */ + char distance_format; /* 34 */ + unsigned short taken_pict_mem; /* 36-37 */ + unsigned short remaining_pic_mem[4]; /* 46-53 */ + unsigned short taken_pict_card; /* 56-57 */ + unsigned short remaining_pic_card[4]; /* 66-73 */ + unsigned long album_count; /* 122-125 */ + char card_id[32]; /* 77-88 */ + char camera_id[32]; /* 90-122 */ } Kodak_dc120_status; int dc120_set_speed (Camera *camera, int speed); diff --git a/camlibs/kodak/dc210/dc210.c b/camlibs/kodak/dc210/dc210.c index b5dc4d0e6..27748aefb 100644 --- a/camlibs/kodak/dc210/dc210.c +++ b/camlibs/kodak/dc210/dc210.c @@ -86,9 +86,9 @@ int camera_abilities (CameraAbilitiesList *list) { static int file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, void *data, GPContext *context) { - Camera *camera = data; + Camera *camera = data; - return dc210_get_filenames(camera, list, context); + return dc210_get_filenames(camera, list, context); } static int get_file_func (CameraFilesystem *fs, const char *folder, diff --git a/camlibs/kodak/ez200/ez200.c b/camlibs/kodak/ez200/ez200.c index 127eeb045..d8213426c 100644 --- a/camlibs/kodak/ez200/ez200.c +++ b/camlibs/kodak/ez200/ez200.c @@ -135,7 +135,7 @@ ez200_read_picture_data (GPPort *port, char *data, int size, int n) { static int ez200_read_picture_header(GPPort *port, char *data) { /* lecture de l'entete :: read header of picture */ - READ(port, PICTURE_HEAD, 3, 3, data, HEADER_SIZE); + READ(port, PICTURE_HEAD, 3, 3, data, HEADER_SIZE); return GP_OK; } diff --git a/camlibs/largan/lmini/lmini_ccd.c b/camlibs/largan/lmini/lmini_ccd.c index af7dd5e37..57f993418 100644 --- a/camlibs/largan/lmini/lmini_ccd.c +++ b/camlibs/largan/lmini/lmini_ccd.c @@ -55,292 +55,289 @@ static const int uv_min[12]= { /* --------------------------------------------------------------------------- */ void largan_ccd2dib(char *pData, char *pDib, long dwDibRowBytes, int nCcdFactor) { - int i, j, w, h; - int YY[4], Cb, Cr; + int i, j, w, h; + int YY[4], Cb, Cr; - _nCcdFactor = nCcdFactor; + _nCcdFactor = nCcdFactor; - data = pData; + data = pData; -/************************************************/ + /************************************************/ - Cb = 0; - Cr = 0; + Cb = 0; + Cr = 0; - pre_y = 0; - pre_cb = 0; - pre_cr = 0; + pre_y = 0; + pre_cb = 0; + pre_cr = 0; - in_string = (*data << 8) | *(data + 1); + in_string = (*data << 8) | *(data + 1); - in_bit = 16; - count = 2; - out_index = 0; + in_bit = 16; + count = 2; + out_index = 0; /******************************************************/ - for (j = 0; j < 1200; j++) -{ - for (i = 0; i < 4; i++) - dhuf(0); + for (j = 0; j < 1200; j++) + { + for (i = 0; i < 4; i++) + dhuf(0); - dhuf(1); - dhuf(2); + dhuf(1); + dhuf(2); } - /* printf("Now process the DC term to R G B transfer !\n"); */ + /* printf("Now process the DC term to R G B transfer !\n"); */ - for (h = 0; h < 30; h++) /* mini size height = 30 x 2 */ + for (h = 0; h < 30; h++) /* mini size height = 30 x 2 */ { - for (w = 0; w < 40; w++) - { - for (i = 0; i < 6; i++) + for (w = 0; w < 40; w++) { - int k = i + w * 6 + h * 240; + for (i = 0; i < 6; i++) + { + int k = i + w * 6 + h * 240; - if (i < 4) - YY[i] = y[k] * _nCcdFactor; - else if (i == 4) - Cb = y[k] * _nCcdFactor; - else if (i == 5) - Cr = y[k] * _nCcdFactor; + if (i < 4) + YY[i] = y[k] * _nCcdFactor; + else if (i == 4) + Cb = y[k] * _nCcdFactor; + else if (i == 5) + Cr = y[k] * _nCcdFactor; + } + + YCbCr2RGB(YY, Cb, Cr, w, h); } - - YCbCr2RGB(YY, Cb, Cr, w, h); - } } - for (i = 0, j = 0; i < 60; i++, j += 240) + for (i = 0, j = 0; i < 60; i++, j += 240) { - memcpy (pDib, &BUFF11[j], 240); - pDib -= dwDibRowBytes; + memcpy (pDib, &BUFF11[j], 240); + pDib -= dwDibRowBytes; } } /* --------------------------------------------------------------------------- */ static void YCbCr2RGB(int *YY, int Cb, int Cr, int w, int h) { - int i; - double B,G,R; - double c2 = 1.7753, c3 = -0.0015; - double c5 = -0.3443, c6 = -0.7137; - double c8 = -0.0009, c9 = 1.4017; + int i; + double B, G, R; + double c2 = 1.7753, c3 = -0.0015; + double c5 = -0.3443, c6 = -0.7137; + double c8 = -0.0009, c9 = 1.4017; - for (i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { - int k = 3 * i + w * 6 + h * 480; + int k = 3 * i + w * 6 + h * 480; - B = ((double) YY[i] + 128.0 + c2 * Cb + c3 * Cr) + 0.5; - if (B > 255) - B = 255; - else if (B < 0) - B = 0; - BUFF11[k] = (unsigned char) B; + B = ((double)YY[i] + 128.0 + c2 * Cb + c3 * Cr) + 0.5; + if (B > 255) + B = 255; + else if (B < 0) + B = 0; + BUFF11[k] = (unsigned char)B; - G = ((double) YY[i] + 128.0 + c5 * Cb + c6 * Cr) + 0.5; - if (G > 255) - G = 255; - else if (G < 0) - G = 0; - BUFF11[k + 1] = (unsigned char) G; + G = ((double)YY[i] + 128.0 + c5 * Cb + c6 * Cr) + 0.5; + if (G > 255) + G = 255; + else if (G < 0) + G = 0; + BUFF11[k + 1] = (unsigned char)G; - R = ((double) YY[i] + 128.0 + c8 * Cb + c9 * Cr) + 0.5; - if (R > 255) - R = 255; - else if (R < 0) - R = 0; - BUFF11[k + 2] = (unsigned char) R; + R = ((double)YY[i] + 128.0 + c8 * Cb + c9 * Cr) + 0.5; + if (R > 255) + R = 255; + else if (R < 0) + R = 0; + BUFF11[k + 2] = (unsigned char)R; } - for (i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { - int k = 3 * i + w * 6 + h * 480 + 240; + int k = 3 * i + w * 6 + h * 480 + 240; - B = ((double) YY[i + 2] + 128.0 + c2 * Cb + c3 * Cr) + 0.5; - if (B > 255) - B = 255; - else if (B < 0) - B = 0; - BUFF11[k] = (unsigned char) B; + B = ((double)YY[i + 2] + 128.0 + c2 * Cb + c3 * Cr) + 0.5; + if (B > 255) + B = 255; + else if (B < 0) + B = 0; + BUFF11[k] = (unsigned char)B; - G = ((double) YY[i + 2] + 128.0 + c5 * Cb + c6 * Cr) + 0.5; - if (G > 255) - G = 255; - else if (G < 0) - G = 0; - BUFF11[k + 1] = (unsigned char) G; + G = ((double)YY[i + 2] + 128.0 + c5 * Cb + c6 * Cr) + 0.5; + if (G > 255) + G = 255; + else if (G < 0) + G = 0; + BUFF11[k + 1] = (unsigned char)G; - R = ((double) YY[i + 2] + 128.0 + c8 * Cb + c9 * Cr) + 0.5; - if (R > 255) - R = 255; - else if (R < 0) - R = 0; - BUFF11[k + 2] = (unsigned char) R; + R = ((double)YY[i + 2] + 128.0 + c8 * Cb + c9 * Cr) + 0.5; + if (R > 255) + R = 255; + else if (R < 0) + R = 0; + BUFF11[k + 2] = (unsigned char)R; } } /* --------------------------------------------------------------------------- */ static void dhuf(int flag) { - int code_leng, val_leng; - int temp_s; - int temp; - int temp1; + int code_leng, val_leng; + int temp_s; + int temp; + int temp1; - code_leng = 2; - val_leng = 0; - temp_s = (int) in_string; - temp_s >>= 14; + code_leng = 2; + val_leng = 0; + temp_s = (int)in_string; + temp_s >>= 14; - if (flag == 0) + if (flag == 0) { - while (((int)temp_s > y_max[code_leng]) || ((int)temp_s < y_min[code_leng])) - { - code_leng++; - temp_s = (int) in_string; - temp_s >>= (16 - code_leng); - } - } - else - { - while (((int)temp_s > uv_max[code_leng]) || ((int)temp_s < uv_min[code_leng])) - { - code_leng++; - temp_s = (int) in_string; - temp_s >>= (16 - code_leng); - } - } - - temp = (int) in_string; - temp >>= (16 - code_leng); - temp1 = (int) temp; - - fetchstr(code_leng, 0, flag); - - if (flag == 0) - { - if (code_leng == 3) - { - switch (temp1) + while (((int)temp_s > y_max[code_leng]) || ((int)temp_s < y_min[code_leng])) { - case 2 : val_leng = 1; break; - case 3 : val_leng = 2; break; - case 4 : val_leng = 3; break; - case 5 : val_leng = 4; break; - case 6 : val_leng = 5; break; - default: break; + code_leng++; + temp_s = (int)in_string; + temp_s >>= (16 - code_leng); } - } - else if (code_leng == 2) - val_leng = 0; - else - val_leng = code_leng + 2; - } - else + } else { - if (code_leng == 2) - { - switch (temp1) + while (((int)temp_s > uv_max[code_leng]) || ((int)temp_s < uv_min[code_leng])) { - case 0 : val_leng = 0; break; - case 1 : val_leng = 1; break; - case 2 : val_leng = 2; break; - default: break; + code_leng++; + temp_s = (int)in_string; + temp_s >>= (16 - code_leng); } - } - else - val_leng = code_leng; } - fetchstr(val_leng, 1, flag); + temp = (int)in_string; + temp >>= (16 - code_leng); + temp1 = (int)temp; + + fetchstr(code_leng, 0, flag); + + if (flag == 0) + { + if (code_leng == 3) + { + switch (temp1) + { + case 2: val_leng = 1; break; + case 3: val_leng = 2; break; + case 4: val_leng = 3; break; + case 5: val_leng = 4; break; + case 6: val_leng = 5; break; + default: break; + } + } + else if (code_leng == 2) + val_leng = 0; + else + val_leng = code_leng + 2; + } else + { + if (code_leng == 2) + { + switch (temp1) + { + case 0: val_leng = 0; break; + case 1: val_leng = 1; break; + case 2: val_leng = 2; break; + default: break; + } + } else + val_leng = code_leng; + } + + fetchstr(val_leng, 1, flag); } /* --------------------------------------------------------------------------- */ static void fetchstr(int shift_bit, int val_flag, int flag) { - int temp_val; - int value1, value2; - int temp = 0; + int temp_val; + int value1, value2; + int temp = 0; - temp_val = (int) in_string; - temp_val >>= (16 - shift_bit); - in_string <<= shift_bit; - in_bit -= shift_bit; + temp_val = (int)in_string; + temp_val >>= (16 - shift_bit); + in_string <<= shift_bit; + in_bit -= shift_bit; - if ((val_flag == 1) && (shift_bit == 0)) + if ((val_flag == 1) && (shift_bit == 0)) { - if (flag == 0) - temp = pre_y; - else if (flag == 1) - temp = pre_cb; - else if (flag == 2) - temp = pre_cr; + if (flag == 0) + temp = pre_y; + else if (flag == 1) + temp = pre_cb; + else if (flag == 2) + temp = pre_cr; - y[out_index] = temp; - out_index++; + y[out_index] = temp; + out_index++; } - if ((val_flag == 1) && (shift_bit != 0)) + if ((val_flag == 1) && (shift_bit != 0)) { - value1 = (int) temp_val; - value2 = value1; - value2 &= (1 << (shift_bit - 1)); + value1 = (int)temp_val; + value2 = value1; + value2 &= (1 << (shift_bit - 1)); - if (value2 != 0) - { - if (flag == 0) + if (value2 != 0) { - pre_y += value1; - temp = pre_y; - } - else if (flag == 1) - { - pre_cb += value1; - temp = pre_cb; - } - else if (flag == 2) - { - pre_cr += value1; - temp=pre_cr; - } + if (flag == 0) + { + pre_y += value1; + temp = pre_y; + } + else if (flag == 1) + { + pre_cb += value1; + temp = pre_cb; + } + else if (flag == 2) + { + pre_cr += value1; + temp=pre_cr; + } - y[out_index] = temp; - out_index++; - } - else - { - value1++; - value1 = -value1; - - value1 &= ((1 << shift_bit) - 1); - value1 = -value1; - - if (flag == 0) - { - pre_y += value1; - temp = pre_y; + y[out_index] = temp; + out_index++; } - else if (flag == 1) + else { - pre_cb += value1; - temp = pre_cb; - } - else if (flag == 2) - { - pre_cr +=value1; - temp = pre_cr; - } + value1++; + value1 = -value1; - y[out_index] = temp; - out_index++; - } + value1 &= ((1 << shift_bit) - 1); + value1 = -value1; + + if (flag == 0) + { + pre_y += value1; + temp = pre_y; + } + else if (flag == 1) + { + pre_cb += value1; + temp = pre_cb; + } + else if (flag == 2) + { + pre_cr +=value1; + temp = pre_cr; + } + + y[out_index] = temp; + out_index++; + } } - while (in_bit <= 8) + while (in_bit <= 8) { - in_string = in_string | (*(data + count) << (8 - in_bit)); - in_bit += 8; - count++; + in_string = in_string | (*(data + count) << (8 - in_bit)); + in_bit += 8; + count++; } } diff --git a/camlibs/mars/library.c b/camlibs/mars/library.c index c7c646346..68d0c867c 100644 --- a/camlibs/mars/library.c +++ b/camlibs/mars/library.c @@ -62,7 +62,7 @@ static const struct { } models[] = { {"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}, + {"Emprex PCD3600", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, {"Vivitar Vivicam 55", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, {"Haimei Electronics HE-501A", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010e}, {"Elta Medi@ digi-cam", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010e}, @@ -72,7 +72,7 @@ static const struct { {"Argus DC-1610", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, {"Argus DC-1620", GP_DRIVER_STATUS_TESTING, 0x093a, 0x010f}, {"Philips P44417B keychain camera", GP_DRIVER_STATUS_TESTING, 0x093a, 0x010e}, - {"Sakar Digital no. 77379", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, + {"Sakar Digital no. 77379", GP_DRIVER_STATUS_EXPERIMENTAL, 0x093a, 0x010f}, {"ION digital camera", GP_DRIVER_STATUS_TESTING, 0x093a, 0x010f}, {"Argus QuickClix", GP_DRIVER_STATUS_DEPRECATED, 0x093a, 0x010f}, {"Pixart Gemini Keychain Camera", GP_DRIVER_STATUS_TESTING, 0x093a, 0x010e}, diff --git a/camlibs/mars/mars.c b/camlibs/mars/mars.c index 06a28bc32..9209ce749 100644 --- a/camlibs/mars/mars.c +++ b/camlibs/mars/mars.c @@ -51,14 +51,14 @@ m_read (GPPort *port, char *data, int size) ret = gp_port_write(port, "\x21", 1); if (ret < GP_OK) return ret; - return gp_port_read(port, data, 16); + return gp_port_read(port, data, 16); } static int m_command (GPPort *port, char *command, int size, char *response) { gp_port_write(port, command, size); - return m_read(port, response, 16); + return m_read(port, response, 16); } static int mars_routine (Info *info, GPPort *port, char param, int n); @@ -141,7 +141,7 @@ mars_read_data (GPPort *port, char *data, int size) while(size > 0) { len = (size>MAX_BULK)?MAX_BULK:size; gp_port_read (port, data, len); - data += len; + data += len; size -= len; } @@ -162,14 +162,14 @@ mars_read_picture_data (Camera *camera, Info *info, GPPort *port, set_usb_in_endpoint (camera, 0x82); mars_read_data (port, data, size); set_usb_in_endpoint (camera, 0x83); - return GP_OK; + return GP_OK; } int mars_reset (GPPort *port) { gp_port_write(port, "\x19\x54", 2); - return GP_OK; + return GP_OK; } static void precalc_table(code_table_t *table) @@ -182,38 +182,38 @@ static void precalc_table(code_table_t *table) val = 0; len = 0; if ((i & 0x80) == 0) { - /* code 0 */ - val = 0; - len = 1; - }else if ((i & 0xE0) == 0xC0) { - /* code 110 */ - val = -3; - len = 3; - }else if ((i & 0xE0) == 0xA0) { - /* code 101 */ - val = +3; - len = 3; - }else if ((i & 0xF0) == 0x80) { - /* code 1000 */ - val = +8; - len = 4; - }else if ((i & 0xF0) == 0x90) { - /* code 1001 */ - val = -8; - len = 4; - }else if ((i & 0xF0) == 0xF0) { - /* code 1111 */ - val = -20; - len = 4; - }else if ((i & 0xF8) == 0xE0) { - /* code 11100 */ - val = +20; - len = 5; - }else if ((i & 0xF8) == 0xE8) { - /* code 11101xxxxx */ - is_abs = 1; - val = 0; /* value is calculated later */ - len = 5; + /* code 0 */ + val = 0; + len = 1; + } else if ((i & 0xE0) == 0xC0) { + /* code 110 */ + val = -3; + len = 3; + } else if ((i & 0xE0) == 0xA0) { + /* code 101 */ + val = +3; + len = 3; + } else if ((i & 0xF0) == 0x80) { + /* code 1000 */ + val = +8; + len = 4; + } else if ((i & 0xF0) == 0x90) { + /* code 1001 */ + val = -8; + len = 4; + } else if ((i & 0xF0) == 0xF0) { + /* code 1111 */ + val = -20; + len = 4; + } else if ((i & 0xF8) == 0xE0) { + /* code 11100 */ + val = +20; + len = 5; + } else if ((i & 0xF8) == 0xE8) { + /* code 11101xxxxx */ + is_abs = 1; + val = 0; /* value is calculated later */ + len = 5; } table[i].is_abs = is_abs; table[i].val = val; diff --git a/camlibs/mustek/core.c b/camlibs/mustek/core.c index e24767942..00c23131b 100644 --- a/camlibs/mustek/core.c +++ b/camlibs/mustek/core.c @@ -47,21 +47,21 @@ mdc800_sendInitialCommand (Camera *camera, unsigned char* answer) unsigned char command [8]={COMMAND_BEGIN,COMMAND_INIT_CONNECT,0,0,0,COMMAND_END,0,0}; if (camera->port->type == GP_PORT_USB) - return mdc800_io_sendCommand_with_retry(camera->port,command,answer,8,1,1); + return mdc800_io_sendCommand_with_retry(camera->port, command, answer, 8, 1, 1); for (rate=0;rate<3;rate++) { - GPPortSettings settings; + GPPortSettings settings; - ret = gp_port_get_settings(camera->port,&settings); - if (ret != GP_OK) return ret; - settings.serial.speed = baud_rates[rate]; - ret = gp_port_set_settings(camera->port, settings); - if (ret != GP_OK) return ret; - if (GP_OK==mdc800_io_sendCommand_with_retry(camera->port,command,answer,8,1,1)) { - printCoreNote("RS232 Baudrate probed at %d.\n",baud_rates[rate]); - return GP_OK; - } - printCoreError("Probing RS232 Baudrate with %d fails.\n",baud_rates[rate]); + ret = gp_port_get_settings(camera->port, &settings); + if (ret != GP_OK) return ret; + settings.serial.speed = baud_rates[rate]; + ret = gp_port_set_settings(camera->port, settings); + if (ret != GP_OK) return ret; + if (GP_OK==mdc800_io_sendCommand_with_retry(camera->port, command, answer, 8, 1, 1)) { + printCoreNote("RS232 Baudrate probed at %d.\n", baud_rates[rate]); + return GP_OK; + } + printCoreError("Probing RS232 Baudrate with %d fails.\n", baud_rates[rate]); } printCoreError ("Probing failed completely.\n"); return GP_ERROR_IO; @@ -85,7 +85,7 @@ int mdc800_openCamera (Camera *camera) camera->pl = malloc(sizeof(struct _CameraPrivateLibrary)); if (!camera->pl) - return GP_ERROR_NO_MEMORY; + return GP_ERROR_NO_MEMORY; camera->pl->system_flags_valid = 0; camera->pl->memory_source = -1; @@ -115,7 +115,7 @@ int mdc800_closeCamera (Camera *camera) free(camera->pl); camera->pl = NULL; - return GP_OK; + return GP_OK; } @@ -132,20 +132,20 @@ int mdc800_changespeed (Camera *camera,int new) printFnkCall ("(mdc800_changespeed) called.\n"); if (camera->port->type != GP_PORT_SERIAL) /* USB ... */ - return GP_OK; + return GP_OK; gp_port_get_settings(camera->port,&settings); if (settings.serial.speed == baud_rate[new]) /* nothing to do */ - return GP_OK; + return GP_OK; for (oldrate=0;oldrateport,COMMAND_CHANGE_RS232_BAUD_RATE,new,oldrate,0,0,0); @@ -181,16 +181,16 @@ int mdc800_getSpeed (Camera *camera, int *speed) GPPortSettings settings; if (camera->port->type != GP_PORT_SERIAL) - return GP_ERROR_IO; + return GP_ERROR_IO; ret = gp_port_get_settings(camera->port,&settings); if (ret!=GP_OK) return ret; for (rate=0;rate<3;rate++) - if (settings.serial.speed == baud_rate[rate]) - break; + if (settings.serial.speed == baud_rate[rate]) + break; if (rate == 3) - return GP_ERROR_IO; + return GP_ERROR_IO; *speed = rate; return GP_OK; } @@ -218,7 +218,7 @@ int mdc800_getThumbnail (Camera *camera,int index, void **data, int *size) *size = 4096; *data = malloc(4096); if (!*data) - return GP_ERROR_NO_MEMORY; + return GP_ERROR_NO_MEMORY; ret = mdc800_io_sendCommand(camera->port,COMMAND_GET_THUMBNAIL,index/100,(index%100)/10,index%10,*data,4096); if (ret != GP_OK) { @@ -304,9 +304,9 @@ int mdc800_getSystemStatus (Camera *camera) return GP_OK; fprintf(stderr,"mdc800_getSystemStatus entered...\n"); while (tries--) { - ret = mdc800_io_sendCommand(camera->port,COMMAND_GET_SYSTEM_STATUS,0,0,0,camera->pl->system_flags,4); - if (ret == GP_OK) - break; + ret = mdc800_io_sendCommand(camera->port, COMMAND_GET_SYSTEM_STATUS, 0, 0, 0, camera->pl->system_flags, 4); + if (ret == GP_OK) + break; } if (ret!=GP_OK) { @@ -681,7 +681,7 @@ int mdc800_getImageQuality (Camera *camera, unsigned char *retval) */ int mdc800_setImageQuality (Camera *camera,int v) { - return mdc800_io_sendCommand (camera->port,COMMAND_SET_IMAGE_QUALITY,v,0,0,0,0); + return mdc800_io_sendCommand (camera->port, COMMAND_SET_IMAGE_QUALITY, v, 0, 0, 0, 0); } @@ -692,7 +692,7 @@ int mdc800_setImageQuality (Camera *camera,int v) */ int mdc800_setWB (Camera *camera, int v) { - return mdc800_io_sendCommand(camera->port,COMMAND_SET_WB,v,0,0,0,0); + return mdc800_io_sendCommand(camera->port, COMMAND_SET_WB, v, 0, 0, 0, 0); } @@ -746,7 +746,7 @@ int mdc800_getExposureMode (Camera *camera,int *retval) int ret; ret = mdc800_io_sendCommand (camera->port,COMMAND_GET_EXPOSURE_MODE,0,0,0,&cretval,1); if (ret == GP_OK) - *retval = cretval; + *retval = cretval; return ret; } diff --git a/camlibs/mustek/core.h b/camlibs/mustek/core.h index 3534808ec..fbbf3ae40 100644 --- a/camlibs/mustek/core.h +++ b/camlibs/mustek/core.h @@ -29,9 +29,9 @@ #define MDC800_FLASHLIGHT_AUTO 0 struct _CameraPrivateLibrary { - unsigned char system_flags[4]; - int system_flags_valid; - int memory_source; + unsigned char system_flags[4]; + int system_flags_valid; + int memory_source; }; /* -------------------------------------------------------------------------- */ diff --git a/camlibs/mustek/mdc800.c b/camlibs/mustek/mdc800.c index 7dc454abc..eef8b601c 100644 --- a/camlibs/mustek/mdc800.c +++ b/camlibs/mustek/mdc800.c @@ -115,7 +115,7 @@ delete_file_func (CameraFilesystem *fs, const char *folder, nr = gp_filesystem_number(fs, folder, filename, context); if (nr < 0) - return nr; + return nr; ret = mdc800_setTarget (camera,1); if (ret!=GP_OK) diff --git a/camlibs/mustek/usb.c b/camlibs/mustek/usb.c index af760415f..b7a1918a5 100644 --- a/camlibs/mustek/usb.c +++ b/camlibs/mustek/usb.c @@ -104,14 +104,14 @@ static int mdc800_usb_readFromIrq (GPPort *port,int type,unsigned char* data,int if (type) { if (!(mdc800_usb_isReady(data)||mdc800_usb_isBusy(data))) { - fprintf(stderr,"got data.\n"); + fprintf(stderr, "got data.\n"); /* Data received successfully */ return GP_OK; } } else { if (mdc800_usb_isReady (data)) { - fprintf(stderr,"got readiness.\n"); + fprintf(stderr, "got readiness.\n"); /* Camera response ready */ return GP_OK; } @@ -119,9 +119,9 @@ static int mdc800_usb_readFromIrq (GPPort *port,int type,unsigned char* data,int /* wait the specified time */ if (1) { - usleep(MDC800_USB_IRQ_INTERVAL * 1000); + usleep(MDC800_USB_IRQ_INTERVAL * 1000); - timeout-=MDC800_USB_IRQ_INTERVAL; + timeout-=MDC800_USB_IRQ_INTERVAL; } } /* Timeout */ @@ -145,7 +145,7 @@ int mdc800_usb_sendCommand(GPPort*port,unsigned char*command,unsigned char*buffe ret = mdc800_usb_readFromIrq(port,0,tmp_buffer,MDC800_DEFAULT_TIMEOUT); if (ret != GP_OK) { - fprintf(stderr,"Camera did not get ready before mdc800_usb_sendCommand!\n"); + fprintf(stderr, "Camera did not get ready before mdc800_usb_sendCommand!\n"); } if ((ret=gp_port_write(port,(char*)command,8)) != 8) diff --git a/camlibs/mustek/usb.h b/camlibs/mustek/usb.h index 9e01d1db5..c4075c19c 100644 --- a/camlibs/mustek/usb.h +++ b/camlibs/mustek/usb.h @@ -17,7 +17,7 @@ */ /* - Header for USB Interface + Header for USB Interface */ #ifndef CAMLIBS_MUSTEK_USB_H diff --git a/camlibs/pccam600/library.c b/camlibs/pccam600/library.c index 0fa41c55f..76b5bdd0c 100644 --- a/camlibs/pccam600/library.c +++ b/camlibs/pccam600/library.c @@ -50,205 +50,203 @@ #define QUALITY_HI 0x45 static const struct models{ - char *name; - unsigned short idVendor; - unsigned short idProduct; - char serial; + char *name; + unsigned short idVendor; + unsigned short idProduct; + char serial; } models[] = { - {"Creative:PC-CAM600",0x041e,0x400b,0}, - {"Creative:PC-CAM750",0x041e,0x4013,0}, - {"Creative PC-CAM350",0x041e,0x4012,0}, - {NULL,0,0,0} + {"Creative:PC-CAM600",0x041e,0x400b,0}, + {"Creative:PC-CAM750",0x041e,0x4013,0}, + {"Creative PC-CAM350",0x041e,0x4012,0}, + {NULL,0,0,0} }; int camera_id(CameraText *id) { - strcpy(id->text, "Creative PC-CAM600/750/350"); - return (GP_OK); + strcpy(id->text, "Creative PC-CAM600/750/350"); + return (GP_OK); } int camera_abilities(CameraAbilitiesList *list) { - int i; - CameraAbilities a; - for(i=0; models[i].name; i++) { - memset(&a , 0, sizeof(CameraAbilities)); - strcpy(a.model, models[i].name); - a.status = GP_DRIVER_STATUS_EXPERIMENTAL; - 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_NONE; - a.file_operations = GP_FILE_OPERATION_DELETE; - gp_abilities_list_append(list, a); - } - return GP_OK; + int i; + CameraAbilities a; + for(i=0; models[i].name; i++) { + memset(&a , 0, sizeof(CameraAbilities)); + strcpy(a.model, models[i].name); + a.status = GP_DRIVER_STATUS_EXPERIMENTAL; + 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_NONE; + a.file_operations = GP_FILE_OPERATION_DELETE; + gp_abilities_list_append(list, a); + } + return GP_OK; } static int camera_exit(Camera *camera, GPContext *context){ - return pccam600_close(camera->port, context); + return pccam600_close(camera->port, context); } static int file_list_func (CameraFilesystem *fs, const char *folder, - CameraList *list, void *data, GPContext *context){ + CameraList *list, void *data, GPContext *context){ - Camera *camera = data; - CameraFileInfo info; - int n,i,nr_of_blocks; - int offset = 64; - char *temp; - char buffer[512]; - FileEntry *file_entry; + Camera *camera = data; + CameraFileInfo info; + int n,i,nr_of_blocks; + int offset = 64; + char *temp; + char buffer[512]; + FileEntry *file_entry; - file_entry = malloc(sizeof(FileEntry)); - if ( (nr_of_blocks = pccam600_get_file_list(camera->port, context)) < 0 ){ - gp_log(GP_LOG_DEBUG,"pccam600","pccam600->get_file_list return <0"); - free (file_entry); - return GP_ERROR; - } - for (n = 0; n != nr_of_blocks; n++) - { - CHECK(pccam600_read_data(camera->port, (unsigned char *)buffer)); - for (i = offset; i <= 512-32; i=i+32) - { - memcpy(file_entry,&(buffer)[i],32); - file_entry->name[8] = 0; - /*Fileentry valid? */ - if( !((file_entry->state & 0x02) != 2) && - !((file_entry->state & 0x08) == 8) ) - { - memset (&info, 0, sizeof (info)); - temp = (char *)&(file_entry->name)[5]; - if (strncmp(temp,"JPG",3) == 0) - { - memcpy(&(file_entry->name)[5],".jpg",4); - strcpy(info.file.type,GP_MIME_JPEG); - info.file.fields = GP_FILE_INFO_TYPE; - } - else if (strncmp(temp,"AVI",3) == 0) - { - memcpy(&(file_entry->name)[5],".avi",4); - info.file.fields = GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_TYPE; - info.file.height = 352; - info.file.width = 288; - strcpy(info.file.type, GP_MIME_AVI); - } - else if (strncmp(temp,"WAV",3) == 0) - { - memcpy(&(file_entry->name)[5],".wav",4); - strcpy(info.file.type, GP_MIME_WAV); - info.file.fields = GP_FILE_INFO_TYPE; - info.file.height = 0; - } - else if (strncmp(temp,"RAW",3) == 0) - { - memcpy(&(file_entry->name)[5],".raw",4); - info.file.width = 1280; - info.file.height = 960; - info.file.fields = GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_TYPE; - strcpy(info.file.type, GP_MIME_RAW); - } - gp_filesystem_append(fs,folder,(char *)file_entry->name,context); - info.preview.fields = 0; - info.file.size = (file_entry->size[1]*256+ - file_entry->size[0]) * 256; - info.file.permissions = GP_FILE_PERM_READ | GP_FILE_PERM_DELETE; - info.file.fields |= GP_FILE_INFO_SIZE | GP_FILE_INFO_PERMISSIONS - |GP_FILE_INFO_TYPE; - CHECK(gp_filesystem_set_info_noop(fs, folder, (char *)file_entry->name, info, context)); - } + file_entry = malloc(sizeof(FileEntry)); + if ((nr_of_blocks = pccam600_get_file_list(camera->port, context)) < 0) { + gp_log(GP_LOG_DEBUG, "pccam600", "pccam600->get_file_list return <0"); + free (file_entry); + return GP_ERROR; } - offset = 0; - } - return GP_OK; + for (n = 0; n != nr_of_blocks; n++) + { + CHECK(pccam600_read_data(camera->port, (unsigned char *)buffer)); + for (i = offset; i <= 512-32; i=i+32) + { + memcpy(file_entry, &(buffer)[i], 32); + file_entry->name[8] = 0; + /*Fileentry valid? */ + if (!((file_entry->state & 0x02) != 2) && + !((file_entry->state & 0x08) == 8)) + { + memset (&info, 0, sizeof (info)); + temp = (char *)&(file_entry->name)[5]; + if (strncmp(temp, "JPG", 3) == 0) + { + memcpy(&(file_entry->name)[5], ".jpg", 4); + strcpy(info.file.type, GP_MIME_JPEG); + info.file.fields = GP_FILE_INFO_TYPE; + } + else if (strncmp(temp, "AVI", 3) == 0) + { + memcpy(&(file_entry->name)[5], ".avi", 4); + info.file.fields = GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_TYPE; + info.file.height = 352; + info.file.width = 288; + strcpy(info.file.type, GP_MIME_AVI); + } + else if (strncmp(temp, "WAV", 3) == 0) + { + memcpy(&(file_entry->name)[5], ".wav", 4); + strcpy(info.file.type, GP_MIME_WAV); + info.file.fields = GP_FILE_INFO_TYPE; + info.file.height = 0; + } + else if (strncmp(temp, "RAW", 3) == 0) + { + memcpy(&(file_entry->name)[5], ".raw", 4); + info.file.width = 1280; + info.file.height = 960; + info.file.fields = GP_FILE_INFO_WIDTH | GP_FILE_INFO_HEIGHT | GP_FILE_INFO_TYPE; + strcpy(info.file.type, GP_MIME_RAW); + } + gp_filesystem_append(fs, folder, (char *)file_entry->name, context); + info.preview.fields = 0; + info.file.size = (file_entry->size[1]*256 + file_entry->size[0]) * 256; + info.file.permissions = GP_FILE_PERM_READ | GP_FILE_PERM_DELETE; + info.file.fields |= GP_FILE_INFO_SIZE | GP_FILE_INFO_PERMISSIONS |GP_FILE_INFO_TYPE; + CHECK(gp_filesystem_set_info_noop(fs, folder, (char *)file_entry->name, info, context)); + } + } + offset = 0; + } + return GP_OK; } static int camera_get_file (Camera *camera, GPContext *context, int index, - unsigned char **data, int *size) + unsigned char **data, int *size) { - unsigned char buffer[512]; - int nr_of_blocks = 0; - int n,id,canceled=0; - int picturebuffersize = 0; - int offset = 0; - nr_of_blocks = pccam600_get_file(camera->port,context,index); - if (nr_of_blocks < 0) - return GP_ERROR_FILE_NOT_FOUND; - picturebuffersize = nr_of_blocks * 512; - id = gp_context_progress_start(context,nr_of_blocks,_("Downloading file...")); - *data= malloc(picturebuffersize+1); - memset(*data,0,picturebuffersize+1); - for (n = 0; n != nr_of_blocks; n++){ - pccam600_read_data(camera->port, buffer); - memmove(&(*data)[offset],buffer,512); - offset = offset + 512; - gp_context_progress_update(context,id,n); - if (gp_context_cancel(context) == GP_CONTEXT_FEEDBACK_CANCEL) - { - /* Keep reading data or else data will be invalid next time*/ - canceled = 1; - } - } - *size = offset; - gp_context_progress_stop(context,id); - if (canceled) return GP_ERROR_CANCEL; - return GP_OK; + unsigned char buffer[512]; + int nr_of_blocks = 0; + int n,id,canceled=0; + int picturebuffersize = 0; + int offset = 0; + nr_of_blocks = pccam600_get_file(camera->port,context,index); + if (nr_of_blocks < 0) + return GP_ERROR_FILE_NOT_FOUND; + picturebuffersize = nr_of_blocks * 512; + id = gp_context_progress_start(context,nr_of_blocks,_("Downloading file...")); + *data= malloc(picturebuffersize+1); + memset(*data,0,picturebuffersize+1); + for (n = 0; n != nr_of_blocks; n++) { + pccam600_read_data(camera->port, buffer); + memmove(&(*data)[offset],buffer,512); + offset = offset + 512; + gp_context_progress_update(context,id,n); + if (gp_context_cancel(context) == GP_CONTEXT_FEEDBACK_CANCEL) + { + /* Keep reading data or else data will be invalid next time*/ + canceled = 1; + } + } + *size = offset; + gp_context_progress_stop(context,id); + if (canceled) return GP_ERROR_CANCEL; + return GP_OK; } static int get_file_func (CameraFilesystem *fs, const char *folder, - const char *filename, CameraFileType type, - CameraFile *file, void *user_data, - GPContext *context) + const char *filename, CameraFileType type, + CameraFile *file, void *user_data, + GPContext *context) { - Camera *camera = user_data; - unsigned char *data = NULL; - int size,index; - size = 0; - index = gp_filesystem_number(fs, folder, filename, context); - if (index < 0) - return index; - switch(type) - { - case GP_FILE_TYPE_NORMAL: - CHECK(camera_get_file(camera, context, index, &data, &size)); - break; - default: - return GP_ERROR_NOT_SUPPORTED; - } - return gp_file_set_data_and_size(file, (char *)data, size); + Camera *camera = user_data; + unsigned char *data = NULL; + int size,index; + size = 0; + index = gp_filesystem_number(fs, folder, filename, context); + if (index < 0) + return index; + switch (type) + { + case GP_FILE_TYPE_NORMAL: + CHECK(camera_get_file(camera, context, index, &data, &size)); + break; + default: + return GP_ERROR_NOT_SUPPORTED; + } + return gp_file_set_data_and_size(file, (char *)data, size); } static int camera_summary(Camera *camera, CameraText *summary, GPContext *context) { - int totalmem; - int freemem; - char summary_text[256]; - CHECK(pccam600_get_mem_info(camera->port,context,&totalmem,&freemem)); - snprintf(summary_text,sizeof(summary_text), - (" Total memory is %8d bytes.\n Free memory is %8d bytes."), - totalmem,freemem ); - strcat(summary->text,summary_text); - return GP_OK; + int totalmem; + int freemem; + char summary_text[256]; + CHECK(pccam600_get_mem_info(camera->port,context,&totalmem,&freemem)); + snprintf(summary_text,sizeof(summary_text), + (" Total memory is %8d bytes.\n Free memory is %8d bytes."), + totalmem,freemem ); + strcat(summary->text,summary_text); + return GP_OK; } static int camera_about(Camera *camera, CameraText *about, GPContext *context) { - strcpy(about->text, + strcpy(about->text, _("Creative PC-CAM600\nAuthor: Peter Kajberg \n")); - return GP_OK; + return GP_OK; } static int delete_file_func(CameraFilesystem *fs, const char *folder, - const char *filename, void *data, GPContext *context){ - int index; + const char *filename, void *data, GPContext *context){ + int index; - Camera *camera = data; - index = gp_filesystem_number(fs, folder, filename, context); - gp_log(GP_LOG_DEBUG,"pccam","deleting '%s' in '%s'.. index:%d",filename, folder,index); - CHECK(pccam600_delete_file(camera->port, context, index)); - return GP_OK; + Camera *camera = data; + index = gp_filesystem_number(fs, folder, filename, context); + gp_log(GP_LOG_DEBUG,"pccam","deleting '%s' in '%s'.. index:%d",filename, folder,index); + CHECK(pccam600_delete_file(camera->port, context, index)); + return GP_OK; } static CameraFilesystemFuncs fsfuncs = { @@ -258,27 +256,27 @@ static CameraFilesystemFuncs fsfuncs = { }; int camera_init(Camera *camera, GPContext *context){ - GPPortSettings settings; - camera->functions->exit = camera_exit; - camera->functions->summary = camera_summary; - camera->functions->about = camera_about; - gp_log (GP_LOG_DEBUG, "pccam", "Initializing the camera\n"); - switch (camera->port->type) - { - case GP_PORT_USB: - CHECK(gp_port_get_settings(camera->port,&settings)); - settings.usb.inep = 0x82; - settings.usb.outep = 0x03; - settings.usb.config = 1; - settings.usb.interface = 1; - settings.usb.altsetting = 0; - CHECK(gp_port_set_settings(camera->port,settings)); - break; - case GP_PORT_SERIAL: - return GP_ERROR_IO_SUPPORTED_SERIAL; - default: - return GP_ERROR_NOT_SUPPORTED; - } - CHECK(pccam600_init(camera->port, context)); - return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); + GPPortSettings settings; + camera->functions->exit = camera_exit; + camera->functions->summary = camera_summary; + camera->functions->about = camera_about; + gp_log (GP_LOG_DEBUG, "pccam", "Initializing the camera\n"); + switch (camera->port->type) + { + case GP_PORT_USB: + CHECK(gp_port_get_settings(camera->port, &settings)); + settings.usb.inep = 0x82; + settings.usb.outep = 0x03; + settings.usb.config = 1; + settings.usb.interface = 1; + settings.usb.altsetting = 0; + CHECK(gp_port_set_settings(camera->port, settings)); + break; + case GP_PORT_SERIAL: + return GP_ERROR_IO_SUPPORTED_SERIAL; + default: + return GP_ERROR_NOT_SUPPORTED; + } + CHECK(pccam600_init(camera->port, context)); + return gp_filesystem_set_funcs (camera->fs, &fsfuncs, camera); } diff --git a/camlibs/polaroid/pdc320.c b/camlibs/polaroid/pdc320.c index 9221e5187..53f99e298 100644 --- a/camlibs/polaroid/pdc320.c +++ b/camlibs/polaroid/pdc320.c @@ -426,7 +426,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, gpi_jpeg_destroy(myjpeg); free (tempchunk); break; - } + } return (GP_OK); } diff --git a/camlibs/polaroid/pdc320.h b/camlibs/polaroid/pdc320.h index 8a4bd5018..36cedd4f4 100644 --- a/camlibs/polaroid/pdc320.h +++ b/camlibs/polaroid/pdc320.h @@ -54,21 +54,21 @@ static struct { }; #define HUFF_00 33, \ - "\xFF\xC4\x00\x1F\x00\x00\x01\x05" "\x01\x01\x01\x01\x01\x01\x00\x00" \ - "\x00\x00\x00\x00\x00\x00\x01\x02" "\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" + "\xFF\xC4\x00\x1F\x00\x00\x01\x05" "\x01\x01\x01\x01\x01\x01\x00\x00" \ + "\x00\x00\x00\x00\x00\x00\x01\x02" "\x03\x04\x05\x06\x07\x08\x09\x0A\x0B" #define HUFF_10 183, \ - "\xFF\xC4\x00\xB5\x10\x00\x02\x01" "\x03\x03\x02\x04\x03\x05\x05\x04" \ - "\x04\x00\x00\x01\x7D\x01\x02\x03" "\x00\x04\x11\x05\x12\x21\x31\x41" \ - "\x06\x13\x51\x61\x07\x22\x71\x14" "\x32\x81\x91\xA1\x08\x23\x42\xB1" \ - "\xC1\x15\x52\xD1\xF0\x24\x33\x62" "\x72\x82\x09\x0A\x16\x17\x18\x19" \ - "\x1A\x25\x26\x27\x28\x29\x2A\x34" "\x35\x36\x37\x38\x39\x3A\x43\x44" \ - "\x45\x46\x47\x48\x49\x4A\x53\x54" "\x55\x56\x57\x58\x59\x5A\x63\x64" \ - "\x65\x66\x67\x68\x69\x6A\x73\x74" "\x75\x76\x77\x78\x79\x7A\x83\x84" \ - "\x85\x86\x87\x88\x89\x8A\x92\x93" "\x94\x95\x96\x97\x98\x99\x9A\xA2" \ - "\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA" "\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9" \ - "\xBA\xC2\xC3\xC4\xC5\xC6\xC7\xC8" "\xC9\xCA\xD2\xD3\xD4\xD5\xD6\xD7" \ - "\xD8\xD9\xDA\xE1\xE2\xE3\xE4\xE5" "\xE6\xE7\xE8\xE9\xEA\xF1\xF2\xF3" \ - "\xF4\xF5\xF6\xF7\xF8\xF9\xFA" + "\xFF\xC4\x00\xB5\x10\x00\x02\x01" "\x03\x03\x02\x04\x03\x05\x05\x04" \ + "\x04\x00\x00\x01\x7D\x01\x02\x03" "\x00\x04\x11\x05\x12\x21\x31\x41" \ + "\x06\x13\x51\x61\x07\x22\x71\x14" "\x32\x81\x91\xA1\x08\x23\x42\xB1" \ + "\xC1\x15\x52\xD1\xF0\x24\x33\x62" "\x72\x82\x09\x0A\x16\x17\x18\x19" \ + "\x1A\x25\x26\x27\x28\x29\x2A\x34" "\x35\x36\x37\x38\x39\x3A\x43\x44" \ + "\x45\x46\x47\x48\x49\x4A\x53\x54" "\x55\x56\x57\x58\x59\x5A\x63\x64" \ + "\x65\x66\x67\x68\x69\x6A\x73\x74" "\x75\x76\x77\x78\x79\x7A\x83\x84" \ + "\x85\x86\x87\x88\x89\x8A\x92\x93" "\x94\x95\x96\x97\x98\x99\x9A\xA2" \ + "\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA" "\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9" \ + "\xBA\xC2\xC3\xC4\xC5\xC6\xC7\xC8" "\xC9\xCA\xD2\xD3\xD4\xD5\xD6\xD7" \ + "\xD8\xD9\xDA\xE1\xE2\xE3\xE4\xE5" "\xE6\xE7\xE8\xE9\xEA\xF1\xF2\xF3" \ + "\xF4\xF5\xF6\xF7\xF8\xF9\xFA" #endif /* !defined(CAMLIBS_POLAROID_PDC320_H) */ diff --git a/camlibs/polaroid/pdc700.c b/camlibs/polaroid/pdc700.c index 2eb8c3aa0..c0fb38342 100644 --- a/camlibs/polaroid/pdc700.c +++ b/camlibs/polaroid/pdc700.c @@ -509,7 +509,7 @@ pdc700_info (Camera *camera, PDCInfo *info, GPContext *context) * 01 20 .. 02 */ - info->memory = buf[2]; + info->memory = buf[2]; /* Power source state (make sure it's valid) */ info->ac_power = buf[4]; @@ -518,7 +518,7 @@ pdc700_info (Camera *camera, PDCInfo *info, GPContext *context) info->ac_power = PDC_BOOL_OFF; } - info->auto_poweroff = buf[5]; + info->auto_poweroff = buf[5]; /* Mode (make sure we know it) */ info->mode = buf[6]; @@ -1015,7 +1015,7 @@ static int which_radio_button (CameraWidget *window, const char *label, const char * const *opt) { - CameraWidget *child; + CameraWidget *child; int i; const char *value; @@ -1038,7 +1038,7 @@ which_radio_button (CameraWidget *window, const char *label, static int camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) { - CameraWidget *child; + CameraWidget *child; int i = 0, r; float range; diff --git a/camlibs/ptp2/config.c b/camlibs/ptp2/config.c index f17fcc991..0fdedaa22 100644 --- a/camlibs/ptp2/config.c +++ b/camlibs/ptp2/config.c @@ -1400,7 +1400,7 @@ fallback: \ If we made a small +-1 adjustment, check for overshoot. \ However, use enum position instead of value itself for comparisons as enums \ are not always sorted (e.g. Auto ISO has higher numerical value but comes earlier). \ - */ \ + */ \ overshoot = ((propval.u8 == 0x01) && (posnow > posnew)) || ((propval.u8 == 0xff) && (posnow < posnew)); \ } else { \ overshoot = ((propval.u8 == 0x01) && (dpd.CurrentValue.bits > value)) || ((propval.u8 == 0xff) && (dpd.CurrentValue.bits < value)); \ @@ -6556,11 +6556,11 @@ static struct deviceproptableu8 nikon_moviequality[] = { GENERIC8TABLE(Nikon_MovieQuality, nikon_moviequality); static struct deviceproptableu8 nikon_d850_moviequality[] = { - {"3840x2160; 30p", 0, 0}, + {"3840x2160; 30p", 0, 0}, {"3840x2160; 25p", 1, 0}, {"3840x2160; 24p", 2, 0}, - {"1920x1080; 60p", 3, 0}, + {"1920x1080; 60p", 3, 0}, {"1920x1080; 50p", 4, 0}, {"1920x1080; 30p", 5, 0}, {"1920x1080; 25p", 6, 0}, @@ -6578,7 +6578,7 @@ GENERIC8TABLE(Nikon_D850_MovieQuality, nikon_d850_moviequality); static struct deviceproptableu8 nikon_d5100_moviequality[] = { {"640x424; 25fps; normal", 0, 0}, {"640x424; 25fps; high quality", 1, 0}, - {"1280x720; 24fps; normal", 2, 0}, + {"1280x720; 24fps; normal", 2, 0}, {"1280x720; 24fps; high quality", 3, 0}, {"1280x720; 25fps; normal", 4, 0}, {"1280x720; 25fps; high quality", 5, 0}, @@ -6592,7 +6592,7 @@ GENERIC8TABLE(Nikon_D5100_MovieQuality, nikon_d5100_moviequality); static struct deviceproptableu8 nikon_d7100_moviequality[] = { {"1920x1080; 60i", 0, 0}, {"1920x1080; 50i", 1, 0}, - {"1920x1080; 30p", 2, 0}, + {"1920x1080; 30p", 2, 0}, {"1920x1080; 25p", 3, 0}, {"1920x1080; 24p", 4, 0}, {"1280x720; 60p", 5, 0}, @@ -6608,7 +6608,7 @@ GENERIC8TABLE(Nikon_D7100_MovieQuality2, nikon_d7100_moviequality2); static struct deviceproptableu8 nikon_1_moviequality[] = { {"1080/60i", 0, 0}, - {"1080/30p", 1, 0}, + {"1080/30p", 1, 0}, {"720/60p", 3, 0}, {"720/30p", 4, 0}, }; diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index 519fce52b..56ddf22ef 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -511,11 +511,11 @@ fixup_cached_deviceinfo (Camera *camera, PTPDeviceInfo *di) { /* Marcus note: GetVendorPropCodes crashes at least the V1, the J1 and J2. * but it works on the J3, J4... - * V1: crashes protocol flow - * J1: crashes protocol flow - * J2: crashes protocol flow - * J3: works - * J4: works + * V1: crashes protocol flow + * J1: crashes protocol flow + * J2: crashes protocol flow + * J3: works + * J4: works * J5: reports invalid opcode */ if ( !ptp_operation_issupported(&camera->pl->params, PTP_OC_NIKON_InitiateCaptureRecInMedia) && @@ -927,7 +927,7 @@ static struct { /* EasyShare Z740, Benjamin Mesing */ {"Kodak:Z740", 0x040a, 0x0588, 0}, /* EasyShare C360, Guilherme de S. Pastore via Debian */ - {"Kodak:C360", 0x040a, 0x0589, 0}, + {"Kodak:C360", 0x040a, 0x0589, 0}, /* Giulio Salani */ {"Kodak:C310", 0x040a, 0x058a, 0}, /* Brandon Sharitt */ @@ -2007,19 +2007,19 @@ static struct { {"Canon:PowerShot A310 (PTP mode)", 0x04a9, 0x30b8, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, {"Canon:PowerShot A85 (PTP mode)", 0x04a9, 0x30b9, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, {"Canon:Digital IXUS 430 (PTP mode)", 0x04a9, 0x30ba, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, - {"Canon:PowerShot S410 (PTP mode)", 0x04a9, 0x30ba, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, - {"Canon:PowerShot A95 (PTP mode)", 0x04a9, 0x30bb, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, - {"Canon:EOS 10D (PTP mode)", 0x04a9, 0x30bc, PTPBUG_DELETE_SENDS_EVENT}, + {"Canon:PowerShot S410 (PTP mode)", 0x04a9, 0x30ba, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, + {"Canon:PowerShot A95 (PTP mode)", 0x04a9, 0x30bb, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, + {"Canon:EOS 10D (PTP mode)", 0x04a9, 0x30bc, PTPBUG_DELETE_SENDS_EVENT}, {"Canon:Digital IXUS 40 (PTP mode)", 0x04a9, 0x30bf, PTPBUG_DELETE_SENDS_EVENT}, #if 0 /* the 30c0 id cannot remote capture, use normal mode. */ - {"Canon:PowerShot SD200 (PTP mode)", 0x04a9, 0x30c0, PTPBUG_DELETE_SENDS_EVENT}, - {"Canon:Digital IXUS 30 (PTP mode)", 0x04a9, 0x30c0, PTPBUG_DELETE_SENDS_EVENT}, + {"Canon:PowerShot SD200 (PTP mode)", 0x04a9, 0x30c0, PTPBUG_DELETE_SENDS_EVENT}, + {"Canon:Digital IXUS 30 (PTP mode)", 0x04a9, 0x30c0, PTPBUG_DELETE_SENDS_EVENT}, #endif - {"Canon:PowerShot A520 (PTP mode)", 0x04a9, 0x30c1, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, + {"Canon:PowerShot A520 (PTP mode)", 0x04a9, 0x30c1, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, {"Canon:PowerShot A510 (PTP mode)", 0x04a9, 0x30c2, PTPBUG_DELETE_SENDS_EVENT|PTP_CAP|PTP_CAP_PREVIEW}, {"Canon:EOS 1D Mark II (PTP mode)", 0x04a9, 0x30ea, 0}, - {"Canon:EOS 20D (PTP mode)", 0x04a9, 0x30ec, 0}, + {"Canon:EOS 20D (PTP mode)", 0x04a9, 0x30ec, 0}, /* 30ef is the ID in explicit PTP mode. * 30ee is the ID with the camera in Canon mode, but the camera reacts to * PTP commands according to: @@ -2051,9 +2051,9 @@ static struct { /* Rob Lensen */ {"Canon:Digital IXUS 55 (PTP mode)", 0x04a9, 0x30ff, 0}, {"Canon:PowerShot SD450 (PTP mode)", 0x04a9, 0x30ff, 0}, - {"Canon:Optura 600 (PTP mode)", 0x04a9, 0x3105, 0}, + {"Canon:Optura 600 (PTP mode)", 0x04a9, 0x3105, 0}, /* Jeff Mock */ - {"Canon:EOS 5D (PTP mode)", 0x04a9, 0x3102, 0}, + {"Canon:EOS 5D (PTP mode)", 0x04a9, 0x3102, 0}, /* Nick Richards */ {"Canon:Digital IXUS 50 (PTP mode)", 0x04a9, 0x310e, PTPBUG_DELETE_SENDS_EVENT}, /* http://sourceforge.net/tracker/index.php?func=detail&aid=1640547&group_id=8874&atid=358874 */ @@ -4863,8 +4863,8 @@ camera_canon_capture (Camera *camera, CameraCaptureType type, CameraFilePath *pa GP_LOG_D ("Event: 0x%X (2)", event.Code); } if (!found) { - GP_LOG_D ("ERROR: Capture timed out!"); - return GP_ERROR_TIMEOUT; + GP_LOG_D ("ERROR: Capture timed out!"); + return GP_ERROR_TIMEOUT; } if (viewfinderwason) { /* disable during capture ... reenable later on. */ viewfinderwason = 0; @@ -9361,7 +9361,7 @@ delete_file_func (CameraFilesystem *fs, const char *folder, } } /* FIXME: need to handle folder additions during capture-image-and-download */ - } + } return (GP_OK); } diff --git a/camlibs/ptp2/ptp.c b/camlibs/ptp2/ptp.c index 7b4d94d90..a0b04e0ce 100644 --- a/camlibs/ptp2/ptp.c +++ b/camlibs/ptp2/ptp.c @@ -5623,44 +5623,44 @@ ptp_chdk_download(PTPParams* params, char *remote_fn, PTPDataHandler *handler) #if 0 int ptp_chdk_upload(PTPParams* params, char *local_fn, char *remote_fn) { - uint16_t ret; - PTPContainer ptp; - char *buf = NULL; - FILE *f; - unsigned file_len,data_len,file_name_len; + uint16_t ret; + PTPContainer ptp; + char *buf = NULL; + FILE *f; + unsigned file_len, data_len, file_name_len; - PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_UploadFile); + PTP_CNT_INIT(ptp, PTP_OC_CHDK, PTP_CHDK_UploadFile); - f = fopen(local_fn,"rb"); - if ( f == NULL ) - { - ptp_error(params,"could not open file \'%s\'",local_fn); - return 0; - } + f = fopen(local_fn, "rb"); + if (f == NULL) + { + ptp_error(params, "could not open file \'%s\'", local_fn); + return 0; + } - fseek(f,0,SEEK_END); - file_len = ftell(f); - fseek(f,0,SEEK_SET); + fseek(f, 0, SEEK_END); + file_len = ftell(f); + fseek(f, 0, SEEK_SET); - file_name_len = strlen(remote_fn); - data_len = 4 + file_name_len + file_len; - buf = malloc(data_len); - memcpy(buf,&file_name_len,4); - memcpy(buf+4,remote_fn,file_name_len); - fread(buf+4+file_name_len,1,file_len,f); + file_name_len = strlen(remote_fn); + data_len = 4 + file_name_len + file_len; + buf = malloc(data_len); + memcpy(buf, &file_name_len, 4); + memcpy(buf+4, remote_fn, file_name_len); + fread(buf+4+file_name_len, 1, file_len, f); - fclose(f); + fclose(f); - ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, data_len, &buf, NULL); + ret=ptp_transaction(params, &ptp, PTP_DP_SENDDATA, data_len, &buf, NULL); - free(buf); + free(buf); - if ( ret != PTP_RC_OK ) - { - ptp_error(params,"unexpected return code 0x%x",ret); - return 0; - } - return 1; + if (ret != PTP_RC_OK) + { + ptp_error(params, "unexpected return code 0x%x", ret); + return 0; + } + return 1; } #endif @@ -5700,7 +5700,7 @@ ptp_chdk_rcgetchunk(PTPParams* params, int fmt, ptp_chdk_rc_chunk *chunk) CHECK_PTP_RC(ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &chunk->data, NULL)); chunk->size = ptp.Param1; chunk->last = (ptp.Param2 == 0); - chunk->offset = ptp.Param3; //-1 for none + chunk->offset = ptp.Param3; //-1 for none return PTP_RC_OK; } diff --git a/camlibs/quicktake1x0/qtkn-decoder.c b/camlibs/quicktake1x0/qtkn-decoder.c index 1512a96e3..afd97d738 100644 --- a/camlibs/quicktake1x0/qtkn-decoder.c +++ b/camlibs/quicktake1x0/qtkn-decoder.c @@ -33,7 +33,7 @@ #define radc_token(tree, ptr) ((signed char) getbithuff(8, ptr, huff[tree])) #define PREDICTOR (c ? (buf[c][y-1][x] + buf[c][y][x+1]) / 2 \ - : (buf[c][y-1][x+1] + 2*buf[c][y-1][x] + buf[c][y][x+1]) / 4) + : (buf[c][y-1][x+1] + 2*buf[c][y-1][x] + buf[c][y][x+1]) / 4) int qtkn_decode(unsigned char *raw, int width, int height, unsigned char **out) { static const char src[] = { @@ -56,8 +56,8 @@ int qtkn_decode(unsigned char *raw, int width, int height, unsigned char **out) 2,-1, 2,13, 2,26, 3,39, 4,-16, 5,55, 6,-37, 6,76, 2,-26, 2,-13, 2,1, 3,-39, 4,16, 5,-55, 6,-76, 6,37 }; - static const unsigned short pt[] = - { 0,0, 1280,1344, 2320,3616, 3328,8000, 4095,16383, 65535,16383 }; + static const unsigned short pt[] = + { 0,0, 1280,1344, 2320,3616, 3328,8000, 4095,16383, 65535,16383 }; unsigned short curve[0x10000]; unsigned short huff[19][256]; int row, col, tree, nreps, rep, step, i, c, s, r, x, y, val, len; @@ -85,15 +85,15 @@ int qtkn_decode(unsigned char *raw, int width, int height, unsigned char **out) return GP_ERROR_NO_MEMORY; } - for (i=2; i < 12; i+=2) { - for (c=pt[i-2]; c <= pt[i]; c++) { - curve[c] = (float) (c-pt[i-2]) / (pt[i]-pt[i-2]) * (pt[i+1]-pt[i-1]) + pt[i-1] + 0.5; + for (i=2; i < 12; i+=2) { + for (c=pt[i-2]; c <= pt[i]; c++) { + curve[c] = (float)(c-pt[i-2]) / (pt[i]-pt[i-2]) * (pt[i+1]-pt[i-1]) + pt[i-1] + 0.5; } } for (s=i=0; i < (int)sizeof src; i+=2) { for (c=0; c < 256 >> src[i]; c++) { - ((unsigned short *)huff)[s++] = src[i] << 8 | (unsigned char) src[i+1]; + ((unsigned short *)huff)[s++] = src[i] << 8 | (unsigned char)src[i+1]; } } s = 3; @@ -181,8 +181,8 @@ int qtkn_decode(unsigned char *raw, int width, int height, unsigned char **out) } } - for (i=0; i < height*width; i++) { - tmp_c[i] = LIM(curve[tmp[i]] >> 4, 0, 255); + for (i=0; i < height*width; i++) { + tmp_c[i] = LIM(curve[tmp[i]] >> 4, 0, 255); } *out = calloc(1, len); diff --git a/camlibs/ricoh/ricoh.c b/camlibs/ricoh/ricoh.c index f8a1ea572..36d2881f8 100644 --- a/camlibs/ricoh/ricoh.c +++ b/camlibs/ricoh/ricoh.c @@ -574,18 +574,17 @@ ricoh_get_pic (Camera *camera, GPContext *context, unsigned int n, RicohMode mode; GP_DEBUG ("Getting image %i as %s...", n, - (type==RICOH_FILE_TYPE_PREVIEW ? "thumbnail":"image")); + (type==RICOH_FILE_TYPE_PREVIEW ? "thumbnail":"image")); /* Put camera into play mode, if not already */ CR (ricoh_get_mode (camera, context, &mode)); if (mode != RICOH_MODE_PLAY) - CR (ricoh_set_mode (camera, context, RICOH_MODE_PLAY)); + CR (ricoh_set_mode (camera, context, RICOH_MODE_PLAY)); /* Send picture number */ p[0] = n >> 0; p[1] = n >> 8; - CR (ricoh_transmit (camera, context, (unsigned char) type, - p, 2, buf, &len)); + CR (ricoh_transmit (camera, context, (unsigned char) type, p, 2, buf, &len)); C_LEN (context, len, 16); /* @@ -839,8 +838,7 @@ ricoh_put_file (Camera *camera, GPContext *context, const char *name, for (i = 0; i < size; i += 128) { memset (block, 0, sizeof (buf)); memcpy (block, data + i, MIN (128, size - i)); - CR (ricoh_transmit (camera, context, 0xa2, block, 128, - buf, &len)); + CR (ricoh_transmit (camera, context, 0xa2, block, 128, buf, &len)); C_LEN (context, len, 0); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) return (GP_ERROR_CANCEL); diff --git a/camlibs/sierra/library.c b/camlibs/sierra/library.c index f1395b4df..30f939f02 100644 --- a/camlibs/sierra/library.c +++ b/camlibs/sierra/library.c @@ -1290,9 +1290,9 @@ int sierra_get_string_register (Camera *camera, int reg, int fnumber, *b_len += packlength; if (file) { - CHECK (gp_file_append (file, (char *)&p[4], packlength)); - if (total > min_progress_bytes) - gp_context_progress_update (context, id, *b_len); + CHECK (gp_file_append (file, (char *)&p[4], packlength)); + if (total > min_progress_bytes) + gp_context_progress_update (context, id, *b_len); } } while (p[0] != SIERRA_PACKET_DATA_END); diff --git a/camlibs/sierra/sierra-usbwrap.c b/camlibs/sierra/sierra-usbwrap.c index e89e5fd90..e00df64cf 100644 --- a/camlibs/sierra/sierra-usbwrap.c +++ b/camlibs/sierra/sierra-usbwrap.c @@ -316,7 +316,7 @@ usb_wrap_RDY(gp_port* dev, unsigned int type) msg.length = uw_value(sizeof(msg)); msg.packet_type = UW_PACKET_RDY; ret = gp_port_send_scsi_cmd (dev, 1, (char*)&cmd, sizeof(cmd), - sense_buffer, sizeof(sense_buffer), (char*)&msg, sizeof(msg)); + sense_buffer, sizeof(sense_buffer), (char*)&msg, sizeof(msg)); if (retport, 5, 1, 0, reply, 2); if(reply[0]!=1) - return (GP_ERROR_IO); + return (GP_ERROR_IO); gp_port_usb_msg_read (camera->port, 5, 0, 0, reply, 8); if(reply[0]!=1) - return (GP_ERROR_IO); + return (GP_ERROR_IO); return (GP_OK); } diff --git a/camlibs/sipix/web2.c b/camlibs/sipix/web2.c index 3041dee6b..4f78526be 100644 --- a/camlibs/sipix/web2.c +++ b/camlibs/sipix/web2.c @@ -493,7 +493,7 @@ camera_abilities (CameraAbilitiesList *list) static int camera_exit (Camera *camera, GPContext *context) { - return web2_exit(camera->port, context); + return web2_exit(camera->port, context); } static int diff --git a/camlibs/smal/ultrapocket.c b/camlibs/smal/ultrapocket.c index a430837ad..483681e03 100644 --- a/camlibs/smal/ultrapocket.c +++ b/camlibs/smal/ultrapocket.c @@ -193,7 +193,7 @@ getpicture_logitech_pd(Camera *camera, GPContext *context, unsigned char **rd, c for (pc=1;pcnum_fats++; } - } + } return (GP_OK); } @@ -520,9 +520,8 @@ spca50x_sdram_request_thumbnail (CameraPrivateLibrary * lib, uint8_t ** buf, * Middle: 640x480 0 * High: 1024x768 (interpolated) 1*/ if (lib->bridge == BRIDGE_SPCA500 - && (g_file->fat[20] & 0xFF) == 2) { - return (spca50x_get_image (lib, buf, len, g_file)); - + && (g_file->fat[20] & 0xFF) == 2) { + return (spca50x_get_image (lib, buf, len, g_file)); } else { return (spca50x_get_image_thumbnail (lib, buf, len, g_file)); diff --git a/camlibs/spca50x/spca50x.c b/camlibs/spca50x/spca50x.c index ea4123029..1b386b0c7 100644 --- a/camlibs/spca50x/spca50x.c +++ b/camlibs/spca50x/spca50x.c @@ -135,7 +135,7 @@ spca50x_reset (CameraPrivateLibrary * lib) 0x0d04, NULL, 0)); CHECK (gp_port_usb_msg_write(lib->gpdev, 0x1e, 0, 0, NULL, 0)); if (lib->bridge == BRIDGE_SPCA504B_PD) { - CHECK (spca50x_pd_enable (lib)); + CHECK (spca50x_pd_enable (lib)); } } #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION @@ -214,9 +214,9 @@ create_jpeg_from_data (uint8_t * dst, uint8_t * src, unsigned int qIndex, int w, /* 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/sq905/library.c b/camlibs/sq905/library.c index 87c69efbc..ad52e216b 100644 --- a/camlibs/sq905/library.c +++ b/camlibs/sq905/library.c @@ -346,7 +346,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, } GP_DEBUG("Fetch entry %i\n", to_fetch); sq_read_picture_data - (camera->port, camera->pl->last_fetched_data, b); + (camera->port, camera->pl->last_fetched_data, b); camera->pl->last_fetched_entry = to_fetch; } while (camera->pl->last_fetched_entrypl->orientation)); - gp_widget_append (*window, child); + gp_widget_set_value (child, + orientation_to_string (camera->pl->orientation)); + gp_widget_append (*window, child); return GP_OK; } diff --git a/camlibs/stv0674/stv0674.c b/camlibs/stv0674/stv0674.c index 8d6273b2c..086476152 100644 --- a/camlibs/stv0674/stv0674.c +++ b/camlibs/stv0674/stv0674.c @@ -41,8 +41,8 @@ static const struct camera_to_usb { unsigned short idProduct; } camera_to_usb[] = { /* http://www.digitaldreamco.com/shop/xtra.htm, SVGA */ - { "DigitalDream:l'espion xtra", 0x05DA, 0x1020 }, - { "Che-ez!:Splash", 0x0553, 0x1002 } + { "DigitalDream:l'espion xtra", 0x05DA, 0x1020 }, + { "Che-ez!:Splash", 0x0553, 0x1002 } }; @@ -55,57 +55,54 @@ int camera_id (CameraText *id) int camera_abilities (CameraAbilitiesList *list) { - CameraAbilities a; - unsigned int i; + CameraAbilities a; + unsigned int i; - for(i = 0; - i < (sizeof(camera_to_usb) / sizeof(struct camera_to_usb)); - i++) - { + for (i = 0; i < (sizeof(camera_to_usb) / sizeof(struct camera_to_usb)); i++) + { - memset(&a, 0, sizeof(a)); - strcpy(a.model, camera_to_usb[i].name); + memset(&a, 0, sizeof(a)); + strcpy(a.model, camera_to_usb[i].name); - a.port = GP_PORT_USB; - a.status = GP_DRIVER_STATUS_EXPERIMENTAL; - a.operations = GP_OPERATION_CAPTURE_IMAGE | - GP_OPERATION_CAPTURE_PREVIEW; - a.file_operations = GP_FILE_OPERATION_PREVIEW; - a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; + a.port = GP_PORT_USB; + a.status = GP_DRIVER_STATUS_EXPERIMENTAL; + a.operations = GP_OPERATION_CAPTURE_IMAGE | + GP_OPERATION_CAPTURE_PREVIEW; + a.file_operations = GP_FILE_OPERATION_PREVIEW; + a.folder_operations = GP_FOLDER_OPERATION_DELETE_ALL; - a.usb_vendor = camera_to_usb[i].idVendor; - a.usb_product = camera_to_usb[i].idProduct; + a.usb_vendor = camera_to_usb[i].idVendor; + a.usb_product = camera_to_usb[i].idProduct; - gp_abilities_list_append(list, a); - } + gp_abilities_list_append(list, a); + } - 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 = stv0674_file_count(camera->port, &count); + if (result < GP_OK) + { + GP_DEBUG("file count returned %d\n", result); + return result; + } + if (count > 10000) { /* arbitrary limit to avoid resource exhaustion by malicious USB */ + GP_DEBUG("count %d is over 10000 arbitrary limit. Increase if needed.\n", count); + return GP_ERROR_CORRUPTED_DATA; + } - result = stv0674_file_count(camera->port, &count); - if (result < GP_OK) - { - GP_DEBUG("file count returned %d\n",result); - return result; - } - if (count > 10000) { /* arbitrary limit to avoid resource exhaustion by malicious USB */ - GP_DEBUG("count %d is over 10000 arbitrary limit. Increase if needed.\n", count); - return GP_ERROR_CORRUPTED_DATA; - } + GP_DEBUG("count is %x\n", count); - GP_DEBUG("count is %x\n",count); + gp_list_populate(list, "image%03i.jpg", count); - gp_list_populate(list, "image%03i.jpg", count); - - return (GP_OK); + return (GP_OK); } @@ -159,8 +156,7 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat sprintf(path->name,"image%03i.jpg",count); /* Tell the filesystem about it */ - result = gp_filesystem_append (camera->fs, path->folder, path->name, - context); + result = gp_filesystem_append (camera->fs, path->folder, path->name, context); if (result < 0) return (result); diff --git a/camlibs/stv0680/library.c b/camlibs/stv0680/library.c index 3b032c475..78b13dc3f 100644 --- a/camlibs/stv0680/library.c +++ b/camlibs/stv0680/library.c @@ -521,87 +521,87 @@ int stv0680_capture_preview(GPPort *port, char **data, int *size) int stv0680_delete_all(GPPort *port) { - return stv0680_try_cmd(port,CMDID_SET_IMAGE_INDEX,0,NULL,0); + return stv0680_try_cmd(port, CMDID_SET_IMAGE_INDEX, 0, NULL, 0); } int stv0680_summary(GPPort *port, char *txt) { - struct stv680_camera_info caminfo; - struct stv680_image_info imginfo; - int ret; + struct stv680_camera_info caminfo; + struct stv680_image_info imginfo; + int ret; - strcpy(txt,_("Information on STV0680-based camera:\n")); - /* Get Camera Information */ - if ((ret = stv0680_try_cmd(port, CMDID_GET_CAMERA_INFO, - 0, (void*)&caminfo, sizeof(caminfo)) < 0)) - return ret; - sprintf(txt+strlen(txt),_("Firmware Revision: %d.%d\n"), - caminfo.firmware_revision[0], - caminfo.firmware_revision[1] - ); - sprintf(txt+strlen(txt),_("ASIC Revision: %d.%d\n"), - caminfo.asic_revision[0], - caminfo.asic_revision[1] - ); - sprintf(txt+strlen(txt),_("Sensor ID: %d.%d\n"), - caminfo.sensor_id[0], - caminfo.sensor_id[1] - ); - /* HWCONFIG_COMMSLINK_MASK ... not really needed, the user knows, he - * plugged it in. */ - sprintf(txt+strlen(txt),_("Camera is configured for lights flickering by %dHz.\n"), - (caminfo.hardware_config & HWCONFIG_FLICKERFREQ_60HZ)?60:50 - ); - sprintf(txt+strlen(txt),_("Memory in camera: %d Mbit.\n"), - (caminfo.hardware_config & HWCONFIG_MEMSIZE_16MBIT)?16:64 - ); - if (caminfo.hardware_config & HWCONFIG_HAS_THUMBNAILS) - strcat(txt,_("Camera supports Thumbnails.\n")); - if (caminfo.hardware_config & HWCONFIG_HAS_VIDEO) - strcat(txt,_("Camera supports Video.\n")); - /* HWCONFIG_STARTUP_COMPLETED ... Would the camera even answer if not ? */ - if (caminfo.hardware_config & HWCONFIG_IS_MONOCHROME) - strcat(txt,_("Camera pictures are monochrome.\n")); - if (caminfo.hardware_config & HWCONFIG_MEM_FITTED) /* Is this useful? */ - strcat(txt,_("Camera has memory.\n")); + strcpy(txt, _("Information on STV0680-based camera:\n")); + /* Get Camera Information */ + if ((ret = stv0680_try_cmd(port, CMDID_GET_CAMERA_INFO, + 0, (void*)&caminfo, sizeof(caminfo)) < 0)) + return ret; + sprintf(txt+strlen(txt), _("Firmware Revision: %d.%d\n"), + caminfo.firmware_revision[0], + caminfo.firmware_revision[1] + ); + sprintf(txt+strlen(txt), _("ASIC Revision: %d.%d\n"), + caminfo.asic_revision[0], + caminfo.asic_revision[1] + ); + sprintf(txt+strlen(txt), _("Sensor ID: %d.%d\n"), + caminfo.sensor_id[0], + caminfo.sensor_id[1] + ); + /* HWCONFIG_COMMSLINK_MASK ... not really needed, the user knows, he + * plugged it in. */ + sprintf(txt+strlen(txt), _("Camera is configured for lights flickering by %dHz.\n"), + (caminfo.hardware_config & HWCONFIG_FLICKERFREQ_60HZ) ? 60 : 50 + ); + sprintf(txt+strlen(txt), _("Memory in camera: %d Mbit.\n"), + (caminfo.hardware_config & HWCONFIG_MEMSIZE_16MBIT) ? 16 : 64 + ); + if (caminfo.hardware_config & HWCONFIG_HAS_THUMBNAILS) + strcat(txt, _("Camera supports Thumbnails.\n")); + if (caminfo.hardware_config & HWCONFIG_HAS_VIDEO) + strcat(txt, _("Camera supports Video.\n")); + /* HWCONFIG_STARTUP_COMPLETED ... Would the camera even answer if not ? */ + if (caminfo.hardware_config & HWCONFIG_IS_MONOCHROME) + strcat(txt, _("Camera pictures are monochrome.\n")); + if (caminfo.hardware_config & HWCONFIG_MEM_FITTED) /* Is this useful? */ + strcat(txt, _("Camera has memory.\n")); - strcat(txt,_("Camera supports videoformats: ")); - if (caminfo.capabilities & CAP_CIF) strcat(txt,"CIF "); - if (caminfo.capabilities & CAP_VGA) strcat(txt,"VGA "); - if (caminfo.capabilities & CAP_QCIF) strcat(txt,"QCIF "); - if (caminfo.capabilities & CAP_QVGA) strcat(txt,"QVGA "); - strcat(txt,"\n"); - sprintf(txt+strlen(txt),_("Vendor ID: %02x%02x\n"), - caminfo.vendor_id[0], - caminfo.vendor_id[1] - ); - sprintf(txt+strlen(txt),_("Product ID: %02x%02x\n"), - caminfo.product_id[0], - caminfo.product_id[1] - ); - if ((ret = stv0680_try_cmd(port, CMDID_GET_IMAGE_INFO, 0, - (void*)&imginfo, sizeof(imginfo))!=GP_OK)) - return ret; - sprintf(txt+strlen(txt),_("Number of Images: %d\n"), - (imginfo.index[0]<<8)|imginfo.index[1] - ); - sprintf(txt+strlen(txt),_("Maximum number of Images: %d\n"), - (imginfo.maximages[0]<<8)|imginfo.maximages[1] - ); - sprintf(txt+strlen(txt),_("Image width: %d\n"), - (imginfo.width[0]<<8)|imginfo.width[1] - ); - sprintf(txt+strlen(txt),_("Image height: %d\n"), - (imginfo.height[0]<<8)|imginfo.height[1] - ); - sprintf(txt+strlen(txt),_("Image size: %d\n"), - (imginfo.size[0]<<24)|(imginfo.size[1]<<16)|(imginfo.size[2]<<8)| - imginfo.size[3] - ); - sprintf(txt+strlen(txt),_("Thumbnail width: %d\n"),imginfo.thumb_width); - sprintf(txt+strlen(txt),_("Thumbnail height: %d\n"),imginfo.thumb_height); - sprintf(txt+strlen(txt),_("Thumbnail size: %d\n"), - (imginfo.thumb_size[0]<<8)|imginfo.thumb_size[1] - ); - return GP_OK; + strcat(txt, _("Camera supports videoformats: ")); + if (caminfo.capabilities & CAP_CIF) strcat(txt, "CIF "); + if (caminfo.capabilities & CAP_VGA) strcat(txt, "VGA "); + if (caminfo.capabilities & CAP_QCIF) strcat(txt, "QCIF "); + if (caminfo.capabilities & CAP_QVGA) strcat(txt, "QVGA "); + strcat(txt, "\n"); + sprintf(txt+strlen(txt), _("Vendor ID: %02x%02x\n"), + caminfo.vendor_id[0], + caminfo.vendor_id[1] + ); + sprintf(txt+strlen(txt), _("Product ID: %02x%02x\n"), + caminfo.product_id[0], + caminfo.product_id[1] + ); + if ((ret = stv0680_try_cmd(port, CMDID_GET_IMAGE_INFO, 0, + (void*)&imginfo, sizeof(imginfo))!=GP_OK)) + return ret; + sprintf(txt+strlen(txt), _("Number of Images: %d\n"), + (imginfo.index[0]<<8)|imginfo.index[1] + ); + sprintf(txt+strlen(txt), _("Maximum number of Images: %d\n"), + (imginfo.maximages[0]<<8)|imginfo.maximages[1] + ); + sprintf(txt+strlen(txt), _("Image width: %d\n"), + (imginfo.width[0]<<8)|imginfo.width[1] + ); + sprintf(txt+strlen(txt), _("Image height: %d\n"), + (imginfo.height[0]<<8)|imginfo.height[1] + ); + sprintf(txt+strlen(txt), _("Image size: %d\n"), + (imginfo.size[0]<<24)|(imginfo.size[1]<<16)|(imginfo.size[2]<<8)| + imginfo.size[3] + ); + sprintf(txt+strlen(txt), _("Thumbnail width: %d\n"), imginfo.thumb_width); + sprintf(txt+strlen(txt), _("Thumbnail height: %d\n"), imginfo.thumb_height); + sprintf(txt+strlen(txt), _("Thumbnail size: %d\n"), + (imginfo.thumb_size[0]<<8)|imginfo.thumb_size[1] + ); + return GP_OK; } diff --git a/camlibs/stv0680/stv0680.c b/camlibs/stv0680/stv0680.c index 1a2fbbbab..27d28283c 100644 --- a/camlibs/stv0680/stv0680.c +++ b/camlibs/stv0680/stv0680.c @@ -75,13 +75,13 @@ static const struct camera_to_usb { { "Micromaxx:Digital Camera", 0x0553, 0x0202, 0 }, /* http://www.digitaldreamco.com/shop/elegante.htm, VGA */ - { "DigitalDream:l'elegante", 0x0553, 0x0202, 0 }, + { "DigitalDream:l'elegante", 0x0553, 0x0202, 0 }, /* http://www.digitaldreamco.com/shop/espion.htm, CIF */ - { "DigitalDream:l'espion", 0x0553, 0x0202, 0 }, + { "DigitalDream:l'espion", 0x0553, 0x0202, 0 }, /* http://www.digitaldreamco.com/shop/lesprit.html, CIF */ - { "DigitalDream:l'esprit", 0x0553, 0x0202, 0 }, + { "DigitalDream:l'esprit", 0x0553, 0x0202, 0 }, /* http://www.digitaldreamco.com/shop/laronde.htm, VGA */ - { "DigitalDream:la ronde", 0x0553, 0x0202, 0 }, + { "DigitalDream:la ronde", 0x0553, 0x0202, 0 }, /* https://sf.net/tracker/index.php?func=detail&aid=1000498&group_id=8874&atid=358874 */ { "DigitalDream:l'espion XS", 0x1183, 0x0001, 0 }, @@ -220,7 +220,7 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat /* Just added a new picture... */ result = stv0680_file_count(camera->port,&count); if (count == oldcount) - return GP_ERROR; /* unclear what went wrong ... hmm */ + return GP_ERROR; /* unclear what went wrong ... hmm */ strcpy(path->folder,"/"); sprintf(path->name,"image%03i.pnm",count); diff --git a/camlibs/sx330z/sx330z.c b/camlibs/sx330z/sx330z.c index 5fea4b48a..1a9af20be 100644 --- a/camlibs/sx330z/sx330z.c +++ b/camlibs/sx330z/sx330z.c @@ -177,7 +177,7 @@ sx330z_get_toc_page(Camera *camera, GPContext *context, struct traveler_toc_page */ int sx330z_get_data(Camera *camera, GPContext *context, const char *filename, - char **data, unsigned long int *size, int thumbnail) + char **data, unsigned long int *size, int thumbnail) { uint8_t *dptr; int pages, cnt, ret; diff --git a/camlibs/sx330z/sx330z.h b/camlibs/sx330z/sx330z.h index f5d4d7aee..9785738e8 100644 --- a/camlibs/sx330z/sx330z.h +++ b/camlibs/sx330z/sx330z.h @@ -125,7 +125,7 @@ int sx330z_get_toc_page(Camera *camera,GPContext *context,struct traveler_toc_pa * Load image data (thumbnail(exif) / image) */ int sx330z_get_data(Camera *camera,GPContext *context, const char* filename, - char **,unsigned long int *size,int thumbnail); + char **,unsigned long int *size,int thumbnail); diff --git a/camlibs/topfield/puppy.c b/camlibs/topfield/puppy.c index c9244172b..6ed12fbfd 100644 --- a/camlibs/topfield/puppy.c +++ b/camlibs/topfield/puppy.c @@ -398,7 +398,7 @@ decode_dir(Camera *camera, struct tf_packet *p, int listdirs, CameraList *list) printf("%c %20llu %24.24s %s\n", type, get_u64(&entries[i].size), ctime(×tamp), entries[i].name); #endif - } + } } static void @@ -447,7 +447,7 @@ decode_and_get_info(Camera *camera, const char *folder, struct tf_packet *p, con printf("%c %20llu %24.24s %s\n", type, get_u64(&entries[i].size), ctime(×tamp), entries[i].name); #endif - } + } } #if 0 @@ -1116,16 +1116,16 @@ make_dir_func (CameraFilesystem *fs, const char *folder, const char *foldername, return r; switch (get_u32(&reply.cmd)) { case SUCCESS: - return GP_OK; - break; + return GP_OK; + break; case FAIL: - gp_log (GP_LOG_ERROR, "topfield", "ERROR: Device reports %s\n", - decode_error(&reply)); - break; + gp_log (GP_LOG_ERROR, "topfield", "ERROR: Device reports %s\n", + decode_error(&reply)); + break; default: - gp_log (GP_LOG_ERROR, "topfield", "ERROR: Unhandled packet\n"); + gp_log (GP_LOG_ERROR, "topfield", "ERROR: Unhandled packet\n"); } return GP_ERROR_IO; } @@ -1151,9 +1151,9 @@ camera_abilities (CameraAbilitiesList *list) a.port = GP_PORT_USB; a.usb_vendor = 0x11db; a.usb_product = 0x1000; - a.operations = GP_OPERATION_NONE; - a.file_operations = GP_FILE_OPERATION_DELETE; - a.folder_operations = GP_FOLDER_OPERATION_NONE; + a.operations = GP_OPERATION_NONE; + a.file_operations = GP_FILE_OPERATION_DELETE; + a.folder_operations = GP_FOLDER_OPERATION_NONE; return gp_abilities_list_append(list, a); } diff --git a/camlibs/tp6801/library.c b/camlibs/tp6801/library.c index 0f66eb2c6..5ff4527a1 100644 --- a/camlibs/tp6801/library.c +++ b/camlibs/tp6801/library.c @@ -468,9 +468,9 @@ camera_exit (Camera *camera, GPContext *context) int camera_init (Camera *camera, GPContext *context) { - CameraAbilities a; - int ret; - char *dump, buf[256]; + CameraAbilities a; + int ret; + char *dump, buf[256]; /* First, set up all the function pointers */ camera->functions->exit = camera_exit; diff --git a/gphoto2/gphoto2-camera.h b/gphoto2/gphoto2-camera.h index a8d58176c..e402e164c 100644 --- a/gphoto2/gphoto2-camera.h +++ b/gphoto2/gphoto2-camera.h @@ -329,7 +329,7 @@ struct _Camera { GPPort *port; CameraFilesystem *fs; CameraFunctions *functions; - /**@}*/ + /**@}*/ CameraPrivateLibrary *pl; /**< Private data of camera libraries. */ CameraPrivateCore *pc; /**< Private data of the core of gphoto2. */ diff --git a/libgphoto2/gphoto2-abilities-list.c b/libgphoto2/gphoto2-abilities-list.c index a74424861..93d41d218 100644 --- a/libgphoto2/gphoto2-abilities-list.c +++ b/libgphoto2/gphoto2-abilities-list.c @@ -563,9 +563,9 @@ gp_abilities_list_append (CameraAbilitiesList *list, CameraAbilities abilities) C_PARAMS (list); if (list->count == list->maxcount) { - C_MEM (list->abilities = realloc (list->abilities, + C_MEM (list->abilities = realloc (list->abilities, sizeof (CameraAbilities) * (list->maxcount + 100))); - list->maxcount += 100; + list->maxcount += 100; } memcpy (&(list->abilities [list->count]), &abilities, diff --git a/libgphoto2/gphoto2-file.c b/libgphoto2/gphoto2-file.c index ab787d6c9..04d4d5e3e 100644 --- a/libgphoto2/gphoto2-file.c +++ b/libgphoto2/gphoto2-file.c @@ -576,29 +576,30 @@ gp_file_save (CameraFile *file, const char *filename) * See also the GP_MIME_* definitions. */ static const char *mime_table[] = { - "bmp", GP_MIME_BMP, - "jpg", GP_MIME_JPEG, - "tif", GP_MIME_TIFF, - "ppm", GP_MIME_PPM, - "pgm", GP_MIME_PGM, - "pnm", GP_MIME_PNM, - "png", GP_MIME_PNG, - "wav", GP_MIME_WAV, - "avi", GP_MIME_AVI, - "mp3", GP_MIME_MP3, - "wma", GP_MIME_WMA, - "asf", GP_MIME_ASF, - "ogg", GP_MIME_OGG, - "mpg", GP_MIME_MPEG, - "raw", GP_MIME_RAW, - "mts", GP_MIME_AVCHD, - "m2ts", GP_MIME_AVCHD, - "arw", GP_MIME_ARW, - "raf", GP_MIME_RAF, - "txt", GP_MIME_TXT, - "qtk", GP_MIME_QTKT, - "qtk", GP_MIME_QTKN, - NULL}; + "bmp", GP_MIME_BMP, + "jpg", GP_MIME_JPEG, + "tif", GP_MIME_TIFF, + "ppm", GP_MIME_PPM, + "pgm", GP_MIME_PGM, + "pnm", GP_MIME_PNM, + "png", GP_MIME_PNG, + "wav", GP_MIME_WAV, + "avi", GP_MIME_AVI, + "mp3", GP_MIME_MP3, + "wma", GP_MIME_WMA, + "asf", GP_MIME_ASF, + "ogg", GP_MIME_OGG, + "mpg", GP_MIME_MPEG, + "raw", GP_MIME_RAW, + "mts", GP_MIME_AVCHD, + "m2ts", GP_MIME_AVCHD, + "arw", GP_MIME_ARW, + "raf", GP_MIME_RAF, + "txt", GP_MIME_TXT, + "qtk", GP_MIME_QTKT, + "qtk", GP_MIME_QTKN, + NULL +}; /** * @param file a #CameraFile * @param filename diff --git a/libgphoto2/gphoto2-list.c b/libgphoto2/gphoto2-list.c index 126c170f4..cacddcc20 100644 --- a/libgphoto2/gphoto2-list.c +++ b/libgphoto2/gphoto2-list.c @@ -256,12 +256,12 @@ gp_list_find_by_name (CameraList *list, int *index, const char *name) * camlibs/ptp2/library.c thinks this is faster */ for (i=list->used-1; i >= 0; i--) { - if (0==strcmp(list->entry[i].name, name)) { - if (index) { - (*index) = i; - } - return (GP_OK); - } + if (0==strcmp(list->entry[i].name, name)) { + if (index) { + (*index) = i; + } + return (GP_OK); + } } return (GP_ERROR); diff --git a/libgphoto2/gphoto2-widget.c b/libgphoto2/gphoto2-widget.c index 5ff46b766..2471a34c3 100644 --- a/libgphoto2/gphoto2-widget.c +++ b/libgphoto2/gphoto2-widget.c @@ -138,7 +138,7 @@ gp_widget_free (CameraWidget *widget) /* Free children recursively */ if ((widget->type == GP_WIDGET_WINDOW) || (widget->type == GP_WIDGET_SECTION)) { - for (x = 0; x < gp_widget_count_children (widget); x++) + for (x = 0; x < gp_widget_count_children (widget); x++) gp_widget_free (widget->children[x]); free (widget->children); } diff --git a/libgphoto2_port/gphoto2/gphoto2-port-log.h b/libgphoto2_port/gphoto2/gphoto2-port-log.h index 57deb0fa9..6b3b585e3 100644 --- a/libgphoto2_port/gphoto2/gphoto2-port-log.h +++ b/libgphoto2_port/gphoto2/gphoto2-port-log.h @@ -70,8 +70,7 @@ int gp_log_add_func (GPLogLevel level, GPLogFunc func, void *data); int gp_log_remove_func (int id); /* Logging */ -void gp_log (GPLogLevel level, const char *domain, - const char *format, ...) +void gp_log (GPLogLevel level, const char *domain, const char *format, ...) #ifdef __GNUC__ __attribute__((__format__(printf,3,4))) #endif @@ -83,8 +82,7 @@ void gp_log_with_source_location( __attribute__((__format__(printf,5,6))) #endif ; -void gp_logv (GPLogLevel level, const char *domain, const char *format, - va_list args) +void gp_logv (GPLogLevel level, const char *domain, const char *format, va_list args) #ifdef __GNUC__ __attribute__((__format__(printf,3,0))) #endif @@ -178,39 +176,19 @@ __attribute__((__format__(printf,4,5))) #ifdef _GPHOTO2_INTERNAL_CODE - typedef struct StringFlagItem { - char *str; - unsigned int flag; - } StringFlagItem; +typedef struct StringFlagItem { + char *str; + unsigned int flag; +} StringFlagItem; - typedef void (*string_item_func) (const char *str, void *data); +typedef void (*string_item_func) (const char *str, void *data); - const char * - gpi_enum_to_string(const unsigned int _enum, - const StringFlagItem *map); - - int - gpi_string_to_enum(const char *str, - unsigned int *result, - const StringFlagItem *map); - - void - gpi_flags_to_string_list(const unsigned int flags, - const StringFlagItem *map, - string_item_func func, void *data); - - int - gpi_string_or_to_flags(const char *str, - unsigned int *flags, - const StringFlagItem *map); - - unsigned int - gpi_string_to_flag(const char *str, - const StringFlagItem *map); - - unsigned int - gpi_string_list_to_flags(const char *str[], - const StringFlagItem *map); +const char * gpi_enum_to_string (unsigned int _enum, const StringFlagItem *map); +int gpi_string_to_enum (const char *str, unsigned int *result, const StringFlagItem *map); +void gpi_flags_to_string_list (unsigned int flags, const StringFlagItem *map, string_item_func func, void *data); +int gpi_string_or_to_flags (const char *str, unsigned int *flags, const StringFlagItem *map); +unsigned int gpi_string_to_flag (const char *str, const StringFlagItem *map); +unsigned int gpi_string_list_to_flags (const char *str[], const StringFlagItem *map); /* Allocates a sufficiently large buffer and interpolates the format * string with the proveded va_list args. The returned memory has to diff --git a/libgphoto2_port/gphoto2/gphoto2-port.h b/libgphoto2_port/gphoto2/gphoto2-port.h index 6cfcf9c3c..487ee48e1 100644 --- a/libgphoto2_port/gphoto2/gphoto2-port.h +++ b/libgphoto2_port/gphoto2/gphoto2-port.h @@ -48,9 +48,9 @@ extern "C" { */ typedef enum _GPPortSerialParity { - GP_PORT_SERIAL_PARITY_OFF = 0, /**< \brief Parity is off (disabled) */ - GP_PORT_SERIAL_PARITY_EVEN, /**< \brief Parity is even. */ - GP_PORT_SERIAL_PARITY_ODD /**< \brief Parity is odd. */ + GP_PORT_SERIAL_PARITY_OFF = 0, /**< \brief Parity is off (disabled) */ + GP_PORT_SERIAL_PARITY_EVEN, /**< \brief Parity is even. */ + GP_PORT_SERIAL_PARITY_ODD /**< \brief Parity is odd. */ } GPPortSerialParity; /** \brief Maximum length of receive buffer */ @@ -140,7 +140,7 @@ typedef struct _GPPort { /* For your convenience */ GPPortType type; /**< \brief Actual type of this port */ - GPPortSettings settings; /**< \brief Current port settings. */ + GPPortSettings settings; /**< \brief Current port settings. */ GPPortSettings settings_pending;/**< \brief Settings to be committed. */ int timeout; /**< \brief Port timeout in milliseconds. */ diff --git a/libgphoto2_port/libgphoto2_port/gphoto2-port.c b/libgphoto2_port/libgphoto2_port/gphoto2-port.c index e41930466..1dd5eb2e5 100644 --- a/libgphoto2_port/libgphoto2_port/gphoto2-port.c +++ b/libgphoto2_port/libgphoto2_port/gphoto2-port.c @@ -1224,24 +1224,24 @@ static int gp_port_usb_fd = -1; int gp_port_usb_set_sys_device(int fd) { - gp_port_usb_fd = fd; - return (GP_OK); + gp_port_usb_fd = fd; + return (GP_OK); } int gp_port_usb_get_sys_device(void) { - return gp_port_usb_fd; + return gp_port_usb_fd; } #else int gp_port_usb_set_sys_device(int fd) { - return GP_ERROR_NOT_SUPPORTED; + return GP_ERROR_NOT_SUPPORTED; } int gp_port_usb_get_sys_device() { - return -1; + return -1; } #endif diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c index 507e934b9..a669ea4cc 100644 --- a/libgphoto2_port/libusb1/libusb1.c +++ b/libgphoto2_port/libusb1/libusb1.c @@ -589,7 +589,7 @@ gp_libusb1_close (GPPort *port) _close_async_interrupts(port); #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - if(gp_port_usb_get_sys_device() == -1) { + if (gp_port_usb_get_sys_device() == -1) { #endif if (libusb_release_interface (port->pl->dh, port->settings.usb.interface) < 0) { @@ -622,7 +622,7 @@ gp_libusb1_close (GPPort *port) libusb_close (port->pl->dh); #ifdef HAVE_LIBUSB_WRAP_SYS_DEVICE - } + } #endif struct _PrivateIrqCompleted *irq_iter; diff --git a/libgphoto2_port/serial/unix.c b/libgphoto2_port/serial/unix.c index 27f1f6d3f..baddd94c6 100644 --- a/libgphoto2_port/serial/unix.c +++ b/libgphoto2_port/serial/unix.c @@ -524,45 +524,45 @@ gp_port_serial_read (GPPort *dev, char *bytes, int size) return (GP_ERROR_TIMEOUT); if (dev->settings.serial.parity != GP_PORT_SERIAL_PARITY_OFF) { - unsigned char ffchar[1]; - unsigned char nullchar[1]; + unsigned char ffchar[1]; + unsigned char nullchar[1]; - ffchar[0] = 0xff; - nullchar[0] = 0; - now = read (dev->pl->fd, bytes, 1); - if (now < 0) - return GP_ERROR_IO_READ; - if (!memcmp(bytes,ffchar,1)) { + ffchar[0] = 0xff; + nullchar[0] = 0; now = read (dev->pl->fd, bytes, 1); if (now < 0) return GP_ERROR_IO_READ; + if (!memcmp(bytes, ffchar, 1)) { + now = read (dev->pl->fd, bytes, 1); + if (now < 0) + return GP_ERROR_IO_READ; - /* Parity errors are signaled by the serial layer - * as 0xff 0x00 sequence. - * - * 0xff sent by the camera are escaped as - * 0xff 0xff sequence. - * - * All other 0xff 0xXX sequences are errors. - * - * cf. man tcsetattr, description of PARMRK. - */ - if (!memcmp(bytes,nullchar,1)) { - gp_port_set_error (dev, _("Parity error.")); - return GP_ERROR_IO_READ; + /* Parity errors are signaled by the serial layer + * as 0xff 0x00 sequence. + * + * 0xff sent by the camera are escaped as + * 0xff 0xff sequence. + * + * All other 0xff 0xXX sequences are errors. + * + * cf. man tcsetattr, description of PARMRK. + */ + if (!memcmp(bytes, nullchar, 1)) { + gp_port_set_error (dev, _("Parity error.")); + return GP_ERROR_IO_READ; + } + if (memcmp(bytes, ffchar, 1)) { + gp_port_set_error (dev, _("Unexpected parity response sequence 0xff 0x%02x."), ((unsigned char*)bytes)[0]); + return GP_ERROR_IO_READ; + } + /* Ok, we read 1 byte and it is 0xff */ + /* FALLTHROUGH */ } - if (memcmp(bytes,ffchar,1)) { - gp_port_set_error (dev, _("Unexpected parity response sequence 0xff 0x%02x."), ((unsigned char*)bytes)[0]); - return GP_ERROR_IO_READ; - } - /* Ok, we read 1 byte and it is 0xff */ - /* FALLTHROUGH */ - } } else { - /* Just read the bytes */ - now = read (dev->pl->fd, bytes, size - readen); - if (now < 0) - return GP_ERROR_IO_READ; + /* Just read the bytes */ + now = read (dev->pl->fd, bytes, size - readen); + if (now < 0) + return GP_ERROR_IO_READ; } bytes += now; readen += now; @@ -798,12 +798,12 @@ gp_port_serial_check_speed (GPPort *dev) 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"); - tio.c_iflag &= ~IGNPAR; - tio.c_iflag |= INPCK | PARMRK ; - tio.c_cflag |= PARENB; - if (dev->settings.serial.parity == GP_PORT_SERIAL_PARITY_ODD) - tio.c_cflag |= PARODD; + GP_LOG_D ("Setting parity to %s...", dev->settings.serial.parity == GP_PORT_SERIAL_PARITY_ODD ? "odd" : "even"); + tio.c_iflag &= ~IGNPAR; + tio.c_iflag |= INPCK | PARMRK; + tio.c_cflag |= PARENB; + if (dev->settings.serial.parity == GP_PORT_SERIAL_PARITY_ODD) + tio.c_cflag |= PARODD; } /* Set the new speed. */