libgphoto2 photo camera library (libgphoto2) Internals  2.5.26
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 }
const char * gp_port_result_as_string(int result)
static struct @0 result_descriptions[]
#define _(String)
const char * description
#define N_(String)
int result
const char * gp_result_as_string(int result)
Translate a gphoto error code into a localized string.
#define GP_ERROR_CAMERA_BUSY
The camera is already busy.
#define GP_ERROR_PATH_NOT_ABSOLUTE
Path is not absolute.
#define GP_ERROR_CANCEL
Cancellation successful.
#define GP_ERROR_NO_SPACE
Not enough space.
#define GP_ERROR_FILE_EXISTS
File already exists.
#define GP_ERROR_FILE_NOT_FOUND
Specified file was not found.
#define GP_ERROR_OS_FAILURE
Unspecified failure of the operating system.
#define GP_ERROR_DIRECTORY_NOT_FOUND
Specified directory was not found.
#define GP_ERROR_DIRECTORY_EXISTS
Specified directory already exists.
#define GP_ERROR_MODEL_NOT_FOUND
Specified camera model was not found.
#define GP_ERROR_CAMERA_ERROR
Unspecified camera error.
#define GP_ERROR_CORRUPTED_DATA
Corrupted data received.