libgphoto2 photo camera library (libgphoto2) API: libgphoto2_port/libgphoto2_port/gphoto2-port-info-list.c File Reference

libgphoto2 photo camera library (libgphoto2) API 2.5.34

Loading...
Searching...
No Matches
gphoto2-port-info-list.c File Reference
`#include "config.h"`
`#include <gphoto2/gphoto2-port-info-list.h>`
`#include <errno.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <stdio.h>`
`#include <ltdl.h>`
`#include <gphoto2/gphoto2-port-result.h>`
`#include <gphoto2/gphoto2-port-library.h>`
`#include <gphoto2/gphoto2-port-log.h>`
`#include <gphoto2/gphoto2-port-locking.h>`
`#include "libgphoto2_port/gphoto2-port-info.h"`
`#include "libgphoto2_port/i18n.h"`
Include dependency graph for gphoto2-port-info-list.c:

## Data Structures
struct | _GPPortInfoList

## Macros
#define | _GNU_SOURCE
#define | _DARWIN_C_SOURCE
#define | CR(x)

## Functions
int | gp_port_init_localedir (const char *localedir)
| Initialize the localedir directory for the libgphoto2_port gettext domain.
const char * | gp_port_message_codeset (const char *codeset)
| Specify codeset for translations.
int | gp_port_info_list_new (GPPortInfoList **list)
| Create a new GPPortInfoList.
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_load (GPPortInfoList *list)
| Load system ports.
int | gp_port_info_list_count (GPPortInfoList *list)
| Number of ports in the list.
int | gp_port_info_list_lookup_path (GPPortInfoList *list, const char *path)
| Lookup a specific path in the list.
int | gp_port_info_list_lookup_name (GPPortInfoList *list, const char *name)
| Look up a name in the list.
int | gp_port_info_list_get_info (GPPortInfoList *list, int n, GPPortInfo *info)
| Get port information of specific entry.
int | gp_port_info_get_name (GPPortInfo info, char **name)
| Get name of a specific port entry.
int | gp_port_info_set_name (GPPortInfo info, const char *name)
| Set name of a specific port entry.
int | gp_port_info_get_path (GPPortInfo info, char **path)
| Get path of a specific port entry.
int | gp_port_info_set_path (GPPortInfo info, const char *path)
| Set path of a specific port entry.
int | gp_port_info_get_type (GPPortInfo info, GPPortType *type)
| Get type 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_new (GPPortInfo *info)
| Create a new portinfo.

## Detailed Description

Author
  Copyright 2001 Lutz Mueller lutz@.nosp@m.user.nosp@m.s.sf..nosp@m.net

License
  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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

## Macro Definition Documentation

## ◆ CR

#define CR | ( |  | x | ) |

Value:
{int r=(x);if (r<0) return (r);}

## Function Documentation

## ◆ gp_port_info_get_name()

int gp_port_info_get_name | ( | GPPortInfo | info,
|  | char ** | name )

Get name of a specific port entry.

Parameters

  info | a #GPPortInfo
  name | a pointer to a char* which will receive the name

Retrieves the name of the passed in GPPortInfo, by reference.

Returns
  a gphoto2 error code

References GP_OK, and _GPPortInfo::name.

## ◆ gp_port_info_get_path()

int gp_port_info_get_path | ( | GPPortInfo | info,
|  | char ** | path )

Get path of a specific port entry.

Parameters

  info | a #GPPortInfo
  path | a pointer to a char* which will receive the path

Retrieves the path of the passed in GPPortInfo, by reference.

Returns
  a gphoto2 error code

References GP_OK, and _GPPortInfo::path.

Referenced by gp_abilities_list_detect(), and gp_camera_init().

## ◆ gp_port_info_get_type()

int gp_port_info_get_type | ( | GPPortInfo | info,
|  | GPPortType * | type )

Get type of a specific port entry.

Parameters

  info | a #GPPortInfo
  type | a pointer to a GPPortType variable which will receive the type

Retrieves the type of the passed in GPPortInfo

Returns
  a gphoto2 error code

References GP_OK, and _GPPortInfo::type.

Referenced by gp_abilities_list_detect(), and gp_camera_init().

## ◆ gp_port_info_list_append()

int gp_port_info_list_append | ( | GPPortInfoList * | list,
|  | GPPortInfo | info )

Append a portinfo to the port information list.

Parameters

  list | a #GPPortInfoList
  info | the info to append

Appends an entry to the list. This function is typically called by an io-driver during #gp_port_library_list. If you leave info.name blank, gp_port_info_list_lookup_path will try to match non-existent paths against info.path and - if successful - will append this entry to the list.

Returns
  A gphoto2 error code, or an index into the port list (excluding generic entries). which can be used for gp_port_info_list_get_info.

References _GPPortInfo::name.

Referenced by gp_port_info_list_lookup_path().

## ◆ gp_port_info_list_count()

int gp_port_info_list_count | ( | GPPortInfoList * | list | ) |

Number of ports in the list.

Parameters

  list | a #GPPortInfoList

Returns the number of entries in the passed list.

Returns
  The number of entries or a gphoto2 error code

References _GPPortInfo::name.

Referenced by gp_abilities_list_detect(), and gp_camera_autodetect().

## ◆ gp_port_info_list_free()

int gp_port_info_list_free | ( | GPPortInfoList * | list | ) |

Free a GPPortInfo list.

Parameters

  list | a #GPPortInfoList

Frees a GPPortInfoList structure and its internal data structures.

Returns
  a gphoto2 error code

References GP_OK, _GPPortInfo::library_filename, _GPPortInfo::name, and _GPPortInfo::path.

Referenced by gp_camera_autodetect(), and gp_camera_init().

## ◆ gp_port_info_list_get_info()

int gp_port_info_list_get_info | ( | GPPortInfoList * | list,
|  | int | n,
|  | GPPortInfo * | info )

Get port information of specific entry.

Parameters

  list | a #GPPortInfoList
  n | the index of the entry
  info | the returned information

Returns a pointer to the current port entry.

Returns
  a gphoto2 error code

References GP_OK, and _GPPortInfo::name.

Referenced by gp_abilities_list_detect(), and gp_camera_init().

## ◆ gp_port_info_list_load()

int gp_port_info_list_load | ( | GPPortInfoList * | list | ) |

Load system ports.

Parameters

  list | a #GPPortInfoList

Searches the system for io-drivers and appends them to the list. You would normally call this function once after gp_port_info_list_new and then use this list in order to supply gp_port_set_info with parameters or to do autodetection.

Returns
  a gphoto2 error code

References GP_ERROR_LIBRARY, and GP_OK.

Referenced by gp_camera_autodetect(), and gp_camera_init().

## ◆ gp_port_info_list_lookup_name()

int gp_port_info_list_lookup_name | ( | GPPortInfoList * | list,
|  | const char * | name )

Look up a name in the list.

Parameters

  list | a #GPPortInfoList
  name | a name

Looks for an entry in the list with the exact given name.

Returns
  The index of the entry or a gphoto2 error code

References GP_ERROR_UNKNOWN_PORT, and _GPPortInfo::name.

## ◆ gp_port_info_list_lookup_path()

int gp_port_info_list_lookup_path | ( | GPPortInfoList * | list,
|  | const char * | path )

Lookup a specific path in the list.

Parameters

  list | a #GPPortInfoList
  path | a path

Looks for an entry in the list with the supplied path. If no exact match can be found, a regex search will be performed in the hope some driver claimed ports like "serial:*".

Returns
  The index of the entry or a gphoto2 error code

References GP_ERROR_UNKNOWN_PORT, gp_port_info_list_append(), gp_port_info_new(), gp_port_info_set_name(), gp_port_info_set_path(), gp_port_info_set_type(), _GPPortInfo::library_filename, _GPPortInfo::name, _GPPortInfo::path, and _GPPortInfo::type.

Referenced by gp_camera_init().

## ◆ gp_port_info_list_new()

int gp_port_info_list_new | ( | GPPortInfoList ** | list | ) |

Create a new GPPortInfoList.

Parameters

  list | pointer to a GPPortInfoList* which is allocated

Creates a new list which can later be filled with port infos (#GPPortInfo) using gp_port_info_list_load.

Returns
  a gphoto2 error code

References GP_OK, and gp_port_init_localedir().

Referenced by gp_camera_autodetect(), and gp_camera_init().

## ◆ gp_port_info_new()

int gp_port_info_new | ( | GPPortInfo * | info | ) |

Create a new portinfo.

Parameters

  info | pointer to a #GPPortInfo

Allocates and initializes a GPPortInfo structure. This is a libgphoto2_port internal function.

Returns
  a gphoto2 error code

References GP_OK.

Referenced by gp_port_info_list_lookup_path().

## ◆ gp_port_info_set_name()

int gp_port_info_set_name | ( | GPPortInfo | info,
|  | const char * | name )

Set name of a specific port entry.

Parameters

  info | a #GPPortInfo
  name | a char* pointer which will receive the name

Sets the name of the passed in GPPortInfo This is a libgphoto2_port internal function.

Returns
  a gphoto2 error code

References GP_OK, and _GPPortInfo::name.

Referenced by gp_port_info_list_lookup_path().

## ◆ gp_port_info_set_path()

int gp_port_info_set_path | ( | GPPortInfo | info,
|  | const char * | path )

Set path of a specific port entry.

Parameters

  info | a #GPPortInfo
  path | a char* pointer which will receive the path

Sets the path of the passed in GPPortInfo This is a libgphoto2_port internal function.

Returns
  a gphoto2 error code

References GP_OK, and _GPPortInfo::path.

Referenced by gp_port_info_list_lookup_path().

## ◆ gp_port_info_set_type()

int gp_port_info_set_type | ( | GPPortInfo | info,
|  | GPPortType | type )

Set type of a specific port entry.

Parameters

  info | a #GPPortInfo
  type | a GPPortType variable which will has the type

Sets the type of the passed in GPPortInfo This is a libgphoto2_port internal function.

Returns
  a gphoto2 error code

References GP_OK, and _GPPortInfo::type.

Referenced by gp_port_info_list_lookup_path().

## ◆ gp_port_init_localedir()

int gp_port_init_localedir | ( | const char * | localedir | ) |

Initialize the localedir directory for the libgphoto2_port gettext domain.

Override the localedir directory libgphoto2_port uses for its message translations.

This function is called by the gp_init_localedir() function, so if you are calling that already, there is no need to call gp_port_init_localedir() yourself.

You only need to call this if you have a non-standard installation where the locale files are at a location which differs from the compiled in default location.

If you need to call this function, call it before calling any non-initialization function.

Internally, this will make sure bindtextdomain() is called for the relevant gettext text domain(s).

Parameters

  localedir | Root directory of libgphoto2_port's localization files. If NULL, use the compiled in default value, which will be something like "/usr/share/locale".

Returns
  gphoto2 error code.

References GP_ERROR, GP_ERROR_NO_MEMORY, gp_log(), GP_LOG_DEBUG, and GP_OK.

Referenced by gp_init_localedir(), and gp_port_info_list_new().

## ◆ gp_port_message_codeset()

const char * gp_port_message_codeset | ( | const char * | codeset | ) |

Specify codeset for translations.

This function specifies the codeset that is used for the translated strings that are passed back by the libgphoto2_port functions.

This function is called by the gp_message_codeset() function, so there is no need to call it yourself.

Parameters

  codeset | new codeset to use

Returns
  the previous codeset

Referenced by gp_message_codeset().