summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--daemon/gvfsafpconnection.c211
-rw-r--r--daemon/gvfsafpconnection.h60
-rw-r--r--daemon/gvfsafpserver.c87
-rw-r--r--daemon/gvfsafpserver.h1
-rw-r--r--daemon/gvfsbackendafp.c41
-rw-r--r--daemon/gvfsbackendafpbrowse.c10
6 files changed, 309 insertions, 101 deletions
diff --git a/daemon/gvfsafpconnection.c b/daemon/gvfsafpconnection.c
index f9caeb4e..9146e481 100644
--- a/daemon/gvfsafpconnection.c
+++ b/daemon/gvfsafpconnection.c
@@ -40,13 +40,21 @@ struct _GVfsAfpReply
GDataInputStream parent_instance;
AfpResultCode result_code;
+
+ char *data;
+ guint len;
+
+ gint pos;
};
-G_DEFINE_TYPE (GVfsAfpReply, g_vfs_afp_reply, G_TYPE_DATA_INPUT_STREAM);
+G_DEFINE_TYPE (GVfsAfpReply, g_vfs_afp_reply, G_TYPE_OBJECT);
static void
-g_vfs_afp_reply_init (GVfsAfpReply *object)
+g_vfs_afp_reply_init (GVfsAfpReply *reply)
{
+ reply->data = NULL;
+ reply->len = 0;
+ reply->pos = 0;
}
static void
@@ -55,67 +63,188 @@ g_vfs_afp_reply_class_init (GVfsAfpReplyClass *klass)
}
static GVfsAfpReply *
-g_vfs_afp_reply_new (AfpResultCode result_code, const char *data, gsize len)
+g_vfs_afp_reply_new (AfpResultCode result_code, char *data, gsize len)
{
GVfsAfpReply *reply;
- if (data)
- reply = g_object_new (G_VFS_TYPE_AFP_REPLY, "base-stream",
- g_memory_input_stream_new_from_data (data, len, g_free),
- NULL);
- else
- reply = g_object_new (G_VFS_TYPE_AFP_REPLY, "base-stream",
- g_memory_input_stream_new (), NULL);
-
+ reply = g_object_new (G_VFS_TYPE_AFP_REPLY, NULL);
reply->result_code = result_code;
+ reply->len = len;
+ reply->data = data;
return reply;
}
-char *
-g_vfs_afp_reply_read_pascal (GVfsAfpReply *reply)
+gboolean
+g_vfs_afp_reply_read_byte (GVfsAfpReply *reply, guint8 *byte)
+{
+ if ((reply->len - reply->pos) < 1)
+ return FALSE;
+
+ if (byte)
+ *byte = reply->data[reply->pos];
+
+ reply->pos++;
+
+ return TRUE;
+}
+
+gboolean
+g_vfs_afp_reply_read_int32 (GVfsAfpReply *reply, gint32 *val)
+{
+ if ((reply->len - reply->pos) < 4)
+ return FALSE;
+
+ if (val)
+ *val = GINT32_FROM_BE (*((gint32 *)(reply->data + reply->pos)));
+
+ reply->pos += 4;
+
+ return TRUE;
+}
+
+gboolean
+g_vfs_afp_reply_read_int16 (GVfsAfpReply *reply, gint16 *val)
+{
+ if ((reply->len - reply->pos) < 2)
+ return FALSE;
+
+ if (val)
+ *val = GINT16_FROM_BE (*((gint16 *)(reply->data + reply->pos)));
+
+ reply->pos += 2;
+
+ return TRUE;
+}
+
+gboolean
+g_vfs_afp_reply_read_uint32 (GVfsAfpReply *reply, guint32 *val)
+{
+ if ((reply->len - reply->pos) < 4)
+ return FALSE;
+
+ if (val)
+ *val = GUINT32_FROM_BE (*((guint32 *)(reply->data + reply->pos)));
+
+ reply->pos += 4;
+
+ return TRUE;
+}
+
+gboolean
+g_vfs_afp_reply_read_uint16 (GVfsAfpReply *reply, guint16 *val)
+{
+ if ((reply->len - reply->pos) < 2)
+ return FALSE;
+
+ if (val)
+ *val = GUINT16_FROM_BE (*((guint16 *)(reply->data + reply->pos)));
+
+ reply->pos += 2;
+
+ return TRUE;
+}
+
+gboolean
+g_vfs_afp_reply_get_data (GVfsAfpReply *reply, guint size, guint8 **data)
+{
+ if ((reply->len - reply->pos) < size)
+ return FALSE;
+
+ if (data)
+ *data = (guint8 *)(reply->data + reply->pos);
+
+ reply->pos += size;
+
+ return TRUE;
+}
+
+gboolean
+g_vfs_afp_reply_dup_data (GVfsAfpReply *reply, guint size, guint8 **data)
+{
+ if ((reply->len - reply->pos) < size)
+ return FALSE;
+
+ if (data)
+ {
+ *data = g_malloc (size);
+ memcpy (*data, reply->data + reply->pos, size);
+ }
+
+ reply->pos += size;
+
+ return TRUE;
+}
+
+gboolean
+g_vfs_afp_reply_read_pascal (GVfsAfpReply *reply, char **str)
{
- GError *err;
guint8 strsize;
- char *str;
- gboolean res;
- gsize bytes_read;
+
+ if (!g_vfs_afp_reply_read_byte (reply, &strsize))
+ return FALSE;
- err = NULL;
- strsize = g_data_input_stream_read_byte (G_DATA_INPUT_STREAM (reply), NULL, &err);
- if (err != NULL)
+ if (strsize > (reply->len - reply->pos))
{
- g_error_free (err);
- return NULL;
+ reply->pos--;
+ return FALSE;
}
- str = g_malloc (strsize + 1);
- res = g_input_stream_read_all (G_INPUT_STREAM (reply), str, strsize,
- &bytes_read, NULL, NULL);
- if (!res || (bytes_read < strsize))
+ if (str)
{
- g_free (str);
- return NULL;
+ *str = g_malloc (strsize + 1);
+ memcpy (*str, reply->data + reply->pos, strsize);
+ (*str)[strsize] = '\0';
+ }
+
+ reply->pos += strsize;
+
+ return TRUE;
+}
+
+gboolean
+g_vfs_afp_reply_seek (GVfsAfpReply *reply, gint offset, GSeekType type)
+{
+ gint absolute;
+
+ switch (type)
+ {
+ case G_SEEK_CUR:
+ absolute = reply->pos + offset;
+ break;
+
+ case G_SEEK_SET:
+ absolute = offset;
+ break;
+
+ case G_SEEK_END:
+ absolute = reply->len + offset;
+ break;
+
+ default:
+ return FALSE;
}
- str[strsize] = '\0';
- return str;
+ if (absolute < 0 || absolute >= reply->len)
+ return FALSE;
+
+ reply->pos = absolute;
+ return TRUE;
}
gboolean
-g_vfs_afp_reply_seek (GVfsAfpReply *reply, goffset offset, GSeekType type)
+g_vfs_afp_reply_skip_to_even (GVfsAfpReply *reply)
{
- gsize avail;
- GMemoryInputStream *mem_stream;
+ if ((reply->pos % 2) == 0)
+ return TRUE;
- /* flush buffered data */
- avail = g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (reply));
- g_input_stream_skip (G_INPUT_STREAM (reply), avail, NULL, NULL);
-
- g_object_get (reply, "base-stream", &mem_stream, NULL);
-
- return g_seekable_seek (G_SEEKABLE (mem_stream), offset, type, NULL, NULL);
+ if ((reply->len - reply->pos) < 1)
+ return FALSE;
+
+ reply->pos++;
+
+ return TRUE;
}
AfpResultCode
@@ -871,7 +1000,7 @@ g_vfs_afp_connection_get_server_info (GVfsAfpConnection *afp_connection,
if (!conn)
return NULL;
-
+
res = send_request_sync (g_io_stream_get_output_stream (conn), DSI_GET_STATUS,
0, 0, 0, NULL, cancellable, error);
if (!res)
diff --git a/daemon/gvfsafpconnection.h b/daemon/gvfsafpconnection.h
index 14b55021..bb8b5f1b 100644
--- a/daemon/gvfsafpconnection.h
+++ b/daemon/gvfsafpconnection.h
@@ -29,6 +29,46 @@ G_BEGIN_DECLS
typedef enum
{
+ AFP_DIR_BITMAP_ATTRIBUTE_BIT = 0x1,
+ AFP_DIR_BITMAP_PARENT_DIR_ID_BIT = 0x2,
+ AFP_DIR_BITMAP_CREATE_DATE_BIT = 0x4,
+ AFP_DIR_BITMAP_MOD_DATE_BIT = 0x8,
+ AFP_DIR_BITMAP_BACKUP_DATE_BIT = 0x10,
+ AFP_DIR_BITMAP_FINDER_INFO_BIT = 0x20,
+ AFP_DIR_BITMAP_LONG_NAME_BIT = 0x40,
+ AFP_DIR_BITMAP_SHORT_NAME_BIT = 0x80,
+ AFP_DIR_BITMAP_NODE_ID_BIT = 0x100,
+ AFP_DIR_BITMAP_OFFSPRING_COUNT_BIT = 0x0200,
+ AFP_DIR_BITMAP_OWNER_ID_BIT = 0x0400,
+ AFP_DIR_BITMAP_GROUP_ID_BIT = 0x0800,
+ AFP_DIR_BITMAP_ACCESS_RIGHTS_BIT = 0x1000,
+ AFP_DIR_BITMAP_UTF8_NAME_BIT = 0x2000,
+ AFP_DIR_BITMAP_UNIX_PRIVS_BIT = 0x8000,
+ AFP_DIR_BITMAP_UUID_BIT = 0x10000 // AFP version 3.2 and later (with ACL support)
+} AfpDirBitmap;
+
+typedef enum
+{
+ AFP_FILE_BITMAP_ATTRIBUTE_BIT = 0x1,
+ AFP_FILE_BITMAP_PARENT_DIR_ID_BIT = 0x2,
+ AFP_FILE_BITMAP_CREATE_DATE_BIT = 0x4,
+ AFP_FILE_BITMAP_MOD_DATE_BIT = 0x8,
+ AFP_FILE_BITMAP_BACKUP_DATE_BIT = 0x10,
+ AFP_FILE_BITMAP_FINDER_INFO_BIT = 0x20,
+ AFP_FILE_BITMAP_LONG_NAME_BIT = 0x40,
+ AFP_FILE_BITMAP_SHORT_NAME_BIT = 0x80,
+ AFP_FILE_BITMAP_NODE_ID_BIT = 0x100,
+ AFP_FILE_BITMAP_DATA_FORK_LEN_BIT = 0x0200,
+ AFP_FILE_BITMAP_RSRC_FORK_LEN_BI = 0x0400,
+ AFP_FILE_BITMAP_EXT_DATA_FORK_LEN_BIT = 0x0800,
+ AFP_FILE_BITMAP_LAUNCH_LIMIT_BIT = 0x1000,
+ AFP_FILE_BITMAP_UTF8_NAME_BIT = 0x2000,
+ AFP_FILE_BITMAP_EXT_RSRC_FORK_LEN_BIT = 0x4000,
+ AFP_FILE_BITMAP_UNIX_PRIVS_BIT = 0x8000
+} AfpFileBitmap;
+
+typedef enum
+{
AFP_VOLUME_BITMAP_ATTRIBUTE_BIT = 0x1,
AFP_VOLUME_BITMAP_SIGNATURE_BIT = 0x2,
AFP_VOLUME_BITMAP_CREATE_DATE_BIT = 0x4,
@@ -52,7 +92,9 @@ typedef enum
AFP_COMMAND_LOGIN_CONT = 19,
AFP_COMMAND_OPEN_VOL = 24,
AFP_COMMAND_WRITE = 33,
- AFP_COMMAND_WRITE_EXT = 61
+ AFP_COMMAND_WRITE_EXT = 61,
+ AFP_COMMAND_ENUMERATE_EXT = 66,
+ AFP_COMMAND_ENUMERATE_EXT2 = 68
} AfpCommandType;
typedef enum
@@ -76,8 +118,20 @@ typedef enum
typedef struct _GVfsAfpReplyClass GVfsAfpReplyClass;
typedef struct _GVfsAfpReply GVfsAfpReply;
-char * g_vfs_afp_reply_read_pascal (GVfsAfpReply *reply);
-gboolean g_vfs_afp_reply_seek (GVfsAfpReply *reply, goffset offset, GSeekType type);
+gboolean g_vfs_afp_reply_read_byte (GVfsAfpReply *reply, guint8 *byte);
+
+gboolean g_vfs_afp_reply_read_int32 (GVfsAfpReply *reply, gint32 *val);
+gboolean g_vfs_afp_reply_read_int16 (GVfsAfpReply *reply, gint16 *val);
+
+gboolean g_vfs_afp_reply_read_uint32 (GVfsAfpReply *reply, guint32 *val);
+gboolean g_vfs_afp_reply_read_uint16 (GVfsAfpReply *reply, guint16 *val);
+
+gboolean g_vfs_afp_reply_get_data (GVfsAfpReply *reply, guint size, guint8 **data);
+gboolean g_vfs_afp_reply_dup_data (GVfsAfpReply *reply, guint size, guint8 **data);
+
+gboolean g_vfs_afp_reply_read_pascal (GVfsAfpReply *reply, char **str);
+gboolean g_vfs_afp_reply_seek (GVfsAfpReply *reply, gint offset, GSeekType type);
+gboolean g_vfs_afp_reply_skip_to_even (GVfsAfpReply *reply);
AfpResultCode g_vfs_afp_reply_get_result_code (GVfsAfpReply *reply);
diff --git a/daemon/gvfsafpserver.c b/daemon/gvfsafpserver.c
index aebedd59..0bcd8974 100644
--- a/daemon/gvfsafpserver.c
+++ b/daemon/gvfsafpserver.c
@@ -83,10 +83,9 @@ dhx2_login (GVfsAfpServer *afp_serv,
/* reply 1 */
guint16 id;
- guint8 g_buf[4];
guint16 len;
guint32 bits;
- guint8 *buf;
+ guint8 *tmp_buf, *buf;
gcry_mpi_t g, p, Ma, Mb, Ra, key;
gcry_cipher_hd_t cipher;
@@ -160,25 +159,24 @@ dhx2_login (GVfsAfpServer *afp_serv,
}
/* Get data from reply */
- id = g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_uint16 (reply, &id);
/* read g */
- g_input_stream_read_all (G_INPUT_STREAM (reply), &g_buf, 4, NULL, NULL, NULL);
- gcry_err = gcry_mpi_scan (&g, GCRYMPI_FMT_USG, &g_buf, 4, NULL);
+ g_vfs_afp_reply_get_data (reply, 4, &tmp_buf);
+ gcry_err = gcry_mpi_scan (&g, GCRYMPI_FMT_USG, tmp_buf, 4, NULL);
g_assert (gcry_err == 0);
- len = g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_uint16 (reply, &len);
bits = len * 8;
- buf = g_malloc (len);
/* read p */
- g_input_stream_read_all (G_INPUT_STREAM (reply), buf, len, NULL, NULL, NULL);
- gcry_err = gcry_mpi_scan (&p, GCRYMPI_FMT_USG, buf, len, NULL);
+ g_vfs_afp_reply_get_data (reply, len, &tmp_buf);
+ gcry_err = gcry_mpi_scan (&p, GCRYMPI_FMT_USG, tmp_buf, len, NULL);
g_assert (gcry_err == 0);
/* read Mb */
- g_input_stream_read_all (G_INPUT_STREAM (reply), buf, len, NULL, NULL, NULL);
- gcry_err = gcry_mpi_scan (&Mb, GCRYMPI_FMT_USG, buf, len, NULL);
+ g_vfs_afp_reply_get_data (reply, len, &tmp_buf);
+ gcry_err = gcry_mpi_scan (&Mb, GCRYMPI_FMT_USG, tmp_buf, len, NULL);
g_assert (gcry_err == 0);
g_object_unref (reply);
@@ -200,6 +198,7 @@ dhx2_login (GVfsAfpServer *afp_serv,
key = gcry_mpi_new (bits);
gcry_mpi_powm (key, Mb, Ra, p);
+ buf = g_malloc0 (len);
gcry_err = gcry_mpi_print (GCRYMPI_FMT_USG, buf, len, NULL,
key);
g_assert (gcry_err == 0);
@@ -263,9 +262,10 @@ dhx2_login (GVfsAfpServer *afp_serv,
}
/* read data from reply 2 */
- id = g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_uint16 (reply, &id);
- g_input_stream_read_all (G_INPUT_STREAM (reply), reply2_buf, 32, NULL, NULL, NULL);
+ g_vfs_afp_reply_get_data (reply, 32, &tmp_buf);
+ memcpy (reply2_buf, tmp_buf, 32);
g_object_unref (reply);
@@ -383,14 +383,14 @@ dhx_login (GVfsAfpServer *afp_serv,
AfpResultCode res_code;
gboolean res;
guint16 id;
+ guint8 *tmp_buf;
/* Mb */
- guint8 mb_buf[16];
gcry_mpi_t mb;
/* Nonce */
guint8 nonce_buf[32];
- gcry_mpi_t nonce, nonce1;
+ gcry_mpi_t nonce;
/* Key */
gcry_mpi_t key;
@@ -470,18 +470,16 @@ dhx_login (GVfsAfpServer *afp_serv,
goto generic_error;
}
- id = g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply),
- NULL, NULL);
+ g_vfs_afp_reply_read_uint16 (reply, &id);
/* read Mb */
- g_input_stream_read_all (G_INPUT_STREAM (reply), mb_buf, G_N_ELEMENTS (mb_buf),
- NULL, NULL, NULL);
- gcry_err = gcry_mpi_scan (&mb, GCRYMPI_FMT_USG, mb_buf, G_N_ELEMENTS (mb_buf), NULL);
+ g_vfs_afp_reply_get_data (reply, 16, &tmp_buf);
+ gcry_err = gcry_mpi_scan (&mb, GCRYMPI_FMT_USG, tmp_buf, 16, NULL);
g_assert (gcry_err == 0);
/* read Nonce */
- g_input_stream_read_all (G_INPUT_STREAM (reply), nonce_buf, G_N_ELEMENTS (nonce_buf),
- NULL, NULL, NULL);
+ g_vfs_afp_reply_get_data (reply, 32, &tmp_buf);
+ memcpy (nonce_buf, tmp_buf, 32);
g_object_unref (reply);
@@ -511,17 +509,15 @@ dhx_login (GVfsAfpServer *afp_serv,
g_assert (gcry_err == 0);
/* add one to nonce */
- nonce1 = gcry_mpi_new (128);
- gcry_mpi_add_ui (nonce1, nonce, 1);
- gcry_mpi_release (nonce);
+ gcry_mpi_add_ui (nonce, nonce, 1);
/* set client->server initialization vector */
gcry_cipher_setiv (cipher, C2SIV, G_N_ELEMENTS (C2SIV));
/* create encrypted answer */
- gcry_err = gcry_mpi_print (GCRYMPI_FMT_USG, answer_buf, 16, &len, nonce1);
+ gcry_err = gcry_mpi_print (GCRYMPI_FMT_USG, answer_buf, 16, &len, nonce);
g_assert (gcry_err == 0);
- gcry_mpi_release (nonce1);
+ gcry_mpi_release (nonce);
if (len < 16)
{
@@ -675,44 +671,40 @@ get_server_info (GVfsAfpServer *afp_serv,
GError **error)
{
GVfsAfpReply *reply;
- GError *err = NULL;
guint16 MachineType_offset, AFPVersionCount_offset, UAMCount_offset;
guint8 count;
guint i;
reply = g_vfs_afp_connection_get_server_info (afp_serv->conn, cancellable,
- &err);
+ error);
if (!reply)
return FALSE;
- MachineType_offset =
- g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
- AFPVersionCount_offset =
- g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
- UAMCount_offset =
- g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_uint16 (reply, &MachineType_offset);
+ g_vfs_afp_reply_read_uint16 (reply, &AFPVersionCount_offset);
+ g_vfs_afp_reply_read_uint16 (reply, &UAMCount_offset);
/* VolumeIconAndMask_offset */
- (void)g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
-
- afp_serv->flags =
- g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_uint16 (reply, NULL);
- afp_serv->server_name = g_vfs_afp_reply_read_pascal (reply);
+ g_vfs_afp_reply_read_uint16 (reply, &afp_serv->flags);
+ g_vfs_afp_reply_read_pascal (reply, &afp_serv->server_name);
+
/* Parse MachineType */
g_vfs_afp_reply_seek (reply, MachineType_offset, G_SEEK_SET);
- afp_serv->machine_type = g_vfs_afp_reply_read_pascal (reply);
-
+ g_vfs_afp_reply_read_pascal (reply, &afp_serv->machine_type);
+
/* Parse Versions */
g_vfs_afp_reply_seek (reply, AFPVersionCount_offset, G_SEEK_SET);
- count = g_data_input_stream_read_byte (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_byte (reply, &count);
for (i = 0; i < count; i++)
{
char *version;
AfpVersion afp_version;
- version = g_vfs_afp_reply_read_pascal (reply);
+ g_vfs_afp_reply_read_pascal (reply, &version);
+ g_debug ("version: %s\n", version);
afp_version = string_to_afp_version (version);
if (afp_version > afp_serv->version)
afp_serv->version = afp_version;
@@ -729,12 +721,12 @@ get_server_info (GVfsAfpServer *afp_serv,
/* Parse UAMs */
g_vfs_afp_reply_seek (reply, UAMCount_offset, G_SEEK_SET);
- count = g_data_input_stream_read_byte (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_byte (reply, &count);
for (i = 0; i < count; i++)
{
char *uam;
- uam = g_vfs_afp_reply_read_pascal (reply);
+ g_vfs_afp_reply_read_pascal (reply, &uam);
afp_serv->uams = g_slist_prepend (afp_serv->uams, uam);
}
@@ -884,7 +876,9 @@ try_login:
g_free (user);
g_free (password);
+ g_debug ("ASDASD!!!\n");
g_propagate_error (error, err);
+ g_debug ("ASDASD2!!!\n");
return FALSE;
}
@@ -927,6 +921,7 @@ g_vfs_afp_server_init (GVfsAfpServer *afp_serv)
{
afp_serv->machine_type = NULL;
afp_serv->server_name = NULL;
+ afp_serv->utf8_server_name = NULL;
afp_serv->uams = NULL;
afp_serv->version = AFP_VERSION_INVALID;
}
diff --git a/daemon/gvfsafpserver.h b/daemon/gvfsafpserver.h
index 69ecf88a..545997a7 100644
--- a/daemon/gvfsafpserver.h
+++ b/daemon/gvfsafpserver.h
@@ -64,6 +64,7 @@ struct _GVfsAfpServer
guint16 flags;
char *machine_type;
char *server_name;
+ char *utf8_server_name;
GSList *uams;
AfpVersion version;
};
diff --git a/daemon/gvfsbackendafp.c b/daemon/gvfsbackendafp.c
index d8d3412b..3df2cbe4 100644
--- a/daemon/gvfsbackendafp.c
+++ b/daemon/gvfsbackendafp.c
@@ -73,6 +73,36 @@ is_root (const char *filename)
return *p == 0;
}
+# if 0
+static GString *
+filename_to_afp_pathname (const char *filename)
+{
+ GString *pathname;
+
+ pathname = g_string_new (NULL);
+
+ while (filename && *filename == '/')
+ filename++;
+
+ while (filename)
+ {
+ char *end;
+
+ end = strchr (filename, '/');
+ if (!end)
+ end = filename + strlen (filename);
+
+ g_string_append_c (pathname, 0);
+ g_string_append_len (pathname, filename, end - filename);
+
+ while (filename && *filename == '/')
+ filename++;
+ }
+
+ return pathname;
+}
+#endif
+
static void
get_vol_parms_cb (GVfsAfpConnection *afp_connection,
GVfsAfpReply *reply,
@@ -105,12 +135,12 @@ get_vol_parms_cb (GVfsAfpConnection *afp_connection,
g_file_info_set_name (info, afp_backend->volume);
/* CreateDate is in apple time e.g. seconds since Januari 1 1904 */
- create_date = g_data_input_stream_read_uint32 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_uint32 (reply, &create_date);
g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CREATED,
create_date - 2082844800);
/* ModDate is in apple time e.g. seconds since Januari 1 1904 */
- mod_date = g_data_input_stream_read_uint32 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_uint32 (reply, &mod_date);
g_file_info_set_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED,
mod_date - 2082844800);
@@ -234,11 +264,10 @@ do_mount (GVfsBackend *backend,
}
/* Volume Bitmap */
- g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_uint16 (reply, NULL);
- afp_backend->volume_id =
- g_data_input_stream_read_uint16 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
- g_debug ("volume_id: %d", afp_backend->volume_id);
+ /* Volume ID */
+ g_vfs_afp_reply_read_uint16 (reply, &afp_backend->volume_id);
g_object_unref (reply);
diff --git a/daemon/gvfsbackendafpbrowse.c b/daemon/gvfsbackendafpbrowse.c
index 2db0ce91..02b9ab92 100644
--- a/daemon/gvfsbackendafpbrowse.c
+++ b/daemon/gvfsbackendafpbrowse.c
@@ -132,12 +132,12 @@ get_srvr_parms_cb (GVfsAfpConnection *afp_connection,
}
/* server time */
- (void)g_data_input_stream_read_int32 (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+ g_vfs_afp_reply_read_int32 (reply, NULL);
g_slist_free_full (data->afp_backend->volumes, (GDestroyNotify) volume_data_free);
data->afp_backend->volumes = NULL;
-
- num_volumes = g_data_input_stream_read_byte (G_DATA_INPUT_STREAM (reply), NULL, NULL);
+
+ g_vfs_afp_reply_read_byte (reply, &num_volumes);
for (i = 0; i < num_volumes; i++)
{
guint8 flags;
@@ -145,8 +145,8 @@ get_srvr_parms_cb (GVfsAfpConnection *afp_connection,
VolumeData *volume_data;
- flags = g_data_input_stream_read_byte (G_DATA_INPUT_STREAM (reply), NULL, NULL);
- vol_name = g_vfs_afp_reply_read_pascal (reply);
+ g_vfs_afp_reply_read_byte (reply, &flags);
+ g_vfs_afp_reply_read_pascal (reply, &vol_name);
if (!vol_name)
continue;