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
);
62 const char *CanonicalizeFilename (char *filename
, int n
, CanonMode mode
);
64 bool ExtractFile (unzFile zip
, int fd
);
65 bool ExtractAll (unzFile zip
, const char *dir
, CanonMode mode
);
67 char *MakeTempDir (char *tmpdir
);
68 char *CreateTempDir (const char *filename
);
70 int RemoveDir (const char *dir
);
72 int CopyFileTo (const char *filename
, int fd
);
74 int write_all (int fd
, char *buf
, size_t len
);
76 cairo_t
*measuring_context_create (void);
77 void measuring_context_destroy (cairo_t
*cr
);
79 GArray
*double_garray_from_str (const char *s
, gint max
);
82 * Returns a pointer to the first token found.
84 * @input: the input string
85 * @c: output, upon return contains the first character not in the token.
86 * @end: output, upon return contains a pointer to the remaining input (NULL if no more data)
88 * Note: the input string is modified.
90 char *parse_rfc_1945_token (char *input
, char *c
, char **end
);
93 * Returns a pointer to the unquoted string.
95 * @input: the input string
96 * @c: output, upon return contains the first character not in the quoted string.
97 * @end: output, upon return contains a pointer to the remaining input (NULL if no more data)
99 * Note: the input string is modified.
101 char *parse_rfc_1945_quoted_string (char *input
, char *c
, char **end
);
121 bool ReadBOM (bool force
);
122 ssize_t
ReadInternal (char *buf
, ssize_t n
);
128 bool OpenBuffer (const char *buf
, int size
);
129 bool OpenFile (const char *filename
, bool force
);
134 ssize_t
Read (char *buf
, size_t n
);
137 typedef void (*CancelCallback
) (gpointer user_data
, void *context
);
141 CancelCallback cancel_cb
;
142 Downloader
*downloader
;
149 void SetCancelFuncAndData (CancelCallback cb
, Downloader
*user_data
, void *context
);
152 #endif /* __UTILS_H__ */