Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=d66c7651e49a5c83d76f91746a05cf18c0cc40a7

commit d66c7651e49a5c83d76f91746a05cf18c0cc40a7
Author: Michel Hermier <herm...@frugalware.org>
Date:   Mon Nov 11 12:08:04 2013 +0100

libpacman: Move _pacman_db_getlastupdate and _pacman_db_setlastupdate to db.c, 
and rip be_files.c.

diff --git a/lib/libpacman/Makefile.am b/lib/libpacman/Makefile.am
index 4bd0066..7c06423 100644
--- a/lib/libpacman/Makefile.am
+++ b/lib/libpacman/Makefile.am
@@ -52,8 +52,7 @@ TARGETS = \
sync.c \
handle.c \
server.c \
-       pacman.c \
-       be_files.c
+       pacman.c

lib_LTLIBRARIES = libpacman.la

diff --git a/lib/libpacman/be_files.c b/lib/libpacman/be_files.c
index a0004e4..37fe328 100644
--- a/lib/libpacman/be_files.c
+++ b/lib/libpacman/be_files.c
@@ -52,66 +52,5 @@
#include "error.h"
#include "handle.h"

-/* Reads dbpath/treename.lastupdate and populates *ts with the contents.
- * *ts should be malloc'ed and should be at least 15 bytes.
- *
- * Returns 0 on success, -1 on error.
- */
-int _pacman_db_getlastupdate(pmdb_t *db, char *ts)
-{
-       FILE *fp;
-       char file[PATH_MAX];
-
-       ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
-       if(ts == NULL) {
-               return(-1);
-       }
-
-       snprintf(file, PATH_MAX, "%s%s/%s.lastupdate", handle->root, 
handle->dbpath, db->treename);
-
-       /* get the last update time, if it's there */
-       if((fp = fopen(file, "r")) == NULL) {
-               return(-1);
-       } else {
-               char line[256];
-               if(fgets(line, sizeof(line), fp)) {
-                       STRNCPY(ts, line, 15); /* YYYYMMDDHHMMSS */
-                       ts[14] = '\0';
-               } else {
-                       fclose(fp);
-                       return(-1);
-               }
-       }
-       fclose(fp);
-       return(0);
-}
-
-/* Writes the dbpath/treename.lastupdate with the contents of *ts
- *
- * Returns 0 on success, -1 on error.
- */
-int _pacman_db_setlastupdate(pmdb_t *db, const char *ts)
-{
-       FILE *fp;
-       char file[PATH_MAX];
-
-       ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
-       if(_pacman_strempty(ts)) {
-               return(-1);
-       }
-
-       snprintf(file, PATH_MAX, "%s%s/%s.lastupdate", handle->root, 
handle->dbpath, db->treename);
-
-       if((fp = fopen(file, "w")) == NULL) {
-               return(-1);
-       }
-       if(fputs(ts, fp) <= 0) {
-               fclose(fp);
-               return(-1);
-       }
-       fclose(fp);
-
-       return(0);
-}

/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libpacman/db.c b/lib/libpacman/db.c
index d0c79c3..609d6a5 100644
--- a/lib/libpacman/db.c
+++ b/lib/libpacman/db.c
@@ -244,6 +244,68 @@ int _pacman_db_remove(pmdb_t *db, pmpkg_t *info)
}
}

+/* Reads dbpath/treename.lastupdate and populates *ts with the contents.
+ * *ts should be malloc'ed and should be at least 15 bytes.
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int _pacman_db_getlastupdate(pmdb_t *db, char *ts)
+{
+       FILE *fp;
+       char file[PATH_MAX];
+
+       ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
+       if(ts == NULL) {
+               return(-1);
+       }
+
+       snprintf(file, PATH_MAX, "%s%s/%s.lastupdate", handle->root, 
handle->dbpath, db->treename);
+
+       /* get the last update time, if it's there */
+       if((fp = fopen(file, "r")) == NULL) {
+               return(-1);
+       } else {
+               char line[256];
+               if(fgets(line, sizeof(line), fp)) {
+                       STRNCPY(ts, line, 15); /* YYYYMMDDHHMMSS */
+                       ts[14] = '\0';
+               } else {
+                       fclose(fp);
+                       return(-1);
+               }
+       }
+       fclose(fp);
+       return(0);
+}
+
+/* Writes the dbpath/treename.lastupdate with the contents of *ts
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int _pacman_db_setlastupdate(pmdb_t *db, const char *ts)
+{
+       FILE *fp;
+       char file[PATH_MAX];
+
+       ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
+       if(_pacman_strempty(ts)) {
+               return(-1);
+       }
+
+       snprintf(file, PATH_MAX, "%s%s/%s.lastupdate", handle->root, 
handle->dbpath, db->treename);
+
+       if((fp = fopen(file, "w")) == NULL) {
+               return(-1);
+       }
+       if(fputs(ts, fp) <= 0) {
+               fclose(fp);
+               return(-1);
+       }
+       fclose(fp);
+
+       return(0);
+}
+
pmdb_t *_pacman_db_register(const char *treename, pacman_cb_db_register 
callback)
{
struct stat buf;
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to