Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=593841ff12744dd2fdb09bf123c851d340cce3b6
commit 593841ff12744dd2fdb09bf123c851d340cce3b6 Author: Michel Hermier <[email protected]> Date: Sat Apr 26 07:59:08 2014 +0200 libpacman: Compile as C++. diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e7ae6c..0ff449a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8) -PROJECT(PACMAN-G2 C) +PROJECT(PACMAN-G2 C CXX) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") @@ -19,6 +19,7 @@ SET(PM_VERSION_TEMP "0." ${PACMAN_G2_LIB_VERSION}) STRING(REPLACE ";" "" PM_VERSION ${PM_VERSION_TEMP}) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -std=c99 -Wall -D_GNU_SOURCE") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -std=c99 -Wall -D_GNU_SOURCE -fpermissive") OPTION(DISABLE_BINDINGS "disables all libpacman bindings" OFF) OPTION(DISABLE_TRANSLATIONS "disables all translations" OFF) diff --git a/lib/libpacman/CMakeLists.txt b/lib/libpacman/CMakeLists.txt index c783ccf..9268814 100644 --- a/lib/libpacman/CMakeLists.txt +++ b/lib/libpacman/CMakeLists.txt @@ -40,30 +40,30 @@ set(FLIB_SOURCES set(LIBPACMAN_SOURCES ${FLIB_SOURCES} - db/fakedb.c - db/localdb.c - db/localdb_files.c - db/syncdb.c - package/fpmpackage.c - package/packagecache.c - cache.c - config_parser.c - conflict.c - db.c - deps.c - error.c - group.c - handle.c - object.c - package.c - packages_transaction.c - pacman.c - server.c - sync.c - trans.c - trans_sysupgrade.c - util.c - versioncmp.c + db/fakedb.cpp + db/localdb.cpp + db/localdb_files.cpp + db/syncdb.cpp + package/fpmpackage.cpp + package/packagecache.cpp + cache.cpp + config_parser.cpp + conflict.cpp + db.cpp + deps.cpp + error.cpp + group.cpp + handle.cpp + object.cpp + package.cpp + packages_transaction.cpp + pacman.cpp + server.cpp + sync.cpp + trans.cpp + trans_sysupgrade.cpp + util.cpp + versioncmp.cpp ) include_directories (${PACMAN-G2_SOURCE_DIR}) diff --git a/lib/libpacman/cache.c b/lib/libpacman/cache.cpp similarity index 100% rename from lib/libpacman/cache.c rename to lib/libpacman/cache.cpp diff --git a/lib/libpacman/config_parser.c b/lib/libpacman/config_parser.cpp similarity index 100% rename from lib/libpacman/config_parser.c rename to lib/libpacman/config_parser.cpp diff --git a/lib/libpacman/conflict.c b/lib/libpacman/conflict.cpp similarity index 100% rename from lib/libpacman/conflict.c rename to lib/libpacman/conflict.cpp diff --git a/lib/libpacman/db.c b/lib/libpacman/db.cpp similarity index 100% rename from lib/libpacman/db.c rename to lib/libpacman/db.cpp diff --git a/lib/libpacman/db/fakedb.c b/lib/libpacman/db/fakedb.cpp similarity index 100% rename from lib/libpacman/db/fakedb.c rename to lib/libpacman/db/fakedb.cpp diff --git a/lib/libpacman/db/localdb.c b/lib/libpacman/db/localdb.cpp similarity index 99% rename from lib/libpacman/db/localdb.c rename to lib/libpacman/db/localdb.cpp index f7be7fa..31f4c1b 100644 --- a/lib/libpacman/db/localdb.c +++ b/lib/libpacman/db/localdb.cpp @@ -508,6 +508,7 @@ const pmdb_ops_t _pacman_localdb_ops = { .test = _pacman_localdb_test, .open = _pacman_localdb_open, .close = _pacman_localdb_close, + .gettimestamp = NULL, .rewind = _pacman_localdb_rewind, .readpkg = _pacman_localdb_readpkg, .scan = _pacman_localdb_scan, diff --git a/lib/libpacman/db/localdb.h b/lib/libpacman/db/localdb.h index 133802e..282b2dd 100644 --- a/lib/libpacman/db/localdb.h +++ b/lib/libpacman/db/localdb.h @@ -23,6 +23,7 @@ #include "db.h" +extern const pmdb_ops_t _pacman_localdb_ops; #endif /* _PACMAN_LOCALDB_H */ diff --git a/lib/libpacman/db/localdb_files.c b/lib/libpacman/db/localdb_files.cpp similarity index 100% rename from lib/libpacman/db/localdb_files.c rename to lib/libpacman/db/localdb_files.cpp diff --git a/lib/libpacman/db/syncdb.c b/lib/libpacman/db/syncdb.cpp similarity index 99% rename from lib/libpacman/db/syncdb.c rename to lib/libpacman/db/syncdb.cpp index 3b48e71..5cc6c64 100644 --- a/lib/libpacman/db/syncdb.c +++ b/lib/libpacman/db/syncdb.cpp @@ -355,6 +355,7 @@ const pmdb_ops_t _pacman_syncdb_ops = { .test = _pacman_syncdb_test, .open = _pacman_syncdb_open, .close = _pacman_syncdb_close, + .gettimestamp = NULL, .rewind = _pacman_syncdb_rewind, .readpkg = _pacman_syncdb_readpkg, .scan = _pacman_syncdb_scan, diff --git a/lib/libpacman/db/syncdb.h b/lib/libpacman/db/syncdb.h index 3456d76..c39367e 100644 --- a/lib/libpacman/db/syncdb.h +++ b/lib/libpacman/db/syncdb.h @@ -23,6 +23,7 @@ #include "db.h" +extern const pmdb_ops_t _pacman_syncdb_ops; int _pacman_syncdb_update(pmdb_t *db, int force); diff --git a/lib/libpacman/deps.c b/lib/libpacman/deps.cpp similarity index 99% rename from lib/libpacman/deps.c rename to lib/libpacman/deps.cpp index 55d95ab..1f1fc5b 100644 --- a/lib/libpacman/deps.c +++ b/lib/libpacman/deps.cpp @@ -751,6 +751,7 @@ int inList(pmlist_t *lst, char *lItem) { return 0; } +extern "C" { int pacman_output_generate(pmlist_t *targets, pmlist_t *dblist) { pmlist_t *found = NULL; pmlist_t *k = NULL, *j = NULL; @@ -795,5 +796,6 @@ int pacman_output_generate(pmlist_t *targets, pmlist_t *dblist) { printf("\n"); return 0; } +} /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/error.c b/lib/libpacman/error.cpp similarity index 100% rename from lib/libpacman/error.c rename to lib/libpacman/error.cpp diff --git a/lib/libpacman/fstring.h b/lib/libpacman/fstring.h index 86e9a61..d1f2789 100644 --- a/lib/libpacman/fstring.h +++ b/lib/libpacman/fstring.h @@ -25,6 +25,10 @@ #include "util/fcallback.h" +#ifdef __cplusplus +extern "C" { +#endif + char *f_basename(const char *path); char *f_dirname(const char *path); @@ -121,6 +125,9 @@ void f_str_visit(char *str, FStrVisitor *strvisitor) { int f_strmatcher_init(FStrMatcher *strmatcher, const char *pattern, int flags); int f_strmatcher_fini(FStrMatcher *strmatcher); +#ifdef __cplusplus +} +#endif #endif /* F_STRING_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/group.c b/lib/libpacman/group.cpp similarity index 100% rename from lib/libpacman/group.c rename to lib/libpacman/group.cpp diff --git a/lib/libpacman/handle.c b/lib/libpacman/handle.cpp similarity index 100% rename from lib/libpacman/handle.c rename to lib/libpacman/handle.cpp diff --git a/lib/libpacman/hash/md5.h b/lib/libpacman/hash/md5.h index 31d613e..02b0a62 100644 --- a/lib/libpacman/hash/md5.h +++ b/lib/libpacman/hash/md5.h @@ -23,6 +23,10 @@ These notices must be retained in any copies of any part of this documentation and/or software. */ +#ifdef __cplusplus +extern "C" { +#endif + /* POINTER defines a generic pointer type */ typedef unsigned char *POINTER; @@ -47,4 +51,8 @@ void _pacman_MD5Final(unsigned char [16], MD5_CTX *); char* _pacman_MDFile(char *); void _pacman_MDPrint(unsigned char [16]); +#ifdef __cplusplus +} +#endif + /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/io/archive.h b/lib/libpacman/io/archive.h index 8672f4e..9e25727 100644 --- a/lib/libpacman/io/archive.h +++ b/lib/libpacman/io/archive.h @@ -24,6 +24,10 @@ #include <archive.h> #include <archive_entry.h> +#ifdef __cplusplus +extern "C" { +#endif + enum __pmfiletype_t { PM_FILE_UNKNOWN = -1, PM_FILE_DB = 0, @@ -37,6 +41,9 @@ FILE *_pacman_archive_read_fropen(struct archive *a); int checkFile(pmfiletype_t fileType, char *file); int checkXZ(char *file); +#ifdef __cplusplus +} +#endif #endif /* _PACMAN_ARCHIVE_FILE_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/io/ffilelock.h b/lib/libpacman/io/ffilelock.h index 16102b7..557c3c9 100644 --- a/lib/libpacman/io/ffilelock.h +++ b/lib/libpacman/io/ffilelock.h @@ -21,6 +21,10 @@ #ifndef _F_FILELOCK_H #define _F_FILELOCK_H +#ifdef __cplusplus +extern "C" { +#endif + typedef struct FFileLock FFileLock; #define F_FILELOCK_CREATE_HOLD_DIR (1<<0) @@ -30,6 +34,9 @@ typedef struct FFileLock FFileLock; FFileLock *f_filelock_aquire(const char *pathname, int flags); int f_filelock_release(FFileLock *filelock); +#ifdef __cplusplus +} +#endif #endif /* _F_FILELOCK_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/io/ftp.h b/lib/libpacman/io/ftp.h index 9eeae4a..45b574f 100644 --- a/lib/libpacman/io/ftp.h +++ b/lib/libpacman/io/ftp.h @@ -23,11 +23,18 @@ #include <time.h> +#ifdef __cplusplus +extern "C" { +#endif + #define PM_FMT_MDTM_MAX 64 size_t _pacman_ftp_strfmdtm(char *s, size_t max, const time_t *time); char *_pacman_ftp_strpmdtm(const char *s, time_t *time); +#ifdef __cplusplus +} +#endif #endif /* _PACMAN_FTP_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/object.c b/lib/libpacman/object.cpp similarity index 100% rename from lib/libpacman/object.c rename to lib/libpacman/object.cpp diff --git a/lib/libpacman/package.c b/lib/libpacman/package.cpp similarity index 100% rename from lib/libpacman/package.c rename to lib/libpacman/package.cpp diff --git a/lib/libpacman/package/fpmpackage.c b/lib/libpacman/package/fpmpackage.cpp similarity index 100% rename from lib/libpacman/package/fpmpackage.c rename to lib/libpacman/package/fpmpackage.cpp diff --git a/lib/libpacman/package/packagecache.c b/lib/libpacman/package/packagecache.cpp similarity index 100% rename from lib/libpacman/package/packagecache.c rename to lib/libpacman/package/packagecache.cpp diff --git a/lib/libpacman/packages_transaction.c b/lib/libpacman/packages_transaction.cpp similarity index 93% rename from lib/libpacman/packages_transaction.c rename to lib/libpacman/packages_transaction.cpp index d810cc5..8edd104 100644 --- a/lib/libpacman/packages_transaction.c +++ b/lib/libpacman/packages_transaction.cpp @@ -29,7 +29,13 @@ #include "fstring.h" static const char *trigger_function_table[STATE_MAX] = { + [STATE_IDLE] = NULL, + [STATE_INITIALIZED] = NULL, + [STATE_PREPARED] = NULL, + [STATE_DOWNLOADING] = NULL, + [STATE_COMMITING] = NULL, [STATE_COMMITED] = "commited", + [STATE_INTERRUPTED] = NULL, }; static int diff --git a/lib/libpacman/pacman.c b/lib/libpacman/pacman.cpp similarity index 100% rename from lib/libpacman/pacman.c rename to lib/libpacman/pacman.cpp diff --git a/lib/libpacman/server.c b/lib/libpacman/server.cpp similarity index 100% rename from lib/libpacman/server.c rename to lib/libpacman/server.cpp diff --git a/lib/libpacman/sync.c b/lib/libpacman/sync.cpp similarity index 98% rename from lib/libpacman/sync.c rename to lib/libpacman/sync.cpp index ca95776..03de629 100644 --- a/lib/libpacman/sync.c +++ b/lib/libpacman/sync.cpp @@ -711,13 +711,13 @@ int _pacman_sync_commit(pmtrans_t *trans, pmlist_t **data) for(i = trans->syncpkgs; i; i = i->next) { pmsyncpkg_t *ps = i->data; if(ps->type == PM_SYNC_TYPE_REPLACE) { - pmpkg_t *new = _pacman_db_get_pkgfromcache(db_local, ps->pkg_name); + pmpkg_t *pkg_new = _pacman_db_get_pkgfromcache(db_local, ps->pkg_name); for(j = ps->data; j; j = j->next) { pmlist_t *k; pmpkg_t *old = j->data; /* merge lists */ for(k = old->requiredby; k; k = k->next) { - if(!_pacman_list_is_strin(k->data, new->requiredby)) { + if(!_pacman_list_is_strin(k->data, pkg_new->requiredby)) { /* replace old's name with new's name in the requiredby's dependency list */ pmlist_t *m; pmpkg_t *depender = _pacman_db_get_pkgfromcache(db_local, k->data); @@ -731,21 +731,21 @@ int _pacman_sync_commit(pmtrans_t *trans, pmlist_t **data) for(m = depender->depends; m; m = m->next) { if(!strcmp(m->data, old->name)) { FREE(m->data); - m->data = strdup(new->name); + m->data = strdup(pkg_new->name); } } if(_pacman_db_write(db_local, depender, INFRQ_DEPENDS) == -1) { _pacman_log(PM_LOG_ERROR, _("could not update requiredby for database entry %s-%s"), - new->name, new->version); + pkg_new->name, pkg_new->version); } /* add the new requiredby */ - new->requiredby = _pacman_stringlist_append(new->requiredby, k->data); + pkg_new->requiredby = _pacman_stringlist_append(pkg_new->requiredby, k->data); } } } - if(_pacman_db_write(db_local, new, INFRQ_DEPENDS) == -1) { + if(_pacman_db_write(db_local, pkg_new, INFRQ_DEPENDS) == -1) { _pacman_log(PM_LOG_ERROR, _("could not update new database entry %s-%s"), - new->name, new->version); + pkg_new->name, pkg_new->version); } } } diff --git a/lib/libpacman/sync.h b/lib/libpacman/sync.h index 1c79fde..2ff9478 100644 --- a/lib/libpacman/sync.h +++ b/lib/libpacman/sync.h @@ -38,6 +38,7 @@ struct __pmsyncpkg_t { pmsyncpkg_t *_pacman_syncpkg_new(int type, pmpkg_t *spkg, void *data); int _pacman_syncpkg_delete(pmsyncpkg_t *syncpkg); +extern const pmtrans_ops_t _pacman_sync_pmtrans_opts; #endif /* _PACMAN_SYNC_H */ diff --git a/lib/libpacman/trans.c b/lib/libpacman/trans.cpp similarity index 100% rename from lib/libpacman/trans.c rename to lib/libpacman/trans.cpp diff --git a/lib/libpacman/trans_sysupgrade.c b/lib/libpacman/trans_sysupgrade.cpp similarity index 100% rename from lib/libpacman/trans_sysupgrade.c rename to lib/libpacman/trans_sysupgrade.cpp diff --git a/lib/libpacman/util.c b/lib/libpacman/util.cpp similarity index 100% rename from lib/libpacman/util.c rename to lib/libpacman/util.cpp diff --git a/lib/libpacman/util.h b/lib/libpacman/util.h index a797638..d4f04eb 100644 --- a/lib/libpacman/util.h +++ b/lib/libpacman/util.h @@ -53,7 +53,6 @@ #define DONESTR "DONE " #define _pacman_basename f_basename -int _pacman_makepath(const char *path); int _pacman_copyfile(char *src, char *dest); int _pacman_unpack(const char *archive, const char *prefix, const char *fn); int _pacman_rmrf(char *path); @@ -76,6 +75,15 @@ char* mkdtemp(char *template); #define _pacman_malloc f_malloc #define _pacman_zalloc f_zalloc +#ifdef __cplusplus +extern "C" { +#endif + +int _pacman_makepath(const char *path); + +#ifdef __cplusplus +} +#endif #endif /* _PACMAN_UTIL_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/util/flist.h b/lib/libpacman/util/flist.h index dd3aa9f..e91fd9b 100644 --- a/lib/libpacman/util/flist.h +++ b/lib/libpacman/util/flist.h @@ -26,6 +26,9 @@ #include "util/fcallback.h" +#ifdef __cplusplus +extern "C" { +#endif #ifndef F_NOCOMPAT typedef struct __pmlist_t FList; typedef struct __pmlist_t FListItem; @@ -84,6 +87,9 @@ const FListItem *f_list_last_const(const FList *self); FListItem *f_list_rend(FList *self); const FListItem *f_list_rend_const(const FList *self); +#ifdef __cplusplus +} +#endif #endif /* F_LIST_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/util/fptrlist.h b/lib/libpacman/util/fptrlist.h index 1259074..f75d7db 100644 --- a/lib/libpacman/util/fptrlist.h +++ b/lib/libpacman/util/fptrlist.h @@ -26,6 +26,10 @@ #include "util/flist.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef F_NOCOMPAT typedef struct __pmlist_t FPtrList; typedef struct __pmlist_t FPtrListItem; @@ -81,7 +85,9 @@ FPtrList *f_ptrlist_filter(const FPtrList *list, const FMatcher *matcher); #define f_ptrlist_last(self) ((FPtrListItem *)f_list_last(self)) #define f_ptrlist_last_const(self) ((const FPtrListItem *)f_list_last_const(self)) - +#ifdef __cplusplus +} +#endif #endif /* F_PTRLIST_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/util/list.h b/lib/libpacman/util/list.h index d9c808d..1528ed8 100644 --- a/lib/libpacman/util/list.h +++ b/lib/libpacman/util/list.h @@ -25,6 +25,10 @@ #include "util/fptrlist.h" +#ifdef __cplusplus +extern "C" { +#endif + #define _FREELIST(p, f) do { if(p) { FVisitor visitor = { .fn = (FVisitorFunc)f, .data = NULL, }; f_ptrlist_delete(p, &visitor); p = NULL; } } while(0) #define FREELIST(p) _FREELIST(p, free) #define FREELISTPTR(p) _FREELIST(p, NULL) @@ -43,6 +47,9 @@ pmlist_t *_pacman_list_add_sorted(pmlist_t *list, void *data, _pacman_fn_cmp fn) pmlist_t *_pacman_list_remove(pmlist_t *haystack, void *needle, _pacman_fn_cmp fn, void **data); pmlist_t *_pacman_list_reverse(pmlist_t *list); +#ifdef __cplusplus +} +#endif #endif /* _PACMAN_LIST_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/util/log.h b/lib/libpacman/util/log.h index 0bcd841..b7cc20e 100644 --- a/lib/libpacman/util/log.h +++ b/lib/libpacman/util/log.h @@ -26,6 +26,9 @@ #include <stdarg.h> /* for va_list */ #include <stdio.h> /* for FILE */ +#ifdef __cplusplus +extern "C" { +#endif #define LOG_STR_LEN 256 extern pacman_cb_log pm_logcb; @@ -35,6 +38,9 @@ void _pacman_log(unsigned char flag, const char *format, ...); void _pacman_vlog(unsigned char flag, const char *format, va_list ap); void _pacman_vlogaction(unsigned char usesyslog, FILE *f, const char *format, va_list ap); +#ifdef __cplusplus +} +#endif #endif /* _PACMAN_LOG_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/util/stringlist.h b/lib/libpacman/util/stringlist.h index 3a0595c..8fcfe37 100644 --- a/lib/libpacman/util/stringlist.h +++ b/lib/libpacman/util/stringlist.h @@ -24,6 +24,10 @@ #include "util/list.h" #include "fstring.h" +#ifdef __cplusplus +extern "C" { +#endif + #ifndef F_NOCOMPAT typedef struct __pmlist_t FStringList; typedef struct __pmlist_t FStringListItem; @@ -61,6 +65,9 @@ FStringList *f_stringlist_append(FStringList *list, const char *s); FStringList *f_stringlist_append_stringlist(FStringList *dest, const FStringList *src); int f_stringlist_clear(FStringList *self); +#ifdef __cplusplus +} +#endif #endif /* _PACMAN_STRINGLIST_H */ /* vim: set ts=2 sw=2 noet: */ diff --git a/lib/libpacman/versioncmp.c b/lib/libpacman/versioncmp.cpp similarity index 100% rename from lib/libpacman/versioncmp.c rename to lib/libpacman/versioncmp.cpp _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
