Logo Search packages:      
Sourcecode: pam-pkcs11 version File versions  Download package

URI_EXTERN int get_from_uri ( const char *  uri_str,
unsigned char **  data,
size_t *  length 
)

Downloads data from a given URI

Parameters:
uri_str URL string where to retrieve data
data Pointer to a String buffer where data is retrieved
length Length of retrieved data
Returns:
-1 on error, 0 on sucess

Definition at line 582 of file uri.c.

{
  int rv;
  uri_t *uri;

  /* parse uri */
  DBG("parsing uri:");
  rv = parse_uri(str, &uri);
  if (rv != 0) {
    set_error("parse_uri() failed: %s", get_error());
    return -1;
  }
  /* download data depending on the scheme */
  switch (uri->scheme) {
    case file:
      rv = get_file(uri, data, (ssize_t *) length);
      if (rv != 0)
        set_error("get_file() failed: %s", get_error());
      break;
    case http:
      rv = get_http(uri, data, length, 0);
      if (rv != 0)
        set_error("get_http() failed: %s", get_error());
      break;
    case ldap:
#ifdef HAVE_LDAP
      rv = get_ldap(uri, data, length);
      if (rv != 0)
        set_error("get_ldap() failed: %s", get_error());
#else
      rv = -1;
      set_error("Compiled without LDAP support");
#endif
      break;
    default:
      set_error("unsupported protocol");
      rv = -1;
  }
  free_uri(uri);
  return rv;
}


Generated by  Doxygen 1.6.0   Back to index