1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
19 #include <sys/types.h>
21 #include "downloader.h"
22 #include "zip/unzip.h"
26 typedef gboolean (*Stream_CanSeek
) (void *handle
);
27 typedef gboolean (*Stream_CanRead
) (void *handle
);
28 typedef gint64 (*Stream_Length
) (void *handle
);
29 typedef gint64 (*Stream_Position
) (void *handle
);
30 typedef gint32 (*Stream_Read
) (void *handle
, void *buffer
, gint32 offset
, gint32 count
);
31 typedef void (*Stream_Write
) (void *handle
, void *buffer
, gint32 offset
, gint32 count
);
32 typedef void (*Stream_Seek
) (void *handle
, gint64 offset
, gint32 origin
);
33 typedef void (*Stream_Close
) (void *handle
);
35 struct ManagedStreamCallbacks
{
37 Stream_CanSeek CanSeek
;
38 Stream_CanRead CanRead
;
40 Stream_Position Position
;
47 /* @GeneratePInvoke */
48 gboolean
managed_unzip_stream_to_stream (ManagedStreamCallbacks
*source
, ManagedStreamCallbacks
*dest
, const char *partname
);
50 gboolean
managed_unzip_extract_to_stream (unzFile zipFile
, ManagedStreamCallbacks
*dest
);
52 G_GNUC_INTERNAL
void g_ptr_array_insert (GPtrArray
*array
, guint index
, void *item
);
54 G_GNUC_INTERNAL
void g_ptr_array_insert_sorted (GPtrArray
*array
, GCompareFunc cmp
, void *item
);
56 const char *CanonicalizeFilename (char *filename
, int n
, bool lower
);
58 bool ExtractFile (unzFile zip
, int fd
);
59 bool ExtractAll (unzFile zip
, const char *dir
, bool lower
);
61 char *MakeTempDir (char *tmpdir
);
62 char *CreateTempDir (const char *filename
);
64 int RemoveDir (const char *dir
);
66 int CopyFileTo (const char *filename
, int fd
);
68 int write_all (int fd
, char *buf
, size_t len
);
70 cairo_t
*measuring_context_create (void);
71 void measuring_context_destroy (cairo_t
*cr
);
73 GArray
*double_garray_from_str (const char *s
, gint max
);
76 * Returns a pointer to the first token found.
78 * @input: the input string
79 * @c: output, upon return contains the first character not in the token.
80 * @end: output, upon return contains a pointer to the remaining input (NULL if no more data)
82 * Note: the input string is modified.
84 char *parse_rfc_1945_token (char *input
, char *c
, char **end
);
87 * Returns a pointer to the unquoted string.
89 * @input: the input string
90 * @c: output, upon return contains the first character not in the quoted string.
91 * @end: output, upon return contains a pointer to the remaining input (NULL if no more data)
93 * Note: the input string is modified.
95 char *parse_rfc_1945_quoted_string (char *input
, char *c
, char **end
);
115 bool ReadBOM (bool force
);
116 ssize_t
ReadInternal (char *buf
, ssize_t n
);
122 bool OpenBuffer (const char *buf
, int size
);
123 bool OpenFile (const char *filename
, bool force
);
128 ssize_t
Read (char *buf
, size_t n
);
131 typedef void (*CancelCallback
) (gpointer user_data
, void *context
);
135 CancelCallback cancel_cb
;
136 Downloader
*downloader
;
143 void SetCancelFuncAndData (CancelCallback cb
, Downloader
*user_data
, void *context
);
146 #endif /* __UTILS_H__ */