librazor/razor.h.in
author J. Ali Harlow <ali@juiblex.co.uk>
Thu Jul 07 15:18:02 2016 +0100 (2016-07-07)
changeset 480 18c1225cfa1b
parent 477 6ba4c0f3c9d1
child 483 8087224f30c4
permissions -rw-r--r--
Release 0.6.3.100
     1 /*
     2  * Copyright (C) 2008  Kristian Høgsberg <krh@redhat.com>
     3  * Copyright (C) 2008  Red Hat, Inc
     4  * Copyright (C) 2009, 2011, 2012, 2014, 2016  J. Ali Harlow <ali@juiblex.co.uk>
     5  *
     6  * This program is free software; you can redistribute it and/or modify
     7  * it under the terms of the GNU General Public License as published by
     8  * the Free Software Foundation; either version 2 of the License, or
     9  * (at your option) any later version.
    10  *
    11  * This program is distributed in the hope that it will be useful,
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  * GNU General Public License for more details.
    15  *
    16  * You should have received a copy of the GNU General Public License along
    17  * with this program; if not, write to the Free Software Foundation, Inc.,
    18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
    19  */
    20 
    21 #ifndef _RAZOR_H_
    22 #define _RAZOR_H_
    23 
    24 #include <stdio.h>
    25 #include <stdint.h>
    26 #include <sys/stat.h>
    27 
    28 /* GCC extensions */
    29 #if defined(__GNUC__)
    30 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
    31 #define RAZOR_MALLOC __attribute__((__malloc__))
    32 #else
    33 #define RAZOR_MALLOC
    34 #endif
    35 #if __GNUC__ >= 4
    36 #define RAZOR_NULL_TERMINATED __attribute__ ((__sentinel__))
    37 #else
    38 #define RAZOR_NULL_TERMINATED
    39 #endif
    40 #endif	/* __GNUC__ */
    41 
    42 enum razor_section_type {
    43 	RAZOR_SECTION_MAIN = 0x01,
    44 	RAZOR_SECTION_DETAILS = 0x02,
    45 	RAZOR_SECTION_FILES = 0x04,
    46 	RAZOR_SECTION_ALL = 0x07
    47 };
    48 
    49 enum razor_stage_type {
    50 	RAZOR_STAGE_SCRIPTS_PRE = 0x1,
    51 	RAZOR_STAGE_FILES = 0x2,
    52 	RAZOR_STAGE_SCRIPTS_POST = 0x4,
    53 	RAZOR_STAGE_SCRIPTS = 0x5,
    54 	RAZOR_STAGE_ALL = 0x7
    55 };
    56 
    57 enum razor_detail_type {
    58 	RAZOR_DETAIL_LAST = 0,	/* the sentinel */
    59 	RAZOR_DETAIL_NAME,
    60 	RAZOR_DETAIL_VERSION,
    61 	RAZOR_DETAIL_ARCH,
    62 	RAZOR_DETAIL_SUMMARY,
    63 	RAZOR_DETAIL_DESCRIPTION,
    64 	RAZOR_DETAIL_URL,
    65 	RAZOR_DETAIL_LICENSE,
    66 	RAZOR_DETAIL_PREUNPROG,
    67 	RAZOR_DETAIL_PREUN,
    68 	RAZOR_DETAIL_POSTUNPROG,
    69 	RAZOR_DETAIL_POSTUN,
    70 	RAZOR_DETAIL_PREFIXES
    71 };
    72 
    73 enum razor_property_flags {
    74 	RAZOR_PROPERTY_LESS		= 1 << 0,
    75 	RAZOR_PROPERTY_GREATER		= 1 << 1,
    76 	RAZOR_PROPERTY_EQUAL		= 1 << 2,
    77 	RAZOR_PROPERTY_RELATION_MASK	=
    78 		RAZOR_PROPERTY_LESS |
    79 		RAZOR_PROPERTY_GREATER |
    80 		RAZOR_PROPERTY_EQUAL,
    81 
    82 	RAZOR_PROPERTY_REQUIRES		= 0 << 3,
    83 	RAZOR_PROPERTY_PROVIDES		= 1 << 3,
    84 	RAZOR_PROPERTY_CONFLICTS	= 2 << 3,
    85 	RAZOR_PROPERTY_OBSOLETES	= 3 << 3,
    86 	RAZOR_PROPERTY_TYPE_MASK	= 3 << 3,
    87 		
    88 	RAZOR_PROPERTY_PRE		= 1 << 5,
    89 	RAZOR_PROPERTY_POST		= 1 << 6,
    90 	RAZOR_PROPERTY_PREUN		= 1 << 7,
    91 	RAZOR_PROPERTY_POSTUN		= 1 << 8,
    92 	RAZOR_PROPERTY_SCRIPT_MASK	=
    93 		RAZOR_PROPERTY_PRE |
    94 		RAZOR_PROPERTY_POST |
    95 		RAZOR_PROPERTY_PREUN |
    96 		RAZOR_PROPERTY_POSTUN
    97 };
    98 
    99 enum razor_set_flags {
   100 	/*
   101 	 * Create a private copy of the razor set such that changes made
   102 	 * to the underlying file are not visible in the razor set.
   103 	 * If this flag is not set then the caller must ensure that the
   104 	 * underlying file (if any) is not changed.
   105 	 */
   106 	RAZOR_SET_PRIVATE		= 1 << 0,
   107 };
   108 
   109 /**
   110  * SECTION:error
   111  * @title: Error reporting
   112  * @short_description: A system for reporting errors.
   113  *
   114  * This object represents an error condition.
   115  */
   116 struct razor_error;
   117 
   118 struct razor_error *razor_error_new_str(int domain, int code,
   119 					const char *object, const char *str);
   120 struct razor_error *razor_error_dup(struct razor_error *src,
   121 				    const char *summary);
   122 
   123 #define razor_set_error(error, domain, code, object, str) \
   124 	if (error) \
   125 		*(error) = razor_error_new_str(domain, code, object, str); \
   126 	else
   127 
   128 #define razor_propagate_error(dest, src, summary) \
   129 	if (dest) \
   130 		*(dest) = razor_error_dup(src, summary); \
   131 	else
   132 
   133 #define razor_error_matches(error, domain, code) \
   134 	((error) && razor_error_get_domain(error) == (domain) && \
   135 	 razor_error_get_code(error) == (code))
   136 
   137 #define RAZOR_ERROR_DOMAIN(i1,i2,i3,c) \
   138 	(((i1)&0xff)<<24|((i2)&0xff)<<16|((i3)&0xff)<<8|(c)&0xff)
   139 
   140 #define RAZOR_GENERAL_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',0)
   141 #define RAZOR_POSIX_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',1)
   142 #define RAZOR_MSWIN_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',2)
   143 #define RAZOR_ZLIB_ERROR	RAZOR_ERROR_DOMAIN('R','z','r',3)
   144 
   145 enum razor_general_error {
   146 	RAZOR_GENERAL_ERROR_FAILED,
   147 	RAZOR_GENERAL_ERROR_DATABASE_CORRUPTED,
   148 	RAZOR_GENERAL_ERROR_DATABASE_INCOMPATIBLE,
   149 	RAZOR_GENERAL_ERROR_DATABASE_EXISTS,
   150 	RAZOR_GENERAL_ERROR_DATABASE_LOCKED,
   151 	RAZOR_GENERAL_ERROR_RPM_UNSUPPORTED,
   152 	RAZOR_GENERAL_ERROR_UNSUPPORTED_URI,
   153 	RAZOR_GENERAL_ERROR_BAD_URI,
   154 };
   155 
   156 int razor_error_get_domain(struct razor_error *error);
   157 int razor_error_get_code(struct razor_error *error);
   158 const char *razor_error_get_object(struct razor_error *error);
   159 const char *razor_error_get_primary_text(struct razor_error *error);
   160 const char *razor_error_get_secondary_text(struct razor_error *error);
   161 const char *razor_error_get_msg(struct razor_error *error);
   162 void razor_error_free(struct razor_error *error);
   163 
   164 /**
   165  * SECTION:atomic
   166  * @title: Atomic transactions
   167  * @short_description: File-based transactions that shouldn't half-succeed
   168  *
   169  * This is a helper object for issuing a sequence of file-based actions
   170  * that should either all succeed or all fail.
   171  *
   172  * Note that currently only Windows 7 has a native implementation and that
   173  * while the emulated fallback implementation attempts to rollback the
   174  * transaction if it fails, this is not guaranteed to succeed and that
   175  * the transaction is held in core (and thus vulnernable to program crashes,
   176  * power loss, etc.). This could (and should) be improved.
   177  *
   178  * Atomic transactions can be disabled via configure, in which case all
   179  * bets are off.
   180  **/
   181 
   182 @RAZOR_HAVE_ATOMIC_ROLLBACK@
   183 
   184 struct razor_atomic;
   185 
   186 struct razor_atomic *razor_atomic_open(const char *description);
   187 int razor_atomic_commit(struct razor_atomic *atomic);
   188 struct razor_error *razor_atomic_get_error(struct razor_atomic *atomic);
   189 const char *razor_atomic_get_error_msg(struct razor_atomic *atomic);
   190 void razor_atomic_destroy(struct razor_atomic *atomic);
   191 
   192 /**
   193  * razor_atomic_make_dirs
   194  * 
   195  * Create all sub-directories leading up to uri. We know root_uri exists
   196  * and is a dir, root_uri does not end in a '/', and uri either has a
   197  * leading '/' or (on MS-Windows only) root_uri is the empty string
   198  * and uri starts with drive (eg., "c:/windows").
   199  * Note: uri itself is not created, only the directory in which it
   200  * (would) exist.
   201  *
   202  * Returns: non-zero on error.
   203  **/
   204 int razor_atomic_make_dirs(struct razor_atomic *atomic, const char *root_uri,
   205   const char *uri);
   206 int razor_atomic_remove(struct razor_atomic *atomic, const char *path);
   207 int razor_atomic_rename_file(struct razor_atomic *atomic, const char *old_uri,
   208 			     const char *new_uri);
   209 
   210 /**
   211  * razor_atomic_create_dir
   212  * 
   213  * Create a directory, replacing any existing object at this path except
   214  * an existing directory (which is not counted as a error).
   215  *
   216  * Returns: non-zero on error.
   217  */
   218 int razor_atomic_create_dir(struct razor_atomic *atomic, const char *uri,
   219 			    mode_t mode);
   220 
   221 /**
   222  * razor_atomic_create_symlink
   223  * 
   224  * Create a symbolic link, replacing any existing object at this path except
   225  * a non-empty directory.
   226  *
   227  * Note: This function will always fail on platforms that don't support
   228  * symbolic links.
   229  *
   230  * Returns: non-zero on error.
   231  */
   232 int razor_atomic_create_symlink(struct razor_atomic *atomic, const char *target,
   233 				const char *uri);
   234 /**
   235  * razor_atomic_create_file
   236  * 
   237  * Create a file, replacing any existing object at this path except
   238  * a non-empty directory.
   239  *
   240  * Returns: A handle to be passed to razor_atomic_write() and
   241  * razor_atomic_close() or a negative value on error.
   242  */
   243 int razor_atomic_create_file(struct razor_atomic *atomic, const char *uri,
   244 			     mode_t mode);
   245 int razor_atomic_write(struct razor_atomic *atomic, int handle,
   246 		       const void *data, size_t size);
   247 int razor_atomic_close(struct razor_atomic *atomic, int handle);
   248 int razor_atomic_sync(struct razor_atomic *atomic, int handle);
   249 void razor_atomic_abort(struct razor_atomic *atomic, int domain, int code,
   250 			const char *error_msg);
   251 void
   252 razor_atomic_propagate_error(struct razor_atomic *atomic,
   253 			     struct razor_error *error, const char *summary);
   254 int razor_atomic_in_error_state(struct razor_atomic *atomic);
   255 
   256 /**
   257  * SECTION:set
   258  * @title: Package Set
   259  * @short_description: Represents a set of packages and their metadata.
   260  *
   261  * This object represents a set of packages, their dependency
   262  * information, the file lists and a number of other details.
   263  **/
   264 
   265 struct razor_set;
   266 struct razor_package;
   267 struct razor_property;
   268 
   269 #define RAZOR_HEADER_VERSION		2	/* Current version */
   270 #define RAZOR_HEADER_VERSION_MIN	1	/* Minimum version we support */
   271 
   272 /**
   273  * razor_set_create:
   274  * 
   275  * Create a new #razor_set object.
   276  * 
   277  * Returns: the new #razor_set object.
   278  **/
   279 struct razor_set *razor_set_create_without_root(void);
   280 struct razor_set *razor_set_create(void);
   281 struct razor_set *
   282 razor_set_open(const char *uri, enum razor_set_flags flags,
   283 	       struct razor_error **error);
   284 uint32_t razor_set_get_header_version(struct razor_set *set);
   285 int razor_set_set_header_version(struct razor_set *set,
   286 				 uint32_t header_version);
   287 void razor_set_unref(struct razor_set *set);
   288 struct razor_set *razor_set_ref(struct razor_set *set);
   289 void razor_set_write_to_handle(struct razor_set *set,
   290 			       struct razor_atomic *atomic, int handle,
   291 			       uint32_t section_mask);
   292 int razor_set_write(struct razor_set *set, struct razor_atomic *atomic,
   293 		    const char *uri, uint32_t setions);
   294 int
   295 razor_set_bind_sections(struct razor_set *set, const char *uri,
   296 			enum razor_set_flags flags, struct razor_error **error);
   297 
   298 void
   299 razor_package_get_details(struct razor_set *set,
   300 			  struct razor_package *package, ...);
   301 int
   302 razor_package_remove(struct razor_set *prev, struct razor_set *next,
   303 		     struct razor_atomic *atomic, struct razor_package *package,
   304 		     const char *root_uri, int install_count,
   305 		     enum razor_stage_type stage);
   306 
   307 /**
   308  * SECTION:iterator
   309  * @title: Iterators
   310  * @short_description: Objects for traversing packages or properties.
   311  *
   312  * The razor iterator objects provides a way to iterate through a set
   313  * of packages or properties.
   314  **/
   315 
   316 struct razor_package_iterator;
   317 
   318 /**
   319  * razor_package_iterator_create:
   320  * 
   321  * Create a new #razor_package_iterator object.
   322  * 
   323  * Returns: the new #razor_package_iterator object.
   324  **/
   325 
   326 struct razor_package_iterator *
   327 razor_package_iterator_create(struct razor_set *set);
   328 
   329 /**
   330  * razor_package_iterator_create_for_property:
   331  * 
   332  * Create a new #razor_package_iterator object for the packages that
   333  * own the given property.
   334  * 
   335  * Returns: the new #razor_package_iterator object.
   336  **/
   337 struct razor_package_iterator *
   338 razor_package_iterator_create_for_property(struct razor_set *set,
   339 					   struct razor_property *property);
   340 
   341 /**
   342  * razor_package_iterator_create_for_file:
   343  *
   344  * Create a new #razor_package_iterator object for the packages that
   345  * contain the given file name.
   346  *
   347  * Returns: the new #razor_package_iterator object.
   348  **/
   349 struct razor_package_iterator *
   350 razor_package_iterator_create_for_file(struct razor_set *set,
   351 				       const char *filename);
   352 
   353 int razor_package_iterator_next(struct razor_package_iterator *pi,
   354 				struct razor_package **package, ...);
   355 void razor_package_iterator_destroy(struct razor_package_iterator *pi);
   356 
   357 struct razor_package_query *
   358 razor_package_query_create(struct razor_set *set);
   359 void
   360 razor_package_query_add_package(struct razor_package_query *pq,
   361 				struct razor_package *p);
   362 void
   363 razor_package_query_add_iterator(struct razor_package_query *pq,
   364 				 struct razor_package_iterator *pi);
   365 struct razor_package_iterator *
   366 razor_package_query_finish(struct razor_package_query *pq);
   367 
   368 struct razor_property_iterator;
   369 struct razor_property_iterator *
   370 razor_property_iterator_create(struct razor_set *set,
   371 			       struct razor_package *package);
   372 int razor_property_iterator_next(struct razor_property_iterator *pi,
   373 				 struct razor_property **property,
   374 				 const char **name,
   375 				 uint32_t *flags,
   376 				 const char **version);
   377 void
   378 razor_property_iterator_destroy(struct razor_property_iterator *pi);
   379 
   380 struct razor_file_iterator;
   381 struct razor_file_iterator *
   382 razor_file_iterator_create(struct razor_set *set,
   383 			   struct razor_package *package, int post_order);
   384 int razor_file_iterator_next(struct razor_file_iterator *fi,
   385 			     const char **name);
   386 void razor_file_iterator_destroy(struct razor_file_iterator *fi);
   387 
   388 void razor_set_list_files(struct razor_set *set, const char *prefix);
   389 void razor_set_list_package_files(struct razor_set *set,
   390 				  struct razor_package *package);
   391 
   392 struct razor_string_iterator;
   393 struct razor_string_iterator *
   394 razor_install_prefix_iterator_create(struct razor_set *set,
   395 				     struct razor_package *package);
   396 int razor_string_iterator_next(struct razor_string_iterator *si,
   397 			       const char **string);
   398 void razor_string_iterator_destroy(struct razor_string_iterator *si);
   399 
   400 enum razor_diff_action {
   401 	RAZOR_DIFF_ACTION_ADD,
   402 	RAZOR_DIFF_ACTION_REMOVE,
   403 };
   404 
   405 typedef void (*razor_diff_callback_t)(enum razor_diff_action action,
   406 				      struct razor_package *package,
   407 				      const char *name,
   408 				      const char *version,
   409 				      const char *arch,
   410 				      void *data);
   411 
   412 void
   413 razor_set_diff(struct razor_set *set, struct razor_set *upstream,
   414 	       razor_diff_callback_t callback, void *data);
   415 
   416 struct razor_install_iterator;
   417 
   418 enum razor_install_action {
   419 	RAZOR_INSTALL_ACTION_ADD,
   420 	RAZOR_INSTALL_ACTION_REMOVE,
   421 	RAZOR_INSTALL_ACTION_COMMIT
   422 };
   423 
   424 struct razor_install_iterator *
   425 razor_set_create_install_iterator(struct razor_set *set,
   426 				  struct razor_set *next);
   427 
   428 int razor_install_iterator_next(struct razor_install_iterator *ii,
   429 				struct razor_package **package,
   430 				enum razor_install_action *action,
   431 				int *count);
   432 
   433 /**
   434  * razor_install_iterator_commit_set
   435  *
   436  * Immediately after razor_install_iterator_next() returns
   437  * RAZOR_INSTALL_ACTION_COMMIT, this function will return the razor_set
   438  * which should be committed.
   439  *
   440  * Returns: a new #razor_set object.
   441  **/
   442 struct razor_set *
   443 razor_install_iterator_commit_set(struct razor_install_iterator *ii);
   444 
   445 void razor_install_iterator_rewind(struct razor_install_iterator *ii);
   446 size_t razor_install_iterator_tell(struct razor_install_iterator *ii);
   447 size_t razor_install_iterator_seek(struct razor_install_iterator *ii,
   448 				   size_t pos);
   449 void razor_install_iterator_destroy(struct razor_install_iterator *ii);
   450 
   451 /**
   452  * SECTION:transaction
   453  * @title: Transaction
   454  * @short_description: Create a new package set by merging two or more sets.
   455  *
   456  * The razor transaction object provides a way to create a new package set
   457  * from packages from one or more other package sets.
   458  **/
   459 
   460 struct razor_rpm;
   461 
   462 struct razor_transaction *
   463 razor_transaction_create(struct razor_set *system, struct razor_set *upstream);
   464 void razor_transaction_install_package(struct razor_transaction *transaction,
   465 				       struct razor_package *package);
   466 void razor_transaction_remove_package(struct razor_transaction *transaction,
   467 				      struct razor_package *package);
   468 void razor_transaction_update_package(struct razor_transaction *trans,
   469 				      struct razor_package *package);
   470 void razor_transaction_fixup_package(struct razor_transaction *trans,
   471 				     struct razor_package *package,
   472 				     struct razor_rpm *rpm);
   473 void razor_transaction_update_all(struct razor_transaction *transaction);
   474 int razor_transaction_resolve(struct razor_transaction *trans);
   475 
   476 typedef void (*razor_unsatisfied_callback_t)(const char *requirement,
   477 					     struct razor_package *package,
   478 					     const char *name,
   479 					     const char *version,
   480 					     const char *arch,
   481 					     void *data);
   482 
   483 int razor_transaction_unsatisfied(struct razor_transaction *trans,
   484 				  razor_unsatisfied_callback_t callback,
   485 				  void *data);
   486 int razor_transaction_describe(struct razor_transaction *trans);
   487 struct razor_set *razor_transaction_commit(struct razor_transaction *trans);
   488 void razor_transaction_destroy(struct razor_transaction *trans);
   489 
   490 /* Temporary helper for test suite. */
   491 int razor_transaction_unsatisfied_property(struct razor_transaction *trans,
   492 					   const char *name,
   493 					   uint32_t flags,
   494 					   const char *version);
   495 
   496 /**
   497  * SECTION:rpm
   498  * @title: Razor RPM
   499  * @short_description: Operating on RPM files.
   500  *
   501  * Functions for open RPM files and extracting information and
   502  * installing or removing RPM files.
   503  **/
   504 
   505 struct razor_relocations;
   506 
   507 struct razor_relocations *razor_relocations_create(void);
   508 void razor_relocations_add(struct razor_relocations *relocations,
   509 			   const char *oldpath, const char *newpath);
   510 void razor_relocations_set_rpm(struct razor_relocations *relocations,
   511 			       struct razor_rpm *rpm);
   512 const char *razor_relocations_apply(struct razor_relocations *relocations,
   513 				    const char *path);
   514 void razor_relocations_destroy(struct razor_relocations *relocations);
   515 
   516 struct razor_rpm *razor_rpm_open(const char *uri, struct razor_error **error);
   517 void razor_rpm_get_details(struct razor_rpm *rpm, ...);
   518 void razor_rpm_set_relocations(struct razor_rpm *rpm,
   519 			       struct razor_relocations *relocations);
   520 int razor_rpm_install(struct razor_rpm *rpm, struct razor_atomic *atomic,
   521 		      const char *root_uri, int install_count,
   522 		      enum razor_stage_type stage);
   523 int razor_rpm_close(struct razor_rpm *rpm);
   524 
   525 /**
   526  * SECTION:importer
   527  * @title: Importer
   528  * @short_description: A mechanism for building #razor_set objects
   529  *
   530  * The %razor_importer is a helper object for building a razor set
   531  * from external sources, like yum metadata, the RPM database or RPM
   532  * files.
   533  *
   534  * The importer is a stateful object; it has the notion of a current
   535  * package, and the caller can provide meta data such as properties,
   536  * files and similiar for the package as it becomes available.  Once a
   537  * package is fully described, the next pacakge can begin.  When all
   538  * packages have been described to the importer, the importer will
   539  * create a new %razor_set with the specified packages.
   540  *
   541  * A typical use
   542  * of the importer will follow this template:
   543  * |[
   544  * importer = razor_importer_create();
   545  *
   546  * while ( /<!-- -->* more packages to import *<!-- -->/; ) {
   547  *   /<!-- -->* get name, version and arch of next package *<!-- -->/
   548  *   razor_importer_begin_package(importer, name, version, arch);
   549  *   razor_importer_add_details(importer, summary, description, url, license);
   550  *
   551  *   while ( /<!-- -->* more properties to add *<!-- -->/ )
   552  *     razor_importer_add_property(importer, name, flags, version);
   553  *
   554  *   while ( /<!-- -->* [more files to add *<!-- -->/ )
   555  *     razor_importer_add_file(importer, name);
   556  *
   557  *   razor_importer_finish_package(importer);
   558  * }
   559  *
   560  * return razor_importer_finish(importer);
   561  * ]|
   562  **/
   563 struct razor_importer;
   564 
   565 struct razor_importer *razor_importer_create(void);
   566 void razor_importer_destroy(struct razor_importer *importer);
   567 void razor_importer_begin_package(struct razor_importer *importer,
   568 				  const char *name,
   569 				  const char *version,
   570 				  const char *arch);
   571 void razor_importer_add_details(struct razor_importer *importer,
   572 				const char *summary,
   573 				const char *description,
   574 				const char *url,
   575 				const char *license);
   576 void razor_importer_add_script(struct razor_importer *importer,
   577 			       enum razor_property_flags script,
   578 			       const char *program,
   579 			       const char *body);
   580 void razor_importer_add_install_prefix(struct razor_importer *importer,
   581 				       const char *install_prefix);
   582 void razor_importer_add_property(struct razor_importer *importer,
   583 				 const char *name,
   584 				 uint32_t flags,
   585 				 const char *version);
   586 void razor_importer_add_file(struct razor_importer *importer,
   587 			     const char *name);
   588 void razor_importer_finish_package(struct razor_importer *importer);
   589 
   590 int razor_importer_add_rpm(struct razor_importer *importer,
   591 			   struct razor_rpm *rpm);
   592 
   593 struct razor_set *razor_importer_finish(struct razor_importer *importer);
   594 
   595 /**
   596  * SECTION:root
   597  * @title: Root
   598  * @short_description: Functions for accessing an install root.
   599  *
   600  * The #razor_root object encapsulate access to and locking of a razor
   601  * install root.
   602  **/
   603 struct razor_root;
   604 
   605 const char *razor_get_database_uri(void);
   606 void razor_set_database_uri(const char *database_uri);
   607 int razor_root_create(const char *root_uri, struct razor_error **error);
   608 struct razor_root *
   609 razor_root_open(const char *root_uri, struct razor_error **error);
   610 struct razor_set *
   611 razor_root_open_read_only(const char *root_uri, struct razor_error **error);
   612 struct razor_set *razor_root_get_system_set(struct razor_root *root);
   613 int razor_root_close(struct razor_root *root);
   614 int
   615 razor_root_update(struct razor_root *root, struct razor_set *next,
   616 		  struct razor_atomic *atomic);
   617 
   618 /**
   619  * SECTION:uri-io
   620  * @title: URI Input/Output
   621  * @short_description: Functions to support non-file URI handlers
   622  *
   623  * Libraries that want to support URIs other than file URIs (which razor
   624  * handles internally), can install their own URI handlers. Unsupported
   625  * virtual functions should be set to %NULL. A fallback URI handler (which
   626  * will be used if no scheme-specific handler is found) can be installed
   627  * by passing scheme as %NULL. Finally, URI handlers can be removed by
   628  * passing vtable as %NULL.
   629  **/
   630 
   631 struct razor_uri_vtable {
   632 	unsigned structure_size;
   633 	int (*mkdir)(const char *path, mode_t mode, struct razor_error **error);
   634 	int (*unlink)(const char *path, struct razor_error **error);
   635 	int (*open)(const char *path, int flags, mode_t mode,
   636 		    struct razor_error **error);
   637 	int (*move)(const char *path, const char *dest,
   638 		    struct razor_error **error);
   639 	void *(*get_contents)(const char *path, size_t *length, int _private,
   640 			      struct razor_error **error);
   641 	int (*free_contents)(void *addr, size_t length);
   642 	int (*is_directory)(const char *path, struct razor_error **error);
   643 	char *(*mkdtemp_near)(const char *path, const char *_template,
   644 			      struct razor_error **error);
   645 	void *(*opendir)(const char *path, struct razor_error **error);
   646 	char *(*readdir)(void *dir, struct razor_error **error);
   647 	int (*closedir)(void *dir, struct razor_error **error);
   648 };
   649 
   650 int razor_uri_mkdir(const char *uri, mode_t mode, struct razor_error **error);
   651 int razor_uri_unlink(const char *uri, struct razor_error **error);
   652 int razor_uri_open(const char *uri, int flags, mode_t mode,
   653 		   struct razor_error **error);
   654 int razor_uri_move(const char *uri, const char *dest,
   655 		   struct razor_error **error);
   656 int razor_uri_is_directory(const char *uri, struct razor_error **error);
   657 char *razor_uri_mkdtemp_near(const char *uri, const char *_template,
   658 			     struct razor_error **error) RAZOR_MALLOC;
   659 void *razor_uri_opendir(const char *uri, struct razor_error **error);
   660 char *razor_uri_readdir(void *dir, struct razor_error **error) RAZOR_MALLOC;
   661 int razor_uri_closedir(void *dir, struct razor_error **error);
   662 void *razor_uri_get_contents(const char *uri, size_t *length, int _private,
   663 			     struct razor_error **error);
   664 int razor_uri_free_contents(void *addr, size_t length);
   665 
   666 int razor_uri_set_vtable(const char *scheme, struct razor_uri_vtable *vtable,
   667 			 struct razor_error **error);
   668 
   669 /**
   670  * SECTION:misc
   671  * @title: Miscellaneous Functions
   672  * @short_description: Various helper functions
   673  *
   674  * Functions that doesn't fit anywhere else.
   675  **/
   676 
   677 const char *
   678 razor_property_relation_to_string(struct razor_property *p);
   679 const char *
   680 razor_property_type_to_string(struct razor_property *p);
   681 
   682 void razor_build_evr(char *evr_buf, int size, const char *epoch,
   683 		     const char *version, const char *release);
   684 int razor_versioncmp(const char *s1, const char *s2);
   685 
   686 void razor_disable_root_name_checks(int disable);
   687 
   688 void razor_set_lua_loader(const char *modname, void (*loader)());
   689 void (*razor_get_lua_loader(const char *modname))();
   690 
   691 char *razor_concat(const char *s, ...) RAZOR_MALLOC RAZOR_NULL_TERMINATED;
   692 
   693 char *razor_path_from_uri(const char *uri, struct razor_error **error)
   694       RAZOR_MALLOC;
   695 char *razor_path_to_uri(const char *path) RAZOR_MALLOC;
   696 char *razor_path_relative_to_uri(const char *uri, const char *path,
   697 				 struct razor_error **error) RAZOR_MALLOC;
   698 
   699 /* According to RFC 3986 § 5.2 */
   700 char *razor_resolve_relative_uri(const char *base_uri, const char *relative_uri,
   701 				 struct razor_error **error);
   702 
   703 const char *razor_system_arch(void);
   704 
   705 int razor_dump_database(FILE *fp, const char *root_uri, const char *filename,
   706 			struct razor_error **error);
   707 
   708 #endif /* _RAZOR_H_ */