Skip to content

Commit

Permalink
fix white-space and indentation inconsistencies in ... (#1002)
Browse files Browse the repository at this point in the history
* examples
 * gphoto2
 * libgphoto2
 * libgphoto2_port

The code (at least in this part of the project) is effectively formated
using tabs with a tab-size of 8 as a means for indentation.

There have been a few places where spaces were introduced. Some obviously
with an indent size of 8 in mind, others with an indent size of 4.

This commit tries its best to make the use of tabs consistent again, at
least for indenting lines. The "intra line" indentation (white space after
the first non-white-space character) is still a bit of a mess.

Co-authored-by: axxel <[email protected]>
  • Loading branch information
axxel and axxel authored Sep 5, 2024
1 parent 1dabc5a commit 5c9d7b2
Show file tree
Hide file tree
Showing 29 changed files with 880 additions and 884 deletions.
46 changes: 23 additions & 23 deletions examples/autodetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static CameraAbilitiesList *abilities = NULL;
int
sample_autodetect (CameraList *list, GPContext *context) {
gp_list_reset (list);
return gp_camera_autodetect (list, context);
return gp_camera_autodetect (list, context);
}

/*
Expand All @@ -41,11 +41,11 @@ sample_open_camera (Camera ** camera, const char *model, const char *port, GPCon
}

/* First lookup the model / driver */
m = gp_abilities_list_lookup_model (abilities, model);
m = gp_abilities_list_lookup_model (abilities, model);
if (m < GP_OK) return ret;
ret = gp_abilities_list_get_abilities (abilities, m, &a);
ret = gp_abilities_list_get_abilities (abilities, m, &a);
if (ret < GP_OK) return ret;
ret = gp_camera_set_abilities (*camera, a);
ret = gp_camera_set_abilities (*camera, a);
if (ret < GP_OK) return ret;

if (!portinfolist) {
Expand All @@ -59,25 +59,25 @@ sample_open_camera (Camera ** camera, const char *model, const char *port, GPCon
}

/* Then associate the camera with the specified port */
p = gp_port_info_list_lookup_path (portinfolist, port);
switch (p) {
case GP_ERROR_UNKNOWN_PORT:
fprintf (stderr, "The port you specified "
"('%s') can not be found. Please "
"specify one of the ports found by "
"'gphoto2 --list-ports' and make "
"sure the spelling is correct "
"(i.e. with prefix 'serial:' or 'usb:').",
port);
break;
default:
break;
}
if (p < GP_OK) return p;
p = gp_port_info_list_lookup_path (portinfolist, port);
switch (p) {
case GP_ERROR_UNKNOWN_PORT:
fprintf (stderr, "The port you specified "
"('%s') can not be found. Please "
"specify one of the ports found by "
"'gphoto2 --list-ports' and make "
"sure the spelling is correct "
"(i.e. with prefix 'serial:' or 'usb:').",
port);
break;
default:
break;
}
if (p < GP_OK) return p;

ret = gp_port_info_list_get_info (portinfolist, p, &pi);
if (ret < GP_OK) return ret;
ret = gp_camera_set_port_info (*camera, pi);
if (ret < GP_OK) return ret;
ret = gp_port_info_list_get_info (portinfolist, p, &pi);
if (ret < GP_OK) return ret;
ret = gp_camera_set_port_info (*camera, pi);
if (ret < GP_OK) return ret;
return GP_OK;
}
78 changes: 39 additions & 39 deletions examples/best-iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@
static int aperture;
static float shutterspeed;

static void errordumper(GPLogLevel level, const char *domain, const char *str,
void *data) {
fprintf(stdout, "%s\n", str);
static void errordumper(GPLogLevel level, const char *domain, const char *str, void *data)
{
fprintf(stdout, "%s\n", str);
}

static void
ctx_error_func (GPContext *context, const char *str, void *data)
{
fprintf (stderr, "\n*** Contexterror *** \n%s\n",str);
fflush (stderr);
fprintf (stderr, "\n*** Contexterror *** \n%s\n",str);
fflush (stderr);
}

static void
ctx_status_func (GPContext *context, const char *str, void *data)
{
fprintf (stderr, "%s\n", str);
fflush (stderr);
fprintf (stderr, "%s\n", str);
fflush (stderr);
}

static
Expand All @@ -51,16 +51,16 @@ GPContext* sample_create_context() {
context = gp_context_new();

/* All the parts below are optional! */
gp_context_set_error_func (context, ctx_error_func, NULL);
gp_context_set_status_func (context, ctx_status_func, NULL);
gp_context_set_error_func (context, ctx_error_func, NULL);
gp_context_set_status_func (context, ctx_status_func, NULL);

/* also:
gp_context_set_cancel_func (p->context, ctx_cancel_func, p);
gp_context_set_message_func (p->context, ctx_message_func, p);
if (isatty (STDOUT_FILENO))
gp_context_set_progress_funcs (p->context,
ctx_progress_start_func, ctx_progress_update_func,
ctx_progress_stop_func, p);
gp_context_set_message_func (p->context, ctx_message_func, p);
if (isatty (STDOUT_FILENO))
gp_context_set_progress_funcs (p->context,
ctx_progress_start_func, ctx_progress_update_func,
ctx_progress_stop_func, p);
*/
return context;
}
Expand Down Expand Up @@ -115,9 +115,9 @@ get_config_value_string (Camera *camera, const char *key, char **str, GPContext
goto out;
}
switch (type) {
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
break;
default:
fprintf (stderr, "widget has bad type %d\n", type);
Expand Down Expand Up @@ -174,9 +174,9 @@ set_config_value_string (Camera *camera, const char *key, const char *val, GPCon
goto out;
}
switch (type) {
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
/* This is the actual set call. Note that we keep
* ownership of the string and have to free it if necessary.
*/
Expand All @@ -186,7 +186,7 @@ set_config_value_string (Camera *camera, const char *key, const char *val, GPCon
goto out;
}
break;
case GP_WIDGET_TOGGLE: {
case GP_WIDGET_TOGGLE: {
int ival;

sscanf(val,"%d",&ival);
Expand Down Expand Up @@ -321,9 +321,9 @@ main(int argc, char **argv) {
int retval, iso, tries;
char buf[20];
GPContext *context = sample_create_context();
/*int fd;*/
CameraFile *file;
/*CameraFilePath camera_file_path;*/
/*int fd;*/
CameraFile *file;
/*CameraFilePath camera_file_path;*/

gp_log_add_func(GP_LOG_ERROR, errordumper, NULL);
gp_camera_new(&camera);
Expand Down Expand Up @@ -404,31 +404,31 @@ main(int argc, char **argv) {

#if 0

printf("Capturing.\n");
printf("Capturing.\n");

retval = gp_camera_capture(camera, GP_CAPTURE_IMAGE, &camera_file_path, context);
if (retval != GP_OK) {
retval = gp_camera_capture(camera, GP_CAPTURE_IMAGE, &camera_file_path, context);
if (retval != GP_OK) {
printf(" capture failed: %d\n", retval);
exit(1);
}

printf("Pathname on the camera: %s/%s\n", camera_file_path.folder, camera_file_path.name);
printf("Pathname on the camera: %s/%s\n", camera_file_path.folder, camera_file_path.name);

fd = open("capture.jpg", O_CREAT | O_WRONLY | O_BINARY, 0644);
fd = open("capture.jpg", O_CREAT | O_WRONLY | O_BINARY, 0644);

retval = gp_file_new_from_fd(&file, fd);
if (retval != GP_OK) printf(" gp_file_new failed: %d\n", retval);
retval = gp_file_new_from_fd(&file, fd);
if (retval != GP_OK) printf(" gp_file_new failed: %d\n", retval);

retval = gp_camera_file_get(camera, camera_file_path.folder, camera_file_path.name,
GP_FILE_TYPE_NORMAL, file, context);
if (retval != GP_OK) printf(" file_get failed: %d\n", retval);
retval = gp_camera_file_get(camera, camera_file_path.folder, camera_file_path.name,
GP_FILE_TYPE_NORMAL, file, context);
if (retval != GP_OK) printf(" file_get failed: %d\n", retval);

printf("Deleting downloaded image.\n");
retval = gp_camera_file_delete(camera, camera_file_path.folder, camera_file_path.name,
context);
if (retval != GP_OK) printf(" Retval: %d\n", retval);
printf("Deleting downloaded image.\n");
retval = gp_camera_file_delete(camera, camera_file_path.folder, camera_file_path.name,
context);
if (retval != GP_OK) printf(" Retval: %d\n", retval);

gp_file_free(file);
gp_file_free(file);

#endif
#if 1
Expand Down
14 changes: 7 additions & 7 deletions examples/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ get_config_value_string (Camera *camera, const char *key, char **str, GPContext
goto out;
}
switch (type) {
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
break;
default:
fprintf (stderr, "widget has bad type %d\n", type);
Expand Down Expand Up @@ -121,9 +121,9 @@ set_config_value_string (Camera *camera, const char *key, const char *val, GPCon
goto out;
}
switch (type) {
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
case GP_WIDGET_MENU:
case GP_WIDGET_RADIO:
case GP_WIDGET_TEXT:
break;
default:
fprintf (stderr, "widget has bad type %d\n", type);
Expand Down Expand Up @@ -178,7 +178,7 @@ canon_enable_capture (Camera *camera, int onoff, GPContext *context) {
goto out;
}
switch (type) {
case GP_WIDGET_TOGGLE:
case GP_WIDGET_TOGGLE:
break;
default:
fprintf (stderr, "widget has bad type %d\n", type);
Expand Down
22 changes: 11 additions & 11 deletions examples/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
static void
ctx_error_func (GPContext *context, const char *str, void *data)
{
fprintf (stderr, "\n*** Contexterror *** \n%s\n",str);
fflush (stderr);
fprintf (stderr, "\n*** Contexterror *** \n%s\n",str);
fflush (stderr);
}

static void
ctx_status_func (GPContext *context, const char *str, void *data)
{
fprintf (stderr, "%s\n", str);
fflush (stderr);
fprintf (stderr, "%s\n", str);
fflush (stderr);
}

GPContext* sample_create_context() {
Expand All @@ -22,16 +22,16 @@ GPContext* sample_create_context() {
context = gp_context_new();

/* All the parts below are optional! */
gp_context_set_error_func (context, ctx_error_func, NULL);
gp_context_set_status_func (context, ctx_status_func, NULL);
gp_context_set_error_func (context, ctx_error_func, NULL);
gp_context_set_status_func (context, ctx_status_func, NULL);

/* also:
gp_context_set_cancel_func (p->context, ctx_cancel_func, p);
gp_context_set_message_func (p->context, ctx_message_func, p);
if (isatty (STDOUT_FILENO))
gp_context_set_progress_funcs (p->context,
ctx_progress_start_func, ctx_progress_update_func,
ctx_progress_stop_func, p);
gp_context_set_message_func (p->context, ctx_message_func, p);
if (isatty (STDOUT_FILENO))
gp_context_set_progress_funcs (p->context,
ctx_progress_start_func, ctx_progress_update_func,
ctx_progress_stop_func, p);
*/
return context;
}
8 changes: 4 additions & 4 deletions examples/focus.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ camera_eosviewfinder(Camera *camera, GPContext *context, int onoff) {
goto out;
}
switch (type) {
case GP_WIDGET_TOGGLE:
case GP_WIDGET_TOGGLE:
break;
default:
fprintf (stderr, "widget has bad type %d\n", type);
Expand Down Expand Up @@ -99,7 +99,7 @@ camera_auto_focus(Camera *camera, GPContext *context, int onoff) {
goto out;
}
switch (type) {
case GP_WIDGET_TOGGLE:
case GP_WIDGET_TOGGLE:
break;
default:
fprintf (stderr, "widget has bad type %d\n", type);
Expand Down Expand Up @@ -161,7 +161,7 @@ camera_manual_focus (Camera *camera, int xx, GPContext *context) {
goto out;
}
switch (type) {
case GP_WIDGET_RADIO: {
case GP_WIDGET_RADIO: {
int choices = gp_widget_count_choices (child);

ret = gp_widget_get_value (child, &mval);
Expand All @@ -184,7 +184,7 @@ camera_manual_focus (Camera *camera, int xx, GPContext *context) {
}
break;
}
case GP_WIDGET_RANGE:
case GP_WIDGET_RANGE:
ret = gp_widget_get_value (child, &rval);
if (ret < GP_OK) {
fprintf (stderr, "could not get widget value: %d\n", ret);
Expand Down
Loading

0 comments on commit 5c9d7b2

Please sign in to comment.