Functions
Utility functions

Functions

QUVIcode quvi_supported (quvi_t quvi, char *url)
 Check whether the library could parse the URL.
QUVIcode quvi_supported_ident (quvi_t quvi, char *url, quvi_ident_t *ident)
 Check whether the library could parse the URL.
QUVIcode quvi_ident_getprop (quvi_ident_t handle, QUVIidentProperty property,...)
 Get property information from an ident handle.
void quvi_supported_ident_close (quvi_ident_t *ident)
 Close ident handle.
QUVIcode quvi_next_supported_website (quvi_t quvi, char **domain, char **formats)
 Return next supported website.
QUVIcode quvi_next_host (char **domain, char **formats)
 Next supported host.
char * quvi_strerror (quvi_t quvi, QUVIcode code)
 Return a string describing the error code.
char * quvi_version (QUVIversion type)
 Return libquvi version.
void quvi_free (void *ptr)
 Free allocated memory.

Function Documentation

QUVIcode quvi_supported ( quvi_t  quvi,
char *  url 
)

Check whether the library could parse the URL.

The library checks the URL with each website script to see whether it could parse the URL. This function is designed to work without an Internet connection.

Most URL shortening services require that the URL is resolved over an Internet connection. This means that most "shortened" URLs will fail with this function (QUVI_NOSUPPORT).

Parameters:
quviHandle to session
urlNull-terminated string to an URL
Note:
  • Fails (QUVI_NOSUPPORT) with most "shortened" URLs
  • Works with a limited number of URL shorteners, e.g. youtu.be and dai.ly, in which cases the LUA scripts can resolve to the destination URL without an Internet connection
  • Consider using quvi_supported_ident() instead
Since:
0.2.9
Remarks:
  • 0.2.9 - 0.2.14: Limited to basic domain name comparison
  • 0.2.15: Improved heuristics: Additional checks for different URL parts
See also:
quvi_supported_ident
Returns:
Non-zero if an error occurred
Examples:
quvi.c.
QUVIcode quvi_supported_ident ( quvi_t  quvi,
char *  url,
quvi_ident_t ident 
)

Check whether the library could parse the URL.

Identical to quvi_supported() but returns the `ident' data from a matched website script.

The library checks the URL with each website script to see whether it could parse the URL. This function is designed to work without an Internet connection.

Most URL shortening services require that the URL is resolved over an Internet connection. This means that most "shortened" URLs will fail with this function (QUVI_NOSUPPORT).

Parameters:
quviHandle to session
urlNull-terminated string to an URL
identHandle to ident data (set to NULL to emulate quvi_supported())
Remarks:
Close ident handle with quvi_supported_ident_close() unless `ident' parameter is set to NULL (see above)
See also:
quvi_ident_getprop
quvi_supported_ident_close
quvi_supported
Since:
0.2.16
Returns:
Non-zero if an error occurred
Examples:
quvi.c.
QUVIcode quvi_ident_getprop ( quvi_ident_t  handle,
QUVIidentProperty  property,
  ... 
)

Get property information from an ident handle.

Parameters:
handleHandle to a website script returned ident data
propertyProperty ID
...Parameter
Warning:
Do not attempt to free the memory returned by this function
See also:
quvi_supported_ident
quvi_supported_ident_close
Since:
0.2.16
Returns:
Non-zero if an error occurred

Example:

 quvi_ident_t ident;
 if (quvi_supported_ident(quvi, url, &ident) == QUVI_OK)
  {
    char *formats;
    quvi_ident_getprop(ident, QUVI_IDENT_PROPERTY_FORMATS, &formats);
    puts(formats);
    quvi_supported_ident_close(&ident);
  }
Examples:
quvi.c.
void quvi_supported_ident_close ( quvi_ident_t ident)

Close ident handle.

See also:
quvi_supported_ident
Since:
0.2.16
Examples:
quvi.c.
QUVIcode quvi_next_supported_website ( quvi_t  quvi,
char **  domain,
char **  formats 
)

Return next supported website.

This function can be used to iterate the supported websites.

Parameters:
quviHandle to a session
domainPointer to a null-terminated string (e.g. "youtube.com")
formatsPointer to a null-terminated string (e.g. "default|best|hq|hd")
Returns:
QUVI_OK or a non-zero value if an error occurred
  • QUVI_LAST indicates end of the list of the websites
  • Any other returned non-zero value indicates an actual error and should be handled accordingly (e.g. relaying the return code to quvi_strerror)
Note:
  • Both domain and formats string must be quvi_free()d after use
  • Return value QUVI_LAST is a non-zero value and indicates the end iteration
  • Consider handling errors
Since:
0.2.0

Example:

 while (quvi_next_supported_website(quvi, &domain, &formats) == QUVI_OK)
   {
     printf("%s\t%s\n", domain, formats);
     quvi_free(domain);
     quvi_free(formats);
   }
Examples:
quvi.c.
QUVIcode quvi_next_host ( char **  domain,
char **  formats 
)

Next supported host.

Iterate the list of the supported hosts.

Parameters:
domainPointer to a null-terminated string
formatsPointer to a null-terminated string
Returns:
QUVI_LAST (always)
Deprecated:
Since 0.2.0, use quvi_next_supported_website() instead
char* quvi_strerror ( quvi_t  quvi,
QUVIcode  code 
)

Return a string describing the error code.

Parameters:
quviHandle to a libquvi session
codeError code
Returns:
Null-terminated string
Warning:
Do not attempt to free the memory returned by this function

Example:

 quvi_t quvi;
 QUVIcode rc = quvi_init(&quvi);
 if (rc != QUVI_OK)
   {
     fprintf(stderr, "error: %s\n", quvi_strerror(quvi,rc));
     exit (rc);
   }
 quvi_close(&quvi);
Examples:
quvi.c.
char* quvi_version ( QUVIversion  type)

Return libquvi version.

Parameters:
typeVersion type
Returns:
Null-terminated string
Warning:
Do not attempt to free the memory returned by this function

Example:

Examples:
quvi.c.
void quvi_free ( void *  ptr)

Free allocated memory.

Parameters:
ptrPointer to data
Examples:
quvi.c.
 All Files Functions Typedefs Enumerations Enumerator Defines