34 #elif defined(_MSC_VER)
35 #pragma message("We need regex.h, but it has not been detected.")
37 #warning We need regex.h, but it has not been detected.
51 # define _(String) dgettext (GETTEXT_PACKAGE, String)
53 # define N_(String) gettext_noop (String)
55 # define N_(String) (String)
58 # define textdomain(String) (String)
59 # define gettext(String) (String)
60 # define dgettext(Domain,Message) (Message)
61 # define dcgettext(Domain,Message,Type) (Message)
62 # define bindtextdomain(Domain,Directory) (Domain)
63 # define bind_textdomain_codeset(Domain,codeset) (codeset)
64 # define ngettext(String1,String2,Count) ((Count==1)?String1:String2)
65 # define _(String) (String)
66 # define N_(String) (String)
80 #define CR(x) {int r=(x);if (r<0) return (r);}
142 for (i=0;i<list->
count;i++) {
149 free (list->
info[i]);
179 unsigned int generic, i;
188 for (
generic = i = 0; i < list->
count; i++)
191 return (list->
count - 1 -
generic);
203 unsigned int j, old_size = list->
count;
206 GP_LOG_D (
"Called for filename '%s'.", filename );
208 lh = lt_dlopenext (filename);
210 GP_LOG_D (
"Could not load '%s': '%s'.", filename, lt_dlerror ());
214 lib_type = lt_dlsym (lh,
"gp_port_library_type");
215 lib_list = lt_dlsym (lh,
"gp_port_library_list");
216 if (!lib_type || !lib_list) {
217 GP_LOG_D (
"Could not find some functions in '%s': '%s'.",
218 filename, lt_dlerror ());
224 for (j = 0; j < list->
count; j++)
227 if (j != list->
count) {
228 GP_LOG_D (
"'%s' already loaded", filename);
234 #if !defined(VALGRIND)
238 GP_LOG_E (
"Error during assembling of port list: '%s' (%d).",
242 if (old_size != list->
count) {
249 for (j = old_size; j < list->
count; j++){
250 GP_LOG_D (
"Loaded '%s' ('%s') from '%s'.",
276 const char *iolibs_env = getenv(IOLIBDIR_ENV);
277 const char *iolibs = (iolibs_env != NULL)?iolibs_env:IOLIBS;
282 GP_LOG_D (
"Using ltdl to load io-drivers from '%s'...", iolibs);
284 lt_dladdsearchdir (iolibs);
290 GP_LOG_E (
"No iolibs found in '%s'", iolibs);
307 unsigned int count, i;
311 GP_LOG_D (
"Counting entries (%i available)...", list->
count);
315 for (i = 0; i < list->
count; i++)
319 GP_LOG_D (
"%i regular entries available.", count);
342 #ifdef HAVE_GNU_REGEX
349 C_PARAMS (list && path);
351 GP_LOG_D (
"Looking for path '%s' (%i entries available)...", path, list->
count);
354 for (
generic = i = 0; i < list->
count; i++)
357 else if (!strcmp (list->
info[i]->
path, path))
358 return (i -
generic);
362 GP_LOG_D (
"Starting regex search for '%s'...", path);
363 for (i = 0; i < list->
count; i++) {
369 GP_LOG_D (
"Trying '%s'...", list->
info[i]->
path);
372 #ifdef HAVE_GNU_REGEX
373 memset (&pattern, 0,
sizeof (pattern));
374 rv = re_compile_pattern (list->
info[i]->
path,
375 strlen (list->
info[i]->
path), &pattern);
384 if (regerror (
result, &pattern, buf,
sizeof (buf)))
385 GP_LOG_E (
"%s", buf);
387 GP_LOG_E (
"regcomp failed");
393 #ifdef HAVE_GNU_REGEX
394 result = re_match (&pattern, path, strlen (path), 0, NULL);
397 GP_LOG_D (
"re_match failed (%i)",
result);
401 result = regexec (&pattern, path, 1, &match, 0);
404 GP_LOG_D (
"regexec failed");
433 unsigned int i,
generic;
435 C_PARAMS (list && name);
437 GP_LOG_D (
"Looking up entry '%s'...", name);
440 for (
generic = i = 0; i < list->
count; i++)
443 else if (!strcmp (list->
info[i]->
name, name))
444 return (i -
generic);
464 C_PARAMS (list && info);
466 GP_LOG_D (
"Getting info of entry %i (%i available)...", n, list->
count);
468 C_PARAMS ((n >= 0) && (
unsigned int)n < list->count);
471 for (i = 0; i <= n; i++)
472 if (!strlen (list->
info[i]->
name)) {
474 C_PARAMS ((
unsigned int)n < list->count);
477 *info = list->
info[n];
509 C_MEM (info->
name = strdup (name));
540 C_MEM (info->
path = strdup (path));
586 C_MEM (*info = calloc (1,
sizeof(
struct _GPPortInfo)));
#define bind_textdomain_codeset(Domain, codeset)
int gp_port_info_set_name(GPPortInfo info, const char *name)
Set name of a specific port entry.
int gp_port_info_list_count(GPPortInfoList *list)
Number of ports in the list.
int gp_port_info_list_new(GPPortInfoList **list)
Create a new GPPortInfoList.
const char * gp_port_message_codeset(const char *codeset)
Specify codeset for translations.
int gp_port_info_list_lookup_name(GPPortInfoList *list, const char *name)
Look up a name in the list.
int gp_port_info_set_path(GPPortInfo info, const char *path)
Set path of a specific port entry.
int gp_port_info_list_load(GPPortInfoList *list)
Load system ports.
int gp_port_info_get_type(GPPortInfo info, GPPortType *type)
Get type of a specific port entry.
int gp_port_info_list_get_info(GPPortInfoList *list, int n, GPPortInfo *info)
Get port information of specific entry.
int gp_port_info_new(GPPortInfo *info)
Create a new portinfo.
int gp_port_info_get_path(GPPortInfo info, char **path)
Get path of a specific port entry.
int gp_port_info_get_name(GPPortInfo info, char **name)
Get name of a specific port entry.
int gp_port_info_set_type(GPPortInfo info, GPPortType type)
Set type of a specific port entry.
int gp_port_info_list_free(GPPortInfoList *list)
Free a GPPortInfo list.
int gp_port_info_list_append(GPPortInfoList *list, GPPortInfo info)
Append a portinfo to the port information list.
int gp_port_info_list_lookup_path(GPPortInfoList *list, const char *path)
Lookup a specific path in the list.
#define bindtextdomain(Domain, Directory)
static int foreach_func(const char *filename, lt_ptr data)
GPPortType
The gphoto port type.
GPPortType(* GPPortLibraryType)(void)
int(* GPPortLibraryList)(GPPortInfoList *list)
const char * gp_port_result_as_string(int result)
#define GP_OK
Everything is OK.
#define GP_ERROR_LIBRARY
Error in the camera driver.
#define GP_ERROR_UNKNOWN_PORT
Unknown libgphoto2 port passed.
char * library_filename
Internal pathname of the port driver. Do not use outside of the port library.
char * path
The path of this port (usb:001,023)
GPPortType type
The type of this port.
char * name
The name of this port (usb:)