liblicense/liblicense.h File Reference

Go to the source code of this file.

Data Structures

struct  _LLModuleDesc
struct  _LLModuleDesc_and_index
struct  ll_license_list_t

Defines

#define LL_DIR_SEPARATOR   '/'
#define LL_DIR_SEPARATOR_S   "/"
#define LL_WEBSTATEMENT   "http://ns.adobe.com/xap/1.0/rights/WebStatement"
#define LL_LICENSE   "http://creativecommons.org/ns#license"
#define LL_MORE_PERMISSIONS   "http://creativecommons.org/ns#morePermissions"
#define LL_ATTRIBUTION   "http://creativecommons.org/ns#Attribution"
#define LL_COMMERCIAL_USE   "http://creativecommons.org/ns#CommercialUse"
#define LL_DERIVATIVE_WORKS   "http://creativecommons.org/ns#DerivativeWorks"
#define LL_DISTRIBUTION   "http://creativecommons.org/ns#Distribution"
#define LL_HIGH_INCOME_NATION_USE   "http://creativecommons.org/ns#HighIncomeNationUse"
#define LL_NOTICE   "http://creativecommons.org/ns#Notice"
#define LL_REPRODUCTION   "http://creativecommons.org/ns#Reproduction"
#define LL_SHARE_ALIKE   "http://creativecommons.org/ns#ShareAlike"
#define LL_SHARING   "http://creativecommons.org/ns#Sharing"
#define LL_SOURCE_CODE   "http://creativecommons.org/ns#SourceCode"
#define LL_REPLACED_BY   "http://purl.org/dc/terms/isReplacedBy"
#define LL_JURISDICTION   "http://creativecommons.org/ns#jurisdiction"
#define LL_NAME   "http://purl.org/dc/elements/1.1/title"
#define LL_VERSION   "http://purl.org/dc/terms/hasVersion"
#define LL_CREATOR   "http://purl.org/dc/elements/1.1/creator"
#define LL_PROHIBITS   "http://creativecommons.org/ns#prohibits"
#define LL_PERMITS   "http://creativecommons.org/ns#permits"
#define LL_REQUIRES   "http://creativecommons.org/ns#requires"
#define LL_PREDICATE_ANY   "?predicate"
#define LL_MODULE_EXPORT
#define LL_MODULE_DEFINE(name, description, version, features, supported_predicates, mime_types, init, read, write, shutdown)
#define LL_E_MODULE_WRITE_FAIL   1
#define LL_UNSPECIFIED   0

Typedefs

typedef char * ll_juris_t
typedef char * ll_uri_t
typedef char * ll_locale_t
typedef int * ll_version_t
typedef char * ll_attribute_t
typedef char * ll_filename_t
typedef char * ll_module_t
typedef char * ll_symbol_t
typedef char * ll_mime_type_t
typedef struct _LLModuleDesc LLModuleDesc
typedef void(* LLModuleInitFunc )(void)
typedef char *(* LLModuleReadFunc )(const char *, const char *)
typedef int(* LLModuleWriteFunc )(const char *, const char *, const char *)
typedef void(* LLModuleShutdownFunc )(void)
typedef enum ll_features ll_features
typedef struct
_LLModuleDesc_and_index 
LLModuleSearchState
typedef struct
_ll_license_chooser_t 
ll_license_chooser_t
typedef struct ll_license_list_t ll_license_list_t

Enumerations

enum  ll_features { LL_FEATURES_NONE = 0x000000, LL_FEATURES_EMBED = 0x000001 }

Functions

ll_version_t ll_parse_version (const char *version)
char ** ll_get_attribute (ll_uri_t license_uri, const char *attribute_uri, int locale)
ll_uri_t ll_filename_to_uri (const ll_filename_t filename)
ll_filename_t ll_uri_to_filename (const ll_uri_t uri)
char * ll_get_first (char **list)
char * ll_jurisdiction_name (const char *jurisdiction)
int ll_init (void)
int ll_stop (void)
int ll_verify_uri (const ll_uri_t license_uri)
ll_uri_tll_get_all_licenses (void)
ll_uri_tll_get_licenses (const ll_juris_t justrisdiction)
ll_juris_tll_get_jurisdictions (void)
void ll_license_print_info (ll_uri_t license_uri)
ll_module_tll_get_config_modules (void)
ll_module_tll_get_io_modules (void)
int ll_module_init (const char *directory, ll_module_t module)
void * ll_get_module_symbol (const char *directory, ll_module_t module, ll_symbol_t symbol)
int ll_module_shutdown (const char *directory, ll_module_t module)
void ll_print_module_info (void)
void ll_init_modules (void)
void ll_stop_modules (void)
int _ll_contains_token (const char **haystack, const char *needle)
unsigned int _ll_modules_count_available ()
int ll_license_default_set (const ll_uri_t license_uri)
ll_uri_t ll_license_default_get (void)
ll_uri_t ll_read (ll_filename_t filename, const ll_uri_t predicate)
ll_uri_t ll_module_read (ll_filename_t filename, const ll_uri_t predicate, ll_module_t module)
unsigned int ll_modules_count_available ()
LLModuleDescll_module_search (ll_filename_t filename, const char *predicate, LLModuleSearchState *state)
int ll_write (ll_filename_t filename, const ll_uri_t predicate, ll_uri_t value)
int ll_module_write (ll_filename_t filename, ll_uri_t predicate, const ll_uri_t license_uri, ll_module_t module)
ll_license_chooser_tll_new_license_chooser (const ll_juris_t jurisdiction, const char **attributes)
void ll_free_license_chooser (ll_license_chooser_t *choo)
const ll_license_list_tll_get_licenses_from_flags (ll_license_chooser_t *choo, int permits, int requires, int prohibits)
void ll_get_license_flags (ll_license_chooser_t *choo, const char *license, int *permits, int *requires, int *prohibits)
int ll_attribute_flag (ll_license_chooser_t *choo, const char *attr)
char ** ll_new_list (int length)
void ll_free_list (char **list)
int ll_list_contains (char **haystack, char *needle)
int ll_list_index (char **haystack, char *needle)
int ll_list_length (char **list)
char * ll_list_mode (char **list, char *ignore)
void ll_list_print (char **lptr)
int ll_int_arrays_equal (int *ra1, int *ra2)
int ll_lists_equal (char **list_one, char **list_two)

Variables

LLModuleDesc ** _ll_module_list


Define Documentation

#define LL_ATTRIBUTION   "http://creativecommons.org/ns#Attribution"

The LL_ATTRIBUTION string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

credit be given to copyright holder and/or author

#define LL_COMMERCIAL_USE   "http://creativecommons.org/ns#CommercialUse"

The LL_COMMERCIAL_USE string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

exercising rights for commercial purposes

#define LL_CREATOR   "http://purl.org/dc/elements/1.1/creator"

The LL_CREATOR string can be passed to the ll_get_attribute function to obtain a license's creator.

Example: "Creative Commons"

#define LL_DERIVATIVE_WORKS   "http://creativecommons.org/ns#DerivativeWorks"

The LL_DERIVATIVE_WORKS string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

creation and distribution of derivative works

#define LL_DIR_SEPARATOR   '/'

#define LL_DIR_SEPARATOR_S   "/"

#define LL_DISTRIBUTION   "http://creativecommons.org/ns#Distribution"

The LL_DISTRIBUTION string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

distribution, public display, and publicly performance

#define LL_E_MODULE_WRITE_FAIL   1

A constant indicating that module writing failed.

#define LL_HIGH_INCOME_NATION_USE   "http://creativecommons.org/ns#HighIncomeNationUse"

The LL_HIGH_INCOME_NATION_USE string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS functions.

use in a non-developing country

#define LL_JURISDICTION   "http://creativecommons.org/ns#jurisdiction"

The LL_JURISDICTION string can be passed to the ll_get_attribute function to obtain a license's jurisdiction. The ll_get_jurisdiction function does this very thing.

#define LL_LICENSE   "http://creativecommons.org/ns#license"

The LL_LICENSE attribute is the URI of a license that permits some sharing of this work.

#define LL_MODULE_DEFINE ( name,
description,
version,
features,
supported_predicates,
mime_types,
init,
read,
write,
shutdown   ) 

Value:

LL_MODULE_EXPORT LLModuleDesc ll_module_desc = {        \
name,                                                   \
description,                                            \
version,                                                \
features,                                               \
supported_predicates,                                   \
mime_types,                                             \
init,                                                   \
read,                                                   \
write,                                                  \
shutdown ,                                              \
0                                                       \
};

#define LL_MODULE_EXPORT

#define LL_MORE_PERMISSIONS   "http://creativecommons.org/ns#morePermissions"

The LL_MORE_PERMISSIONS attribute is the URI of a web page indicating how to get more permissions than the embedded license.

#define LL_NAME   "http://purl.org/dc/elements/1.1/title"

The LL_NAME string can be passed to the ll_get_attribute function to obtain a license's name. Example: "Creative Commons Attribution 3.0 Unported"

#define LL_NOTICE   "http://creativecommons.org/ns#Notice"

The LL_NOTICE string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

copyright and license notices be kept intact

#define LL_PERMITS   "http://creativecommons.org/ns#permits"

The LL_PERMITS string can be passed to the ll_get_attribute function to obtain a list of the rights permitted by a license. The LL_PERMITS function does this very thing.

#define LL_PREDICATE_ANY   "?predicate"

LL_PREDICATE_ANY is a string meaning that a module can store any URI as a predicate.

#define LL_PROHIBITS   "http://creativecommons.org/ns#prohibits"

The LL_PROHIBITS string can be passed to the ll_get_attribute function to obtain a list of the rights prohibited by a license. The LL_PROHIBITS function does this very thing.

#define LL_REPLACED_BY   "http://purl.org/dc/terms/isReplacedBy"

The LL_REPLACED_BY string can be passed to the ll_get_attribute function to obtain a license's successor.

#define LL_REPRODUCTION   "http://creativecommons.org/ns#Reproduction"

The LL_REPRODUCTION string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

making multiple copies

#define LL_REQUIRES   "http://creativecommons.org/ns#requires"

The LL_REQUIRES string can be passed to the ll_get_attribute function to obtain a list of the rights required by a license. The LL_REQUIRES function does this very thing.

#define LL_SHARE_ALIKE   "http://creativecommons.org/ns#ShareAlike"

The LL_SHARE_ALIKE string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

derivative works be licensed under the same terms as the original work

#define LL_SHARING   "http://creativecommons.org/ns#Sharing"

The LL_SHARING string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

noncommercial distribution, permits commercial derivatives, but only non-commercial distribution

#define LL_SOURCE_CODE   "http://creativecommons.org/ns#SourceCode"

The LL_SOURCE_CODE string may be returned by the LL_PERMITS, LL_REQUIRES and LL_PROHIBITS attributes.

source code (the preferred form for making modifications) must be provided for all derivative works

#define LL_UNSPECIFIED   0

#define LL_VERSION   "http://purl.org/dc/terms/hasVersion"

The LL_VERSION string can be passed to the ll_get_attribute function to obtain a license's version. The LL_VERSION function does this very thing.

#define LL_WEBSTATEMENT   "http://ns.adobe.com/xap/1.0/rights/WebStatement"

The LL_WEBSTATEMENT attribute is the URL to a web page making a license assertion about a document. See http://wiki.creativecommons.org/Embedded_Metadata for a comic!


Typedef Documentation

typedef char* ll_attribute_t

typedef enum ll_features ll_features

typedef char* ll_filename_t

typedef char* ll_juris_t

typedef struct _ll_license_chooser_t ll_license_chooser_t

This is an opaque type, used to remember the results of a license query.

typedef char* ll_locale_t

typedef char* ll_mime_type_t

typedef char* ll_module_t

typedef char* ll_symbol_t

typedef char* ll_uri_t

typedef int* ll_version_t

typedef struct _LLModuleDesc LLModuleDesc

typedef void(* LLModuleInitFunc)(void)

typedef char*(* LLModuleReadFunc)(const char *, const char *)

typedef void(* LLModuleShutdownFunc)(void)

typedef int(* LLModuleWriteFunc)(const char *, const char *, const char *)


Enumeration Type Documentation

Enumerator:
LL_FEATURES_NONE 
LL_FEATURES_EMBED 


Function Documentation

int _ll_contains_token ( const char **  haystack,
const char *  needle 
)

The _ll_contains_token function is used to look for a given token in a string.

Parameters:
haystack The string to be searched
needle The string to be searched for
Returns:
non-zero (true) if the needle is found in the haystack, zero (false) if not found.

unsigned int _ll_modules_count_available (  ) 

Calculates the number of modules available to us.

Returns:
int # of modules available...

int ll_attribute_flag ( ll_license_chooser_t choo,
const char *  attr 
)

The ll_attribute_flag function is used to obtain the bit map bit corresponding to the named attribute in the ll_free_license_chooser result. This is used to query the result for licenses.

Parameters:
choo The results from an earlier ll_new_license_chooser call.
attr The name of the attribute
Returns:
integer with single bit set

ll_uri_t ll_filename_to_uri ( const ll_filename_t  filename  ) 

The ll_filename_to_uri function is used to convert a filename string to a URI. The last four characters (the 3 character extension and the dot, assuming ".xmp") are ignored. Underscore characters (_) are mapped to slash (/). It is happed to a http:// style URI, it is not mapped into a file:/// style URI.

Given a license RDF file found on disk, this is used to repopulate what URI the RDF refers to.

Parameters:
filename The file name to be converted to a URI.
Returns:
a new string. use free() when you are done with it.

void ll_free_license_chooser ( ll_license_chooser_t choo  ) 

The ll_free_license_chooser function is used to release the resources used by the result of a ll_new_license_chooser function call.

Parameters:
choo the license chooser results to be released

void ll_free_list ( char **  list  ) 

The ll_free_list function is used to release memory used by a string list created by the function.

Parameters:
list The list of strings to be free()ed. Nothing bad happens if it is NULL. Very bad things happen if you call it too many times for the same list.

ll_uri_t* ll_get_all_licenses ( void   ) 

The ll_get_all_licenses function is used to obtain a list of all general license URIs available for new works.

Returns:
a NULL terminated list of strings. Use ll_free_list when you are done with it.

char** ll_get_attribute ( ll_uri_t  license_uri,
const char *  attribute_uri,
int  locale 
)

The ll_get_attribute function is used to obtain the names of all attributes of the given license which have the given URI.

Parameters:
license_uri The license of interest
attribute_uri The attribute URI of interest (e.g. LL_PERMITS)
locale non-zero if $LANG to be used, zero if not relevant
Returns:
a NULL terminated list of strings, use ll_free_list when you are done with it.

ll_module_t* ll_get_config_modules ( void   ) 

The ll_get_config_modules function may be used to obtain a list of available configuration modules.

Returns:
a NULL terminated list of config module filenames (strings). Use ll_free_list when you are done with it.

char* ll_get_first ( char **  list  ) 

Simple function to get the first element of a list FIXME: Using this directly may lead to memory leaks!

Parameters:
list 
Returns:
The first element of the list passed in, a char *.

ll_module_t* ll_get_io_modules ( void   ) 

The ll_get_io_modules function may be used to obtain a list of available I/O modules.

Returns:
a NULL terminated list of I/O module filenames (strings). Use ll_free_list when you are done with it.
Note:
The ll_init_modules function shall be called before this function.

ll_juris_t* ll_get_jurisdictions ( void   ) 

The ll_get_jurisdictions function is used to obtain a list of all jurisdiction codes.

Returns:
a NULL terminated list of strings containing available juristriction codes (as opposed to all possible jurisdiction codes). Use ll_free_list when you are done with it.

void ll_get_license_flags ( ll_license_chooser_t choo,
const char *  license,
int *  permits,
int *  requires,
int *  prohibits 
)

Given a license chooser object and a license, this function determines what "permits", "requires", and "prohibits" arguments to the chooser would be necessary to find the license.

If the license cannot be found by the chooser, the flags are set to -1.

Only useful for debugging, as far as I know.

Parameters:
choo A chooser created by ll_new_license_chooser.
license The license to explain how to find.
permits (modified) set to the permits value necessary to find this license
requires (modified) set to the requires value necessary to find this license
prohibits (modified) set to the prohibits value necessary to find this license

ll_uri_t* ll_get_licenses ( const ll_juris_t  justrisdiction  ) 

The ll_get_licenses function is used to obtain a list of all general licenses in a family.

Parameters:
justrisdiction A string naming the jurisdiction code of interest.
Returns:
a NULL terminated list of strings containing URIs of licenses. Use ll_free_list when you are done with it.

const ll_license_list_t* ll_get_licenses_from_flags ( ll_license_chooser_t choo,
int  permits,
int  requires,
int  prohibits 
)

The ll_get_licenses_from_flags function is used to extract a linked-list of matching licenses from the result returned by a call to ll_new_license_chooser. The flags given should be OR'ed together and come from the result of ll_attribute_flag()

Parameters:
choo The results from an earlier ll_new_license_chooser call.
permits bit mask
requires bit mask
prohibits bit mask
Returns:
list of URIs of compatible licenses

void* ll_get_module_symbol ( const char *  directory,
ll_module_t  module,
ll_symbol_t  symbol 
)

The ll_get_module_symbol function may be used to obtain a pointer to a symbol in a module. Usually this will be a function, but it could be data.

Parameters:
directory The directory containing the modules.
module The name of the module of interest
symbol The name of the symbol of interest
Returns:
the NULL pointer if the symbol does not exist, or a pointer to the symbol in dynamic memory.
Note:
This function will exit with a fatal error if it is not possble to dlopen the module.

int ll_init ( void   ) 

The ll_init function is used to prepare the liblicense library for use. This function is to be called before any other use of the library.

Returns:
0 on success, 1 if there was a problem (printed on stderr)

void ll_init_modules ( void   ) 

The ll_init_modules function is used to initialize the I/O module system before any of the module handling functions are called.

It is safe to call this function more than once, but this does not increase a reference count, so the first call to ll_stop_modules will stop all modules.

Note:
If an error occurs reading the modules directory, an error will be reported on stderr, and this function will return without doing anything.

Clients of this API should never need to call this function directly, as the ll_init functions calls it for you.

int ll_int_arrays_equal ( int *  ra1,
int *  ra2 
)

The ll_int_arrays_equal function is used to check if two arrays of integers are equivalent. It assumes:

  • that the pointers are not NULL
  • that the first element of the array is the length of the array (not including the size) For example, this is valid: {2, 1, 2}

Parameters:
ra1 Pointer to the first thing to compare
ra2 Pointer to the second thing to compare

char* ll_jurisdiction_name ( const char *  jurisdiction  ) 

The ll_jurisdiction_name functions is used to map a jusrisdiction code (two letter country code, usually) to a jusrisdiction name (country name).

Parameters:
jurisdiction The justisdiction code of interest
Returns:
a string containing the jurisdiction name (country name), or NULL on error. Use free when you are done with it.

ll_uri_t ll_license_default_get ( void   ) 

The ll_license_default_get function is used to obtain the URI of the default license.

Returns:
NULL if there is no default, or a pointer to a new string. Use free() when you are done with it.

int ll_license_default_set ( const ll_uri_t  license_uri  ) 

The ll_license_default_set function is used to set a specific license as the default license.

Parameters:
license_uri the URL of the license to be remembered as the default license
Returns:
1 on succes, or 0 on failure

void ll_license_print_info ( ll_uri_t  license_uri  ) 

The ll_license_print_info function is used to print all available details of a license on the standard output.

Parameters:
license_uri The URI of the license who's details are to be printed.

int ll_list_contains ( char **  haystack,
char *  needle 
)

The ll_list_contains function is used to examine a list of strings to determine whether or not it contains a specific string.

Parameters:
haystack The list of strings to be searched
needle The string being searched for.
Returns:
false if haystack is NULL, false if needle is NULL, false if the needle is not present in the haystack, true only if the needle is present in the haystack,

int ll_list_index ( char **  haystack,
char *  needle 
)

The ll_list_index function is used to determine the index of a string in a list of strings.

Parameters:
haystack The list of strings to be searched Must not be NULL.
needle The string being searched for. Must not be NULL.
Returns:
the index of the needle within the haystack, or -1 if not present at all

int ll_list_length ( char **  list  ) 

The ll_list_length function is used to determine the length of a list of strings.

Parameters:
list The list of strings to measure. Must not be NULL.
Returns:
The number of strings in the list.

char* ll_list_mode ( char **  list,
char *  ignore 
)

The ll_list_mode function is used to determine the string which appears most often in the list.

Parameters:
list The list of strings to obtain the commonest string from Must not be NULL.
ignore string value to ignore. Must not be NULL.
Returns:
The commonest string (one of the instances). It has not been copied, so do not free() it.

void ll_list_print ( char **  lptr  ) 

The ll_list_print function is used to print a list of strings to the standard output. If lptr is NULL, "(null)" will be printed, otherwise the list contents will be printed within square brackets. Each string will be printed in single quotes.

Parameters:
lptr pointer to the list to be printed

int ll_lists_equal ( char **  list_one,
char **  list_two 
)

The ll_lists_equal function is used to check if two arrays of char* elements are equivalent. It assumes:

  • that the pointers are not NULL
  • that the lists end in a NULL For example, this is valid: {"your", "mom", NULL}

Parameters:
list_one Pointer to the first thing to compare
list_two Pointer to the second thing to compare

int ll_module_init ( const char *  directory,
ll_module_t  module 
)

The ll_module_init function may be used to load a module and call its "init" function with no arguments. If the module does not have an "init" symbol, nothing is called, but the module is still dlopen()ed. No checks are made that the "init" symbol is a functions (and not, say, a variable) and no checks are made that the function takes no arguments.

Each successfull call must be balanced by a ll_module_shutdown call when you are done with the module.

Parameters:
directory The directory containing the modules.
module The name of the module of interest
Returns:
0 if the module can't be opened with dlopen, 1 if it can.

ll_uri_t ll_module_read ( ll_filename_t  filename,
const ll_uri_t  predicate,
ll_module_t  module 
)

The ll_module_read function may be used to obtain the URI of the license of the given file, as determined by the named module.

Parameters:
filename The name of the file for which the license is desired
predicate Read this predicate from the file. NULL is NOT accepted. If you are unsure, you should ask for the license of the file with the LL_LICENSE predicate.
module The name of the module to scan the file with
Returns:
a string containing the URI of the license corresponding to the file. CHECKME: Probably could also return NULL, just like ll_read().
Note:
The ll_init_modules function shall be called before this function.

LLModuleDesc* ll_module_search ( ll_filename_t  filename,
const char *  predicate,
LLModuleSearchState state 
)

LLModuleSearchState state = {0}; ll_module_for_file("/your/mom/music.mp3", LL_LICENSE, &state); modifies a LLModuleSearchState struct passed in so that the search can be resumed (without index, searching would be O(N^2)

Parameters:
filename The filename to search for. If NULL, then get every module.
predicate Return only modules that support this predicate. Use NULL if you want to find all modules independent of which predicate they support. Using LL_PREDICATE_ANY will actually search for modules that literally support any predicate.
Returns:
LLModuleDesc for the currently-found module If that is NULL, there are no more matching modules.

int ll_module_shutdown ( const char *  directory,
ll_module_t  module 
)

The ll_module_shutdown function may be used to call the shutdown symbol (if it exists) of the module and then unloads the module. No checks are made that the "shutdown" symbol is a function (and not, say, a variable) and no checks are made that the function takes no arguments.

Parameters:
directory The directory containing the modules.
module The name of the module of interest
Returns:
-1 on error (the module cannot be dlopen()ed), 0 on success

int ll_module_write ( ll_filename_t  filename,
ll_uri_t  predicate,
const ll_uri_t  license_uri,
ll_module_t  module 
)

The ll_module write function is used to write the given license to the given file using the given module.

Parameters:
filename The name of the file the license is about
predicate The exact predicate being stored (NULL is not okay)
value The value to store (typically a URL/URI for a license)
module The name of the module to use to write the license to the file.
Returns:
-1 if no embedders are available for this file type; 0 if all available embedders failed; 1 on success
Note:
The ll_init_modules function shall be called before this function.

unsigned int ll_modules_count_available (  ) 

Calculates the number of modules available to us.

Returns:
int # of modules available...

ll_license_chooser_t* ll_new_license_chooser ( const ll_juris_t  jurisdiction,
const char **  attributes 
)

The ll_new_license_chooser function is used to find a suitable license given a list of license attributes.

Parameters:
jurisdiction The two letter country code of the jurisdiction of interest
attributes a NULL terminated list of attribute names
Returns:
an opaque pointer to a result. Free with ll_free_license_chooser when you are done with it.

char** ll_new_list ( int  length  ) 

The ll_new_list function is used to allocate a list large enough to hold the given number of strings. It will be created empty.

When you add strings to the list, make sure you use the strdup() function, or any other method which directly or indirectly uses malloc. This is because the ll_free_list function will pass it to free().

Parameters:
length the size of the new list (>= 0)
Returns:
a ponter to the new list. Use ll_free_list when you are done with it.

ll_version_t ll_parse_version ( const char *  version  ) 

The ll_parse_version function is used to parse a version string into a heap-allocated array of integers.

Typically this follows a call to ll_get_attribute() requesting the LL_VERSION attribute.

Parameters:
version The version number as a string
Returns:
an array of integers representing each division. The first element of the array specifies the number of version divisions that follow, and the rest are the actual version numbers. Use free() when you are done with it.

void ll_print_module_info ( void   ) 

The ll_print_module_info function is used to print a human readable summary of all available I/O modules on the standard output.

Note:
The ll_init_modules function shall be called before this function.

ll_uri_t ll_read ( ll_filename_t  filename,
const ll_uri_t  predicate 
)

The ll_read function may be used to obtain the URI of the license of the given file. All available modules will be tried against the file.

Parameters:
filename The name of the file for which the license is desired.
predicate Read this predicate from the file. NULL is NOT accepted. If you are unsure, you should ask for the LL_LICENSE predicate.
Returns:
NULL if the file cannot be read, or no license can be found; otherwise a string containing the URI of the license corresponding to the file. (sort of: it actually returns the license with the highest count)
Note:
The ll_init_modules function shall be called before this function.

int ll_stop ( void   ) 

The ll_stop function is used to release all resources held by the library. It must be used after all uses of the library are completed... there may be writes and updates to perform before the program completes.

Returns:
0 on success

void ll_stop_modules ( void   ) 

The ll_stop_modules function is used to finalize the I/O module system after the last use of the module system has completed.

It is mostly safe to call this function more than once. See the note on ll_init_modules for more information.

Note:
Clients of this API should never need to call this function directly, as the ll_stop functions calls it for you.

ll_filename_t ll_uri_to_filename ( const ll_uri_t  uri  ) 

The ll_uri_to_filename function is used to convert a URI string to a filename. The http:// prefix is removed, and a ".rdf" extension is added. The slash (/) characters are mapped to underscore (_) characters.

Given a license URI we need to store or read on disk, this is used to determine what filename to save the RDF as or where to read it from.

Parameters:
uri The uri to be converted
Returns:
a new string. Use free() when you are done with it.
Note:
this function and the ll_filename_to_uri function are not completely symmetric. Don't expect strcmp(ll_uri_to_filename(ll_filename_to_uri(x)), x) == 0 and do not expect strcmp(ll_filename_to_uri(ll_uri_to_filename(x)), x) == 0

int ll_verify_uri ( const ll_uri_t  license_uri  ) 

The ll_verify_uri function is used to determine whether or not the given uri is recognized by the system.

Parameters:
license_uri The URI of the license of interest
Returns:
1 if recognized, 0 if not

int ll_write ( ll_filename_t  filename,
const ll_uri_t  predicate,
ll_uri_t  value 
)

The ll_write function is used to write the given license to the given file using all applicable modules.

It first attempts to embed the license into the file, it only writes to external locations if it cannot embed the license using any module.

Parameters:
filename The name of the file the license is about
predicate The exact predicate being stored (NULL is not okay)
value The value to store (typically a URL/URI for a license)
Returns:
-1 if no embedders are available for this file type; 0 if all available embedders failed; 1 on success
Note:
The ll_init_modules function shall be called before this function.


Variable Documentation


Generated on Mon May 4 16:03:19 2009 for LibLicense by  doxygen 1.5.6