Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

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 successfull - will append this entry to the list.

Note:
This returns index - number of generic entries, not the correct index.
Returns:
A non-negative number or a gphoto2 error code

Definition at line 173 of file gphoto2-port-info-list.c.

References CHECK_NULL, _GPPortInfoList::count, GP_ERROR_NO_MEMORY, _GPPortInfoList::info, and _GPPortInfo::name.

Referenced by gp_port_info_list_lookup_path().

{
      int generic, i;
      GPPortInfo *new_info;

      CHECK_NULL (list);

      if (!list->info)
            new_info = malloc (sizeof (GPPortInfo));
      else
            new_info = realloc (list->info, sizeof (GPPortInfo) *
                                          (list->count + 1));
      if (!new_info)
            return (GP_ERROR_NO_MEMORY);

      list->info = new_info;
      list->count++;

      memcpy (&(list->info[list->count - 1]), &info, sizeof (GPPortInfo));

      /* Ignore generic entries */
      for (generic = i = 0; i < list->count; i++)
            if (!strlen (list->info[i].name))
                  generic++;
      return (list->count - 1 - generic);
}


Generated by  Doxygen 1.6.0   Back to index