diff --git a/ChangeLog b/ChangeLog index 926075dbb..4e85e91df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-01-16 Lutz Müller + + Black magic by Marcus Meissner : + + find . -type f | xargs grep -l gp_debug_printf | xargs perl -pi -e 's/gp_debug_printf\(\s*GP_DEBUG[^,]*,[^,]*,(.*)$/GP_DEBUG(\1/' + 2002-01-15 Lutz Müller * libgphoto2/*.h: Fix headers: no config.h, ifdef __cplusplus ... diff --git a/camlibs/agfa/agfa.c b/camlibs/agfa/agfa.c index f7ec26320..4291244c6 100644 --- a/camlibs/agfa/agfa.c +++ b/camlibs/agfa/agfa.c @@ -40,6 +40,8 @@ #include +#define GP_MODULE "agfa" + struct { char *name; unsigned short idVendor; @@ -102,11 +104,10 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, int i; char temp_file[14]; - gp_debug_printf (GP_DEBUG_HIGH, "agfa", "camera_file_list %s\n", - folder); + GP_DEBUG ("camera_file_list %s\n", folder); if (agfa_get_file_list(camera->pl) < 0) { - gp_debug_printf (GP_DEBUG_HIGH, "agfa", "Could not agfa_file_list!"); + GP_DEBUG ("Could not agfa_file_list!"); return GP_ERROR; } @@ -124,7 +125,7 @@ static int agfa_file_get (Camera *camera, const char *filename, int thumbnail, int buflen,throwaway,result; - gp_debug_printf(GP_DEBUG_LOW, "agfa", "Getting file '%s'...",filename); + GP_DEBUG( "Getting file '%s'...",filename); agfa_reset(camera->pl); /* Always have to check num photos, @@ -149,7 +150,7 @@ static int agfa_file_get (Camera *camera, const char *filename, int thumbnail, result=agfa_get_thumb(camera->pl, filename, *data, buflen); if (result < 0) { free (*data); - gp_debug_printf(GP_DEBUG_LOW,"agfa","agfa_get_thumb_failed!"); + GP_DEBUG("agfa_get_thumb_failed!"); return result; } } @@ -157,7 +158,7 @@ static int agfa_file_get (Camera *camera, const char *filename, int thumbnail, result=agfa_get_pic(camera->pl, filename, *data, buflen); if (result < 0) { free(*data); - gp_debug_printf(GP_DEBUG_LOW,"agfa","agfa_get_pic_failed!"); + GP_DEBUG("agfa_get_pic_failed!"); return result; } } @@ -239,7 +240,7 @@ static int delete_file_func (CameraFilesystem *fs, const char *folder, Camera *camera = data; - gp_debug_printf(GP_DEBUG_LOW,"agfa","Deleting '%s' in '%s'...",filename,folder); + GP_DEBUG("Deleting '%s' in '%s'...",filename,folder); agfa_delete_picture(camera->pl,filename); @@ -261,7 +262,7 @@ int camera_init(Camera *camera, GPContext *context) { camera->functions->about = camera_about; camera->functions->capture = camera_capture; - gp_debug_printf (GP_DEBUG_LOW, "agfa", "Initializing the camera\n"); + GP_DEBUG ("Initializing the camera\n"); switch (camera->port->type) { case GP_PORT_USB: diff --git a/camlibs/agfa/commands.c b/camlibs/agfa/commands.c index 79c5d0725..b977dfd0d 100644 --- a/camlibs/agfa/commands.c +++ b/camlibs/agfa/commands.c @@ -5,6 +5,7 @@ * * Copyright 2001 Vince Weaver */ +#include #include #include @@ -19,6 +20,8 @@ #include "agfa.h" +#define GP_MODULE "agfa" + /* Regular commands always 8 bytes long */ static int agfa_send_command(int command, int argument, CameraPrivateLibrary *dev) { @@ -159,7 +162,7 @@ int agfa_get_file_list(CameraPrivateLibrary *dev) { buffer = malloc(buflen); if (!buffer) { - gp_debug_printf(GP_DEBUG_HIGH,"agfa","Could not allocate %i bytes!", + GP_DEBUG("Could not allocate %i bytes!", buflen); return GP_ERROR_NO_MEMORY; } @@ -180,7 +183,7 @@ int agfa_get_file_list(CameraPrivateLibrary *dev) { dev->file_list = malloc(taken * 13); if (!dev->file_list) { - gp_debug_printf(GP_DEBUG_HIGH,"agfa","Could not allocate %i bytes!", + GP_DEBUG("Could not allocate %i bytes!", taken*13); free(buffer); return (GP_ERROR_NO_MEMORY); @@ -366,7 +369,7 @@ int agfa_delete_picture(CameraPrivateLibrary *dev, const char *filename) { buffer = malloc(buflen); if (!buffer) { - gp_debug_printf(GP_DEBUG_HIGH,"agfa","Could not allocate %i bytes!", + GP_DEBUG("Could not allocate %i bytes!", buflen); return (GP_ERROR_NO_MEMORY); } diff --git a/camlibs/barbie/barbie.c b/camlibs/barbie/barbie.c index 9b337e450..27659af85 100644 --- a/camlibs/barbie/barbie.c +++ b/camlibs/barbie/barbie.c @@ -22,6 +22,8 @@ #include "barbie.h" +#define GP_MODULE "barbie" + extern char packet_1[]; static char *models[] = { diff --git a/camlibs/barbie/library.c b/camlibs/barbie/library.c index 79257b692..b32566f74 100644 --- a/camlibs/barbie/library.c +++ b/camlibs/barbie/library.c @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -5,6 +7,8 @@ #include #include "barbie.h" +#define GP_MODULE "barbie" + /* packet headers/footers */ char packet_header[3] = {0x02, 0x01}; char packet_header_data[6] = {0x02, 0x01, 0x01, 0x01, 0x01}; @@ -24,16 +28,16 @@ void barbie_packet_dump(GPPort *port, int direction, char *buf, int size) { int x; if (direction == 0) - gp_debug_printf(GP_DEBUG_LOW, "barbie", "\tRead Packet (%i): ", size); + GP_DEBUG( "\tRead Packet (%i): ", size); else - gp_debug_printf(GP_DEBUG_LOW, "barbie", "\tWrite Packet (%i): ", size); + GP_DEBUG( "\tWrite Packet (%i): ", size); for (x=0; xtext, "canon"); @@ -82,7 +82,7 @@ camera_id (CameraText *id) static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_manual()"); + GP_DEBUG ("camera_manual()"); strcpy (manual->text, _("For the A50, 115200 may not be faster than 57600\n" "Folders are NOT supported\n" @@ -98,7 +98,7 @@ camera_abilities (CameraAbilitiesList *list) int i; CameraAbilities a; - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_abilities()"); + GP_DEBUG ("camera_abilities()"); for (i = 0; models[i].id_str; i++) { memset (&a, 0, sizeof(a)); @@ -132,7 +132,7 @@ camera_abilities (CameraAbilitiesList *list) void clear_readiness (Camera *camera) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "clear_readiness()"); + GP_DEBUG ("clear_readiness()"); camera->pl->cached_ready = 0; } @@ -140,7 +140,7 @@ clear_readiness (Camera *camera) static int check_readiness (Camera *camera, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "check_readiness() cached_ready == %i", + GP_DEBUG ("check_readiness() cached_ready == %i", camera->pl->cached_ready); if (camera->pl->cached_ready) @@ -206,7 +206,7 @@ update_disk_cache (Camera *camera, GPContext *context) char root[10]; /* D:\ or such */ int res; - gp_debug_printf (GP_DEBUG_LOW, "canon", "update_disk_cache()"); + GP_DEBUG ("update_disk_cache()"); if (camera->pl->cached_disk) return 1; @@ -533,7 +533,7 @@ old_get_file_func (CameraFilesystem *fs, const char *folder, const char *filenam int buflen, size, ret; char path[300], tempfilename[300]; - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_file_get() " + GP_DEBUG ("camera_file_get() " "folder '%s' filename '%s'", folder, filename); if (check_readiness (camera, context) != 1) @@ -553,14 +553,13 @@ old_get_file_func (CameraFilesystem *fs, const char *folder, const char *filenam * is located */ if (get_file_path (camera, filename, path) == GP_ERROR) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_file_get: " + GP_DEBUG ("camera_file_get: " "Filename '%s' path '%s' not found!", filename, path); return GP_ERROR; } #endif - gp_debug_printf (GP_DEBUG_HIGH, "canon", "camera_file_get: " - "Found picture, '%s' '%s'", path, filename); + GP_DEBUG ("camera_file_get: Found picture, '%s' '%s'", path, filename); switch (camera->port->type) { case GP_PORT_USB: @@ -571,7 +570,7 @@ old_get_file_func (CameraFilesystem *fs, const char *folder, const char *filenam case GP_PORT_SERIAL: /* find rightmost \ in path */ if (strrchr (path, '\\') == NULL) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_file_get: " + GP_DEBUG ("camera_file_get: " "Could not determine directory part of path '%s'", path); return GP_ERROR; @@ -597,7 +596,7 @@ old_get_file_func (CameraFilesystem *fs, const char *folder, const char *filenam } if (ret != GP_OK) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_file_get: " + GP_DEBUG ("camera_file_get: " "canon_get_picture() failed, returned %i", ret); return ret; } @@ -697,7 +696,7 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) double time_diff; char formatted_camera_time[20]; - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_summary()"); + GP_DEBUG ("camera_summary()"); if (check_readiness (camera, context) != 1) return GP_ERROR; @@ -760,7 +759,7 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_about()"); + GP_DEBUG ("camera_about()"); strcpy (about->text, _("Canon PowerShot series driver by\n" @@ -843,7 +842,7 @@ put_file_func (CameraFilesystem *fs, const char *folder, CameraFile *file, char buf[10]; CameraAbilities a; - gp_debug_printf (GP_DEBUG_LOW, "canon", "camera_folder_put_file()"); + GP_DEBUG ("camera_folder_put_file()"); if (check_readiness (camera, context) != 1) return GP_ERROR; @@ -918,7 +917,7 @@ put_file_func (CameraFilesystem *fs, const char *folder, CameraFile *file, sprintf (destpath, "%s%s", dcf_root_dir, dir); - gp_debug_printf (GP_DEBUG_LOW, "canon", "destpath: %s destname: %s\n", + GP_DEBUG ("destpath: %s destname: %s\n", destpath, destname); } @@ -1078,7 +1077,7 @@ static int get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, CameraFileInfo * info, void *data, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon get_info_func() " + GP_DEBUG ("canon get_info_func() " "called for '%s'/'%s'", folder, filename); info->preview.fields = GP_FILE_INFO_TYPE; @@ -1200,7 +1199,7 @@ camera_init (Camera *camera, GPContext *context) { GPPortSettings settings; - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon camera_init()"); + GP_DEBUG ("canon camera_init()"); /* First, set up all the function pointers */ camera->functions->exit = camera_exit; diff --git a/camlibs/canon/serial.c b/camlibs/canon/serial.c index 1e103db8e..9045c1cfb 100644 --- a/camlibs/canon/serial.c +++ b/camlibs/canon/serial.c @@ -129,7 +129,7 @@ canon_serial_init (Camera *camera) { GPPortSettings settings; - gp_debug_printf (GP_DEBUG_LOW, "canon", "Initializing the (serial) camera.\n"); + GP_DEBUG ("Initializing the (serial) camera.\n"); /* Get the current settings */ gp_port_get_settings (camera->port, &settings); @@ -243,7 +243,7 @@ canon_serial_send_frame (Camera *camera, const unsigned char *pkt, int len) *p++ = CANON_FBEG; while (len--) { if (p - buffer >= sizeof (buffer) - 1) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "FATAL ERROR: send buffer overflow\n"); return -1; } @@ -279,7 +279,7 @@ canon_serial_recv_frame (Camera *camera, int *len) if (c == CANON_ESC) c = canon_serial_get_byte (camera->port) ^ CANON_XOR; if (p - buffer >= sizeof (buffer)) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "FATAL ERROR: receive buffer overflow\n"); return NULL; } @@ -343,13 +343,13 @@ canon_serial_recv_packet (Camera *camera, unsigned char *type, unsigned char *se if (!pkt) return NULL; if (raw_length < PKT_HDR_LEN) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "ERROR: packet truncated\n"); + GP_DEBUG ("ERROR: packet truncated\n"); return NULL; } if (pkt[PKT_TYPE] == PKT_MSG) { length = pkt[PKT_LEN_LSB] | (pkt[PKT_LEN_MSB] << 8); if (length + PKT_HDR_LEN > raw_length - 2) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "ERROR: invalid length\n"); + GP_DEBUG ("ERROR: invalid length\n"); /*fprintf(stderr,"Sending NACK\n"); canon_serial_send_packet(PKT_NACK,camera->pl->seq_rx++,camera->pl->psa50_eot+PKT_HDR_LEN,0); */ camera->pl->receive_error = ERROR_RECEIVED; @@ -358,7 +358,7 @@ canon_serial_recv_packet (Camera *camera, unsigned char *type, unsigned char *se } crc = pkt[raw_length - 2] | (pkt[raw_length - 1] << 8); if (!canon_psa50_chk_crc (pkt, raw_length - 2, crc)) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "ERROR: CRC error\n"); + GP_DEBUG ("ERROR: CRC error\n"); return NULL; } if (type) @@ -396,7 +396,7 @@ canon_serial_wait_for_ack (Camera *camera) return 0; if (seq == camera->pl->seq_tx && type == PKT_ACK) { if (pkt[2] == PKTACK_NACK) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "ERROR: NACK received\n"); return -1; } @@ -407,7 +407,7 @@ canon_serial_wait_for_ack (Camera *camera) if (type == PKT_EOT) { old_seq = pkt[0]; if (camera->pl->receive_error == NOERROR) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "Old EOT received, sending corresponding ACK\n"); if (!canon_serial_send_packet (camera, PKT_ACK, old_seq, @@ -418,7 +418,7 @@ canon_serial_wait_for_ack (Camera *camera) return 0; if (seq == old_seq && type == PKT_ACK) { if (pkt[2] == PKTACK_NACK) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "Old EOT acknowledged\n"); return -1; } @@ -435,9 +435,9 @@ canon_serial_wait_for_ack (Camera *camera) return 1; } - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "ERROR: ACK format or sequence error, retrying\n"); - gp_debug_printf (GP_DEBUG_LOW, "canon", "Sending NACK\n"); + GP_DEBUG ("Sending NACK\n"); canon_serial_send_packet (camera, PKT_NACK, camera->pl->seq_rx++, camera->pl->psa50_eot + PKT_HDR_LEN, 0); camera->pl->receive_error = ERROR_RECEIVED; @@ -489,7 +489,7 @@ canon_serial_send_msg (Camera *camera, unsigned char mtype, unsigned char dir, v len = va_arg (*ap, int); if (pos + len - pkt > MAX_MSG_SIZE && camera->pl->uploading != 1) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "FATAL ERROR: message too big (%i)\n", pos + len - pkt); return -1; @@ -537,12 +537,12 @@ canon_serial_send_msg (Camera *camera, unsigned char mtype, unsigned char dir, v return 0; good_ack = canon_serial_wait_for_ack (camera); if (good_ack == -1) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "NACK received, retrying command\n"); } else if (good_ack == 1) { return good_ack; } else { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "No ACK received, retrying command\n"); if (try == 2) { /* is the camera still there? */ @@ -553,7 +553,7 @@ canon_serial_send_msg (Camera *camera, unsigned char mtype, unsigned char dir, v good_ack = canon_serial_wait_for_ack (camera); if (good_ack == 0) { camera->pl->receive_error = FATAL_ERROR; - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "ERROR: FATAL ERROR\n"); clear_readiness (camera); return -1; @@ -597,12 +597,12 @@ canon_serial_recv_msg (Camera *camera, unsigned char mtype, unsigned char dir, i /* uploading is special */ /* if (type == PKT_ACK && mtype == 0x3 && dir == 0x21) break; */ if (type == PKT_EOT) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "Old EOT received sending corresponding ACK\n"); canon_serial_send_packet (camera, PKT_ACK, frag[0], camera->pl->psa50_eot + PKT_HDR_LEN, 0); } - gp_debug_printf (GP_DEBUG_LOW, "canon", "ERROR: protocol error, retrying\n"); + GP_DEBUG ("ERROR: protocol error, retrying\n"); } /* we keep the fragment only if there was no error */ if (camera->pl->receive_error == NOERROR) { @@ -611,12 +611,12 @@ canon_serial_recv_msg (Camera *camera, unsigned char mtype, unsigned char dir, i * not always in the same order */ /* if (type == PKT_ACK && mtype == 0x3 && dir == 0x21) { - gp_debug_printf(GP_DEBUG_LOW,"canon","ignoring ACK received while waiting for MSG\n"); + GP_DEBUG("ignoring ACK received while waiting for MSG\n"); return frag; } */ if (len < MSG_HDR_LEN || frag[MSG_02] != 2) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "ERROR: message format error\n"); return NULL; } @@ -840,15 +840,15 @@ canon_serial_error_type (Camera *camera) { switch (camera->pl->receive_error) { case ERROR_LOWBATT: - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "ERROR: no battery left, Bailing out!\n"); break; case FATAL_ERROR: - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "ERROR: camera connection lost!\n"); break; default: - gp_debug_printf (GP_DEBUG_LOW, "canon", "ERROR: malformed message\n"); + GP_DEBUG ("ERROR: malformed message\n"); break; } } @@ -931,7 +931,7 @@ canon_serial_get_file (Camera *camera, const char *name, int *length, GPContext int len; if (camera->pl->receive_error == FATAL_ERROR) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "ERROR: can't continue a fatal error condition detected\n"); return NULL; } @@ -952,8 +952,7 @@ canon_serial_get_file (Camera *camera, const char *name, int *length, GPContext total = le32atoh (msg + 4); if (total > camera->pl->md->max_picture_size) { - gp_debug_printf (GP_DEBUG_LOW, "canon", - "ERROR: %d is too big\n", total); + GP_DEBUG ("ERROR: %d is too big\n", total); break; } file = malloc (total); @@ -966,7 +965,7 @@ canon_serial_get_file (Camera *camera, const char *name, int *length, GPContext } size = le32atoh (msg + 12); if (le32atoh (msg + 8) != expect || expect + size > total || size > len - 20) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "ERROR: doesn't fit\n"); + GP_DEBUG ("ERROR: doesn't fit\n"); break; } memcpy (file + expect, msg + 20, size); @@ -1141,7 +1140,7 @@ canon_serial_ready (Camera *camera, GPContext *context) /* First of all, we must check if the camera is already on */ /* cts=canon_serial_get_cts(); - gp_debug_printf(GP_DEBUG_LOW,"canon","cts : %i\n",cts); + GP_DEBUG("cts : %i\n",cts); if (cts==32) { CTS == 32 when the camera is connected. */ if (camera->pl->first_init == 0 && camera->pl->cached_ready == 1) { /* First case, the serial speed of the camera is the same as @@ -1151,7 +1150,7 @@ canon_serial_ready (Camera *camera, GPContext *context) camera->pl->psa50_eot + PKT_HDR_LEN, 0)) return GP_ERROR; good_ack = canon_serial_wait_for_ack (camera); - gp_debug_printf (GP_DEBUG_LOW, "canon", "good_ack = %i\n", good_ack); + GP_DEBUG ("good_ack = %i\n", good_ack); if (good_ack == 0) { /* no answer from the camera, let's try * at the speed saved in the settings... */ @@ -1173,17 +1172,17 @@ canon_serial_ready (Camera *camera, GPContext *context) return canon_int_ready (camera, context); } if (good_ack == -1) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "Received a NACK !\n"); + GP_DEBUG ("Received a NACK !\n"); return GP_ERROR; } gp_context_status (context, _("Camera OK.\n")); return 1; } if (good_ack == -1) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "Received a NACK !\n"); + GP_DEBUG ("Received a NACK !\n"); return GP_ERROR; } - gp_debug_printf (GP_DEBUG_LOW, "canon", "Camera replied to ping, proceed.\n"); + GP_DEBUG ("Camera replied to ping, proceed.\n"); return GP_OK; } @@ -1194,7 +1193,7 @@ canon_serial_ready (Camera *camera, GPContext *context) /* we try to recover from an error we go back to 9600bps */ if (!canon_serial_change_speed (camera->port, 9600)) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "ERROR: Error changing speed"); + GP_DEBUG ("ERROR: Error changing speed"); return GP_ERROR; } camera->pl->receive_error = NOERROR; diff --git a/camlibs/canon/usb.c b/camlibs/canon/usb.c index ad5dca212..52bc6e5ef 100644 --- a/camlibs/canon/usb.c +++ b/camlibs/canon/usb.c @@ -402,7 +402,7 @@ canon_usb_dialogue (Camera *camera, int canon_funct, int *return_length, i++; } if (canon_usb_cmd[i].num == 0) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon_usb_dialogue() " + GP_DEBUG ("canon_usb_dialogue() " "called for ILLEGAL function %i! Aborting.", canon_funct); return NULL; } @@ -555,7 +555,7 @@ canon_usb_long_dialogue (Camera *camera, int canon_funct, unsigned char **data, * above, but as the saying goes: better safe than sorry. */ if (bytes_read != 0x40) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "canon_usb_long_dialogue: canon_usb_dialogue " "did not return (%i bytes) the number of bytes " "we expected (%i)!. Aborting.", bytes_read, 0x40); @@ -569,7 +569,7 @@ canon_usb_long_dialogue (Camera *camera, int canon_funct, unsigned char **data, _("Receiving data...")); if (max_data_size && (total_data_size > max_data_size)) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon_usb_long_dialogue: " + GP_DEBUG ("canon_usb_long_dialogue: " "ERROR: Packet of size %i is too big " "(max reasonable size specified is %i)", total_data_size, max_data_size); @@ -577,7 +577,7 @@ canon_usb_long_dialogue (Camera *camera, int canon_funct, unsigned char **data, } *data = malloc (total_data_size); if (!*data) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon_usb_long_dialogue: " + GP_DEBUG ("canon_usb_long_dialogue: " "ERROR: Could not allocate %i bytes of memory", total_data_size); return GP_ERROR_NO_MEMORY; @@ -588,13 +588,12 @@ canon_usb_long_dialogue (Camera *camera, int canon_funct, unsigned char **data, if ((total_data_size - bytes_received) < read_bytes) read_bytes = (total_data_size - bytes_received); - gp_debug_printf (GP_DEBUG_HIGH, "canon", - "calling gp_port_read(), total_data_size = %i, " + GP_DEBUG ("calling gp_port_read(), total_data_size = %i, " "bytes_received = %i, read_bytes = %i (0x%x)", total_data_size, bytes_received, read_bytes, read_bytes); bytes_read = gp_port_read (camera->port, *data + bytes_received, read_bytes); if (bytes_read < 1) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "gp_port_read() returned error (%i) or no data\n", bytes_read); free (*data); @@ -611,7 +610,7 @@ canon_usb_long_dialogue (Camera *camera, int canon_funct, unsigned char **data, } if (bytes_read < read_bytes) - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "WARNING: gp_port_read() resulted in short read " "(returned %i bytes, expected %i)", bytes_read, read_bytes); @@ -635,12 +634,12 @@ canon_usb_get_file (Camera *camera, const char *name, unsigned char **data, int char payload[100]; int payload_length, res; - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon_usb_get_file() called for file '%s'", + GP_DEBUG ("canon_usb_get_file() called for file '%s'", name); /* 8 is strlen ("12111111") */ if (8 + strlen (name) > sizeof (payload) - 1) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon_usb_get_file: ERROR: " + GP_DEBUG ("canon_usb_get_file: ERROR: " "Supplied file name '%s' does not fit in payload buffer.", name); return GP_ERROR_BAD_PARAMETERS; @@ -650,7 +649,7 @@ canon_usb_get_file (Camera *camera, const char *name, unsigned char **data, int * See the file Protocol in this directory for more information. */ sprintf (payload, "12111111%s", name); - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon_usb_get_file: payload %s", payload); + GP_DEBUG ("canon_usb_get_file: payload %s", payload); payload_length = strlen (payload) + 1; htole32a (payload, 0x0); /* get picture */ htole32a (payload + 0x4, USB_BULK_READ_SIZE); @@ -660,7 +659,7 @@ canon_usb_get_file (Camera *camera, const char *name, unsigned char **data, int camera->pl->md->max_picture_size, payload, payload_length, 1, context); if (res != GP_OK) { - gp_debug_printf (GP_DEBUG_LOW, "canon", + GP_DEBUG ( "canon_usb_get_file: canon_usb_long_dialogue() " "returned error (%i).", res); return res; @@ -677,7 +676,7 @@ canon_usb_get_thumbnail (Camera *camera, const char *name, unsigned char **data, /* 8 is strlen ("11111111") */ if (8 + strlen (name) > sizeof (payload) - 1) { - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon_usb_get_thumbnail: ERROR: " + GP_DEBUG ("canon_usb_get_thumbnail: ERROR: " "Supplied file name '%s' does not fit in " "payload buffer.", name); return GP_ERROR_BAD_PARAMETERS; @@ -687,7 +686,7 @@ canon_usb_get_thumbnail (Camera *camera, const char *name, unsigned char **data, * See the file Protocol in this directory for more information. */ sprintf (payload, "11111111%s", name); - gp_debug_printf (GP_DEBUG_LOW, "canon", "canon_usb_get_thumbnail: " + GP_DEBUG ("canon_usb_get_thumbnail: " "payload %s", payload); payload_length = strlen (payload) + 1; @@ -700,8 +699,7 @@ canon_usb_get_thumbnail (Camera *camera, const char *name, unsigned char **data, payload_length, 0, context); if (res != GP_OK) { - gp_debug_printf (GP_DEBUG_LOW, "canon", - "canon_usb_get_thumbnail: canon_usb_long_dialogue() " + GP_DEBUG ("canon_usb_get_thumbnail: canon_usb_long_dialogue() " "returned error (%i).", res); return res; } diff --git a/camlibs/digita/digita.c b/camlibs/digita/digita.c index aeb76654f..b275cd281 100644 --- a/camlibs/digita/digita.c +++ b/camlibs/digita/digita.c @@ -231,13 +231,13 @@ static char *digita_file_get(Camera *camera, const char *folder, buflen = GFD_BUFSIZE; data = malloc(buflen); if (!data) { - gp_debug_printf(GP_DEBUG_HIGH, "digita", "digita_file_get: allocating memory"); + GP_DEBUG( "digita_file_get: allocating memory"); return NULL; } memset(data, 0, buflen); if (digita_get_file_data(camera->pl, thumbnail, &fn, &tag, data) < 0) { - gp_debug_printf(GP_DEBUG_HIGH, "digita", "digita_get_picture: digita_get_file_data failed"); + GP_DEBUG( "digita_get_picture: digita_get_file_data failed"); return NULL; } @@ -247,7 +247,7 @@ static char *digita_file_get(Camera *camera, const char *folder, data = realloc(data, buflen); if (!data) { - gp_debug_printf(GP_DEBUG_HIGH, "digita", "digita_file_get: couldn't reallocate memory"); + GP_DEBUG( "digita_file_get: couldn't reallocate memory"); return NULL; } @@ -351,8 +351,8 @@ static int get_file_func(CameraFilesystem *fs, const char *folder, memcpy((void *)&width, data + 8, 4); width = ntohl(width); - gp_debug_printf(GP_DEBUG_LOW, "digita", "picture size %dx%d", width, height); - gp_debug_printf(GP_DEBUG_LOW, "digita", "data size %d", buflen - 16); + GP_DEBUG( "picture size %dx%d", width, height); + GP_DEBUG( "data size %d", buflen - 16); sprintf(ppmhead, "P6\n" @@ -445,7 +445,7 @@ int camera_init(Camera *camera, GPContext *context) folder_list_func, camera); gp_filesystem_set_file_funcs(camera->fs, get_file_func, NULL, camera); - gp_debug_printf(GP_DEBUG_LOW, "digita", "Initializing the camera"); + GP_DEBUG( "Initializing the camera"); camera->pl = malloc(sizeof(CameraPrivateLibrary)); if (!camera->pl) @@ -467,7 +467,7 @@ int camera_init(Camera *camera, GPContext *context) } if (ret < 0) { - gp_debug_printf(GP_DEBUG_HIGH, "digita", "camera_init: couldn't open digita device"); + GP_DEBUG( "camera_init: couldn't open digita device"); free(camera->pl); camera->pl = NULL; return ret; diff --git a/camlibs/dimera/dimera3500.c b/camlibs/dimera/dimera3500.c index bcaf85928..9e577aacb 100644 --- a/camlibs/dimera/dimera3500.c +++ b/camlibs/dimera/dimera3500.c @@ -21,6 +21,13 @@ * * History: * $Log$ + * Revision 1.42 2002/01/15 23:49:38 lutz + * 2002-01-16 Lutz Müller + * + * Black magic by Marcus Meissner : + * + * find . -type f | xargs grep -l gp_debug_printf | xargs perl -pi -e 's/gp_debug_printf\(\s*GP_DEBUG[^,]*,[^,]*,(.*)$/GP_DEBUG(\1/' + * * Revision 1.41 2002/01/13 20:34:38 lutz * 2002-01-13 Lutz Müller * @@ -159,12 +166,14 @@ # define N_(String) (String) #endif +#define GP_MODULE "dimera" + /* Legacy macros */ /*#define ERROR( s ) { \ fprintf( stderr, "%s: %s\n", __FUNCTION__, s ); \ error_dialog( s ); }*/ -#define ERROR(e) gp_debug_printf(GP_DEBUG_LOW, "dimera", "%s", (e)) -#define debuglog(e) gp_debug_printf(GP_DEBUG_LOW, "dimera", "%s", (e)) +#define ERROR(e) GP_DEBUG( "%s", (e)) +#define debuglog(e) GP_DEBUG( "%s", (e)) #define update_status(e) ERROR(e) @@ -699,10 +708,10 @@ Dimera_Get_Full_Image (int picnum, long *size, int *width, int *height, if ( (s == GP_ERROR_TIMEOUT || s == GP_ERROR_CORRUPTED_DATA) && --retry > 0) { update_status( _("Retransmitting") ); - gp_debug_printf(GP_DEBUG_LOW, "dimera", "Dimera_Get_Full_Image: retrans"); + GP_DEBUG( "Dimera_Get_Full_Image: retrans"); continue; } - gp_debug_printf(GP_DEBUG_LOW, "dimera", + GP_DEBUG( "Dimera_Get_Full_Image: read error %d (retry %d)",s,retry); /* retry count exceeded, or other error */ free( rbuffer ); @@ -735,10 +744,10 @@ Dimera_Get_Full_Image (int picnum, long *size, int *width, int *height, if ( (s == GP_ERROR_TIMEOUT || s == GP_ERROR_CORRUPTED_DATA) && --retry > 0) { update_status( _("Retransmitting") ); - gp_debug_printf(GP_DEBUG_LOW, "dimera", "Dimera_Get_Full_Image: retrans"); + GP_DEBUG( "Dimera_Get_Full_Image: retrans"); continue; } - gp_debug_printf(GP_DEBUG_LOW, "dimera", + GP_DEBUG( "Dimera_Get_Full_Image: read error %d (retry %d)",s,retry); /* retry count exceeded, or other error */ free( rbuffer ); @@ -798,7 +807,7 @@ static unsigned calc_new_exposure(unsigned exposure, unsigned brightness) { /* Choose the correct curve for this camera scene */ for (i=0; exposure_tables[i].M; ++i) { - gp_debug_printf(GP_DEBUG_LOW, "dimera", "brightness %d, %f ", + GP_DEBUG( "brightness %d, %f ", brightness, exp((double)((brightness/16.0) - exposure_tables[i].b) / exposure_tables[i].M)); if (exp((double)((brightness/16.0) - exposure_tables[i].b) / exposure_tables[i].M) > exposure) @@ -868,14 +877,14 @@ Dimera_Preview( int *size, Camera *camera, GPContext *context ) /* Current picture brightness, where 0 is is dark and 255 is bright */ brightness = exposure_total / (VIEWFIND_SZ / 16); - gp_debug_printf(GP_DEBUG_LOW, "dimera", + GP_DEBUG( "Average pixel brightness %f, Current exposure value: %d", brightness / 16.0, camera->pl->exposure); if (camera->pl->auto_exposure && (brightness < 96 || brightness > 160)) { /* Picture brightness needs to be corrected for next time */ camera->pl->exposure = calc_new_exposure(camera->pl->exposure, brightness); - gp_debug_printf(GP_DEBUG_LOW, "dimera", "New exposure value: %d", camera->pl->exposure); + GP_DEBUG( "New exposure value: %d", camera->pl->exposure); } return image; diff --git a/camlibs/dimera/mesalib.c b/camlibs/dimera/mesalib.c index f4bfd07b2..2029309e3 100644 --- a/camlibs/dimera/mesalib.c +++ b/camlibs/dimera/mesalib.c @@ -19,6 +19,7 @@ * GDB * $Id$ */ +#include #include #include @@ -30,7 +31,8 @@ #include "gphoto2-endian.h" #include "mesalib.h" -#define debuglog(e) gp_debug_printf(GP_DEBUG_LOW, "dimera", "%s", (e)) +#define GP_MODULE "dimera" +#define debuglog(e) GP_DEBUG( "%s", (e)) #ifdef CONVERT_PIXELS static const uint16_t pixelTable[256] = { @@ -202,7 +204,7 @@ mesa_set_speed( GPPort *port, int speed ) if (speed == 0) speed = 115200; /* use default speed */ - gp_debug_printf(GP_DEBUG_LOW, "dimera", + GP_DEBUG( "mesa_set_speed: speed %d", speed); b[0] = SET_SPEED; @@ -264,7 +266,7 @@ mesa_version( GPPort *port, char *version_string) return GP_ERROR_TIMEOUT; } - gp_debug_printf(GP_DEBUG_LOW, "dimera", + GP_DEBUG( "mesa_version: %02x:%02x:%02x\n", r[0], r[1], r[2] ); sprintf(v, "%2x.%02x%c", r[1], r[0], r[2]); /* highest byte must be < MESA_VERSION_SZ */ diff --git a/camlibs/fuji/fuji.h b/camlibs/fuji/fuji.h index a1598c67b..397f0150e 100644 --- a/camlibs/fuji/fuji.h +++ b/camlibs/fuji/fuji.h @@ -18,10 +18,10 @@ #define FUJI_MAXBUF_DEFAULT 9000000 -#define DBG(x) gp_debug_printf(GP_DEBUG_HIGH,"Fuji",x) -#define DBG2(x,y) gp_debug_printf(GP_DEBUG_HIGH,"Fuji",x,y) -#define DBG3(x,y,z) gp_debug_printf(GP_DEBUG_HIGH,"Fuji",x,y,z) -#define DBG4(w,x,y,z) gp_debug_printf(GP_DEBUG_HIGH,"Fuji",w,x,y,z) +#define DBG(x) GP_DEBUG(x) +#define DBG2(x,y) GP_DEBUG(x,y) +#define DBG3(x,y,z) GP_DEBUG(x,y,z) +#define DBG4(w,x,y,z) GP_DEBUG(w,x,y,z) struct _CameraPrivateLibrary { int folders; diff --git a/camlibs/jamcam/jamcam.c b/camlibs/jamcam/jamcam.c index 663b816c1..ed1f95638 100644 --- a/camlibs/jamcam/jamcam.c +++ b/camlibs/jamcam/jamcam.c @@ -49,6 +49,7 @@ #include "library.h" +#define GP_MODULE "jamcam" #define TIMEOUT 2000 #define JAMCAM_VERSION "0.6" @@ -66,7 +67,7 @@ static struct { int camera_id (CameraText *id) { - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* camera_id"); + GP_DEBUG ("* camera_id"); strcpy (id->text, "jamcam"); @@ -79,7 +80,7 @@ int camera_abilities (CameraAbilitiesList *list) char *ptr; CameraAbilities a; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* camera_abilities"); + GP_DEBUG ("* camera_abilities"); ptr = models[x].model; while (ptr) { @@ -113,8 +114,8 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, Camera *camera = data; int count; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* file_list_func"); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "*** folder: %s", folder); + GP_DEBUG ("* file_list_func"); + GP_DEBUG ("*** folder: %s", folder); CHECK (count = jamcam_file_count (camera)); CHECK (gp_list_populate (list, "pic_%04i.ppm", count)); @@ -130,9 +131,9 @@ static int get_info_func (CameraFilesystem *fs, const char *folder, int n; struct jamcam_file *jc_file; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* get_info_func"); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "*** folder: %s", folder); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "*** filename: %s",filename); + GP_DEBUG ("* get_info_func"); + GP_DEBUG ("*** folder: %s", folder); + GP_DEBUG ("*** filename: %s",filename); /* Get the file number from the CameraFileSystem */ CHECK (n = gp_filesystem_number (camera->fs, folder, @@ -156,7 +157,7 @@ static int get_info_func (CameraFilesystem *fs, const char *folder, static int camera_exit (Camera *camera, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* camera_exit"); + GP_DEBUG ("* camera_exit"); jamcam_file_count (camera); return (GP_OK); @@ -176,10 +177,10 @@ static int get_file_func (CameraFilesystem *fs, const char *folder, int width, height; struct jamcam_file *jc_file; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* camera_file_get"); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "*** folder: %s", folder); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "*** filename: %s",filename); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "*** type: %d", type); + GP_DEBUG ("* camera_file_get"); + GP_DEBUG ("*** folder: %s", folder); + GP_DEBUG ("*** filename: %s",filename); + GP_DEBUG ("*** type: %d", type); CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context)); @@ -260,7 +261,7 @@ static int camera_summary (Camera *camera, CameraText *summary, GPContext *conte int count; char tmp[1024]; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* camera_summary"); + GP_DEBUG ("* camera_summary"); /* possibly get # pics, mem free, etc. */ count = jamcam_file_count (camera); @@ -273,7 +274,7 @@ static int camera_summary (Camera *camera, CameraText *summary, GPContext *conte static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* camera_about"); + GP_DEBUG ("* camera_about"); strcpy (about->text, _("jamcam library v" JAMCAM_VERSION @@ -291,11 +292,9 @@ int camera_init (Camera *camera, GPContext *context) int count; GPPortSettings settings; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* camera_init"); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", - " * jamcam library for Gphoto2 by Chris Pinkham "); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", - " * jamcam library v%s, %s", JAMCAM_VERSION, JAMCAM_LAST_MOD ); + GP_DEBUG ("* camera_init"); + GP_DEBUG (" * jamcam library for Gphoto2 by Chris Pinkham "); + GP_DEBUG (" * jamcam library v%s, %s", JAMCAM_VERSION, JAMCAM_LAST_MOD ); /* First, set up all the function pointers */ camera->functions->exit = camera_exit; diff --git a/camlibs/jamcam/library.c b/camlibs/jamcam/library.c index f769b04c0..6e7b659da 100644 --- a/camlibs/jamcam/library.c +++ b/camlibs/jamcam/library.c @@ -52,6 +52,8 @@ # define N_(String) (String) #endif +#define GP_MODULE + struct jamcam_file jamcam_files[1024]; static int jamcam_count = 0; static int jamcam_mmc_card_size = 0; @@ -81,8 +83,8 @@ static int jamcam_get_int_at_pos( unsigned char *buf, int pos ) { static int jamcam_set_usb_mem_pointer( Camera *camera, int position ) { char reply[4]; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_set_usb_mem_pointer"); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "*** position: %d (0x%x)", + GP_DEBUG ("* jamcam_set_usb_mem_pointer"); + GP_DEBUG ("*** position: %d (0x%x)", position, position); gp_port_usb_msg_write( camera->port, @@ -110,7 +112,7 @@ static int jamcam_mmc_card_file_count (Camera *camera) { int width; int height; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_mmc_card_file_count"); + GP_DEBUG ("* jamcam_mmc_card_file_count"); memset( buf, 0, sizeof( buf )); @@ -209,8 +211,7 @@ static int jamcam_mmc_card_file_count (Camera *camera) { break; } - gp_debug_printf (GP_DEBUG_LOW, "jamcam", - "*** returning with jamcam_count = %d", jamcam_count); + GP_DEBUG ( "*** returning with jamcam_count = %d", jamcam_count); return( 0 ); } @@ -223,7 +224,7 @@ int jamcam_file_count (Camera *camera) { int height; int last_offset_size = 0; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_file_count"); + GP_DEBUG ("* jamcam_file_count"); jamcam_count = 0; @@ -308,8 +309,7 @@ int jamcam_file_count (Camera *camera) { jamcam_count += jamcam_mmc_card_file_count( camera ); } - gp_debug_printf (GP_DEBUG_LOW, "jamcam", - "*** returning jamcam_count = %d", jamcam_count); + GP_DEBUG ( "*** returning jamcam_count = %d", jamcam_count); return( jamcam_count ); } @@ -325,10 +325,10 @@ int jamcam_fetch_memory( Camera *camera, CameraFile *file, int res = GP_OK; unsigned int id = 0; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_fetch_memory"); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", " * start: %d (0x%x)", + GP_DEBUG ("* jamcam_fetch_memory"); + GP_DEBUG (" * start: %d (0x%x)", start, start); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", " * length: %d (0x%x)", + GP_DEBUG (" * length: %d (0x%x)", length, length); if ( length > 1000 ) @@ -382,7 +382,7 @@ int jamcam_fetch_memory( Camera *camera, CameraFile *file, if ( length > 1000 ) { gp_context_progress_update (context, id, bytes_read); if (gp_context_cancel (context) == GP_CONTEXT_FEEDBACK_CANCEL) { - gp_debug_printf (GP_DEBUG_LOW, "jamcam", " * CANCELED"); + GP_DEBUG (" * CANCELED"); break; } } @@ -392,7 +392,7 @@ int jamcam_fetch_memory( Camera *camera, CameraFile *file, gp_context_progress_stop (context, id); if ( res == GP_OK ) { - gp_debug_printf (GP_DEBUG_LOW, "jamcam", " * returning OK"); + GP_DEBUG (" * returning OK"); } return( res ); } @@ -403,7 +403,7 @@ int jamcam_request_image( Camera *camera, CameraFile *file, int result; char tmp_buf[300000]; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_request_image"); + GP_DEBUG ("* jamcam_request_image"); position = jamcam_files[number].position; @@ -456,7 +456,7 @@ int jamcam_request_thumbnail( Camera *camera, CameraFile *file, int bytes_to_read; unsigned int id; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_request_thumbnail"); + GP_DEBUG ("* jamcam_request_thumbnail"); memset( packet, 0, sizeof( packet )); @@ -538,7 +538,7 @@ int jamcam_request_thumbnail( Camera *camera, CameraFile *file, int jamcam_write_packet (Camera *camera, char *packet, int length) { int ret, r; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_write_packet"); + GP_DEBUG ("* jamcam_write_packet"); for (r = 0; r < RETRIES; r++) { ret = gp_port_write (camera->port, packet, length); @@ -556,8 +556,8 @@ int jamcam_read_packet (Camera *camera, char *packet, int length) { int r = 0; int bytes_read; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_read_packet"); - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "*** length: %d (0x%x)", + GP_DEBUG ("* jamcam_read_packet"); + GP_DEBUG ("*** length: %d (0x%x)", length, length); for (r = 0; r < RETRIES; r++) { @@ -581,7 +581,7 @@ int jamcam_enq (Camera *camera) int ret, r = 0; unsigned char buf[16]; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_enq"); + GP_DEBUG ("* jamcam_enq"); memset( buf, 0, 16 ); @@ -632,8 +632,7 @@ int jamcam_enq (Camera *camera) jamcam_mmc_card_size = jamcam_get_int_at_pos( buf, 8 ); if ( jamcam_mmc_card_size ) { - gp_debug_printf (GP_DEBUG_LOW, "jamcam", - "* jamcam_enq, MMC card size = %d", + GP_DEBUG ( "* jamcam_enq, MMC card size = %d", jamcam_mmc_card_size ); } @@ -660,7 +659,7 @@ int jamcam_query_mmc_card (Camera *camera) int ret, r = 0; char buf[16]; - gp_debug_printf (GP_DEBUG_LOW, "jamcam", "* jamcam_query_mmc_card"); + GP_DEBUG ("* jamcam_query_mmc_card"); /* usb port doesn't need this packet, this info found in enquiry reply */ if ( camera->port->type == GP_PORT_USB ) { @@ -687,8 +686,7 @@ int jamcam_query_mmc_card (Camera *camera) jamcam_mmc_card_size = jamcam_get_int_at_pos( buf, 0 ); if ( jamcam_mmc_card_size ) { - gp_debug_printf (GP_DEBUG_LOW, "jamcam", - "* jamcam_query_mmc_card, MMC card size = %d", + GP_DEBUG ("* jamcam_query_mmc_card, MMC card size = %d", jamcam_mmc_card_size ); } diff --git a/camlibs/konica/konica.c b/camlibs/konica/konica.c index cf1eeb370..7814c77e2 100644 --- a/camlibs/konica/konica.c +++ b/camlibs/konica/konica.c @@ -22,10 +22,13 @@ #include #include +#include + #include "library.h" #include "lowlevel.h" #include "konica.h" +#define GP_MODULE "konica" #define CHECK_NULL(r) {if (!(r)) return (GP_ERROR_BAD_PARAMETERS);} #define CHECK_RESULT(r,f) { \ int res = (r); \ @@ -88,7 +91,7 @@ case 0x0fff:\ return (KONICA_ERROR_UNKNOWN_ERROR);\ default:\ - gp_debug_printf (GP_DEBUG_MEDIUM, "konica",\ + GP_DEBUG (\ "The camera has just sent an error that has not "\ "yet been discovered. Please report the following "\ "to the maintainer of this driver with some "\ @@ -772,9 +775,7 @@ k_get_status (GPPort *device, KStatus *status) status->power_level = K_POWER_LEVEL_HIGH; break; default: - gp_debug_printf (GP_DEBUG_HIGH, "konica", - "Unknown power level %i!", - rb[6]); + GP_DEBUG ("Unknown power level %i!", rb[6]); break; } switch (rb[7]) { @@ -785,9 +786,7 @@ k_get_status (GPPort *device, KStatus *status) status->power_source = K_POWER_SOURCE_AC; break; default: - gp_debug_printf (GP_DEBUG_HIGH, "konica", - "Unknown power source %i!", - rb[7]); + GP_DEBUG ("Unknown power source %i!", rb[7]); break; } switch (rb[8]) { @@ -798,9 +797,7 @@ k_get_status (GPPort *device, KStatus *status) status->card_status = K_CARD_STATUS_NO_CARD; break; default: - gp_debug_printf (GP_DEBUG_HIGH, "konica", - "Unknown card status %i!", - rb[8]); + GP_DEBUG ("Unknown card status %i!", rb[8]); break; } switch (rb[9]) { @@ -811,8 +808,7 @@ k_get_status (GPPort *device, KStatus *status) status->display = K_DISPLAY_TV; break; default: - gp_debug_printf (GP_DEBUG_HIGH, "konica", - "Unkown display %i!", rb[9]); + GP_DEBUG ("Unkown display %i!", rb[9]); break; } status->card_size = (rb[11] << 8) | rb[10]; diff --git a/camlibs/konica/library.c b/camlibs/konica/library.c index 0c8c18504..4d6733e96 100644 --- a/camlibs/konica/library.c +++ b/camlibs/konica/library.c @@ -27,7 +27,6 @@ #include #include -#include #include #include "konica.h" @@ -521,7 +520,7 @@ camera_summary (Camera* camera, CameraText* summary, GPContext *context) char *name = NULL; char *manufacturer = NULL; - gp_debug_printf (GP_DEBUG_LOW, "konica", "*** ENTER: camera_summary " + GP_DEBUG ("*** ENTER: camera_summary " "***"); CHECK (camera, k_get_information (camera->port, &model, &serial_number, &hardware_version_major, &hardware_version_minor, @@ -642,7 +641,7 @@ camera_get_config (Camera* camera, CameraWidget** window, GPContext *context) GP_SYSTEM_DIRENT de; unsigned int id; - gp_debug_printf (GP_DEBUG_LOW, "konica", "*** ENTER: " + GP_DEBUG ("*** ENTER: " "camera_get_config ***"); /* Get the current settings. */ @@ -865,8 +864,7 @@ camera_set_config (Camera *camera, CameraWidget *window, GPContext *context) struct tm *tm_struct; int result; - gp_debug_printf (GP_DEBUG_LOW, "konica", "*** ENTER: " - "camera_set_config ***"); + GP_DEBUG ("*** ENTER: camera_set_config ***"); /************************/ /* Persistent Settings */ @@ -1136,20 +1134,18 @@ localization_file_read (Camera *camera, const char *file_name, (f != '9') && (f != 'A') && (f != 'B') && (f != 'C') && (f != 'D') && (f != 'E') && (f != 'F')) { - gp_debug_printf (GP_DEBUG_LOW, "konica", - "Error in localization " - "file: '%c' in line %i is " - "not allowed.", f, - (int) line_number); + GP_DEBUG ("Error in localization " + "file: '%c' in line %i is " + "not allowed.", f, + (int) line_number); fclose (file); return (GP_ERROR_CORRUPTED_DATA); } c[j] = (char) f; if (j == 1) { if (sscanf (&c[0], "%X", &d) != 1) { - gp_debug_printf (GP_DEBUG_LOW, - "konica", "Error in " - "localization file."); + GP_DEBUG ("Error in localization " + "file."); return (GP_ERROR_CORRUPTED_DATA); } (*data)[*data_size] = d; diff --git a/camlibs/konica/lowlevel.c b/camlibs/konica/lowlevel.c index acc0f4f5c..387509ea1 100644 --- a/camlibs/konica/lowlevel.c +++ b/camlibs/konica/lowlevel.c @@ -26,7 +26,6 @@ #include #include -#include #include #define GP_MODULE "konica" @@ -168,7 +167,7 @@ l_esc_read (GPPort *device, unsigned char *c) */ if ((*c == STX ) || (*c == ETX) || (*c == ENQ ) || (*c == ACK) || (*c == XOFF) || (*c == XON) || (*c == NACK) || (*c == ETB)) { - gp_debug_printf (GP_DEBUG_HIGH, "konica", "Wrong ESC masking!"); + GP_DEBUG ("Wrong ESC masking!"); if ((*c == ETX) || (*c == ETB)) return (GP_ERROR_CORRUPTED_DATA); } else if (*c == ESC) { @@ -177,8 +176,7 @@ l_esc_read (GPPort *device, unsigned char *c) if ((*c != STX ) && (*c != ETX ) && (*c != ENQ) && (*c != ACK ) && (*c != XOFF) && (*c != XON) && (*c != NACK) && (*c != ETB ) && (*c != ESC)) - gp_debug_printf (GP_DEBUG_HIGH, "konica", - "Wrong ESC masking!"); + GP_DEBUG ("Wrong ESC masking!"); } return (GP_OK); } diff --git a/camlibs/minolta/dimagev/capture.c b/camlibs/minolta/dimagev/capture.c index 57d86862f..59dfb8e3c 100644 --- a/camlibs/minolta/dimagev/capture.c +++ b/camlibs/minolta/dimagev/capture.c @@ -21,8 +21,12 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + /* This function handles sending the camera command to take a new picture, and the Dimage V automatically stores it in the lowest number available, which is the current number of images plus one. Since gphoto2 assumes that images @@ -36,13 +40,13 @@ int dimagev_shutter(dimagev_t *dimagev) { /* Check the device. */ if ( dimagev->dev == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::device not valid"); + GP_DEBUG( "dimagev_shutter::device not valid"); return GP_ERROR_BAD_PARAMETERS; } /* Verify that we can write to the memory card. */ if ( dimagev->status->card_status != (unsigned char) 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to write to memory card - check status"); + GP_DEBUG( "dimagev_shutter::unable to write to memory card - check status"); return GP_ERROR; } @@ -52,23 +56,23 @@ int dimagev_shutter(dimagev_t *dimagev) { /* Make sure we can set the data into the camera. */ if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to set host mode or record mode"); + GP_DEBUG( "dimagev_shutter::unable to set host mode or record mode"); return GP_ERROR; } /* Maybe reduce this later? */ if ( sleep(2) != 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::sleep() returned non-zero value"); + GP_DEBUG( "dimagev_shutter::sleep() returned non-zero value"); } /* Let's say hello and get the current status. */ if ( ( p = dimagev_make_packet(DIMAGEV_SHUTTER, 1, 0)) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to allocate packet"); + GP_DEBUG( "dimagev_shutter::unable to allocate packet"); return GP_ERROR_NO_MEMORY; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to write packet"); + GP_DEBUG( "dimagev_shutter::unable to write packet"); if ( p != NULL ) { free(p); @@ -83,11 +87,11 @@ int dimagev_shutter(dimagev_t *dimagev) { if ( sleep(1) != 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::sleep() returned non-zero value"); + GP_DEBUG( "dimagev_shutter::sleep() returned non-zero value"); } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::no response from camera"); + GP_DEBUG( "dimagev_shutter::no response from camera"); return GP_ERROR_IO; } @@ -95,32 +99,32 @@ int dimagev_shutter(dimagev_t *dimagev) { case DIMAGEV_ACK: /* Sleep for a few seconds while the image is written to flash. */ if ( sleep(5) != 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::sleep() returned non-zero value"); + GP_DEBUG( "dimagev_shutter::sleep() returned non-zero value"); } break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_shutter::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera cancels transmission"); + GP_DEBUG( "dimagev_shutter::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_shutter::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( sleep(1) != 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::sleep() returned non-zero value"); + GP_DEBUG( "dimagev_shutter::sleep() returned non-zero value"); } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to read packet"); + GP_DEBUG( "dimagev_shutter::unable to read packet"); return GP_ERROR_IO; } if ( ( raw = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to strip data packet"); + GP_DEBUG( "dimagev_shutter::unable to strip data packet"); free(p); return GP_ERROR; } @@ -128,7 +132,7 @@ int dimagev_shutter(dimagev_t *dimagev) { free(p); if ( raw->buffer[0] != (unsigned char) 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera returned error code"); + GP_DEBUG( "dimagev_shutter::camera returned error code"); free(raw); return GP_ERROR; } @@ -136,17 +140,17 @@ int dimagev_shutter(dimagev_t *dimagev) { free(raw); if ( sleep(1) != 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::sleep() returned non-zero value"); + GP_DEBUG( "dimagev_shutter::sleep() returned non-zero value"); } char_buffer = DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to send EOT"); + GP_DEBUG( "dimagev_shutter::unable to send EOT"); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::no response from camera"); + GP_DEBUG( "dimagev_shutter::no response from camera"); return GP_ERROR_IO; } @@ -154,20 +158,20 @@ int dimagev_shutter(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_shutter::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera cancels transmission"); + GP_DEBUG( "dimagev_shutter::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_shutter::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } dimagev->data->play_rec_mode = (unsigned char) 0; if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_shutter::unable to set host mode or record mode - non-fatal!"); + GP_DEBUG( "dimagev_shutter::unable to set host mode or record mode - non-fatal!"); /* return GP_ERROR;*/ } diff --git a/camlibs/minolta/dimagev/data.c b/camlibs/minolta/dimagev/data.c index 35b35c14c..18ad195f3 100644 --- a/camlibs/minolta/dimagev/data.c +++ b/camlibs/minolta/dimagev/data.c @@ -21,8 +21,12 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + /* This is the parent function, who calls most of the functions below. It returns GP_ERROR if it cannot get the camera data, and GP_OK otherwise. The subroutines will print out more detained information should they fail. @@ -33,22 +37,22 @@ int dimagev_get_camera_data(dimagev_t *dimagev) { /* Check the device. */ if ( dimagev->dev == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::device not valid"); + GP_DEBUG( "dimagev_get_camera_data::device not valid"); return GP_ERROR_BAD_PARAMETERS; } /* Let's say hello and get the current status. */ if ( ( p = dimagev_make_packet(DIMAGEV_GET_DATA, 1, 0)) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::unable to allocate packet"); + GP_DEBUG( "dimagev_get_camera_data::unable to allocate packet"); return GP_ERROR_NO_MEMORY; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::unable to write packet"); + GP_DEBUG( "dimagev_get_camera_data::unable to write packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::no response from camera"); + GP_DEBUG( "dimagev_get_camera_data::no response from camera"); free(p); return GP_ERROR_IO; } @@ -59,30 +63,30 @@ int dimagev_get_camera_data(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_camera_data::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::camera cancels transmission"); + GP_DEBUG( "dimagev_get_camera_data::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_camera_data::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::unable to read packet"); + GP_DEBUG( "dimagev_get_camera_data::unable to read packet"); return GP_ERROR_IO; } char_buffer = DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::unable to send EOT"); + GP_DEBUG( "dimagev_get_camera_data::unable to send EOT"); free(p); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::no response from camera"); + GP_DEBUG( "dimagev_get_camera_data::no response from camera"); free(p); return GP_ERROR_IO; } @@ -91,27 +95,27 @@ int dimagev_get_camera_data(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_camera_data::camera did not acknowledge transmission"); free(p); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::camera cancels transmission"); + GP_DEBUG( "dimagev_get_camera_data::camera cancels transmission"); free(p); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_camera_data::camera responded with unknown value %x", char_buffer); free(p); return GP_ERROR_IO; } if ( ( raw = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::unable to strip data packet"); + GP_DEBUG( "dimagev_get_camera_data::unable to strip data packet"); free(p); return GP_ERROR; } if ( ( dimagev->data = dimagev_import_camera_data(raw->buffer)) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_get_camera_data::unable to read camera data"); + GP_DEBUG( "dimagev_get_camera_data::unable to read camera data"); free(raw); free(p); return GP_ERROR; @@ -134,30 +138,30 @@ int dimagev_send_data(dimagev_t *dimagev) { if ( dimagev == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::unable to use NULL dimagev_t"); + GP_DEBUG( "dimagev_send_data::unable to use NULL dimagev_t"); return GP_ERROR_BAD_PARAMETERS; } if ( ( export_data = dimagev_export_camera_data(dimagev->data) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::unable to export camera data"); + GP_DEBUG( "dimagev_send_data::unable to export camera data"); return GP_ERROR; } dimagev_dump_camera_data(dimagev->data); if ( ( p = dimagev_make_packet(DIMAGEV_SET_DATA, 1, 0) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::unable to create set_data packet"); + GP_DEBUG( "dimagev_send_data::unable to create set_data packet"); free(export_data); return GP_ERROR_NO_MEMORY; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::unable to send set_data packet"); + GP_DEBUG( "dimagev_send_data::unable to send set_data packet"); free(p); free(export_data); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::no response from camera - trying to send NAK"); + GP_DEBUG( "dimagev_send_data::no response from camera - trying to send NAK"); free(p); free(export_data); return GP_ERROR_IO; @@ -169,21 +173,21 @@ int dimagev_send_data(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_send_data::camera did not acknowledge transmission"); free(export_data); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera cancels transmission"); + GP_DEBUG( "dimagev_send_data::camera cancels transmission"); free(export_data); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_send_data::camera responded with unknown value %x", char_buffer); free(export_data); return GP_ERROR_IO; } if ( ( p = dimagev_make_packet(export_data, 9, 1) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::unable to create set_data packet"); + GP_DEBUG( "dimagev_send_data::unable to create set_data packet"); free(export_data); return GP_ERROR_NO_MEMORY; } @@ -191,7 +195,7 @@ int dimagev_send_data(dimagev_t *dimagev) { free(export_data); if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::unable to send data packet"); + GP_DEBUG( "dimagev_send_data::unable to send data packet"); free(p); return GP_ERROR_IO; } @@ -199,7 +203,7 @@ int dimagev_send_data(dimagev_t *dimagev) { free(p); if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::no response from camera"); + GP_DEBUG( "dimagev_send_data::no response from camera"); return GP_ERROR_IO; } @@ -207,25 +211,25 @@ int dimagev_send_data(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_send_data::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera cancels transmission"); + GP_DEBUG( "dimagev_send_data::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_send_data::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } char_buffer = DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::unable to send EOT"); + GP_DEBUG( "dimagev_send_data::unable to send EOT"); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::no response from camera"); + GP_DEBUG( "dimagev_send_data::no response from camera"); return GP_ERROR_IO; } @@ -233,18 +237,18 @@ int dimagev_send_data(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_send_data::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera cancels transmission"); + GP_DEBUG( "dimagev_send_data::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_send_data::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_send_data::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( sleep(3) != 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_send_data::sleep() returned non-zero value"); + GP_DEBUG( "dimagev_send_data::sleep() returned non-zero value"); } return GP_OK; @@ -325,35 +329,35 @@ unsigned char *dimagev_export_camera_data(dimagev_data_t *good_data) { } void dimagev_dump_camera_data(dimagev_data_t *data) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========= Begin Camera Data ========="); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Host mode: %s ( %d )", data->host_mode != (unsigned char) 0 ? "Host mode" : "Camera mode", data->host_mode); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Exposure valid: %s ( %d )", data->exposure_valid != (unsigned char) 0 ? "Valid" : "Not Valid", data->exposure_valid); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Exposure correction: %d", (signed char)data->exposure_correction); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Date valid: %s ( %d )", data->date_valid != (unsigned char) 0 ? "Valid" : "Not Valid", data->exposure_valid); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Self timer mode: %s ( %d )", data->self_timer_mode != (unsigned char) 0 ? "Yes" : "No", data->self_timer_mode); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Flash mode: "); + GP_DEBUG( "========= Begin Camera Data ========="); + GP_DEBUG( "Host mode: %s ( %d )", data->host_mode != (unsigned char) 0 ? "Host mode" : "Camera mode", data->host_mode); + GP_DEBUG( "Exposure valid: %s ( %d )", data->exposure_valid != (unsigned char) 0 ? "Valid" : "Not Valid", data->exposure_valid); + GP_DEBUG( "Exposure correction: %d", (signed char)data->exposure_correction); + GP_DEBUG( "Date valid: %s ( %d )", data->date_valid != (unsigned char) 0 ? "Valid" : "Not Valid", data->exposure_valid); + GP_DEBUG( "Self timer mode: %s ( %d )", data->self_timer_mode != (unsigned char) 0 ? "Yes" : "No", data->self_timer_mode); + GP_DEBUG( "Flash mode: "); switch ( data->flash_mode ) { case 0: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "\tAuto ( 0 )"); + GP_DEBUG( "\tAuto ( 0 )"); break; case 1: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "\tForce Flash ( 1 )"); + GP_DEBUG( "\tForce Flash ( 1 )"); break; case 2: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "\tProhibit Flash ( 2 )"); + GP_DEBUG( "\tProhibit Flash ( 2 )"); break; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "\tInvalid mode for flash ( %d )", data->flash_mode); + GP_DEBUG( "\tInvalid mode for flash ( %d )", data->flash_mode); break; } - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Quality mode: %s ( %d )", data->quality_setting ? "High" : "Low", data->quality_setting); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Play or Record mode: %s ( %d )", data->play_rec_mode != (unsigned char) 0 ? "Record" : "Play", data->play_rec_mode); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Date: %02d/%02d/%02d %02d:%02d:%02d", data->year, data->month, data->day, data->hour, data->minute, data->second); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card ID Valid: %s ( %d )", data->valid != (unsigned char) 0 ? "Valid" : "Invalid", data->valid); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card ID Data: %02x", data->id_number); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========== End Camera Data =========="); + GP_DEBUG( "Quality mode: %s ( %d )", data->quality_setting ? "High" : "Low", data->quality_setting); + GP_DEBUG( "Play or Record mode: %s ( %d )", data->play_rec_mode != (unsigned char) 0 ? "Record" : "Play", data->play_rec_mode); + GP_DEBUG( "Date: %02d/%02d/%02d %02d:%02d:%02d", data->year, data->month, data->day, data->hour, data->minute, data->second); + GP_DEBUG( "Card ID Valid: %s ( %d )", data->valid != (unsigned char) 0 ? "Valid" : "Invalid", data->valid); + GP_DEBUG( "Card ID Data: %02x", data->id_number); + GP_DEBUG( "========== End Camera Data =========="); return; } @@ -370,16 +374,16 @@ int dimagev_set_date(dimagev_t *dimagev) { } if ( ( now = time(NULL) ) < 0 ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_set_date::unable to get system time"); + GP_DEBUG( "dimagev_set_date::unable to get system time"); return GP_ERROR; } if ( ( this_time = localtime(&now) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_set_date::unable to convert system time to local time"); + GP_DEBUG( "dimagev_set_date::unable to convert system time to local time"); return GP_ERROR; } - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Setting clock to %02d/%02d/%02d %02d:%02d:%02d", this_time->tm_year % 100, ( this_time->tm_mon + 1 ), this_time->tm_mday, this_time->tm_hour, this_time->tm_min, this_time->tm_sec); + GP_DEBUG( "Setting clock to %02d/%02d/%02d %02d:%02d:%02d", this_time->tm_year % 100, ( this_time->tm_mon + 1 ), this_time->tm_mday, this_time->tm_hour, this_time->tm_min, this_time->tm_sec); dimagev->data->date_valid = (unsigned char) 1; dimagev->data->year = (unsigned char) ( this_time->tm_year % 100 ); @@ -390,7 +394,7 @@ int dimagev_set_date(dimagev_t *dimagev) { dimagev->data->second = (unsigned char) this_time->tm_sec; if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_set_date::unable to set time"); + GP_DEBUG( "dimagev_set_date::unable to set time"); return GP_ERROR_IO; } @@ -398,7 +402,7 @@ int dimagev_set_date(dimagev_t *dimagev) { dimagev->data->date_valid = (unsigned char) 0; if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_set_date::unable to set time"); + GP_DEBUG( "dimagev_set_date::unable to set time"); return GP_ERROR_IO; } diff --git a/camlibs/minolta/dimagev/delete.c b/camlibs/minolta/dimagev/delete.c index cf48b0bb9..e4ef6c770 100644 --- a/camlibs/minolta/dimagev/delete.c +++ b/camlibs/minolta/dimagev/delete.c @@ -21,21 +21,25 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + int dimagev_delete_picture(dimagev_t *dimagev, int file_number) { dimagev_packet *p, *raw; unsigned char char_buffer=0, command_buffer[3]; if ( dimagev == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to use NULL dimagev_t"); + GP_DEBUG( "dimagev_delete_picture::unable to use NULL dimagev_t"); return GP_ERROR_BAD_PARAMETERS; } dimagev_dump_camera_status(dimagev->status); /* An image can only be deleted if the card is normal or full. */ if ( dimagev->status->card_status > (unsigned char) 1 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::memory card does not permit deletion"); + GP_DEBUG( "dimagev_delete_picture::memory card does not permit deletion"); return GP_ERROR; } @@ -44,7 +48,7 @@ int dimagev_delete_picture(dimagev_t *dimagev, int file_number) { dimagev->data->host_mode = (unsigned char) 1; if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to set host mode"); + GP_DEBUG( "dimagev_delete_picture::unable to set host mode"); return GP_ERROR_IO; } } @@ -55,16 +59,16 @@ int dimagev_delete_picture(dimagev_t *dimagev, int file_number) { command_buffer[1] = (unsigned char)( file_number / 256 ); command_buffer[2] = (unsigned char)( file_number % 256 ); if ( ( p = dimagev_make_packet(command_buffer, 3, 0) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to allocate command packet"); + GP_DEBUG( "dimagev_delete_picture::unable to allocate command packet"); return GP_ERROR_NO_MEMORY; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to send set_data packet"); + GP_DEBUG( "dimagev_delete_picture::unable to send set_data packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::no response from camera"); + GP_DEBUG( "dimagev_delete_picture::no response from camera"); free(p); return GP_ERROR_IO; } @@ -75,24 +79,24 @@ int dimagev_delete_picture(dimagev_t *dimagev, int file_number) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_delete_picture::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera cancels transmission"); + GP_DEBUG( "dimagev_delete_picture::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_delete_picture::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to read packet"); + GP_DEBUG( "dimagev_delete_picture::unable to read packet"); return GP_ERROR_IO; } if ( ( raw = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to strip packet"); + GP_DEBUG( "dimagev_delete_picture::unable to strip packet"); free(p); return GP_ERROR; } @@ -100,20 +104,20 @@ int dimagev_delete_picture(dimagev_t *dimagev, int file_number) { free(p); if ( raw->buffer[0] != (unsigned char) 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::delete returned error code"); + GP_DEBUG( "dimagev_delete_picture::delete returned error code"); free(raw); return GP_ERROR_NO_MEMORY; } char_buffer=DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::unable to send ACK"); + GP_DEBUG( "dimagev_delete_picture::unable to send ACK"); free(raw); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::no response from camera"); + GP_DEBUG( "dimagev_delete_picture::no response from camera"); free(raw); return GP_ERROR_IO; } @@ -122,15 +126,15 @@ int dimagev_delete_picture(dimagev_t *dimagev, int file_number) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_delete_picture::camera did not acknowledge transmission"); free(raw); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera cancels transmission"); + GP_DEBUG( "dimagev_delete_picture::camera cancels transmission"); free(raw); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_picture::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_delete_picture::camera responded with unknown value %x", char_buffer); free(raw); return GP_ERROR_IO; } @@ -143,14 +147,14 @@ int dimagev_delete_all(dimagev_t *dimagev) { unsigned char char_buffer, command_buffer[3]; if ( dimagev == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::unable to use NULL dimagev_t"); + GP_DEBUG( "dimagev_delete_all::unable to use NULL dimagev_t"); return GP_ERROR_BAD_PARAMETERS; } dimagev_dump_camera_status(dimagev->status); /* An image can only be deleted if the card is normal or full. */ if ( dimagev->status->card_status > (unsigned char) 1 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::memory card does not permit deletion"); + GP_DEBUG( "dimagev_delete_all::memory card does not permit deletion"); return GP_ERROR; } @@ -159,7 +163,7 @@ int dimagev_delete_all(dimagev_t *dimagev) { dimagev->data->host_mode = (unsigned char) 1; if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::unable to set host mode"); + GP_DEBUG( "dimagev_delete_all::unable to set host mode"); return GP_ERROR_IO; } } @@ -168,16 +172,16 @@ int dimagev_delete_all(dimagev_t *dimagev) { /* First make the command packet. */ command_buffer[0] = 0x06; if ( ( p = dimagev_make_packet(command_buffer, 1, 0) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::unable to allocate command packet"); + GP_DEBUG( "dimagev_delete_all::unable to allocate command packet"); return GP_ERROR_IO; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::unable to send set_data packet"); + GP_DEBUG( "dimagev_delete_all::unable to send set_data packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::no response from camera"); + GP_DEBUG( "dimagev_delete_all::no response from camera"); free(p); return GP_ERROR_IO; } @@ -188,24 +192,24 @@ int dimagev_delete_all(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_delete_all::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::camera cancels transmission"); + GP_DEBUG( "dimagev_delete_all::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_delete_all::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::unable to read packet"); + GP_DEBUG( "dimagev_delete_all::unable to read packet"); return GP_ERROR_IO; } if ( ( raw = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::unable to strip packet"); + GP_DEBUG( "dimagev_delete_all::unable to strip packet"); free(p); return GP_ERROR_NO_MEMORY; } @@ -213,20 +217,20 @@ int dimagev_delete_all(dimagev_t *dimagev) { free(p); if ( raw->buffer[0] != (unsigned char) 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::delete returned error code"); + GP_DEBUG( "dimagev_delete_all::delete returned error code"); free(raw); return GP_ERROR; } char_buffer=DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::unable to send ACK"); + GP_DEBUG( "dimagev_delete_all::unable to send ACK"); free(raw); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::no response from camera"); + GP_DEBUG( "dimagev_delete_all::no response from camera"); free(raw); return GP_ERROR_IO; } @@ -235,15 +239,15 @@ int dimagev_delete_all(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_delete_all::camera did not acknowledge transmission"); free(raw); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::camera cancels transmission"); + GP_DEBUG( "dimagev_delete_all::camera cancels transmission"); free(raw); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_delete_all::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_delete_all::camera responded with unknown value %x", char_buffer); free(raw); return GP_ERROR_IO; } diff --git a/camlibs/minolta/dimagev/dimagev.c b/camlibs/minolta/dimagev/dimagev.c index 412efd27b..371b32255 100644 --- a/camlibs/minolta/dimagev/dimagev.c +++ b/camlibs/minolta/dimagev/dimagev.c @@ -21,6 +21,8 @@ /* $Id$ */ +#include + #ifdef ENABLE_NLS # include # undef _ @@ -38,6 +40,8 @@ #include "dimagev.h" +#define GP_MODULE "dimagev" + int camera_id (CameraText *id) { #if defined HAVE_STRNCPY @@ -85,7 +89,7 @@ static int camera_exit (Camera *camera, GPContext *context) /* This will also send the host mode of zero. */ if ( dimagev_set_date(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_init::unable to set camera to system time"); + GP_DEBUG( "camera_init::unable to set camera to system time"); return GP_ERROR_IO; } free (camera->pl->data); @@ -115,12 +119,12 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, int ret; if ( dimagev_get_camera_status(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_file_list::unable to get camera status"); + GP_DEBUG( "camera_file_list::unable to get camera status"); return GP_ERROR_IO; } if ((ret = gp_list_populate(list, DIMAGEV_FILENAME_FMT, camera->pl->status->number_images)) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_file_list::unable to populate list"); + GP_DEBUG( "camera_file_list::unable to populate list"); return ret; } @@ -160,7 +164,7 @@ static int get_file_func (CameraFilesystem *fs, const char *folder, } if (result < 0) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_file_get::unable to retrieve image file"); + GP_DEBUG( "camera_file_get::unable to retrieve image file"); return result; } @@ -190,13 +194,13 @@ static int camera_capture (Camera *camera, CameraCaptureType type, CameraFilePat return (GP_ERROR_NOT_SUPPORTED); if ( dimagev_shutter(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_capture::unable to open shutter"); + GP_DEBUG( "camera_capture::unable to open shutter"); return GP_ERROR_IO; } /* Now check how many pictures are taken, and return the last one. */ if ( dimagev_get_camera_status(camera->pl) != 0 ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_capture::unable to get camera status"); + GP_DEBUG( "camera_capture::unable to get camera status"); return GP_ERROR_IO; } @@ -238,17 +242,17 @@ static int camera_summary (Camera *camera, CameraText *summary, GPContext *conte int i = 0, count = 0; if ( dimagev_get_camera_status(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_summary::unable to get camera status"); + GP_DEBUG( "camera_summary::unable to get camera status"); return GP_ERROR_IO; } if ( dimagev_get_camera_data(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_summary::unable to get camera data"); + GP_DEBUG( "camera_summary::unable to get camera data"); return GP_ERROR_IO; } if ( dimagev_get_camera_info(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_summary::unable to get camera info"); + GP_DEBUG( "camera_summary::unable to get camera info"); return GP_ERROR_IO; } @@ -446,7 +450,7 @@ int camera_init (Camera *camera, GPContext *context) camera->functions->summary = camera_summary; camera->functions->about = camera_about; - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "initializing the camera"); + GP_DEBUG( "initializing the camera"); camera->pl = malloc (sizeof (CameraPrivateLibrary)); if (!camera->pl) @@ -464,14 +468,14 @@ int camera_init (Camera *camera, GPContext *context) gp_port_set_settings(camera->port, settings); if ( dimagev_get_camera_data(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_init::unable to get current camera data"); + GP_DEBUG( "camera_init::unable to get current camera data"); free (camera->pl); camera->pl = NULL; return GP_ERROR_IO; } if ( dimagev_get_camera_status(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_init::unable to get current camera status"); + GP_DEBUG( "camera_init::unable to get current camera status"); free (camera->pl); camera->pl = NULL; return GP_ERROR_IO; @@ -479,7 +483,7 @@ int camera_init (Camera *camera, GPContext *context) /* Let's make this non-fatal. An incorrect date doesn't affect much. */ if ( dimagev_set_date(camera->pl) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "camera_init::unable to set camera to system time"); + GP_DEBUG( "camera_init::unable to set camera to system time"); } /* Set up the filesystem */ diff --git a/camlibs/minolta/dimagev/download.c b/camlibs/minolta/dimagev/download.c index 86bcc7fcb..542b8cae5 100644 --- a/camlibs/minolta/dimagev/download.c +++ b/camlibs/minolta/dimagev/download.c @@ -21,8 +21,12 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { int length, total_packets, i; unsigned long size = 0; @@ -38,12 +42,12 @@ int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { dimagev->data->host_mode = (unsigned char) 1; if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to set host mode"); + GP_DEBUG( "dimagev_get_picture::unable to set host mode"); return GP_ERROR_IO; } } - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::file_number is %d", file_number); + GP_DEBUG( "dimagev_get_picture::file_number is %d", file_number); /* Maybe check if it exists? Check the file type? */ @@ -52,16 +56,16 @@ int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { command_buffer[1] = (unsigned char)( file_number / 256 ); command_buffer[2] = (unsigned char)( file_number % 256 ); if ( ( p = dimagev_make_packet(command_buffer, 3, 0) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to allocate command packet"); + GP_DEBUG( "dimagev_get_picture::unable to allocate command packet"); return GP_ERROR_NO_MEMORY; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to send set_data packet"); + GP_DEBUG( "dimagev_get_picture::unable to send set_data packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::no response from camera"); + GP_DEBUG( "dimagev_get_picture::no response from camera"); free(p); return GP_ERROR_IO; } @@ -72,24 +76,24 @@ int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_picture::camera did not acknowledge transmission"); return dimagev_get_picture(dimagev, file_number, file); /* return GP_ERROR_IO;*/ case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera cancels transmission"); + GP_DEBUG( "dimagev_get_picture::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_picture::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to read packet"); + GP_DEBUG( "dimagev_get_picture::unable to read packet"); return GP_ERROR_IO; } if ( ( r = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to strip packet"); + GP_DEBUG( "dimagev_get_picture::unable to strip packet"); free(p); return GP_ERROR_NO_MEMORY; } @@ -101,7 +105,7 @@ int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { /* Allocate an extra byte just in case. */ if ( ( data = malloc((size_t)((993 * total_packets) + 1)) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to allocate buffer for file"); + GP_DEBUG( "dimagev_get_picture::unable to allocate buffer for file"); free(r); return GP_ERROR_NO_MEMORY; } @@ -115,31 +119,31 @@ int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { char_buffer=DIMAGEV_ACK; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to send ACK"); + GP_DEBUG( "dimagev_get_picture::unable to send ACK"); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { /* - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to read packet"); + GP_DEBUG( "dimagev_get_picture::unable to read packet"); return GP_ERROR_IO; */ - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::sending NAK to get retry"); + GP_DEBUG( "dimagev_get_picture::sending NAK to get retry"); char_buffer=DIMAGEV_NAK; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to send NAK"); + GP_DEBUG( "dimagev_get_picture::unable to send NAK"); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to read packet"); + GP_DEBUG( "dimagev_get_picture::unable to read packet"); return GP_ERROR_IO; } } if ( ( r = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to strip packet"); + GP_DEBUG( "dimagev_get_picture::unable to strip packet"); free(p); return GP_ERROR_NO_MEMORY; } @@ -156,12 +160,12 @@ int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { char_buffer=DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to send ACK"); + GP_DEBUG( "dimagev_get_picture::unable to send ACK"); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::no response from camera"); + GP_DEBUG( "dimagev_get_picture::no response from camera"); return GP_ERROR_IO; } @@ -169,13 +173,13 @@ int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_picture::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera cancels transmission"); + GP_DEBUG( "dimagev_get_picture::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_picture::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } @@ -184,7 +188,7 @@ int dimagev_get_picture(dimagev_t *dimagev, int file_number, CameraFile *file) { exifdat.data = data + 12 ; if ( stat_exif(&exifdat) != 0 ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_picture::unable to stat EXIF tags"); + GP_DEBUG( "dimagev_get_picture::unable to stat EXIF tags"); return GP_OK; } @@ -208,7 +212,7 @@ int dimagev_get_thumbnail(dimagev_t *dimagev, int file_number, CameraFile *file) dimagev->data->host_mode = (unsigned char) 1; if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to set host mode"); + GP_DEBUG( "dimagev_get_thumbnail::unable to set host mode"); return GP_ERROR_IO; } } @@ -218,16 +222,16 @@ int dimagev_get_thumbnail(dimagev_t *dimagev, int file_number, CameraFile *file) command_buffer[1] = (unsigned char)( file_number / 256 ); command_buffer[2] = (unsigned char)( file_number % 256 ); if ( ( p = dimagev_make_packet(command_buffer, 3, 0) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to allocate command packet"); + GP_DEBUG( "dimagev_get_thumbnail::unable to allocate command packet"); return GP_ERROR_NO_MEMORY; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to send set_data packet"); + GP_DEBUG( "dimagev_get_thumbnail::unable to send set_data packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::no response from camera"); + GP_DEBUG( "dimagev_get_thumbnail::no response from camera"); free(p); return GP_ERROR_IO; } @@ -238,24 +242,24 @@ int dimagev_get_thumbnail(dimagev_t *dimagev, int file_number, CameraFile *file) case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_thumbnail::camera did not acknowledge transmission"); return dimagev_get_thumbnail(dimagev, file_number, file); /* return GP_ERROR_IO;*/ case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::camera cancels transmission"); + GP_DEBUG( "dimagev_get_thumbnail::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_thumbnail::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to read packet"); + GP_DEBUG( "dimagev_get_thumbnail::unable to read packet"); return GP_ERROR_IO; } if ( ( r = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to strip packet"); + GP_DEBUG( "dimagev_get_thumbnail::unable to strip packet"); free(p); return GP_ERROR_NO_MEMORY; } @@ -266,7 +270,7 @@ int dimagev_get_thumbnail(dimagev_t *dimagev, int file_number, CameraFile *file) /* Allocate an extra byte just in case. */ if ( ( ycrcb_data = malloc(9600) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to allocate buffer for file"); + GP_DEBUG( "dimagev_get_thumbnail::unable to allocate buffer for file"); free(r); return GP_ERROR_NO_MEMORY; } @@ -280,19 +284,19 @@ int dimagev_get_thumbnail(dimagev_t *dimagev, int file_number, CameraFile *file) char_buffer=DIMAGEV_ACK; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to send ACK"); + GP_DEBUG( "dimagev_get_thumbnail::unable to send ACK"); free(ycrcb_data); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to read packet"); + GP_DEBUG( "dimagev_get_thumbnail::unable to read packet"); free(ycrcb_data); return GP_ERROR_IO; } if ( ( r = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to strip packet"); + GP_DEBUG( "dimagev_get_thumbnail::unable to strip packet"); free(p); free(ycrcb_data); return GP_ERROR_NO_MEMORY; @@ -305,20 +309,20 @@ int dimagev_get_thumbnail(dimagev_t *dimagev, int file_number, CameraFile *file) free(r); - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::current file size is %d", size); + GP_DEBUG( "dimagev_get_thumbnail::current file size is %d", size); } size++; char_buffer=DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::unable to send ACK"); + GP_DEBUG( "dimagev_get_thumbnail::unable to send ACK"); free(ycrcb_data); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::no response from camera"); + GP_DEBUG( "dimagev_get_thumbnail::no response from camera"); free(ycrcb_data); return GP_ERROR_IO; } @@ -327,15 +331,15 @@ int dimagev_get_thumbnail(dimagev_t *dimagev, int file_number, CameraFile *file) case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_thumbnail::camera did not acknowledge transmission"); free(ycrcb_data); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::camera cancels transmission"); + GP_DEBUG( "dimagev_get_thumbnail::camera cancels transmission"); free(ycrcb_data); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_thumbnail::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_thumbnail::camera responded with unknown value %x", char_buffer); free(ycrcb_data); return GP_ERROR_IO; } diff --git a/camlibs/minolta/dimagev/info.c b/camlibs/minolta/dimagev/info.c index f21964749..5131635dd 100644 --- a/camlibs/minolta/dimagev/info.c +++ b/camlibs/minolta/dimagev/info.c @@ -21,8 +21,12 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + /* This is the parent function, who calls most of the functions below. It returns GP_ERROR if it cannot get the camera data, and GP_OK otherwise. The subroutines will print out more detained information should they fail. */ @@ -32,7 +36,7 @@ int dimagev_get_camera_info(dimagev_t *dimagev) { /* Check the device. */ if ( dimagev->dev == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::device not valid"); + GP_DEBUG( "dimagev_get_camera_info::device not valid"); return GP_ERROR_BAD_PARAMETERS; } @@ -45,16 +49,16 @@ int dimagev_get_camera_info(dimagev_t *dimagev) { /* Let's say hello and get the current status. */ if ( ( p = dimagev_make_packet(DIMAGEV_INQUIRY, 1, 0)) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to allocate packet"); + GP_DEBUG( "dimagev_get_camera_info::unable to allocate packet"); return GP_ERROR_IO; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to write packet"); + GP_DEBUG( "dimagev_get_camera_info::unable to write packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::no response from camera"); + GP_DEBUG( "dimagev_get_camera_info::no response from camera"); free(p); return GP_ERROR_IO; } @@ -66,30 +70,30 @@ int dimagev_get_camera_info(dimagev_t *dimagev) { break; case DIMAGEV_NAK: /* Keep trying until a CAN is issued. */ - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_camera_info::camera did not acknowledge transmission"); return dimagev_get_camera_info(dimagev); case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera cancels transmission"); + GP_DEBUG( "dimagev_get_camera_info::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_camera_info::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to read packet"); + GP_DEBUG( "dimagev_get_camera_info::unable to read packet"); return GP_ERROR_IO; } char_buffer = DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to send EOT"); + GP_DEBUG( "dimagev_get_camera_info::unable to send EOT"); free(p); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::no response from camera"); + GP_DEBUG( "dimagev_get_camera_info::no response from camera"); free(p); return GP_ERROR_IO; } @@ -98,27 +102,27 @@ int dimagev_get_camera_info(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_camera_info::camera did not acknowledge transmission"); free(p); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera cancels transmission"); + GP_DEBUG( "dimagev_get_camera_info::camera cancels transmission"); free(p); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_camera_info::camera responded with unknown value %x", char_buffer); free(p); return GP_ERROR_IO; } if ( ( raw = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to strip data packet"); + GP_DEBUG( "dimagev_get_camera_info::unable to strip data packet"); free(p); return GP_ERROR_NO_MEMORY; } if ( ( dimagev->info = dimagev_import_camera_info(raw->buffer) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_info::unable to read camera info"); + GP_DEBUG( "dimagev_get_camera_info::unable to read camera info"); free(p); free(raw); return GP_ERROR; @@ -154,16 +158,16 @@ dimagev_info_t *dimagev_import_camera_info(unsigned char *raw_data) { void dimagev_dump_camera_info(dimagev_info_t *info) { if ( info == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_dump_camera_info::unable to read NULL simagev_info_t"); + GP_DEBUG( "dimagev_dump_camera_info::unable to read NULL simagev_info_t"); return; } - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========= Begin Camera Info ========="); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Vendor: %s", info->vendor); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Model: %s", info->model); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Hardware Revision: %s", info->hardware_rev); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Firmware Revision: %s", info->firmware_rev); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========== End Camera Info =========="); + GP_DEBUG( "========= Begin Camera Info ========="); + GP_DEBUG( "Vendor: %s", info->vendor); + GP_DEBUG( "Model: %s", info->model); + GP_DEBUG( "Hardware Revision: %s", info->hardware_rev); + GP_DEBUG( "Firmware Revision: %s", info->firmware_rev); + GP_DEBUG( "========== End Camera Info =========="); return; } diff --git a/camlibs/minolta/dimagev/packet.c b/camlibs/minolta/dimagev/packet.c index 0e66cfa9e..f2c0dc374 100644 --- a/camlibs/minolta/dimagev/packet.c +++ b/camlibs/minolta/dimagev/packet.c @@ -21,8 +21,12 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + /* This function takes an array of unsigned chars, as well as the length, and creates a dimagev_packet ready for sending to the camera. Packets must be of the form below: @@ -46,7 +50,7 @@ dimagev_packet *dimagev_make_packet(unsigned char *buffer, unsigned int length, dimagev_packet *p; if ( ( p = calloc(1, sizeof(dimagev_packet) ) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev","dimagev_make_packet::unable to allocate packet"); + GP_DEBUG("dimagev_make_packet::unable to allocate packet"); return NULL; } @@ -78,7 +82,7 @@ int dimagev_verify_packet(dimagev_packet *p) { /* All packets must start with DIMAGEV_STX and end with DIMAGEV_ETX. It's an easy check. */ if ( ( p->buffer[0] != (unsigned char) DIMAGEV_STX ) || ( p->buffer[(p->length - 1)] != (unsigned char) DIMAGEV_ETX ) ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_verify_packet::packet missing STX and/or ETX"); + GP_DEBUG( "dimagev_verify_packet::packet missing STX and/or ETX"); return GP_ERROR_CORRUPTED_DATA; } @@ -89,7 +93,7 @@ int dimagev_verify_packet(dimagev_packet *p) { } if ( current_checksum != correct_checksum ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_verify_packet::checksum bytes were %02x%02x, checksum was %d, should be %d", p->buffer[( p->length - 3) ], p->buffer[ ( p->length -2 ) ], current_checksum, correct_checksum); + GP_DEBUG( "dimagev_verify_packet::checksum bytes were %02x%02x, checksum was %d, should be %d", p->buffer[( p->length - 3) ], p->buffer[ ( p->length -2 ) ], current_checksum, correct_checksum); return GP_ERROR_CORRUPTED_DATA; } else { return GP_OK; @@ -101,18 +105,18 @@ dimagev_packet *dimagev_read_packet(dimagev_t *dimagev) { unsigned char char_buffer; if ( ( p = malloc(sizeof(dimagev_packet)) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev","dimagev_read_packet::unable to allocate packet"); + GP_DEBUG("dimagev_read_packet::unable to allocate packet"); return NULL; } if ( gp_port_read(dimagev->dev, p->buffer, 4) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_read_packet::unable to read packet header - will try to send NAK"); + GP_DEBUG( "dimagev_read_packet::unable to read packet header - will try to send NAK"); free(p); /* Send a NAK */ char_buffer = DIMAGEV_NAK; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_read_packet::unable to send NAK"); + GP_DEBUG( "dimagev_read_packet::unable to send NAK"); return NULL; } @@ -124,13 +128,13 @@ dimagev_packet *dimagev_read_packet(dimagev_t *dimagev) { p->length = ( p->buffer[2] * 256 ) + ( p->buffer[3] ); if ( gp_port_read(dimagev->dev, &(p->buffer[4]), ( p->length - 4)) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_read_packet::unable to read packet body - will try to send NAK"); + GP_DEBUG( "dimagev_read_packet::unable to read packet body - will try to send NAK"); free(p); /* Send a NAK */ char_buffer = DIMAGEV_NAK; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_read_packet::unable to send NAK"); + GP_DEBUG( "dimagev_read_packet::unable to send NAK"); return NULL; } @@ -141,13 +145,13 @@ dimagev_packet *dimagev_read_packet(dimagev_t *dimagev) { /* Now we *should* have a packet. Let's do a sanity check. */ if ( dimagev_verify_packet(p) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_read_packet::got an invalid packet - will try to send NAK"); + GP_DEBUG( "dimagev_read_packet::got an invalid packet - will try to send NAK"); free(p); /* Send a NAK */ char_buffer = DIMAGEV_NAK; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_read_packet::unable to send NAK"); + GP_DEBUG( "dimagev_read_packet::unable to send NAK"); return NULL; } @@ -181,7 +185,7 @@ dimagev_packet *dimagev_strip_packet(dimagev_packet *p) { } if ( ( stripped = malloc(sizeof(dimagev_packet)) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev","dimagev_strip_packet::unable to allocate destination packet"); + GP_DEBUG("dimagev_strip_packet::unable to allocate destination packet"); return NULL; } diff --git a/camlibs/minolta/dimagev/status.c b/camlibs/minolta/dimagev/status.c index 0bf6a6add..40ae47c12 100644 --- a/camlibs/minolta/dimagev/status.c +++ b/camlibs/minolta/dimagev/status.c @@ -21,8 +21,12 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + /* This is the parent function, who calls most of the functions below. It returns GP_ERROR if it cannot get the camera data, and GP_OK otherwise. The subroutines will print out more detained information should they fail. @@ -33,22 +37,22 @@ int dimagev_get_camera_status(dimagev_t *dimagev) { /* Check the device. */ if ( dimagev->dev == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::device not valid"); + GP_DEBUG( "dimagev_get_camera_status::device not valid"); return GP_ERROR_BAD_PARAMETERS; } /* Let's say hello and get the current status. */ if ( ( p = dimagev_make_packet(DIMAGEV_GET_STATUS, 1, 0)) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to allocate packet"); + GP_DEBUG( "dimagev_get_camera_status::unable to allocate packet"); return GP_ERROR_IO; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to write packet"); + GP_DEBUG( "dimagev_get_camera_status::unable to write packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::no response from camera"); + GP_DEBUG( "dimagev_get_camera_status::no response from camera"); free(p); return GP_ERROR_IO; } @@ -59,31 +63,31 @@ int dimagev_get_camera_status(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_camera_status::camera did not acknowledge transmission"); return dimagev_get_camera_status(dimagev); /* return GP_ERROR_IO;*/ case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera cancels transmission"); + GP_DEBUG( "dimagev_get_camera_status::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_camera_status::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } if ( ( p = dimagev_read_packet(dimagev) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to read packet"); + GP_DEBUG( "dimagev_get_camera_status::unable to read packet"); return GP_ERROR_IO; } char_buffer = DIMAGEV_EOT; if ( gp_port_write(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to send EOT"); + GP_DEBUG( "dimagev_get_camera_status::unable to send EOT"); free(p); return GP_ERROR_IO; } if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::no response from camera"); + GP_DEBUG( "dimagev_get_camera_status::no response from camera"); free(p); return GP_ERROR_IO; } @@ -92,21 +96,21 @@ int dimagev_get_camera_status(dimagev_t *dimagev) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_get_camera_status::camera did not acknowledge transmission"); free(p); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera cancels transmission"); + GP_DEBUG( "dimagev_get_camera_status::camera cancels transmission"); free(p); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_get_camera_status::camera responded with unknown value %x", char_buffer); free(p); return GP_ERROR_IO; } if ( ( raw = dimagev_strip_packet(p) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to strip data packet"); + GP_DEBUG( "dimagev_get_camera_status::unable to strip data packet"); free(p); return GP_ERROR; } @@ -114,7 +118,7 @@ int dimagev_get_camera_status(dimagev_t *dimagev) { free(p); if ( ( dimagev->status = dimagev_import_camera_status(raw->buffer) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_get_camera_status::unable to read camera status"); + GP_DEBUG( "dimagev_get_camera_status::unable to read camera status"); free(raw); return GP_ERROR; } @@ -155,54 +159,54 @@ dimagev_status_t *dimagev_import_camera_status(unsigned char *raw_data) { void dimagev_dump_camera_status(dimagev_status_t *status) { if ( status == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "Unable to dump NULL status"); + GP_DEBUG( "Unable to dump NULL status"); return; } - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========= Begin Camera Status ========="); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Battery level: %d", status->battery_level); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Number of images: %d", status->number_images); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Minimum images remaining: %d", status->minimum_images_can_take); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Busy: %s ( %d )", status->busy != (unsigned char) 0 ? "Busy" : "Not Busy", status->busy); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Flash charging: %s ( %d )", status->flash_charging != (unsigned char) 0 ? "Charging" : "Ready", status->flash_charging); + GP_DEBUG( "========= Begin Camera Status ========="); + GP_DEBUG( "Battery level: %d", status->battery_level); + GP_DEBUG( "Number of images: %d", status->number_images); + GP_DEBUG( "Minimum images remaining: %d", status->minimum_images_can_take); + GP_DEBUG( "Busy: %s ( %d )", status->busy != (unsigned char) 0 ? "Busy" : "Not Busy", status->busy); + GP_DEBUG( "Flash charging: %s ( %d )", status->flash_charging != (unsigned char) 0 ? "Charging" : "Ready", status->flash_charging); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Lens status: "); + GP_DEBUG( "Lens status: "); switch ( status->lens_status ) { case 0: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Normal ( 0 )"); + GP_DEBUG( "Normal ( 0 )"); break; case 1: case 2: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Lens direction does not match flash light ( %d )", status->lens_status ); + GP_DEBUG( "Lens direction does not match flash light ( %d )", status->lens_status ); break; case 3: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Lens is not attached ( 3 )"); + GP_DEBUG( "Lens is not attached ( 3 )"); break; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Bad value for lens status ( %d )", status->lens_status); + GP_DEBUG( "Bad value for lens status ( %d )", status->lens_status); break; } - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card status: "); + GP_DEBUG( "Card status: "); switch ( status->card_status ) { case 0: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Normal ( 0 )"); + GP_DEBUG( "Normal ( 0 )"); break; case 1: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Full ( 1 )"); + GP_DEBUG( "Full ( 1 )"); break; case 2: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Write-protected ( 2 )"); + GP_DEBUG( "Write-protected ( 2 )"); break; case 3: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card not valid for this camera ( 3 )"); + GP_DEBUG( "Card not valid for this camera ( 3 )"); break; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Invalid value for card status ( %d )", status->card_status); + GP_DEBUG( "Invalid value for card status ( %d )", status->card_status); break; } - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "Card ID Data: %02x", status->id_number); - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "========== End Camera Status =========="); + GP_DEBUG( "Card ID Data: %02x", status->id_number); + GP_DEBUG( "========== End Camera Status =========="); return; } diff --git a/camlibs/minolta/dimagev/upload.c b/camlibs/minolta/dimagev/upload.c index aabfedf12..ea23e3b4e 100644 --- a/camlibs/minolta/dimagev/upload.c +++ b/camlibs/minolta/dimagev/upload.c @@ -21,8 +21,12 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { unsigned char total_packets= (unsigned char) 0, sent_packets= (unsigned char) 0; int left_to_send=0; @@ -33,7 +37,7 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { unsigned char char_buffer, command_buffer[3], *packet_buffer; if ( dimagev == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::null camera device"); + GP_DEBUG( "dimagev_put_file::null camera device"); return GP_ERROR_BAD_PARAMETERS; } @@ -42,7 +46,7 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { dimagev->data->host_mode = (unsigned char) 1; if ( dimagev_send_data(dimagev) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to set host mode"); + GP_DEBUG( "dimagev_put_file::unable to set host mode"); return GP_ERROR_IO; } } @@ -52,16 +56,16 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { /* First make the command packet. */ command_buffer[0] = 0x0e; if ( ( p = dimagev_make_packet(command_buffer, 1, 0) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to allocate command packet"); + GP_DEBUG( "dimagev_put_file::unable to allocate command packet"); return GP_ERROR_NO_MEMORY; } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to send command packet"); + GP_DEBUG( "dimagev_put_file::unable to send command packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::no response from camera"); + GP_DEBUG( "dimagev_put_file::no response from camera"); free(p); return GP_ERROR_IO; } @@ -72,15 +76,15 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_put_file::camera did not acknowledge transmission"); /* Since we haven't sent anything, keep trying until we get a cancel. */ return dimagev_put_file(dimagev, file); /* return GP_ERROR_IO;*/ case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera cancels transmission"); + GP_DEBUG( "dimagev_put_file::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_put_file::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } @@ -90,7 +94,7 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { /* The first packet is a special case. */ if ( ( packet_buffer = malloc((size_t)993)) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to allocate packet buffer"); + GP_DEBUG( "dimagev_put_file::unable to allocate packet buffer"); return GP_ERROR_NO_MEMORY; } @@ -98,7 +102,7 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { memcpy(&(packet_buffer[1]), data, (size_t) 992); if ( ( p = dimagev_make_packet(packet_buffer, 993, 0) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to allocate command packet"); + GP_DEBUG( "dimagev_put_file::unable to allocate command packet"); free(packet_buffer); return GP_ERROR_NO_MEMORY; } @@ -106,11 +110,11 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { free(packet_buffer); if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to send data packet"); + GP_DEBUG( "dimagev_put_file::unable to send data packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::no response from camera"); + GP_DEBUG( "dimagev_put_file::no response from camera"); free(p); return GP_ERROR_IO; } @@ -121,13 +125,13 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_put_file::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera cancels transmission"); + GP_DEBUG( "dimagev_put_file::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_put_file::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } @@ -136,24 +140,24 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { for ( sent_packets = (unsigned char) 1 ; sent_packets < total_packets ; sent_packets++ ) { if ( left_to_send > 993 ) { if ( ( p = dimagev_make_packet(&(data[(sent_packets * 993) - 1]), 993, sent_packets) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to allocate data packet"); + GP_DEBUG( "dimagev_put_file::unable to allocate data packet"); free(p); return GP_ERROR_NO_MEMORY; } left_to_send-=993; } else { if ( ( p = dimagev_make_packet(&(data[((sent_packets * 993) - 1)]), left_to_send, sent_packets) ) == NULL ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to allocate data packet"); + GP_DEBUG( "dimagev_put_file::unable to allocate data packet"); return GP_ERROR_NO_MEMORY; } } if ( gp_port_write(dimagev->dev, p->buffer, p->length) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::unable to send data packet"); + GP_DEBUG( "dimagev_put_file::unable to send data packet"); free(p); return GP_ERROR_IO; } else if ( gp_port_read(dimagev->dev, &char_buffer, 1) < GP_OK ) { - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::no response from camera"); + GP_DEBUG( "dimagev_put_file::no response from camera"); free(p); return GP_ERROR_IO; } @@ -164,13 +168,13 @@ int dimagev_put_file(dimagev_t* dimagev, CameraFile *file) { case DIMAGEV_ACK: break; case DIMAGEV_NAK: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera did not acknowledge transmission"); + GP_DEBUG( "dimagev_put_file::camera did not acknowledge transmission"); return GP_ERROR_IO; case DIMAGEV_CAN: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera cancels transmission"); + GP_DEBUG( "dimagev_put_file::camera cancels transmission"); return GP_ERROR_IO; default: - gp_debug_printf(GP_DEBUG_LOW, "dimagev", "dimagev_put_file::camera responded with unknown value %x", char_buffer); + GP_DEBUG( "dimagev_put_file::camera responded with unknown value %x", char_buffer); return GP_ERROR_IO; } } diff --git a/camlibs/minolta/dimagev/util.c b/camlibs/minolta/dimagev/util.c index e9ad499d8..b0fbbb777 100644 --- a/camlibs/minolta/dimagev/util.c +++ b/camlibs/minolta/dimagev/util.c @@ -21,8 +21,12 @@ /* $Id$ */ +#include + #include "dimagev.h" +#define GP_MODULE "dimagev" + /* This function handles the ugliness of converting Y:Cb:Cr data to RGB. The return value is a pointer to an array of unsigned chars that has 14413) members. The additional thirteen bytes are the PPM "rawbits" header. @@ -70,7 +74,7 @@ unsigned char *dimagev_ycbcr_to_ppm(unsigned char *ycbcr) { unsigned int magic_r, magic_g, magic_b; if ( ( rgb_data = malloc( 14413 ) ) == NULL ) { - gp_debug_printf(GP_DEBUG_HIGH, "dimagev", "dimagev_ycbcr_to_ppm::unable to allocate buffer for Y:Cb:Cr conversion"); + GP_DEBUG( "dimagev_ycbcr_to_ppm::unable to allocate buffer for Y:Cb:Cr conversion"); return NULL; } diff --git a/camlibs/panasonic/coolshot/coolshot.c b/camlibs/panasonic/coolshot/coolshot.c index f38c2a652..4b4802c2f 100644 --- a/camlibs/panasonic/coolshot/coolshot.c +++ b/camlibs/panasonic/coolshot/coolshot.c @@ -25,6 +25,7 @@ /****************************************************************/ #include + #include #include #include @@ -46,6 +47,8 @@ #include "library.h" +#define GP_MODULE "coolshot" + #define TIMEOUT 2000 #define DEFAULT_SPEED 9600 @@ -65,7 +68,7 @@ struct _CameraPrivateLibrary { int camera_id (CameraText *id) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_id"); + GP_DEBUG ("* camera_id"); strcpy (id->text, "coolshot"); @@ -78,7 +81,7 @@ int camera_abilities (CameraAbilitiesList *list) char *ptr; CameraAbilities a; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_abilities"); + GP_DEBUG ("* camera_abilities"); ptr = coolshot_cameras[x++]; while (*ptr) { @@ -110,7 +113,7 @@ int camera_abilities (CameraAbilitiesList *list) static int camera_start (Camera *camera) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_start"); + GP_DEBUG ("* camera_start"); /* coolshot_sb sets to default speed if speed == 0 */ CHECK (coolshot_sb (camera, camera->pl->speed)); @@ -119,7 +122,7 @@ static int camera_start (Camera *camera) static int camera_stop (Camera *camera) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_stop"); + GP_DEBUG ("* camera_stop"); CHECK (coolshot_sb( camera, DEFAULT_SPEED)); return (GP_OK); @@ -131,8 +134,8 @@ static int file_list_func (CameraFilesystem *fs, const char *folder, Camera *camera = data; int count; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* file_list_func"); - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** folder: %s", folder); + GP_DEBUG ("* file_list_func"); + GP_DEBUG ("*** folder: %s", folder); CHECK (camera_start (camera)); CHECK (count = coolshot_file_count (camera)); @@ -148,9 +151,9 @@ static int get_info_func (CameraFilesystem *fs, const char *folder, Camera *camera = data; int n; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* get_info_func"); - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** folder: %s", folder); - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** filename: %s",filename); + GP_DEBUG ("* get_info_func"); + GP_DEBUG ("*** folder: %s", folder); + GP_DEBUG ("*** filename: %s",filename); CHECK (camera_start (camera)); @@ -187,10 +190,10 @@ static int get_file_func (CameraFilesystem *fs, const char *folder, char ppm_filename[128]; int size, n; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_file_get"); - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** folder: %s", folder); - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** filename: %s",filename); - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** type: %d", type); + GP_DEBUG ("* camera_file_get"); + GP_DEBUG ("*** folder: %s", folder); + GP_DEBUG ("*** filename: %s",filename); + GP_DEBUG ("*** type: %d", type); CHECK (camera_start (camera)); @@ -240,7 +243,7 @@ static int camera_summary (Camera *camera, CameraText *summary, int count; char tmp[1024]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_summary"); + GP_DEBUG ("* camera_summary"); CHECK (camera_start (camera)); @@ -255,7 +258,7 @@ static int camera_summary (Camera *camera, CameraText *summary, static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* camera_about"); + GP_DEBUG ("* camera_about"); strcpy (about->text, _("coolshot library v" COOLSHOT_VERSION diff --git a/camlibs/panasonic/coolshot/library.c b/camlibs/panasonic/coolshot/library.c index 1cccb9493..10c9fa04e 100644 --- a/camlibs/panasonic/coolshot/library.c +++ b/camlibs/panasonic/coolshot/library.c @@ -51,6 +51,8 @@ # define N_(String) (String) #endif +#define GP_MODULE "coolshot" + #define COOL_SLEEP 10000 int packet_size = 500; @@ -59,7 +61,7 @@ int packet_size = 500; int coolshot_sm( Camera *camera ) { char buf[16]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_sm"); + GP_DEBUG ("* coolshot_sm"); memset( buf, 0, sizeof( buf )); @@ -90,8 +92,8 @@ int coolshot_sb( Camera *camera, int speed ) { char buf[16]; gp_port_settings settings; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_sb"); - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "*** speed: %i", speed); + GP_DEBUG ("* coolshot_sb"); + GP_DEBUG ("*** speed: %i", speed); memset( buf, 0, sizeof( buf )); @@ -157,7 +159,7 @@ int coolshot_sb( Camera *camera, int speed ) { int coolshot_fs( Camera *camera, int number ) { char buf[16]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_fs"); + GP_DEBUG ("* coolshot_fs"); memset( buf, 0, sizeof( buf )); @@ -185,7 +187,7 @@ int coolshot_fs( Camera *camera, int number ) { int coolshot_sp( Camera *camera ) { char buf[16]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_sp"); + GP_DEBUG ("* coolshot_sp"); memset( buf, 0, sizeof( buf )); @@ -211,7 +213,7 @@ int coolshot_file_count (Camera *camera) { char buf[16]; int count = 0; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_file_count"); + GP_DEBUG ("* coolshot_file_count"); memset( buf, 0, sizeof( buf )); @@ -244,7 +246,7 @@ int coolshot_request_image( Camera *camera, CameraFile *file, char *buf, int *len, int number, GPContext *context ) { char packet[16]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_request_image"); + GP_DEBUG ("* coolshot_request_image"); memset( packet, 0, sizeof( packet )); @@ -279,7 +281,7 @@ int coolshot_request_thumbnail( Camera *camera, CameraFile *file, char *buf, int *len, int number, GPContext *context ) { char packet[16]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_request_thumbnail"); + GP_DEBUG ("* coolshot_request_thumbnail"); memset( packet, 0, sizeof( packet )); @@ -344,7 +346,7 @@ int coolshot_download_image( Camera *camera, CameraFile *file, int last_good = 0; unsigned int id; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_download_image"); + GP_DEBUG ("* coolshot_download_image"); memset( packet, 0, sizeof( packet )); @@ -413,7 +415,7 @@ int coolshot_download_image( Camera *camera, CameraFile *file, int coolshot_write_packet (Camera *camera, char *packet) { int x, ret, r, checksum=0, length; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_write_packet"); + GP_DEBUG ("* coolshot_write_packet"); if ( packet[0] == COOLSHOT_PKT ) { /* fixme */ @@ -453,14 +455,14 @@ int coolshot_read_packet (Camera *camera, char *packet) { int blocksize, bytes_read; char buf[4096]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_read_packet"); + GP_DEBUG ("* coolshot_read_packet"); read_packet_again: buf[0] = 0; packet[0] = 0; if (r > 0) - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* reading again..."); + GP_DEBUG ("* reading again..."); done = 0; @@ -555,7 +557,7 @@ int coolshot_ack (Camera *camera) int ret, r = 0; char buf[16]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_ack"); + GP_DEBUG ("* coolshot_ack"); buf[0] = COOLSHOT_ACK; @@ -575,7 +577,7 @@ int coolshot_nak (Camera *camera) int ret, r = 0; char buf[16]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_nak"); + GP_DEBUG ("* coolshot_nak"); buf[0] = COOLSHOT_NAK; @@ -595,7 +597,7 @@ int coolshot_enq (Camera *camera) int ret, r = 0; char buf[16]; - gp_debug_printf (GP_DEBUG_LOW, "coolshot", "* coolshot_enq"); + GP_DEBUG ("* coolshot_enq"); buf[0] = COOLSHOT_ENQ; diff --git a/camlibs/panasonic/dc.c b/camlibs/panasonic/dc.c index b1ef7fd74..7cc4510fe 100644 --- a/camlibs/panasonic/dc.c +++ b/camlibs/panasonic/dc.c @@ -18,6 +18,7 @@ This is a Panasonic DC series common routines. */ +#include #include #include @@ -34,6 +35,8 @@ # define __FILE__ "dc.c" #endif +#define GP_MODULE "dc" + int dsc1_sendcmd(Camera *camera, uint8_t cmd, void *data, int size) { int i; @@ -227,7 +230,7 @@ char *dsc_msgprintf(char *format, ...) { void dsc_errorprint(int error, char *file, int line) { - gp_debug_printf(GP_DEBUG_LOW, "panasonic", + GP_DEBUG( "%s:%u: return code: %i, errno: %i, %s", file, line, error, errno, dsc_strerror(error)); } diff --git a/camlibs/panasonic/dc.h b/camlibs/panasonic/dc.h index 8d3a26eda..47b60607a 100644 --- a/camlibs/panasonic/dc.h +++ b/camlibs/panasonic/dc.h @@ -99,13 +99,13 @@ void dsc_errorprint(int error, char *file, int line); /* Pre-procesor macros for verbose messaging and debugging */ #define DEBUG_PRINT_LOW(ARGS) \ - gp_debug_printf(GP_DEBUG_LOW, "panasonic", "%s: %s", __FILE__, dsc_msgprintf ARGS ); + GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); #define DEBUG_PRINT_MEDIUM(ARGS) \ - gp_debug_printf(GP_DEBUG_MEDIUM, "panasonic", "%s: %s", __FILE__, dsc_msgprintf ARGS ); + GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); #define DEBUG_PRINT_HIGH(ARGS) \ - gp_debug_printf(GP_DEBUG_HIGH, "panasonic", "%s: %s", __FILE__, dsc_msgprintf ARGS ); + GP_DEBUG( "%s: %s", __FILE__, dsc_msgprintf ARGS ); #define RETURN_ERROR(ERROR) { \ dsc_errorprint(ERROR, __FILE__, __LINE__); \ diff --git a/camlibs/panasonic/dc1000.c b/camlibs/panasonic/dc1000.c index dc5103406..67c853e7a 100644 --- a/camlibs/panasonic/dc1000.c +++ b/camlibs/panasonic/dc1000.c @@ -50,6 +50,8 @@ # define __FILE__ "dc1000.c" #endif +#define GP_MODULE "dc1000" + /******************************************************************************/ /* Internal utility functions */ diff --git a/camlibs/panasonic/dc1580.c b/camlibs/panasonic/dc1580.c index 75576db4d..e8ba8009d 100644 --- a/camlibs/panasonic/dc1580.c +++ b/camlibs/panasonic/dc1580.c @@ -53,6 +53,8 @@ # define __FILE__ "dc1580.c" #endif +#define GP_MODULE "dc1580" + /******************************************************************************/ /* Internal utility functions */ diff --git a/camlibs/polaroid/jd350e.c b/camlibs/polaroid/jd350e.c index 1c4b1390e..d9f268dae 100644 --- a/camlibs/polaroid/jd350e.c +++ b/camlibs/polaroid/jd350e.c @@ -20,15 +20,20 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include -#include -#include #include #include + +#include +#include + #include "jd350e.h" #include "jd350e_red.h" /*#include "jd350e_blue.h"*/ +#define GP_MODULE "jd350e" + #define THRESHOLD 0xf8 #define RED(p,x,y,w) *((p)+3*((y)*(w)+(x)) ) @@ -85,7 +90,7 @@ int jd350e_postprocessing(int width, int height, unsigned char* rgb){ if( (green_max+blue_max)/2 > red_max ){ #endif /* outdoor daylight : red color correction curve*/ - gp_debug_printf(GP_DEBUG_LOW, "jd350e", "daylight mode"); + GP_DEBUG( "daylight mode"); for( y=0; y blue_max ){ /* indoor electric light */ - gp_debug_printf(GP_DEBUG_LOW, "jd350e", "electric light mode"); + GP_DEBUG( "electric light mode"); for( y=0; y */ -#include -#include +#include + #include #include + //#include "jpeghead.h" #include "pdc320.h" //#include +#include +#include + +#define GP_MODULE "pdc320" /*******************************************************************************/ /* NOTICE: There is a 16x8 block of pixels after the image data. */ @@ -74,7 +79,7 @@ pdc320_id (GPPort *port, const char **model) int i; unsigned char buf[32]; - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "*** PDC320_ID ***"); + GP_DEBUG ("*** PDC320_ID ***"); CR (gp_port_write (port, PDC320_ID, sizeof (PDC320_ID) - 1)); CR (gp_port_read (port, buf, 14)); if (model) { @@ -94,7 +99,7 @@ pdc320_init (GPPort *port) { unsigned char buf[32]; - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "*** PDC320_INIT ***"); + GP_DEBUG ("*** PDC320_INIT ***"); CR (gp_port_write (port, PDC320_INIT, sizeof (PDC320_INIT) - 1)); CR (gp_port_read (port, buf, 3)); @@ -107,12 +112,12 @@ pdc320_init (GPPort *port) CR (pdc320_id (port, NULL)); - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "*** PDC320_STATE ***"); + GP_DEBUG ("*** PDC320_STATE ***"); CR (gp_port_write (port, PDC320_STATE, sizeof (PDC320_STATE) - 1)); CR (gp_port_read (port, buf, 16)); - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "*** PDC320_ENDINIT ***"); + GP_DEBUG ("*** PDC320_ENDINIT ***"); CR (gp_port_write (port, PDC320_ENDINIT, sizeof (PDC320_ENDINIT) - 1)); CR (gp_port_read (port, buf, 8)); @@ -138,7 +143,7 @@ pdc320_num (GPPort *port) return (GP_ERROR_CORRUPTED_DATA); #endif - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "The camera contains %i " + GP_DEBUG ("The camera contains %i " "files.", num); return (num); @@ -217,7 +222,7 @@ pdc320_size (Camera *camera, int n) */ CR (gp_port_read (camera->port, buf, 6)); size = (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + buf[3]; - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Image %i has size " + GP_DEBUG ("Image %i has size " "%i.", n, size); return (size); } @@ -234,7 +239,7 @@ pdc320_pic (Camera *camera, int n, unsigned char **data, int *size) int chunksize=2000; /* Get the size of the picture and allocate the memory */ - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Checking size of image %i...", + GP_DEBUG ("Checking size of image %i...", n); CR (*size = pdc320_size (camera, n)); *data = malloc (sizeof (char) * (*size)); @@ -268,7 +273,7 @@ pdc320_pic (Camera *camera, int n, unsigned char **data, int *size) CR_FREE (gp_port_read (camera->port, buf, 5), *data); f1 = (buf[1] << 8) + buf[2]; f2 = (buf[3] << 8) + buf[4]; - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Reading frame %d " + GP_DEBUG ("Reading frame %d " "(%d)...", f1, f2); /* Read the actual data */ @@ -331,12 +336,12 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, * Get the number of the picture from the filesystem and increment * since we need a range starting with 1. */ - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Getting number from fs..."); + GP_DEBUG ("Getting number from fs..."); CR (n = gp_filesystem_number (camera->fs, folder, filename, context)); n++; /* Get the file */ - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Getting file %i...", n); + GP_DEBUG ("Getting file %i...", n); CR (pdc320_pic (camera, n, &data, &size)); /* Post-processing */ @@ -348,21 +353,21 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, break; case GP_FILE_TYPE_NORMAL: default: - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Using Nathan Stenzel's experimental jpeg.c\n"); - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "About to make jpeg header\n"); + GP_DEBUG ("Using Nathan Stenzel's experimental jpeg.c\n"); + GP_DEBUG ("About to make jpeg header\n"); width = data[4]*256 + data[5]; height = data[2]*256 + data[3]; - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Width=%i\tHeight=%i\n", width, height); + GP_DEBUG ("Width=%i\tHeight=%i\n", width, height); myjpeg = gp_jpeg_header(width,height/2, 0x11,0x11,0x21, 1,0,0, &chrominance, &luminance, 0,0,0, chunk_new_filled(HUFF_00), chunk_new_filled(HUFF_10), NULL, NULL); - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Turning the picture data into a chunk data type\n"); + GP_DEBUG ("Turning the picture data into a chunk data type\n"); tempchunk = chunk_new(size); tempchunk->data = data; - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Adding the picture data to the jpeg structure\n"); + GP_DEBUG ("Adding the picture data to the jpeg structure\n"); gp_jpeg_add_marker(myjpeg, tempchunk, 6, size-1); - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Writing the jpeg file\n"); + GP_DEBUG ("Writing the jpeg file\n"); gp_jpeg_write(file, filename, myjpeg); - gp_debug_printf (GP_DEBUG_LOW, "pdc320", "Cleaning up the mess\n"); + GP_DEBUG ("Cleaning up the mess\n"); gp_jpeg_destroy(myjpeg); } diff --git a/camlibs/ptp/library.c b/camlibs/ptp/library.c index 73e6312bc..f1dec9b8f 100644 --- a/camlibs/ptp/library.c +++ b/camlibs/ptp/library.c @@ -24,7 +24,6 @@ #include #include -#include #include #ifdef ENABLE_NLS diff --git a/camlibs/samsung/samsung.c b/camlibs/samsung/samsung.c index 362d14e36..fc8f25714 100644 --- a/camlibs/samsung/samsung.c +++ b/camlibs/samsung/samsung.c @@ -19,10 +19,12 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ +#include #include #include #include + #include /* The commands */ diff --git a/camlibs/sierra/library.c b/camlibs/sierra/library.c index 79890a65c..83b28863e 100644 --- a/camlibs/sierra/library.c +++ b/camlibs/sierra/library.c @@ -31,6 +31,8 @@ #include "sierra.h" #include "sierra-usbwrap.h" +#define GP_MODULE "sierra" + /* Short comm. */ #define NUL 0x00 #define ENQ 0x05 @@ -218,13 +220,12 @@ int sierra_list_folders (Camera *camera, const char *folder, CameraList *list, CHECK (sierra_change_folder (camera, folder, context)); GP_DEBUG ("*** counting folders in '%s'...", folder); CHECK (sierra_get_int_register (camera, 83, &count, context)); - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** found %i folders", count); + GP_DEBUG ("*** found %i folders", count); for (i = 0; i < count; i++) { CHECK (sierra_change_folder (camera, folder, context)); CHECK (sierra_set_int_register (camera, 83, i + 1, context)); bsize = 1024; - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** getting " - "name of folder %i...", i + 1); + GP_DEBUG ("*** getting name of folder %i...", i + 1); CHECK (sierra_get_string_register (camera, 84, 0, NULL, buf, &bsize, context)); diff --git a/camlibs/sierra/sierra-usbwrap.c b/camlibs/sierra/sierra-usbwrap.c index d597ba250..501d9b38b 100644 --- a/camlibs/sierra/sierra-usbwrap.c +++ b/camlibs/sierra/sierra-usbwrap.c @@ -17,9 +17,13 @@ * both of the menu buttons until the camera control menu appears. * Set it to ON. This disables the USB mass-storage support. */ +#include +#include "sierra-usbwrap.h" + #include #include -#include "sierra-usbwrap.h" + +#define GP_MODULE "sierra" /* * The following things are the way the are just to ensure that USB @@ -154,18 +158,18 @@ usb_wrap_OK(gp_port* dev, uw_header_t* hdr) uw_response_t rsp; memset(&rsp, 0, sizeof(rsp)); - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_OK" ); + GP_DEBUG( "usb_wrap_OK" ); if (gp_port_read(dev, (char*)&rsp, sizeof(rsp)) != sizeof(rsp)) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "gp_port_read *** FAILED" ); + GP_DEBUG( "gp_port_read *** FAILED" ); return GP_ERROR; } if (!UW_EQUAL(rsp.magic, UW_MAGIC_IN) || !UW_EQUAL(rsp.sessionid, hdr->sessionid)) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_OK wrong session *** FAILED" ); + GP_DEBUG( "usb_wrap_OK wrong session *** FAILED" ); return GP_ERROR; } @@ -179,7 +183,7 @@ usb_wrap_OK(gp_port* dev, uw_header_t* hdr) rsp.zero[3] != 0 || rsp.zero[4] != 0) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "error: **** usb_wrap_OK failed" ); + GP_DEBUG( "error: **** usb_wrap_OK failed" ); return GP_ERROR; } return GP_OK; @@ -192,7 +196,7 @@ usb_wrap_RDY(gp_port* dev) uw_pkout_rdy_t msg; int retries = 3; - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_RDY" ); + GP_DEBUG( "usb_wrap_RDY" ); try_rdy_again: memset(&hdr, 0, sizeof(hdr)); @@ -209,7 +213,7 @@ try_rdy_again: if (gp_port_write(dev, (char*)&hdr, sizeof(hdr)) != GP_OK || gp_port_write(dev, (char*)&msg, sizeof(msg)) != GP_OK) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_RDY *** FAILED" ); + GP_DEBUG( "usb_wrap_RDY *** FAILED" ); return GP_ERROR; } @@ -217,10 +221,10 @@ try_rdy_again: { if (!retries--) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_RDY GIVING UP" ); + GP_DEBUG( "usb_wrap_RDY GIVING UP" ); return GP_ERROR; } - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_RDY *** RETRYING" ); + GP_DEBUG( "usb_wrap_RDY *** RETRYING" ); goto try_rdy_again; } return GP_OK; @@ -232,7 +236,7 @@ usb_wrap_STAT(gp_port* dev) uw_header_t hdr; uw_stat_t msg; - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_STAT" ); + GP_DEBUG( "usb_wrap_STAT" ); memset(&hdr, 0, sizeof(hdr)); memset(&msg, 0, sizeof(msg)); @@ -246,13 +250,13 @@ usb_wrap_STAT(gp_port* dev) if (gp_port_write(dev, (char*)&hdr, sizeof(hdr)) != GP_OK || gp_port_read(dev, (char*)&msg, sizeof(msg)) != sizeof(msg)) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_STAT *** FAILED" ); + GP_DEBUG( "usb_wrap_STAT *** FAILED" ); return GP_ERROR; } if (!UW_EQUAL(msg.length, hdr.length) || !UW_EQUAL(msg.packet_type, UW_PACKET_STAT)) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_STAT got bad packet *** FAILED" ); + GP_DEBUG( "usb_wrap_STAT got bad packet *** FAILED" ); return GP_ERROR; } @@ -263,7 +267,7 @@ usb_wrap_STAT(gp_port* dev) msg.zero[4] != 0 || msg.zero[5] != 0) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "warning: usb_wrap_STAT found non-zero bytes (ignoring)" ); + GP_DEBUG( "warning: usb_wrap_STAT found non-zero bytes (ignoring)" ); } return usb_wrap_OK(dev, &hdr); @@ -276,7 +280,7 @@ usb_wrap_CMND(gp_port* dev, char* sierra_msg, int sierra_len) uw_pkout_sierra_hdr_t* msg; int msg_len = sizeof(*msg) + sierra_len; - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_CMND" ); + GP_DEBUG( "usb_wrap_CMND" ); msg = (uw_pkout_sierra_hdr_t*)malloc(msg_len); memset(&hdr, 0, sizeof(hdr)); @@ -290,13 +294,13 @@ usb_wrap_CMND(gp_port* dev, char* sierra_msg, int sierra_len) hdr.request_type = UW_REQUEST_CMND; msg->packet_type = UW_PACKET_DATA; memcpy((char*)msg + sizeof(*msg), sierra_msg, sierra_len); - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_CMND writing %i + %i", + GP_DEBUG( "usb_wrap_CMND writing %i + %i", sizeof(hdr), msg_len); if (gp_port_write(dev, (char*)&hdr, sizeof(hdr)) != GP_OK || gp_port_write(dev, (char*)msg, msg_len) != GP_OK) { - gp_debug_printf(GP_DEBUG_LOW, "sierra", "usb_wrap_CMND ** WRITE FAILED"); + GP_DEBUG( "usb_wrap_CMND ** WRITE FAILED"); free(msg); return GP_ERROR; } @@ -311,7 +315,7 @@ usb_wrap_SIZE(gp_port* dev, uw32_t* size) uw_header_t hdr; uw_size_t msg; - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_SIZE" ); + GP_DEBUG( "usb_wrap_SIZE" ); memset(&hdr, 0, sizeof(hdr)); memset(&msg, 0, sizeof(msg)); @@ -323,13 +327,13 @@ usb_wrap_SIZE(gp_port* dev, uw32_t* size) if (gp_port_write(dev, (char*)&hdr, sizeof(hdr)) != GP_OK || gp_port_read(dev, (char*)&msg, sizeof(msg)) != sizeof(msg)) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_SIZE *** FAILED" ); + GP_DEBUG( "usb_wrap_SIZE *** FAILED" ); return GP_ERROR; } if (!UW_EQUAL(msg.length, hdr.length) || !UW_EQUAL(msg.packet_type, UW_PACKET_DATA)) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_SIZE got bad packet *** FAILED" ); + GP_DEBUG( "usb_wrap_SIZE got bad packet *** FAILED" ); return GP_ERROR; } @@ -338,7 +342,7 @@ usb_wrap_SIZE(gp_port* dev, uw32_t* size) msg.zero[2] != 0 || msg.zero[3] != 0) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "warning: usb_wrap_SIZE found non-zero bytes (ignoring)" ); + GP_DEBUG( "warning: usb_wrap_SIZE found non-zero bytes (ignoring)" ); } *size = msg.size; @@ -353,7 +357,7 @@ usb_wrap_DATA(gp_port* dev, char* sierra_response, int sierra_len, uw32_t size) uw_pkout_sierra_hdr_t* msg; unsigned int msg_len; - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_DATA" ); + GP_DEBUG( "usb_wrap_DATA" ); msg_len = 0; msg_len = msg_len * 256 + (unsigned int)(size.c4); @@ -363,7 +367,7 @@ usb_wrap_DATA(gp_port* dev, char* sierra_response, int sierra_len, uw32_t size) if (sierra_len < msg_len - sizeof(*msg)) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_read_packet buffer too small! (%i < %i) *** FAILED", sierra_len, msg_len); + GP_DEBUG( "usb_wrap_read_packet buffer too small! (%i < %i) *** FAILED", sierra_len, msg_len); return GP_ERROR; } sierra_len = msg_len - sizeof(*msg); @@ -381,7 +385,7 @@ usb_wrap_DATA(gp_port* dev, char* sierra_response, int sierra_len, uw32_t size) if (gp_port_write(dev, (char*)&hdr, sizeof(hdr)) != GP_OK || gp_port_read(dev, (char*)msg, msg_len) != msg_len) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_DATA FAILED" ); + GP_DEBUG( "usb_wrap_DATA FAILED" ); free(msg); return GP_ERROR; } @@ -399,13 +403,13 @@ usb_wrap_DATA(gp_port* dev, char* sierra_response, int sierra_len, uw32_t size) int usb_wrap_write_packet(gp_port* dev, char* sierra_msg, int sierra_len) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_write_packet" ); + GP_DEBUG( "usb_wrap_write_packet" ); if (usb_wrap_RDY(dev) != GP_OK || usb_wrap_CMND(dev, sierra_msg, sierra_len) != GP_OK || usb_wrap_STAT(dev) != GP_OK) { - gp_debug_printf(GP_DEBUG_LOW, "sierra", "usb_wrap_write_packet FAILED"); + GP_DEBUG( "usb_wrap_write_packet FAILED"); return GP_ERROR; } return GP_OK; @@ -416,14 +420,14 @@ usb_wrap_read_packet(gp_port* dev, char* sierra_response, int sierra_len) { uw32_t uw_size; - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_read_packet" ); + GP_DEBUG( "usb_wrap_read_packet" ); if (usb_wrap_RDY(dev) != GP_OK || usb_wrap_SIZE(dev, &uw_size) != GP_OK || usb_wrap_DATA(dev, sierra_response, sierra_len, uw_size) != GP_OK || usb_wrap_STAT(dev) != GP_OK) { - gp_debug_printf( GP_DEBUG_LOW, "sierra", "usb_wrap_read_packet FAILED" ); + GP_DEBUG( "usb_wrap_read_packet FAILED" ); return GP_ERROR; } return sierra_len; diff --git a/camlibs/sierra/sierra.c b/camlibs/sierra/sierra.c index c522a67df..8e82b23d3 100644 --- a/camlibs/sierra/sierra.c +++ b/camlibs/sierra/sierra.c @@ -28,10 +28,11 @@ #include #include -#include #include "library.h" +#define GP_MODULE "sierra" + #define TIMEOUT 2000 #ifdef ENABLE_NLS @@ -321,7 +322,7 @@ set_info_func (CameraFilesystem *fs, const char *folder, const char *filename, int camera_start (Camera *camera, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_start"); + GP_DEBUG ("*** camera_start"); /* * Opening and closing of the port happens in libgphoto2. All we @@ -342,7 +343,7 @@ int camera_start (Camera *camera, GPContext *context) int camera_stop (Camera *camera, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_stop"); + GP_DEBUG ("*** camera_stop"); /* * Closing the port happens in libgphoto2. All we do here is @@ -362,7 +363,7 @@ int camera_stop (Camera *camera, GPContext *context) static int camera_exit (Camera *camera, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_exit"); + GP_DEBUG ("*** camera_exit"); if (camera->pl) { free (camera->pl); @@ -473,9 +474,9 @@ delete_all_func (CameraFilesystem *fs, const char *folder, void *data, Camera *camera = data; int count; - gp_debug_printf (GP_DEBUG_LOW, "sierra", + GP_DEBUG ( "*** sierra_folder_delete_all"); - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** folder: %s", folder); + GP_DEBUG ("*** folder: %s", folder); /* Set the working folder and delete all pictures there */ CHECK (camera_start (camera, context)); @@ -505,9 +506,9 @@ delete_file_func (CameraFilesystem *fs, const char *folder, Camera *camera = data; int n; - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** sierra_file_delete"); - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** folder: %s", folder); - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** filename: %s", filename); + GP_DEBUG ("*** sierra_file_delete"); + GP_DEBUG ("*** folder: %s", folder); + GP_DEBUG ("*** filename: %s", filename); /* Get the file number from the CameraFilesystem */ CHECK (n = gp_filesystem_number (camera->fs, folder, filename, context)); @@ -556,9 +557,9 @@ put_file_func (CameraFilesystem * fs, const char *folder, CameraFile * file, voi gp_file_get_name(file, &filename); - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** put_file_func"); - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** folder: %s", folder); - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** filename: %s", filename); + GP_DEBUG ("*** put_file_func"); + GP_DEBUG ("*** folder: %s", folder); + GP_DEBUG ("*** filename: %s", filename); /* Check the size */ CHECK (gp_file_get_data_and_size (file, &data_file, &data_size)); @@ -682,11 +683,11 @@ static void dump_register (Camera *camera, GPContext *context) }; - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** Register:"); + GP_DEBUG ("*** Register:"); for (i = 0; i < 128; i++) { ret = sierra_get_int_register (camera, i, &value, context); if (ret == GP_OK) - gp_debug_printf (GP_DEBUG_LOW, "sierra", + GP_DEBUG ( "*** %3i: %12i (%s)", i, value, description [i]); } @@ -700,7 +701,7 @@ camera_get_config_olympus (Camera *camera, CameraWidget **window, GPContext *con char t[1024]; int ret, value; - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_get_config_olympus"); + GP_DEBUG ("*** camera_get_config_olympus"); CHECK (camera_start (camera, context)); @@ -1035,12 +1036,12 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont char *value; int i = 0; - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_set_config"); + GP_DEBUG ("*** camera_set_config"); CHECK (camera_start (camera, context)); /* Resolution */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting resolution"); + GP_DEBUG ("*** setting resolution"); if ((gp_widget_get_child_by_label (window, _("Resolution"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1059,7 +1060,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Shutter Speed */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting shutter speed"); + GP_DEBUG ("*** setting shutter speed"); if ((gp_widget_get_child_by_label (window, _("Shutter Speed (microseconds)"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1068,7 +1069,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Aperture */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting aperture"); + GP_DEBUG ("*** setting aperture"); if ((gp_widget_get_child_by_label (window, _("Aperture"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1087,7 +1088,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Color Mode */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting color mode"); + GP_DEBUG ("*** setting color mode"); if ((gp_widget_get_child_by_label (window, _("Color Mode"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1108,7 +1109,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Flash Mode */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting flash mode"); + GP_DEBUG ("*** setting flash mode"); if ((gp_widget_get_child_by_label (window, _("Flash Mode"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1129,7 +1130,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Brightness/Contrast */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", + GP_DEBUG ( "*** setting brightness/contrast"); if ((gp_widget_get_child_by_label (window, _("Brightness/Contrast"), &child) == GP_OK) && @@ -1151,7 +1152,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* White Balance */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting white balance"); + GP_DEBUG ("*** setting white balance"); if ((gp_widget_get_child_by_label (window, _("White Balance"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1172,7 +1173,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Lens Mode */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting lens mode"); + GP_DEBUG ("*** setting lens mode"); if ((gp_widget_get_child_by_label (window, _("Lens Mode"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1189,7 +1190,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Spot Metering Mode */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", + GP_DEBUG ( "*** setting spot metering mode"); if ((gp_widget_get_child_by_label (window, _("Spot Metering Mode"), &child) == GP_OK) && @@ -1205,7 +1206,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Zoom */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting zoom"); + GP_DEBUG ("*** setting zoom"); if ((gp_widget_get_child_by_label (window, _("Zoom"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1224,7 +1225,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Auto Off (host) */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting auto off (host)"); + GP_DEBUG ("*** setting auto off (host)"); if ((gp_widget_get_child_by_label (window, _("Auto Off (host) " "(in seconds)"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1233,7 +1234,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* Auto Off (field) */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", + GP_DEBUG ( "*** setting auto off (field)"); if ((gp_widget_get_child_by_label (window, _("Auto Off (field) " "(in seconds)"), &child) == GP_OK) && @@ -1243,7 +1244,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* LCD Brightness */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting lcd brightness"); + GP_DEBUG ("*** setting lcd brightness"); if ((gp_widget_get_child_by_label (window, _("LCD Brightness"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1252,7 +1253,7 @@ camera_set_config_olympus (Camera *camera, CameraWidget *window, GPContext *cont } /* LCD Auto Off */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting lcd auto off"); + GP_DEBUG ("*** setting lcd auto off"); if ((gp_widget_get_child_by_label (window, _("LCD Auto Off (in seconds)"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1272,7 +1273,7 @@ camera_get_config_epson (Camera *camera, CameraWidget **window, GPContext *conte char t[1024]; int ret, value; - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_get_config_epson"); + GP_DEBUG ("*** camera_get_config_epson"); CHECK (camera_start (camera, context)); @@ -1519,12 +1520,12 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex char *value; int i = 0; - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_set_config_epson"); + GP_DEBUG ("*** camera_set_config_epson"); CHECK (camera_start (camera, context)); /* Aperture */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting aperture"); + GP_DEBUG ("*** setting aperture"); if ((gp_widget_get_child_by_label (window, _("Aperture"), &child) == GP_OK) && gp_widget_changed (child)) { gp_widget_get_value (child, &value); @@ -1548,7 +1549,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* Flash Mode */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting flash mode"); + GP_DEBUG ("*** setting flash mode"); if ((gp_widget_get_child_by_label (window, _("Flash Mode"), &child) == GP_OK) && gp_widget_changed (child)) { gp_widget_get_value (child, &value); @@ -1568,7 +1569,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* White Balance */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting white balance"); + GP_DEBUG ("*** setting white balance"); if ((gp_widget_get_child_by_label (window, _("White Balance"), &child) == GP_OK) && gp_widget_changed (child)) { gp_widget_get_value (child, &value); @@ -1584,7 +1585,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* Lens Mode */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting lens mode"); + GP_DEBUG ("*** setting lens mode"); if ((gp_widget_get_child_by_label (window, _("Lens Mode"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1599,7 +1600,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* Resolution */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting resolution"); + GP_DEBUG ("*** setting resolution"); if ((gp_widget_get_child_by_label (window, _("Resolution"), &child) == GP_OK) && gp_widget_changed (child)) { gp_widget_get_value (child, &value); @@ -1617,7 +1618,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* Color Mode */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting color mode"); + GP_DEBUG ("*** setting color mode"); if ((gp_widget_get_child_by_label (window, _("Color Mode"), &child) == GP_OK) && gp_widget_changed (child)) { gp_widget_get_value (child, &value); @@ -1631,7 +1632,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* Auto Off (host) */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting auto off (host)"); + GP_DEBUG ("*** setting auto off (host)"); if ((gp_widget_get_child_by_label (window, _("Auto Off (host) " "(in seconds)"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1640,7 +1641,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* Auto Off (field) */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", + GP_DEBUG ( "*** setting auto off (field)"); if ((gp_widget_get_child_by_label (window, _("Auto Off (field) " "(in seconds)"), &child) == GP_OK) && @@ -1650,7 +1651,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* Language */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting language"); + GP_DEBUG ("*** setting language"); if ((gp_widget_get_child_by_label (window, _("Language"), &child) == GP_OK) && gp_widget_changed (child)) { gp_widget_get_value (child, &value); @@ -1676,7 +1677,7 @@ camera_set_config_epson (Camera *camera, CameraWidget *window, GPContext *contex } /* Date & Time */ - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** setting date"); + GP_DEBUG ("*** setting date"); if ((gp_widget_get_child_by_label (window, _("Date & Time"), &child) == GP_OK) && gp_widget_changed (child)) { @@ -1711,7 +1712,7 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) int value, ret; char t[1024]; - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_summary"); + GP_DEBUG ("*** camera_summary"); CHECK (camera_start (camera, context)); @@ -1770,7 +1771,7 @@ camera_summary (Camera *camera, CameraText *summary, GPContext *context) static int camera_manual (Camera *camera, CameraText *manual, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_manual"); + GP_DEBUG ("*** camera_manual"); switch (camera->pl->model) { case SIERRA_MODEL_EPSON: @@ -1807,7 +1808,7 @@ camera_manual (Camera *camera, CameraText *manual, GPContext *context) static int camera_about (Camera *camera, CameraText *about, GPContext *context) { - gp_debug_printf (GP_DEBUG_LOW, "sierra", "*** camera_about"); + GP_DEBUG ("*** camera_about"); strcpy (about->text, _("sierra SPARClite library\n" @@ -1966,12 +1967,10 @@ int camera_init (Camera *camera, GPContext *context) ret = sierra_set_string_register (camera, 84, "\\", 1, context); if (ret != GP_OK) { camera->pl->folders = 0; - gp_debug_printf (GP_DEBUG_LOW, "sierra", - "*** folder support: no"); + GP_DEBUG ("*** folder support: no"); } else { camera->pl->folders = 1; - gp_debug_printf (GP_DEBUG_LOW, "sierra", - "*** folder support: yes"); + GP_DEBUG ("*** folder support: yes"); } CHECK_STOP_FREE (camera, gp_port_set_timeout (camera->port, TIMEOUT)); diff --git a/camlibs/sonydscf1/sonydscf1.c b/camlibs/sonydscf1/sonydscf1.c index 5fa377fde..5f311ef3a 100644 --- a/camlibs/sonydscf1/sonydscf1.c +++ b/camlibs/sonydscf1/sonydscf1.c @@ -26,8 +26,6 @@ gp_port *dev; -int glob_debug = GP_DEBUG_HIGH; - int camera_id (CameraText *id) { strcpy(id->text, "sonydscf1-bvl"); diff --git a/camlibs/sonydscf55/camera.c b/camlibs/sonydscf55/camera.c index 7089c74e2..0f87b5ae8 100644 --- a/camlibs/sonydscf55/camera.c +++ b/camlibs/sonydscf55/camera.c @@ -27,7 +27,9 @@ #include "sony.h" #include "nls.h" -#include "gphoto2-camera.h" +#include + +#define GP_MODULE "sonydscf55" int camera_id(CameraText * id) { @@ -66,7 +68,7 @@ static int camera_exit(Camera * camera, GPContext *context) { int rc; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "camera_exit()"); if (camera->pl) { @@ -100,7 +102,7 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, Camera *camera = data; int count; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "camera_folder_list_files()"); count = sony_image_count(camera); @@ -122,7 +124,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, int num; int rc = GP_ERROR; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "camera_file_get(\"%s/%s\")", folder, filename); num = gp_filesystem_number(camera->fs, folder, filename, context); @@ -130,7 +132,7 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, return (num); num++; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "file %s has id %d", filename, num); switch (type) { diff --git a/camlibs/sonydscf55/sony.c b/camlibs/sonydscf55/sony.c index 3be47fc8e..fd903e71c 100644 --- a/camlibs/sonydscf55/sony.c +++ b/camlibs/sonydscf55/sony.c @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ - +#include #include #include @@ -26,6 +26,8 @@ #include #include "sony.h" +#define GP_MODULE "sony55" + /** * Constants */ @@ -185,19 +187,19 @@ static int sony_packet_validate(Camera * camera, Packet * p) unsigned char c = sony_packet_checksum(p); if (c != p->checksum) { - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "sony_packet_validate: invalid checksum"); return SONY_INVALID_CHECKSUM; } if (129 == p->buffer[0]) { - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "sony_packet_validate: resend packet"); return SONY_RESEND_PACKET; } if (sony_sequence[camera->pl->sequence_id] != p->buffer[0]) { - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "sony_packet_validate: invalid sequence"); return SONY_INVALID_SEQUENCE; } @@ -239,7 +241,7 @@ static int sony_packet_read(Camera * camera, Packet * pack) unsigned char byte = 0; static Packet p; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "sony_packet_read()"); p.length = 0; @@ -296,7 +298,7 @@ static int sony_packet_write(Camera * camera, Packet * p) unsigned short int count; int rc; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "sony_packet_write()"); rc = gp_port_write(camera->port, &START_PACKET, 1); @@ -341,7 +343,7 @@ sony_converse(Camera * camera, Packet * out, unsigned char *str, int len) int count; int rc; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, "sony_converse()"); + GP_DEBUG( "sony_converse()"); sony_packet_make(camera, &ps, str, len); for (count = 0; count < SONY_CONVERSE_RETRY; count++) { @@ -358,9 +360,7 @@ sony_converse(Camera * camera, Packet * out, unsigned char *str, int len) break; } - gp_debug_printf(GP_DEBUG_LOW, - SONY_CAMERA_ID, - "Checksum invalid"); + GP_DEBUG ("Checksum invalid"); ps.buffer[0] = 129; ps.checksum = sony_packet_checksum(&ps); @@ -382,10 +382,7 @@ sony_converse(Camera * camera, Packet * out, unsigned char *str, int len) out->buffer[0]; if (sequence_count == 4) { - gp_debug_printf - (GP_DEBUG_LOW, - SONY_CAMERA_ID, - "Attempting to reset sequence id - image may be corrupt."); + GP_DEBUG ("Attempting to reset sequence id - image may be corrupt."); camera->pl->sequence_id = 0; while (sony_sequence @@ -397,10 +394,7 @@ sony_converse(Camera * camera, Packet * out, unsigned char *str, int len) return GP_OK; } - - gp_debug_printf(GP_DEBUG_LOW, - SONY_CAMERA_ID, - "Invalid Sequence"); + GP_DEBUG ("Invalid Sequence"); ps.buffer[0] = 129; ps.checksum = sony_packet_checksum(&ps); @@ -411,18 +405,14 @@ sony_converse(Camera * camera, Packet * out, unsigned char *str, int len) return GP_OK; case SONY_RESEND_PACKET: - gp_debug_printf(GP_DEBUG_LOW, - SONY_CAMERA_ID, - "Resending Packet"); + GP_DEBUG ("Resending Packet"); break; case GP_OK: return GP_OK; default: - gp_debug_printf(GP_DEBUG_LOW, - SONY_CAMERA_ID, - "Unknown Error"); + GP_DEBUG ("Unknown Error"); break; } } else { @@ -433,7 +423,7 @@ sony_converse(Camera * camera, Packet * out, unsigned char *str, int len) } } - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "Failed to read packet during transfer."); return GP_ERROR; @@ -464,7 +454,7 @@ static int sony_baud_set(Camera * camera, long baud) Packet dp; int rc; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, "sony_baud_set(%ld)", + GP_DEBUG( "sony_baud_set(%ld)", baud); // FIXME SetTransferRate[3] = sony_baud_to_id(baud); @@ -518,12 +508,12 @@ static int sony_init_first_contact (Camera *camera) rc = sony_converse(camera, &dp, IdentString, 12); if (rc == GP_OK) { - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "Init OK"); break; } usleep(2000); - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, + GP_DEBUG( "Init - Fail %u", count + 1); } return rc; @@ -568,7 +558,7 @@ sony_item_count(Camera * camera, unsigned char *from, int from_len) Packet dp; int rc; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, "sony_item_count()"); + GP_DEBUG( "sony_item_count()"); rc = sony_converse(camera, &dp, SetTransferRate, 4); if (rc == GP_OK) { rc = sony_converse(camera, &dp, from, from_len); @@ -576,9 +566,7 @@ sony_item_count(Camera * camera, unsigned char *from, int from_len) rc = sony_converse(camera, &dp, SendImageCount, 3); if (rc == GP_OK) { int nr = (int) dp.buffer[5]; - gp_debug_printf(GP_DEBUG_LOW, - SONY_CAMERA_ID, - "count = %d", nr); + GP_DEBUG ("count = %d", nr); return nr; } } @@ -617,7 +605,7 @@ sony_file_get(Camera * camera, int imageid, int thumbnail, int rc; char buffer[128]; - gp_debug_printf(GP_DEBUG_LOW, SONY_CAMERA_ID, "sony_file_get()"); + GP_DEBUG( "sony_file_get()"); rc = gp_file_clean(file); if (rc == GP_OK) { gp_file_set_mime_type (file, GP_MIME_JPEG); @@ -638,10 +626,7 @@ sony_file_get(Camera * camera, int imageid, int thumbnail, SelectImage[4] = imageid; sony_converse(camera, &dp, SelectImage, 7); - gp_debug_printf(GP_DEBUG_LOW, - SONY_CAMERA_ID, - "XYZ %11.11s", - dp.buffer + 5); + GP_DEBUG ("XYZ %11.11s", dp.buffer + 5); if (camera->pl->msac_sr1) { gp_file_append(file, diff --git a/camlibs/stv0680/stv0680.c b/camlibs/stv0680/stv0680.c index 771f4affa..56b5f1898 100644 --- a/camlibs/stv0680/stv0680.c +++ b/camlibs/stv0680/stv0680.c @@ -18,6 +18,7 @@ */ #include + #include #include #include @@ -42,6 +43,8 @@ #include "stv0680.h" #include "library.h" +#define GP_MODULE "stv0680" + struct camera_to_usb { char *name; unsigned short idVendor; diff --git a/frontends/command-line/main.c b/frontends/command-line/main.c index 6f1ca3981..601574c3c 100644 --- a/frontends/command-line/main.c +++ b/frontends/command-line/main.c @@ -555,7 +555,7 @@ debug_func (GPLogLevel level, const char *domain, const char *format, OPTION_CALLBACK (debug) { - glob_debug = GP_DEBUG_HIGH; + glob_debug = 1; cli_debug_print("ALWAYS INCLUDE THE FOLLOWING LINE WHEN SENDING DEBUG MESSAGES TO THE MAILING LIST:"); cli_debug_print(PACKAGE " " VERSION ": " "Turning on debug mode"); @@ -1381,7 +1381,7 @@ main (int argc, char **argv) /* Peek ahead: Check to see if we need to turn on debugging output */ if (option_is_present ("debug", argc, argv) == GP_OK) - glob_debug = GP_DEBUG_HIGH; + glob_debug = 1; #ifdef OS2 /*check if environment is set otherwise quit*/ if(CAMLIBS==NULL) diff --git a/libgphoto2/Makefile.am b/libgphoto2/Makefile.am index af4cfe9f3..560b881e7 100644 --- a/libgphoto2/Makefile.am +++ b/libgphoto2/Makefile.am @@ -10,7 +10,6 @@ libgphoto2_la_SOURCES = \ bayer.c bayer.h \ gphoto2-camera.c \ gphoto2-context.c \ - gphoto2-debug.c \ exif.c exif.h \ gphoto2-file.c \ gphoto2-filesys.c \ @@ -32,7 +31,6 @@ libgphoto2include_HEADERS = \ gphoto2-abilities-list.h\ gphoto2-camera.h \ gphoto2-context.h \ - gphoto2-debug.h \ gphoto2-file.h \ gphoto2-filesys.h \ gphoto2-library.h \ diff --git a/libgphoto2/gphoto2-debug.c b/libgphoto2/gphoto2-debug.c deleted file mode 100644 index 94fe71f32..000000000 --- a/libgphoto2/gphoto2-debug.c +++ /dev/null @@ -1,61 +0,0 @@ -/* gphoto2-debug.c - * - * Copyright (C) 2001 Lutz Müller - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include "gphoto2-debug.h" - -#include -#include -#include -#include - -#include - -/** - * gp_debug_printf: - * @level: a gphoto2 debug level - * @id: an id - * @format: the debugging message - * @...: - * - * Prints a debugging message. The debugging message gets added to the - * builtin history. If the given @level is higher than the global debug level - * (set with #gp_debug_set_level), the message gets printed out either via - * the user defined debugging function (set with #gp_debug_set_func) or the - * builtin function (default). - **/ -void -gp_debug_printf (int level, const char *id, const char *format, ...) -{ - va_list args; - int loglevel; - - switch (level) { - case GP_DEBUG_NONE: loglevel = GP_LOG_ERROR; break; - case GP_DEBUG_LOW: loglevel = GP_LOG_VERBOSE; break; - case GP_DEBUG_MEDIUM: loglevel = GP_LOG_DEBUG; break; - case GP_DEBUG_HIGH: loglevel = GP_LOG_DEBUG; break; - default: loglevel = GP_LOG_DEBUG; break; - } - - va_start (args, format); - gp_logv (loglevel, id, format, args); - va_end (args); -} diff --git a/libgphoto2/gphoto2-debug.h b/libgphoto2/gphoto2-debug.h deleted file mode 100644 index f1e744617..000000000 --- a/libgphoto2/gphoto2-debug.h +++ /dev/null @@ -1,34 +0,0 @@ -/* gphoto2-debug.h - * - * Copyright (C) 2001 Lutz Müller - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GPHOTO2_DEBUG_H__ -#define __GPHOTO2_DEBUG_H__ - -#define GP_DEBUG_NONE 0 -#define GP_DEBUG_LOW 1 -#define GP_DEBUG_MEDIUM 2 -#define GP_DEBUG_HIGH 3 - -/** gp_debug_printf: - * DEPRECATED. Log your messages via gp_log*() instead - */ -void gp_debug_printf (int level, const char *id, const char *format, ...); - -#endif /* __GPHOTO2_DEBUG_H__ */ diff --git a/libgphoto2/gphoto2-setting.c b/libgphoto2/gphoto2-setting.c index 3166aa428..d176b9374 100644 --- a/libgphoto2/gphoto2-setting.c +++ b/libgphoto2/gphoto2-setting.c @@ -18,19 +18,20 @@ * Boston, MA 02111-1307, USA. */ +#include +#include "gphoto2-setting.h" + #include #include #include #include -#include "config.h" -#include "gphoto2-setting.h" - #include "gphoto2-result.h" -#include "gphoto2-debug.h" #include "gphoto2-port-log.h" #include "gphoto2-port-portability.h" +#define GP_MODULE "setting" + typedef struct { /* key = value settings */ char id[256]; @@ -106,7 +107,7 @@ verify_settings (char *settings_file) int x, equals; if ((f=fopen(settings_file, "r"))==NULL) { - gp_debug_printf(GP_DEBUG_LOW, "core", "Can't open settings file for reading"); + GP_DEBUG ("Can't open settings file for reading"); return(0); } @@ -123,7 +124,7 @@ verify_settings (char *settings_file) if (equals < 2) { fclose (f); - gp_debug_printf(GP_DEBUG_LOW, "core", "Incorrect settings format. resetting\n"); + GP_DEBUG ("Incorrect settings format. resetting\n"); unlink(settings_file); return (GP_ERROR); } @@ -141,7 +142,7 @@ load_settings (void) char buf[1024], *id, *key, *value; /* Make sure the directories are created */ - gp_debug_printf (GP_DEBUG_LOW, "core", "Creating $HOME/.gphoto"); + GP_DEBUG ("Creating $HOME/.gphoto"); #ifdef WIN32 GetWindowsDirectory (buf, 1024); strcat (buf, "\\gphoto"); @@ -161,10 +162,10 @@ load_settings (void) if (verify_settings(buf) != GP_OK) /* verify_settings will unlink and recreate the settings file */ return (GP_OK); - gp_debug_printf(GP_DEBUG_LOW, "core", "Loading settings from file \"%s\"", buf); + GP_DEBUG ("Loading settings from file \"%s\"", buf); if ((f=fopen(buf, "r"))==NULL) { - gp_debug_printf(GP_DEBUG_LOW, "core", "Can't open settings for reading"); + GP_DEBUG ("Can't open settings for reading"); return(GP_ERROR); } @@ -204,7 +205,7 @@ save_settings (void) glob_setting_count, buf); if ((f=fopen(buf, "w+"))==NULL) { - gp_debug_printf(GP_DEBUG_LOW, "core", "Can't open settings file for writing"); + GP_DEBUG ("Can't open settings file for writing"); return(0); } rewind(f); diff --git a/libgphoto2/gphoto2.h b/libgphoto2/gphoto2.h index 93296d788..8ec22df51 100644 --- a/libgphoto2/gphoto2.h +++ b/libgphoto2/gphoto2.h @@ -50,10 +50,6 @@ extern "C" { #include #include -/* DEPRECATED */ -#include - - #ifdef __cplusplus } #endif diff --git a/libgphoto2/jpeg.h b/libgphoto2/jpeg.h index 56f11c803..599c674b0 100644 --- a/libgphoto2/jpeg.h +++ b/libgphoto2/jpeg.h @@ -19,6 +19,9 @@ #ifndef __GPHOTO2_JPEG_H__ #define __GPHOTO2_JPEG_H__ + +#include + typedef enum { JPEG_START=0xD8, JPEG_COMMENT=0xFE, JPEG_APPO=0xE0, JPEG_QUANTIZATION=0xDB, JPEG_HUFFMAN=0xC4, JPEG_SOFC0=0xC0, diff --git a/tests/test-filesys.c b/tests/test-filesys.c index 0bb65e3c4..a304bd910 100644 --- a/tests/test-filesys.c +++ b/tests/test-filesys.c @@ -28,7 +28,6 @@ #include #include -#include #define CHECK(r) {int ret = r; if (ret < 0) {printf ("Got error: %s\n", gp_result_as_string (ret)); return (1);}}