libgphoto2 photo camera library (libgphoto2) Internals  2.5.23
gphoto2-result.c
Go to the documentation of this file.
1 
24 #include "config.h"
25 #include <gphoto2/gphoto2-result.h>
26 
27 #include <stddef.h>
28 
29 #ifdef ENABLE_NLS
30 # include <libintl.h>
31 # undef _
32 # define _(String) dgettext (GETTEXT_PACKAGE, String)
33 # ifdef gettext_noop
34 # define N_(String) gettext_noop (String)
35 # else
36 # define N_(String) (String)
37 # endif
38 #else
39 # define _(String) (String)
40 # define N_(String) (String)
41 #endif
42 
43 static struct {
44  int result;
45  const char *description;
46 } result_descriptions[] = {
47  {GP_ERROR_CORRUPTED_DATA, N_("Corrupted data")},
48  {GP_ERROR_FILE_EXISTS, N_("File exists")},
49  {GP_ERROR_MODEL_NOT_FOUND, N_("Unknown model")},
50  {GP_ERROR_DIRECTORY_NOT_FOUND, N_("Directory not found")},
51  {GP_ERROR_FILE_NOT_FOUND, N_("File not found")},
52  {GP_ERROR_DIRECTORY_EXISTS, N_("Directory exists")},
53  {GP_ERROR_CAMERA_BUSY, N_("I/O in progress")},
54  {GP_ERROR_PATH_NOT_ABSOLUTE, N_("Path not absolute")},
55  {GP_ERROR_CANCEL, N_("Operation cancelled")},
56  {GP_ERROR_CAMERA_ERROR, N_("Camera could not complete operation")},
57  {GP_ERROR_OS_FAILURE, N_("OS error in camera communication")},
58  {GP_ERROR_NO_SPACE, N_("Not enough free space")},
59  {0, NULL}
60 };
61 
72 const char *
74 {
75  unsigned int i;
76 
77  /* IOlib error? Pass through. */
78  if ((result <= 0) && (result >= -99))
80 
81  /* Camlib error? */
82  if (result <= -1000)
83  return (N_("Unknown camera library error"));
84 
85  for (i = 0; result_descriptions[i].description; i++)
88 
89  return (N_("Unknown error"));
90 }
GP_ERROR_FILE_NOT_FOUND
#define GP_ERROR_FILE_NOT_FOUND
Specified file was not found.
Definition: gphoto2-result.h:75
GP_ERROR_CAMERA_ERROR
#define GP_ERROR_CAMERA_ERROR
Unspecified camera error.
Definition: gphoto2-result.h:117
GP_ERROR_FILE_EXISTS
#define GP_ERROR_FILE_EXISTS
File already exists.
Definition: gphoto2-result.h:50
description
const char * description
Definition: gphoto2-result.c:45
result
int result
Definition: gphoto2-result.c:44
GP_ERROR_MODEL_NOT_FOUND
#define GP_ERROR_MODEL_NOT_FOUND
Specified camera model was not found.
Definition: gphoto2-result.h:59
gphoto2-result.h
result_descriptions
static struct @0 result_descriptions[]
GP_ERROR_PATH_NOT_ABSOLUTE
#define GP_ERROR_PATH_NOT_ABSOLUTE
Path is not absolute.
Definition: gphoto2-result.h:99
gp_result_as_string
const char * gp_result_as_string(int result)
Translate a gphoto error code into a localized string.
Definition: gphoto2-result.c:73
GP_ERROR_CAMERA_BUSY
#define GP_ERROR_CAMERA_BUSY
The camera is already busy.
Definition: gphoto2-result.h:90
GP_ERROR_NO_SPACE
#define GP_ERROR_NO_SPACE
Not enough space.
Definition: gphoto2-result.h:132
GP_ERROR_CORRUPTED_DATA
#define GP_ERROR_CORRUPTED_DATA
Corrupted data received.
Definition: gphoto2-result.h:42
N_
#define N_(String)
Definition: gphoto2-result.c:40
_
#define _(String)
Definition: gphoto2-result.c:39
GP_ERROR_CANCEL
#define GP_ERROR_CANCEL
Cancellation successful.
Definition: gphoto2-result.h:107
GP_ERROR_OS_FAILURE
#define GP_ERROR_OS_FAILURE
Unspecified failure of the operating system.
Definition: gphoto2-result.h:125
GP_ERROR_DIRECTORY_EXISTS
#define GP_ERROR_DIRECTORY_EXISTS
Specified directory already exists.
Definition: gphoto2-result.h:83
GP_ERROR_DIRECTORY_NOT_FOUND
#define GP_ERROR_DIRECTORY_NOT_FOUND
Specified directory was not found.
Definition: gphoto2-result.h:67
gp_port_result_as_string
const char * gp_port_result_as_string(int result)
Definition: gphoto2-port-result.c:54