/*
* Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
*
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
} else {
self->volume_time = g_strdup(timestamp);
}
- strncpy(rval->datestamp, self->volume_time, sizeof(rval->datestamp));
- strncpy(rval->name, label, sizeof(rval->name));
+ g_strlcpy(rval->datestamp, self->volume_time, sizeof(rval->datestamp));
+ g_strlcpy(rval->name, label, sizeof(rval->name));
return rval;
}
rval = malloc(sizeof(*rval));
rval->type = F_TAPEEND;
timestamp = get_timestamp_from_time(time(NULL));
- strncpy(rval->datestamp, timestamp, sizeof(rval->datestamp));
+ g_strlcpy(rval->datestamp, timestamp, sizeof(rval->datestamp));
amfree(timestamp);
return rval;
}
}
}
-gboolean
+int
device_accept(
Device *self,
DirectTCPConnection **conn,
- ProlongProc prolong,
- gpointer prolong_data)
-{
- DeviceClass *klass;
-
- klass = DEVICE_GET_CLASS(self);
- if(klass->accept) {
- return (klass->accept)(self, conn, prolong, prolong_data);
- } else {
- device_set_error(self,
- stralloc(_("Unimplemented method")),
- DEVICE_STATUS_DEVICE_ERROR);
- return FALSE;
- }
-}
-
-gboolean
-device_accept_with_cond(
- Device *self,
- DirectTCPConnection **conn,
+ int *cancelled,
GMutex *abort_mutex,
- GCond *abort_cond)
+ GCond *abort_cond)
{
DeviceClass *klass;
klass = DEVICE_GET_CLASS(self);
- if(klass->accept_with_cond) {
- return (klass->accept_with_cond)(self, conn, abort_mutex, abort_cond);
+ if(klass->accept) {
+ return (klass->accept)(self, conn, cancelled, abort_mutex, abort_cond);
} else {
device_set_error(self,
g_strdup(_("Unimplemented method")),
DEVICE_STATUS_DEVICE_ERROR);
- return FALSE;
+ return 1;
}
}
-gboolean
-device_connect(
- Device *self,
- gboolean for_writing,
- DirectTCPAddr *addrs,
- DirectTCPConnection **conn,
- ProlongProc prolong,
- gpointer prolong_data)
-{
- DeviceClass *klass;
-
- klass = DEVICE_GET_CLASS(self);
- if(klass->connect) {
- return (klass->connect)(self, for_writing, addrs, conn, prolong, prolong_data);
- } else {
- device_set_error(self,
- stralloc(_("Unimplemented method")),
- DEVICE_STATUS_DEVICE_ERROR);
- return FALSE;
- }
-}
-gboolean
-device_connect_with_cond(
+int
+device_connect(
Device *self,
gboolean for_writing,
DirectTCPAddr *addrs,
DirectTCPConnection **conn,
+ int *cancelled,
GMutex *abort_mutex,
- GCond *abort_cond)
+ GCond *abort_cond)
{
DeviceClass *klass;
klass = DEVICE_GET_CLASS(self);
if(klass->connect) {
- return (klass->connect_with_cond)(self, for_writing, addrs, conn, abort_mutex, abort_cond);
+ return (klass->connect)(self, for_writing, addrs, conn, cancelled,
+ abort_mutex, abort_cond);
} else {
device_set_error(self,
g_strdup(_("Unimplemented method")),
DEVICE_STATUS_DEVICE_ERROR);
- return FALSE;
+ return 1;
}
}
-gboolean
+int
device_write_from_connection(
Device *self,
guint64 size,
- guint64 *actual_size)
+ guint64 *actual_size,
+ int *cancelled,
+ GMutex *abort_mutex,
+ GCond *abort_cond)
{
DeviceClass *klass;
g_assert(IS_WRITABLE_ACCESS_MODE(self->access_mode));
if(klass->write_from_connection) {
- return (klass->write_from_connection)(self, size, actual_size);
+ return (klass->write_from_connection)(self, size, actual_size,
+ cancelled,
+ abort_mutex, abort_cond);
} else {
device_set_error(self,
stralloc(_("Unimplemented method")),
DEVICE_STATUS_DEVICE_ERROR);
- return FALSE;
+ return 1;
}
}
-gboolean
+int
device_read_to_connection(
Device *self,
guint64 size,
- guint64 *actual_size)
+ guint64 *actual_size,
+ int *cancelled,
+ GMutex *abort_mutex,
+ GCond *abort_cond)
{
DeviceClass *klass;
klass = DEVICE_GET_CLASS(self);
if(klass->read_to_connection) {
- return (klass->read_to_connection)(self, size, actual_size);
+ return (klass->read_to_connection)(self, size, actual_size,
+ cancelled, abort_mutex, abort_cond);
} else {
device_set_error(self,
stralloc(_("Unimplemented method")),
DEVICE_STATUS_DEVICE_ERROR);
- return FALSE;
+ return 1;
}
}