summaryrefslogtreecommitdiff
path: root/pg.pgc
diff options
context:
space:
mode:
Diffstat (limited to 'pg.pgc')
-rw-r--r--pg.pgc16
1 files changed, 10 insertions, 6 deletions
diff --git a/pg.pgc b/pg.pgc
index f9ebaac..ff9c182 100644
--- a/pg.pgc
+++ b/pg.pgc
@@ -53,6 +53,7 @@ int pg_init() {
channel_id integer,
path varchar,
lastpos integer default 0,
+ lasttime integer,
PRIMARY KEY (id),
FOREIGN KEY (channel_id) REFERENCES channel (id)
);
@@ -157,14 +158,15 @@ int pg_channel_get(struct channel_t *channel) {
return id;
}
-long pg_channel_file_get(int channel_id, struct channel_file_t *file) {
+void pg_channel_file_get(int channel_id, struct channel_file_t *file, long *pos, time_t *time) {
EXEC SQL BEGIN DECLARE SECTION;
int id = channel_id;
const char *path = file->path;
long lastpos = 0;
+ int lasttime = 0;
EXEC SQL END DECLARE SECTION;
- EXEC SQL SELECT lastpos INTO :lastpos FROM channel_file WHERE channel_id = :id AND path = :path;
+ EXEC SQL SELECT lastpos, lasttime INTO :lastpos, :lasttime FROM channel_file WHERE channel_id = :id AND path = :path;
int do_insert = iserror() && testerror("02000");
if(iserror() && !do_insert) {
@@ -178,19 +180,21 @@ long pg_channel_file_get(int channel_id, struct channel_file_t *file) {
EXEC SQL INSERT INTO channel_file (channel_id, path) VALUES (:id, :path);
if(iserror()) sqlprint();
EXEC SQL COMMIT;
+ } else {
+ *pos = lastpos;
+ *time = lasttime;
}
-
- return lastpos;
}
-void pg_channel_file_set(int channel_id, struct channel_file_t *file, long pos) {
+void pg_channel_file_set(int channel_id, struct channel_file_t *file, long pos, time_t time) {
EXEC SQL BEGIN DECLARE SECTION;
int id = channel_id;
const char *path = file->path;
long lastpos = pos;
+ int lasttime = time;
EXEC SQL END DECLARE SECTION;
- EXEC SQL UPDATE channel_file SET lastpos = :lastpos WHERE channel_id = :id AND path = :path;
+ EXEC SQL UPDATE channel_file SET lastpos = :lastpos, lasttime = :lasttime WHERE channel_id = :id AND path = :path;
EXEC SQL COMMIT;
}