Frameworks/libpurple.framework/Versions/0.6.2/Headers/util.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2535 Frameworks/libpurple.framework/Versions/0.6.0/Headers/util.h@39c3c161de14
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
Evan@653
     1
/**
Evan@653
     2
 * @file util.h Utility Functions
Evan@653
     3
 * @ingroup core
Evan@653
     4
 */
Evan@653
     5
Evan@653
     6
/* purple
Evan@653
     7
 *
Evan@653
     8
 * Purple is the legal property of its developers, whose names are too numerous
Evan@653
     9
 * to list here.  Please refer to the COPYRIGHT file distributed with this
Evan@653
    10
 * source distribution.
Evan@653
    11
 *
Evan@653
    12
 * This program is free software; you can redistribute it and/or modify
Evan@653
    13
 * it under the terms of the GNU General Public License as published by
Evan@653
    14
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
    15
 * (at your option) any later version.
Evan@653
    16
 *
Evan@653
    17
 * This program is distributed in the hope that it will be useful,
Evan@653
    18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Evan@653
    20
 * GNU General Public License for more details.
Evan@653
    21
 *
Evan@653
    22
 * You should have received a copy of the GNU General Public License
Evan@653
    23
 * along with this program; if not, write to the Free Software
Evan@653
    24
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
Evan@653
    25
 *
Evan@653
    26
 * @todo Rename the functions so that they live somewhere in the purple
Evan@653
    27
 *       namespace.
Evan@653
    28
 */
Evan@653
    29
#ifndef _PURPLE_UTIL_H_
Evan@653
    30
#define _PURPLE_UTIL_H_
Evan@653
    31
Evan@653
    32
#include <stdio.h>
Evan@653
    33
zacw@1759
    34
typedef struct _PurpleUtilFetchUrlData PurpleUtilFetchUrlData;
zacw@1759
    35
typedef struct _PurpleMenuAction PurpleMenuAction;
zacw@1759
    36
typedef struct _PurpleKeyValuePair PurpleKeyValuePair;
zacw@1759
    37
Evan@653
    38
#include "account.h"
Evan@653
    39
#include "xmlnode.h"
Evan@653
    40
#include "notify.h"
Evan@653
    41
zacw@1759
    42
Evan@653
    43
#ifdef __cplusplus
Evan@653
    44
extern "C" {
Evan@653
    45
#endif
Evan@653
    46
zacw@1759
    47
struct _PurpleMenuAction
Evan@653
    48
{
Evan@653
    49
	char *label;
Evan@653
    50
	PurpleCallback callback;
Evan@653
    51
	gpointer data;
Evan@653
    52
	GList *children;
zacw@1759
    53
};
Evan@653
    54
Evan@653
    55
typedef char *(*PurpleInfoFieldFormatCallback)(const char *field, size_t len);
Evan@653
    56
Evan@653
    57
/**
Evan@653
    58
 * A key-value pair.
Evan@653
    59
 *
Evan@653
    60
 * This is used by, among other things, purple_gtk_combo* functions to pass in a
Evan@653
    61
 * list of key-value pairs so it can display a user-friendly value.
Evan@653
    62
 */
zacw@1759
    63
struct _PurpleKeyValuePair
Evan@653
    64
{
Evan@653
    65
	gchar *key;
Evan@653
    66
	void *value;
Evan@653
    67
zacw@1759
    68
};
Evan@653
    69
Evan@653
    70
/**
Evan@653
    71
 * Creates a new PurpleMenuAction.
Evan@653
    72
 *
Evan@653
    73
 * @param label    The text label to display for this action.
Evan@653
    74
 * @param callback The function to be called when the action is used on
Evan@653
    75
 *                 the selected item.
Evan@653
    76
 * @param data     Additional data to be passed to the callback.
Evan@653
    77
 * @param children A GList of PurpleMenuActions to be added as a submenu
Evan@653
    78
 *                 of the action.
Evan@653
    79
 * @return The PurpleMenuAction.
Evan@653
    80
 */
Evan@653
    81
PurpleMenuAction *purple_menu_action_new(const char *label, PurpleCallback callback,
Evan@653
    82
                                     gpointer data, GList *children);
Evan@653
    83
Evan@653
    84
/**
Evan@653
    85
 * Frees a PurpleMenuAction
Evan@653
    86
 *
Evan@653
    87
 * @param act The PurpleMenuAction to free.
Evan@653
    88
 */
Evan@653
    89
void purple_menu_action_free(PurpleMenuAction *act);
Evan@653
    90
Evan@653
    91
/**
Evan@653
    92
 * Set the appropriate presence values for the currently playing song.
Evan@653
    93
 *
Evan@653
    94
 * @param title     The title of the song, @c NULL to unset the value.
Evan@653
    95
 * @param artist    The artist of the song, can be @c NULL.
Evan@653
    96
 * @param album     The album of the song, can be @c NULL.
Evan@653
    97
 * @since 2.4.0
Evan@653
    98
 */
Evan@653
    99
void purple_util_set_current_song(const char *title, const char *artist,
Evan@653
   100
		const char *album);
Evan@653
   101
Evan@653
   102
/**
Evan@653
   103
 * Format song information.
Evan@653
   104
 *
Evan@653
   105
 * @param title     The title of the song, @c NULL to unset the value.
Evan@653
   106
 * @param artist    The artist of the song, can be @c NULL.
Evan@653
   107
 * @param album     The album of the song, can be @c NULL.
Evan@653
   108
 * @param unused    Currently unused, must be @c NULL.
Evan@653
   109
 *
Evan@653
   110
 * @return   The formatted string. The caller must #g_free the returned string.
Evan@653
   111
 * @since 2.4.0
Evan@653
   112
 */
Evan@653
   113
char * purple_util_format_song_info(const char *title, const char *artist,
Evan@653
   114
		const char *album, gpointer unused);
Evan@653
   115
Evan@653
   116
/**************************************************************************/
Evan@653
   117
/** @name Utility Subsystem                                               */
Evan@653
   118
/**************************************************************************/
Evan@653
   119
/*@{*/
Evan@653
   120
Evan@653
   121
/**
Evan@653
   122
 * Initializes the utility subsystem.
Evan@653
   123
 *
Evan@653
   124
 * @since 2.3.0
Evan@653
   125
 */
Evan@653
   126
void purple_util_init(void);
Evan@653
   127
Evan@653
   128
/**
Evan@653
   129
 * Uninitializes the util subsystem.
Evan@653
   130
 *
Evan@653
   131
 * @since 2.3.0
Evan@653
   132
 */
Evan@653
   133
void purple_util_uninit(void);
Evan@653
   134
Evan@653
   135
/*@}*/
Evan@653
   136
Evan@653
   137
/**************************************************************************/
Evan@653
   138
/** @name Base16 Functions                                                */
Evan@653
   139
/**************************************************************************/
Evan@653
   140
/*@{*/
Evan@653
   141
Evan@653
   142
/**
Evan@653
   143
 * Converts a chunk of binary data to its base-16 equivalent.
Evan@653
   144
 *
Evan@653
   145
 * @param data The data to convert.
Evan@653
   146
 * @param len  The length of the data.
Evan@653
   147
 *
Evan@653
   148
 * @return The base-16 string in the ASCII encoding.  Must be
Evan@653
   149
 *         g_free'd when no longer needed.
Evan@653
   150
 *
Evan@653
   151
 * @see purple_base16_decode()
Evan@653
   152
 */
Evan@653
   153
gchar *purple_base16_encode(const guchar *data, gsize len);
Evan@653
   154
Evan@653
   155
/**
Evan@653
   156
 * Converts an ASCII string of base-16 encoded data to
Evan@653
   157
 * the binary equivalent.
Evan@653
   158
 *
Evan@653
   159
 * @param str     The base-16 string to convert to raw data.
Evan@653
   160
 * @param ret_len The length of the returned data.  You can
Evan@653
   161
 *                pass in NULL if you're sure that you know
Evan@653
   162
 *                the length of the decoded data, or if you
Evan@653
   163
 *                know you'll be able to use strlen to
Evan@653
   164
 *                determine the length, etc.
Evan@653
   165
 *
Evan@653
   166
 * @return The raw data.  Must be g_free'd when no longer needed.
Evan@653
   167
 *
Evan@653
   168
 * @see purple_base16_encode()
Evan@653
   169
 */
Evan@653
   170
guchar *purple_base16_decode(const char *str, gsize *ret_len);
Evan@653
   171
Evan@653
   172
/**
Evan@653
   173
 * Converts a chunk of binary data to a chunked base-16 representation
Evan@653
   174
 * (handy for key fingerprints)
Evan@653
   175
 *
Evan@653
   176
 * Example output: 01:23:45:67:89:AB:CD:EF
Evan@653
   177
 *
Evan@653
   178
 * @param data The data to convert.
Evan@653
   179
 * @param len  The length of the data.
Evan@653
   180
 *
Evan@653
   181
 * @return The base-16 string in the ASCII chunked encoding.  Must be
Evan@653
   182
 *         g_free'd when no longer needed.
Evan@653
   183
 */
Evan@653
   184
gchar *purple_base16_encode_chunked(const guchar *data, gsize len);
Evan@653
   185
Evan@653
   186
Evan@653
   187
/*@}*/
Evan@653
   188
Evan@653
   189
/**************************************************************************/
Evan@653
   190
/** @name Base64 Functions                                                */
Evan@653
   191
/**************************************************************************/
Evan@653
   192
/*@{*/
Evan@653
   193
Evan@653
   194
/**
Evan@653
   195
 * Converts a chunk of binary data to its base-64 equivalent.
Evan@653
   196
 *
Evan@653
   197
 * @param data The data to convert.
Evan@653
   198
 * @param len  The length of the data.
Evan@653
   199
 *
Evan@653
   200
 * @return The base-64 string in the ASCII encoding.  Must be
Evan@653
   201
 *         g_free'd when no longer needed.
Evan@653
   202
 *
Evan@653
   203
 * @see purple_base64_decode()
Evan@653
   204
 */
Evan@653
   205
gchar *purple_base64_encode(const guchar *data, gsize len);
Evan@653
   206
Evan@653
   207
/**
Evan@653
   208
 * Converts an ASCII string of base-64 encoded data to
Evan@653
   209
 * the binary equivalent.
Evan@653
   210
 *
Evan@653
   211
 * @param str     The base-64 string to convert to raw data.
Evan@653
   212
 * @param ret_len The length of the returned data.  You can
Evan@653
   213
 *                pass in NULL if you're sure that you know
Evan@653
   214
 *                the length of the decoded data, or if you
Evan@653
   215
 *                know you'll be able to use strlen to
Evan@653
   216
 *                determine the length, etc.
Evan@653
   217
 *
Evan@653
   218
 * @return The raw data.  Must be g_free'd when no longer needed.
Evan@653
   219
 *
Evan@653
   220
 * @see purple_base64_encode()
Evan@653
   221
 */
Evan@653
   222
guchar *purple_base64_decode(const char *str, gsize *ret_len);
Evan@653
   223
Evan@653
   224
/*@}*/
Evan@653
   225
Evan@653
   226
/**************************************************************************/
Evan@653
   227
/** @name Quoted Printable Functions                                      */
Evan@653
   228
/**************************************************************************/
Evan@653
   229
/*@{*/
Evan@653
   230
Evan@653
   231
/**
Evan@653
   232
 * Converts a quoted printable string back to its readable equivalent.
Evan@653
   233
 * What is a quoted printable string, you ask?  It's an encoding used
Evan@653
   234
 * to transmit binary data as ASCII.  It's intended purpose is to send
Evan@653
   235
 * emails containing non-ASCII characters.  Wikipedia has a pretty good
Evan@653
   236
 * explanation.  Also see RFC 2045.
Evan@653
   237
 *
Evan@653
   238
 * @param str     The quoted printable ASCII string to convert to raw data.
Evan@653
   239
 * @param ret_len The length of the returned data.
Evan@653
   240
 *
Evan@653
   241
 * @return The readable string.  Must be g_free'd when no longer needed.
Evan@653
   242
 */
Evan@653
   243
guchar *purple_quotedp_decode(const char *str, gsize *ret_len);
Evan@653
   244
Evan@653
   245
/*@}*/
Evan@653
   246
Evan@653
   247
/**************************************************************************/
Evan@653
   248
/** @name MIME Functions                                                  */
Evan@653
   249
/**************************************************************************/
Evan@653
   250
/*@{*/
Evan@653
   251
Evan@653
   252
/**
Evan@653
   253
 * Converts a MIME header field string back to its readable equivalent
Evan@653
   254
 * according to RFC 2047.  Basically, a header is plain ASCII and can
Evan@653
   255
 * contain any number of sections called "encoded-words."  The format
Evan@653
   256
 * of an encoded word is =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?=
Evan@653
   257
 * =? designates the beginning of the encoded-word
Evan@653
   258
 * ?= designates the end of the encoded-word
Evan@653
   259
 *
Evan@653
   260
 * An encoded word is segmented into three pieces by the use of a
Evan@653
   261
 * question mark.  The first piece is the character set, the second
Evan@653
   262
 * piece is the encoding, and the third piece is the encoded text.
Evan@653
   263
 *
Evan@653
   264
 * @param str The ASCII string, possibly containing any number of
Evan@653
   265
 *            encoded-word sections.
Evan@653
   266
 *
Evan@653
   267
 * @return The string, with any encoded-word sections decoded and
Evan@653
   268
 *         converted to UTF-8.  Must be g_free'd when no longer
Evan@653
   269
 *         needed.
Evan@653
   270
 */
Evan@653
   271
char *purple_mime_decode_field(const char *str);
Evan@653
   272
Evan@653
   273
/*@}*/
Evan@653
   274
Evan@653
   275
Evan@653
   276
/**************************************************************************/
Evan@653
   277
/** @name Date/Time Functions                                             */
Evan@653
   278
/**************************************************************************/
Evan@653
   279
/*@{*/
Evan@653
   280
Evan@653
   281
/**
Evan@653
   282
 * Formats a time into the specified format.
Evan@653
   283
 *
Evan@653
   284
 * This is essentially strftime(), but it has a static buffer
Evan@653
   285
 * and handles the UTF-8 conversion for the caller.
Evan@653
   286
 *
Evan@653
   287
 * This function also provides the GNU %z formatter if the underlying C
Evan@653
   288
 * library doesn't.  However, the format string parser is very naive, which
Evan@653
   289
 * means that conversions specifiers to %z cannot be guaranteed.  The GNU
Evan@653
   290
 * strftime(3) man page describes %z as: 'The time-zone as hour offset from
Evan@653
   291
 * GMT.  Required to emit RFC822-conformant dates
Evan@653
   292
 * (using "%a, %d %b %Y %H:%M:%S %z"). (GNU)'
Evan@653
   293
 *
Evan@653
   294
 * On Windows, this function also converts the results for %Z from a timezone
Evan@653
   295
 * name (as returned by the system strftime() %Z format string) to a timezone
Evan@653
   296
 * abbreviation (as is the case on Unix).  As with %z, conversion specifiers
Evan@653
   297
 * should not be used.
Evan@653
   298
 *
Evan@653
   299
 * @param format The format string, in UTF-8
Evan@653
   300
 * @param tm     The time to format, or @c NULL to use the current local time
Evan@653
   301
 *
Evan@653
   302
 * @return The formatted time, in UTF-8.
Evan@653
   303
 *
Evan@653
   304
 * @note @a format is required to be in UTF-8.  This differs from strftime(),
Evan@653
   305
 *       where the format is provided in the locale charset.
Evan@653
   306
 */
Evan@653
   307
const char *purple_utf8_strftime(const char *format, const struct tm *tm);
Evan@653
   308
Evan@653
   309
/**
Evan@653
   310
 * Gets a string representation of the local timezone offset
Evan@653
   311
 *
Evan@653
   312
 * @param tm   The time to get the timezone for
Evan@653
   313
 * @param iso  TRUE to format the offset according to ISO-8601, FALSE to
Evan@653
   314
 *             not substitute 'Z' for 0 offset, and to not separate
Evan@653
   315
 *             hours and minutes with a colon.
Evan@653
   316
 */
Evan@653
   317
const char *purple_get_tzoff_str(const struct tm *tm, gboolean iso);
Evan@653
   318
Evan@653
   319
/**
Evan@653
   320
 * Formats a time into the user's preferred short date format.
Evan@653
   321
 *
Evan@653
   322
 * The returned string is stored in a static buffer, so the result
Evan@653
   323
 * should be g_strdup()'d if it's going to be kept.
Evan@653
   324
 *
Evan@653
   325
 * @param tm The time to format, or @c NULL to use the current local time
Evan@653
   326
 *
Evan@653
   327
 * @return The date, formatted as per the user's settings.
Evan@653
   328
 */
Evan@653
   329
const char *purple_date_format_short(const struct tm *tm);
Evan@653
   330
Evan@653
   331
/**
Evan@653
   332
 * Formats a time into the user's preferred short date plus time format.
Evan@653
   333
 *
Evan@653
   334
 * The returned string is stored in a static buffer, so the result
Evan@653
   335
 * should be g_strdup()'d if it's going to be kept.
Evan@653
   336
 *
Evan@653
   337
 * @param tm The time to format, or @c NULL to use the current local time
Evan@653
   338
 *
Evan@653
   339
 * @return The timestamp, formatted as per the user's settings.
Evan@653
   340
 */
Evan@653
   341
const char *purple_date_format_long(const struct tm *tm);
Evan@653
   342
Evan@653
   343
/**
Evan@653
   344
 * Formats a time into the user's preferred full date and time format.
Evan@653
   345
 *
Evan@653
   346
 * The returned string is stored in a static buffer, so the result
Evan@653
   347
 * should be g_strdup()'d if it's going to be kept.
Evan@653
   348
 *
Evan@653
   349
 * @param tm The time to format, or @c NULL to use the current local time
Evan@653
   350
 *
Evan@653
   351
 * @return The date and time, formatted as per the user's settings.
Evan@653
   352
 */
Evan@653
   353
const char *purple_date_format_full(const struct tm *tm);
Evan@653
   354
Evan@653
   355
/**
Evan@653
   356
 * Formats a time into the user's preferred time format.
Evan@653
   357
 *
Evan@653
   358
 * The returned string is stored in a static buffer, so the result
Evan@653
   359
 * should be g_strdup()'d if it's going to be kept.
Evan@653
   360
 *
Evan@653
   361
 * @param tm The time to format, or @c NULL to use the current local time
Evan@653
   362
 *
Evan@653
   363
 * @return The time, formatted as per the user's settings.
Evan@653
   364
 */
Evan@653
   365
const char *purple_time_format(const struct tm *tm);
Evan@653
   366
Evan@653
   367
/**
Evan@653
   368
 * Builds a time_t from the supplied information.
Evan@653
   369
 *
Evan@653
   370
 * @param year  The year.
Evan@653
   371
 * @param month The month.
Evan@653
   372
 * @param day   The day.
Evan@653
   373
 * @param hour  The hour.
Evan@653
   374
 * @param min   The minute.
Evan@653
   375
 * @param sec   The second.
Evan@653
   376
 *
Evan@653
   377
 * @return A time_t.
Evan@653
   378
 */
Evan@653
   379
time_t purple_time_build(int year, int month, int day, int hour,
Evan@653
   380
					   int min, int sec);
Evan@653
   381
Evan@653
   382
/** Used by purple_str_to_time to indicate no timezone offset was
Evan@653
   383
  * specified in the timestamp string. */
Evan@653
   384
#define PURPLE_NO_TZ_OFF -500000
Evan@653
   385
Evan@653
   386
/**
Evan@653
   387
 * Parses a timestamp in jabber, ISO8601, or MM/DD/YYYY format and returns
Evan@653
   388
 * a time_t.
Evan@653
   389
 *
Evan@653
   390
 * @param timestamp The timestamp
Evan@653
   391
 * @param utc       Assume UTC if no timezone specified
Evan@653
   392
 * @param tm        If not @c NULL, the caller can get a copy of the
Evan@653
   393
 *                  struct tm used to calculate the time_t return value.
Evan@653
   394
 * @param tz_off    If not @c NULL, the caller can get a copy of the
Evan@653
   395
 *                  timezone offset (from UTC) used to calculate the time_t
Evan@653
   396
 *                  return value. Note: Zero is a valid offset. As such,
Evan@653
   397
 *                  the value of the macro @c PURPLE_NO_TZ_OFF indicates no
Evan@653
   398
 *                  offset was specified (which means that the local
Evan@653
   399
 *                  timezone was used in the calculation).
Evan@653
   400
 * @param rest      If not @c NULL, the caller can get a pointer to the
Evan@653
   401
 *                  part of @a timestamp left over after parsing is
Evan@653
   402
 *                  completed, if it's not the end of @a timestamp.
Evan@653
   403
 *
Evan@653
   404
 * @return A time_t.
Evan@653
   405
 */
Evan@653
   406
time_t purple_str_to_time(const char *timestamp, gboolean utc,
Evan@653
   407
                        struct tm *tm, long *tz_off, const char **rest);
Evan@653
   408
Evan@653
   409
/*@}*/
Evan@653
   410
Evan@653
   411
Evan@653
   412
/**************************************************************************/
Evan@653
   413
/** @name Markup Functions                                                */
Evan@653
   414
/**************************************************************************/
Evan@653
   415
/*@{*/
Evan@653
   416
Evan@653
   417
/**
zacw@2535
   418
 * Escapes special characters in a plain-text string so they display
zacw@2535
   419
 * correctly as HTML.  For example, & is replaced with &amp; and < is
zacw@2535
   420
 * replaced with &lt;
zacw@2535
   421
 *
zacw@2535
   422
 * This is exactly the same as g_markup_escape_text(), except that it
zacw@2535
   423
 * does not change ' to &apos; because &apos; is not a valid HTML 4 entity,
zacw@2535
   424
 * and is displayed literally in IE7.
zacw@2535
   425
 *
zacw@2535
   426
 * @since 2.6.0
zacw@2535
   427
 */
zacw@2535
   428
gchar *purple_markup_escape_text(const gchar *text, gssize length);
zacw@2535
   429
zacw@2535
   430
/**
Evan@653
   431
 * Finds an HTML tag matching the given name.
Evan@653
   432
 *
Evan@653
   433
 * This locates an HTML tag's start and end, and stores its attributes
Evan@653
   434
 * in a GData hash table. The names of the attributes are lower-cased
Evan@653
   435
 * in the hash table, and the name of the tag is case insensitive.
Evan@653
   436
 *
Evan@653
   437
 * @param needle	  The name of the tag
Evan@653
   438
 * @param haystack	  The null-delimited string to search in
Evan@653
   439
 * @param start		  A pointer to the start of the tag if found
Evan@653
   440
 * @param end		  A pointer to the end of the tag if found
Evan@653
   441
 * @param attributes  The attributes, if the tag was found.  This should
Evan@653
   442
 *                    be freed with g_datalist_clear().
Evan@653
   443
 * @return TRUE if the tag was found
Evan@653
   444
 */
Evan@653
   445
gboolean purple_markup_find_tag(const char *needle, const char *haystack,
Evan@653
   446
							  const char **start, const char **end,
Evan@653
   447
							  GData **attributes);
Evan@653
   448
Evan@653
   449
/**
Evan@653
   450
 * Extracts a field of data from HTML.
Evan@653
   451
 *
Evan@653
   452
 * This is a scary function. See protocols/msn/msn.c and
Evan@653
   453
 * protocols/yahoo/yahoo_profile.c for example usage.
Evan@653
   454
 *
Evan@653
   455
 * @param str            The string to parse.
Evan@653
   456
 * @param len            The size of str.
Evan@653
   457
 * @param user_info      The destination PurpleNotifyUserInfo to which the new
Evan@653
   458
 *                       field info should be added.
Evan@653
   459
 * @param start_token    The beginning token.
Evan@653
   460
 * @param skip           The number of characters to skip after the
Evan@653
   461
 *                       start token.
Evan@653
   462
 * @param end_token      The ending token.
Evan@653
   463
 * @param check_value    The value that the last character must meet.
Evan@653
   464
 * @param no_value_token The token indicating no value is given.
Evan@653
   465
 * @param display_name   The short descriptive name to display for this token.
Evan@653
   466
 * @param is_link        TRUE if this should be a link, or FALSE otherwise.
Evan@653
   467
 * @param link_prefix    The prefix for the link.
Evan@653
   468
 * @param format_cb      A callback to format the value before adding it.
Evan@653
   469
 *
Evan@653
   470
 * @return TRUE if successful, or FALSE otherwise.
Evan@653
   471
 */
Evan@653
   472
gboolean purple_markup_extract_info_field(const char *str, int len, PurpleNotifyUserInfo *user_info,
Evan@653
   473
                                        const char *start_token, int skip,
Evan@653
   474
                                        const char *end_token, char check_value,
Evan@653
   475
                                        const char *no_value_token,
Evan@653
   476
                                        const char *display_name, gboolean is_link,
Evan@653
   477
                                        const char *link_prefix,
Evan@653
   478
					PurpleInfoFieldFormatCallback format_cb);
Evan@653
   479
Evan@653
   480
/**
Evan@653
   481
 * Converts HTML markup to XHTML.
Evan@653
   482
 *
Evan@653
   483
 * @param html       The HTML markup.
Evan@653
   484
 * @param dest_xhtml The destination XHTML output.
Evan@653
   485
 * @param dest_plain The destination plain-text output.
Evan@653
   486
 */
Evan@653
   487
void purple_markup_html_to_xhtml(const char *html, char **dest_xhtml,
Evan@653
   488
							   char **dest_plain);
Evan@653
   489
Evan@653
   490
/**
Evan@653
   491
 * Strips HTML tags from a string.
Evan@653
   492
 *
Evan@653
   493
 * @param str The string to strip HTML from.
Evan@653
   494
 *
Evan@653
   495
 * @return The new string without HTML.  You must g_free this string
Evan@653
   496
 *         when finished with it.
Evan@653
   497
 */
Evan@653
   498
char *purple_markup_strip_html(const char *str);
Evan@653
   499
Evan@653
   500
/**
Evan@653
   501
 * Adds the necessary HTML code to turn URIs into HTML links in a string.
Evan@653
   502
 *
Evan@653
   503
 * @param str The string to linkify.
Evan@653
   504
 *
Evan@653
   505
 * @return The new string with all URIs surrounded in standard
Evan@653
   506
 *         HTML <a href="whatever"></a> tags.  You must g_free this
Evan@653
   507
 *         string when finished with it.
Evan@653
   508
 */
Evan@653
   509
char *purple_markup_linkify(const char *str);
Evan@653
   510
Evan@653
   511
/**
zacw@2151
   512
 * Unescapes HTML entities to their literal characters. Also translates
zacw@2151
   513
 * "<br>" to "\n".
Evan@653
   514
 * For example "&amp;" is replaced by '&' and so on.
Evan@653
   515
 * Actually only "&amp;", "&quot;", "&lt;" and "&gt;" are currently
Evan@653
   516
 * supported.
Evan@653
   517
 *
Evan@653
   518
 * @param html The string in which to unescape any HTML entities
Evan@653
   519
 *
Evan@653
   520
 * @return The text with HTML entities literalized.  You must g_free
Evan@653
   521
 *         this string when finished with it.
Evan@653
   522
 */
Evan@653
   523
char *purple_unescape_html(const char *html);
Evan@653
   524
Evan@653
   525
/**
Evan@653
   526
 * Returns a newly allocated substring of the HTML UTF-8 string "str".
Evan@653
   527
 * The markup is preserved such that the substring will have the same
Evan@653
   528
 * formatting as original string, even though some tags may have been
Evan@653
   529
 * opened before "x", or may close after "y". All open tags are closed
Evan@653
   530
 * at the end of the returned string, in the proper order.
Evan@653
   531
 *
Evan@653
   532
 * Note that x and y are in character offsets, not byte offsets, and
Evan@653
   533
 * are offsets into an unformatted version of str. Because of this,
Evan@653
   534
 * this function may be sensitive to changes in GtkIMHtml and may break
Evan@653
   535
 * when used with other UI's. libpurple users are encouraged to report and
Evan@653
   536
 * work out any problems encountered.
Evan@653
   537
 *
Evan@653
   538
 * @param str The input NUL terminated, HTML, UTF-8 (or ASCII) string.
Evan@653
   539
 * @param x The character offset into an unformatted version of str to
Evan@653
   540
 *          begin at.
Evan@653
   541
 * @param y The character offset (into an unformatted vesion of str) of
Evan@653
   542
 *          one past the last character to include in the slice.
Evan@653
   543
 *
Evan@653
   544
 * @return The HTML slice of string, with all formatting retained.
Evan@653
   545
 */
Evan@653
   546
char *purple_markup_slice(const char *str, guint x, guint y);
Evan@653
   547
Evan@653
   548
/**
Evan@653
   549
 * Returns a newly allocated string containing the name of the tag
Evan@653
   550
 * located at "tag". Tag is expected to point to a '<', and contain
Evan@653
   551
 * a '>' sometime after that. If there is no '>' and the string is
Evan@653
   552
 * not NUL terminated, this function can be expected to segfault.
Evan@653
   553
 *
Evan@653
   554
 * @param tag The string starting a HTML tag.
Evan@653
   555
 * @return A string containing the name of the tag.
Evan@653
   556
 */
Evan@653
   557
char *purple_markup_get_tag_name(const char *tag);
Evan@653
   558
Evan@653
   559
/**
Evan@653
   560
 * Returns a constant string of the character representation of the HTML
Evan@653
   561
 * entity pointed to by @a text. For example, purple_markup_unescape_entity("&amp;")
Evan@653
   562
 * will return "&". The @a text variable is expected to point to an '&',
Evan@653
   563
 * the first character of the entity. If given an unrecognized entity, the function
Evan@653
   564
 * returns @c NULL.
Evan@653
   565
 *
Evan@653
   566
 * Note that this function, unlike purple_unescape_html(), does not search
Evan@653
   567
 * the string for the entity, does not replace the entity, and does not
Evan@653
   568
 * return a newly allocated string.
Evan@653
   569
 *
Evan@653
   570
 * @param text   A string containing an HTML entity.
Evan@653
   571
 * @param length If not @c NULL, the string length of the entity is stored in this location.
Evan@653
   572
 *
Evan@653
   573
 * @return A constant string containing the character representation of the given entity.
Evan@653
   574
 */
Evan@653
   575
const char * purple_markup_unescape_entity(const char *text, int *length);
Evan@653
   576
Evan@653
   577
/**
Evan@653
   578
 * Returns a newly allocated string containing the value of the CSS property specified
Evan@653
   579
 * in opt. The @a style argument is expected to point to a HTML inline CSS.
Evan@653
   580
 * The function will seek for the CSS property and return its value.
Evan@653
   581
 *
Evan@653
   582
 * For example, purple_markup_get_css_property("direction:rtl;color:#dc4d1b;",
Evan@653
   583
 * "color") would return "#dc4d1b".
Evan@653
   584
 *
Evan@653
   585
 * On error or if the requested property was not found, the function returns
Evan@653
   586
 * @c NULL.
Evan@653
   587
 *
Evan@653
   588
 * @param style A string containing the inline CSS text.
Evan@653
   589
 * @param opt   The requested CSS property.
Evan@653
   590
 *
Evan@653
   591
 * @return The value of the requested CSS property.
Evan@653
   592
 */
Evan@653
   593
char * purple_markup_get_css_property(const gchar *style, const gchar *opt);
Evan@653
   594
zacw@2490
   595
/**
zacw@2490
   596
 * Check if the given HTML contains RTL text.
zacw@2490
   597
 *
zacw@2490
   598
 * @param html  The HTML text.
zacw@2490
   599
 *
zacw@2490
   600
 * @return  TRUE if the text contains RTL text, FALSE otherwise.
zacw@2490
   601
 *
zacw@2490
   602
 * @since 2.6.0
zacw@2490
   603
 */
zacw@2490
   604
gboolean purple_markup_is_rtl(const char *html);
Evan@653
   605
Evan@653
   606
/*@}*/
Evan@653
   607
Evan@653
   608
Evan@653
   609
/**************************************************************************/
Evan@653
   610
/** @name Path/Filename Functions                                         */
Evan@653
   611
/**************************************************************************/
Evan@653
   612
/*@{*/
Evan@653
   613
Evan@653
   614
/**
Evan@653
   615
 * Returns the user's home directory.
Evan@653
   616
 *
Evan@653
   617
 * @return The user's home directory.
Evan@653
   618
 *
Evan@653
   619
 * @see purple_user_dir()
Evan@653
   620
 */
Evan@653
   621
const gchar *purple_home_dir(void);
Evan@653
   622
Evan@653
   623
/**
Evan@653
   624
 * Returns the purple settings directory in the user's home directory.
Evan@653
   625
 * This is usually ~/.purple
Evan@653
   626
 *
Evan@653
   627
 * @return The purple settings directory.
Evan@653
   628
 *
Evan@653
   629
 * @see purple_home_dir()
Evan@653
   630
 */
Evan@653
   631
const char *purple_user_dir(void);
Evan@653
   632
Evan@653
   633
/**
Evan@653
   634
 * Define a custom purple settings directory, overriding the default (user's home directory/.purple)
Evan@653
   635
 * @param dir The custom settings directory
Evan@653
   636
 */
Evan@653
   637
void purple_util_set_user_dir(const char *dir);
Evan@653
   638
Evan@653
   639
/**
Evan@653
   640
 * Builds a complete path from the root, making any directories along
Evan@653
   641
 * the path which do not already exist.
Evan@653
   642
 *
Evan@653
   643
 * @param path The path you wish to create.  Note that it must start
Evan@653
   644
 *        from the root or this function will fail.
Evan@653
   645
 * @param mode Unix-style permissions for this directory.
Evan@653
   646
 *
Evan@653
   647
 * @return 0 for success, nonzero on any error.
Evan@653
   648
 */
Evan@653
   649
int purple_build_dir(const char *path, int mode);
Evan@653
   650
Evan@653
   651
/**
Evan@653
   652
 * Write a string of data to a file of the given name in the Purple
Evan@653
   653
 * user directory ($HOME/.purple by default).  The data is typically
Evan@653
   654
 * a serialized version of one of Purple's config files, such as
Evan@653
   655
 * prefs.xml, accounts.xml, etc.  And the string is typically
Evan@653
   656
 * obtained using xmlnode_to_formatted_str.  However, this function
Evan@653
   657
 * should work fine for saving binary files as well.
Evan@653
   658
 *
Evan@653
   659
 * @param filename The basename of the file to write in the purple_user_dir.
Evan@653
   660
 * @param data     A null-terminated string of data to write.
Evan@653
   661
 * @param size     The size of the data to save.  If data is
Evan@653
   662
 *                 null-terminated you can pass in -1.
Evan@653
   663
 *
Evan@653
   664
 * @return TRUE if the file was written successfully.  FALSE otherwise.
Evan@653
   665
 */
Evan@653
   666
gboolean purple_util_write_data_to_file(const char *filename, const char *data,
Evan@653
   667
									  gssize size);
Evan@653
   668
Evan@653
   669
/**
Evan@653
   670
 * Write data to a file using the absolute path.
Evan@653
   671
 *
Evan@653
   672
 * This exists for Glib backwards compatibility reasons.
Evan@653
   673
 *
Evan@653
   674
 * @param filename_full Filename to write to
Evan@653
   675
 * @param data          A null-terminated string of data to write.
Evan@653
   676
 * @param size          The size of the data to save.  If data is
Evan@653
   677
 *                      null-terminated you can pass in -1.
Evan@653
   678
 *
Evan@653
   679
 * @return TRUE if the file was written successfully.  FALSE otherwise.
Evan@653
   680
 *
Evan@653
   681
 * @todo Remove this function (use g_file_set_contents instead) when 3.0.0
Evan@653
   682
 *       rolls around.
Evan@653
   683
 * @see purple_util_write_data_to_file()
Evan@653
   684
 *
Evan@653
   685
 */
Evan@653
   686
gboolean
Evan@653
   687
purple_util_write_data_to_file_absolute(const char *filename_full, const char *data, gssize size);
Evan@653
   688
Evan@653
   689
/**
Evan@653
   690
 * Read the contents of a given file and parse the results into an
Evan@653
   691
 * xmlnode tree structure.  This is intended to be used to read
Evan@653
   692
 * Purple's configuration xml files (prefs.xml, pounces.xml, etc.)
Evan@653
   693
 *
Evan@653
   694
 * @param filename    The basename of the file to open in the purple_user_dir.
Evan@653
   695
 * @param description A very short description of the contents of this
Evan@653
   696
 *                    file.  This is used in error messages shown to the
Evan@653
   697
 *                    user when the file can not be opened.  For example,
Evan@653
   698
 *                    "preferences," or "buddy pounces."
Evan@653
   699
 *
Evan@653
   700
 * @return An xmlnode tree of the contents of the given file.  Or NULL, if
Evan@653
   701
 *         the file does not exist or there was an error reading the file.
Evan@653
   702
 */
Evan@653
   703
xmlnode *purple_util_read_xml_from_file(const char *filename,
Evan@653
   704
									  const char *description);
Evan@653
   705
Evan@653
   706
/**
Evan@653
   707
 * Creates a temporary file and returns a file pointer to it.
Evan@653
   708
 *
Evan@653
   709
 * This is like mkstemp(), but returns a file pointer and uses a
Evan@653
   710
 * pre-set template. It uses the semantics of tempnam() for the
Evan@653
   711
 * directory to use and allocates the space for the file path.
Evan@653
   712
 *
Evan@653
   713
 * The caller is responsible for closing the file and removing it when
Evan@653
   714
 * done, as well as freeing the space pointed to by @a path with
Evan@653
   715
 * g_free().
Evan@653
   716
 *
Evan@653
   717
 * @param path   The returned path to the temp file.
Evan@653
   718
 * @param binary Text or binary, for platforms where it matters.
Evan@653
   719
 *
Evan@653
   720
 * @return A file pointer to the temporary file, or @c NULL on failure.
Evan@653
   721
 */
Evan@653
   722
FILE *purple_mkstemp(char **path, gboolean binary);
Evan@653
   723
Evan@653
   724
/**
Evan@653
   725
 * Returns an extension corresponding to the image data's file type.
Evan@653
   726
 *
Evan@653
   727
 * @param data A pointer to the image data
Evan@653
   728
 * @param len  The length of the image data
Evan@653
   729
 *
Evan@653
   730
 * @return The appropriate extension, or "icon" if unknown.
Evan@653
   731
 */
Evan@653
   732
const char *
Evan@653
   733
purple_util_get_image_extension(gconstpointer data, size_t len);
Evan@653
   734
Evan@653
   735
/**
Evan@653
   736
 * Returns a SHA-1 hash string of the data passed in.
Evan@653
   737
 */
Evan@653
   738
char *purple_util_get_image_checksum(gconstpointer image_data, size_t image_len);
Evan@653
   739
Evan@653
   740
/**
Evan@653
   741
 * @return A hex encoded version of the SHA-1 hash of the data passed
Evan@653
   742
 *         in with the correct file extention appended.  The file
Evan@653
   743
 *         extension is determined by calling
Evan@653
   744
 *         purple_util_get_image_extension().  This return value must
Evan@653
   745
 *         be g_freed by the caller.
Evan@653
   746
 */
Evan@653
   747
char *purple_util_get_image_filename(gconstpointer image_data, size_t image_len);
Evan@653
   748
Evan@653
   749
/*@}*/
Evan@653
   750
Evan@653
   751
Evan@653
   752
/**************************************************************************/
Evan@653
   753
/** @name Environment Detection Functions                                 */
Evan@653
   754
/**************************************************************************/
Evan@653
   755
/*@{*/
Evan@653
   756
Evan@653
   757
/**
Evan@653
   758
 * Checks if the given program name is valid and executable.
Evan@653
   759
 *
Evan@653
   760
 * @param program The file name of the application.
Evan@653
   761
 *
Evan@653
   762
 * @return TRUE if the program is runable.
Evan@653
   763
 */
Evan@653
   764
gboolean purple_program_is_valid(const char *program);
Evan@653
   765
Evan@653
   766
/**
Evan@653
   767
 * Check if running GNOME.
Evan@653
   768
 *
Evan@653
   769
 * @return TRUE if running GNOME, FALSE otherwise.
Evan@653
   770
 */
Evan@653
   771
gboolean purple_running_gnome(void);
Evan@653
   772
Evan@653
   773
/**
Evan@653
   774
 * Check if running KDE.
Evan@653
   775
 *
Evan@653
   776
 * @return TRUE if running KDE, FALSE otherwise.
Evan@653
   777
 */
Evan@653
   778
gboolean purple_running_kde(void);
Evan@653
   779
Evan@653
   780
/**
Evan@653
   781
 * Check if running OS X.
Evan@653
   782
 *
Evan@653
   783
 * @return TRUE if running OS X, FALSE otherwise.
Evan@653
   784
 */
Evan@653
   785
gboolean purple_running_osx(void);
Evan@653
   786
Evan@653
   787
/**
Evan@653
   788
 * Returns the IP address from a socket file descriptor.
Evan@653
   789
 *
Evan@653
   790
 * @param fd The socket file descriptor.
Evan@653
   791
 *
Evan@653
   792
 * @return The IP address, or @c NULL on error.
Evan@653
   793
 */
Evan@653
   794
char *purple_fd_get_ip(int fd);
Evan@653
   795
Evan@653
   796
/*@}*/
Evan@653
   797
Evan@653
   798
Evan@653
   799
/**************************************************************************/
Evan@653
   800
/** @name String Functions                                                */
Evan@653
   801
/**************************************************************************/
Evan@653
   802
/*@{*/
Evan@653
   803
Evan@653
   804
/**
Evan@1427
   805
 * Tests two strings for equality.
Evan@1427
   806
 *
Evan@1427
   807
 * Unlike strcmp(), this function will not crash if one or both of the
Evan@1427
   808
 * strings are @c NULL.
Evan@1427
   809
 *
Evan@1427
   810
 * @param left	A string
Evan@1427
   811
 * @param right A string to compare with left
Evan@1427
   812
 *
Evan@1427
   813
 * @return @c TRUE if the strings are the same, else @c FALSE.
Evan@1427
   814
 *
Evan@1427
   815
 * @since 2.6.0
Evan@1427
   816
 */
Evan@1427
   817
gboolean purple_strequal(const gchar *left, const gchar *right);
Evan@1427
   818
Evan@1427
   819
/**
Evan@653
   820
 * Normalizes a string, so that it is suitable for comparison.
Evan@653
   821
 *
Evan@653
   822
 * The returned string will point to a static buffer, so if the
Evan@653
   823
 * string is intended to be kept long-term, you <i>must</i>
Evan@653
   824
 * g_strdup() it. Also, calling normalize() twice in the same line
Evan@653
   825
 * will lead to problems.
Evan@653
   826
 *
Evan@653
   827
 * @param account  The account the string belongs to, or NULL if you do
Evan@653
   828
 *                 not know the account.  If you use NULL, the string
Evan@653
   829
 *                 will still be normalized, but if the PRPL uses a
Evan@653
   830
 *                 custom normalization function then the string may
Evan@653
   831
 *                 not be normalized correctly.
Evan@653
   832
 * @param str      The string to normalize.
Evan@653
   833
 *
Evan@653
   834
 * @return A pointer to the normalized version stored in a static buffer.
Evan@653
   835
 */
Evan@653
   836
const char *purple_normalize(const PurpleAccount *account, const char *str);
Evan@653
   837
Evan@653
   838
/**
Evan@653
   839
 * Normalizes a string, so that it is suitable for comparison.
Evan@653
   840
 *
Evan@653
   841
 * This is one possible implementation for the PRPL callback
Evan@653
   842
 * function "normalize."  It returns a lowercase and UTF-8
Evan@653
   843
 * normalized version of the string.
Evan@653
   844
 *
Evan@653
   845
 * @param account  The account the string belongs to.
Evan@653
   846
 * @param str      The string to normalize.
Evan@653
   847
 *
Evan@653
   848
 * @return A pointer to the normalized version stored in a static buffer.
Evan@653
   849
 */
Evan@653
   850
const char *purple_normalize_nocase(const PurpleAccount *account, const char *str);
Evan@653
   851
Evan@653
   852
/**
Evan@653
   853
 * Compares two strings to see if the first contains the second as
Evan@653
   854
 * a proper prefix.
Evan@653
   855
 *
Evan@653
   856
 * @param s  The string to check.
Evan@653
   857
 * @param p  The prefix in question.
Evan@653
   858
 *
Evan@653
   859
 * @return   TRUE if p is a prefix of s, otherwise FALSE.
Evan@653
   860
 */
Evan@653
   861
gboolean purple_str_has_prefix(const char *s, const char *p);
Evan@653
   862
Evan@653
   863
/**
Evan@653
   864
 * Compares two strings to see if the second is a proper suffix
Evan@653
   865
 * of the first.
Evan@653
   866
 *
Evan@653
   867
 * @param s  The string to check.
Evan@653
   868
 * @param x  The suffix in question.
Evan@653
   869
 *
Evan@653
   870
 * @return   TRUE if x is a a suffix of s, otherwise FALSE.
Evan@653
   871
 */
Evan@653
   872
gboolean purple_str_has_suffix(const char *s, const char *x);
Evan@653
   873
Evan@653
   874
/**
Evan@653
   875
 * Duplicates a string and replaces all newline characters from the
Evan@653
   876
 * source string with HTML linebreaks.
Evan@653
   877
 *
Evan@653
   878
 * @param src The source string.
Evan@653
   879
 *
Evan@653
   880
 * @return The new string.  Must be g_free'd by the caller.
Evan@653
   881
 */
Evan@653
   882
gchar *purple_strdup_withhtml(const gchar *src);
Evan@653
   883
Evan@653
   884
/**
Evan@653
   885
 * Ensures that all linefeeds have a matching carriage return.
Evan@653
   886
 *
Evan@653
   887
 * @param str The source string.
Evan@653
   888
 *
Evan@653
   889
 * @return The string with carriage returns.
Evan@653
   890
 */
Evan@653
   891
char *purple_str_add_cr(const char *str);
Evan@653
   892
Evan@653
   893
/**
Evan@653
   894
 * Strips all instances of the given character from the
Evan@653
   895
 * given string.  The string is modified in place.  This
Evan@653
   896
 * is useful for stripping new line characters, for example.
Evan@653
   897
 *
Evan@653
   898
 * Example usage:
Evan@653
   899
 * purple_str_strip_char(my_dumb_string, '\n');
Evan@653
   900
 *
Evan@653
   901
 * @param str     The string to strip characters from.
Evan@653
   902
 * @param thechar The character to strip from the given string.
Evan@653
   903
 */
Evan@653
   904
void purple_str_strip_char(char *str, char thechar);
Evan@653
   905
Evan@653
   906
/**
Evan@653
   907
 * Given a string, this replaces all instances of one character
Evan@653
   908
 * with another.  This happens inline (the original string IS
Evan@653
   909
 * modified).
Evan@653
   910
 *
Evan@653
   911
 * @param string The string from which to replace stuff.
Evan@653
   912
 * @param delimiter The character you want replaced.
Evan@653
   913
 * @param replacement The character you want inserted in place
Evan@653
   914
 *        of the delimiting character.
Evan@653
   915
 */
Evan@653
   916
void purple_util_chrreplace(char *string, char delimiter,
Evan@653
   917
						  char replacement);
Evan@653
   918
Evan@653
   919
/**
Evan@653
   920
 * Given a string, this replaces one substring with another
Evan@653
   921
 * and returns a newly allocated string.
Evan@653
   922
 *
Evan@653
   923
 * @param string The string from which to replace stuff.
Evan@653
   924
 * @param delimiter The substring you want replaced.
Evan@653
   925
 * @param replacement The substring you want inserted in place
Evan@653
   926
 *        of the delimiting substring.
Evan@653
   927
 *
Evan@653
   928
 * @return A new string, after performing the substitution.
Evan@653
   929
 *         free this with g_free().
Evan@653
   930
 */
Evan@653
   931
gchar *purple_strreplace(const char *string, const char *delimiter,
Evan@653
   932
					   const char *replacement);
Evan@653
   933
Evan@653
   934
Evan@653
   935
/**
Evan@653
   936
 * Given a string, this replaces any utf-8 substrings in that string with
Evan@653
   937
 * the corresponding numerical character reference, and returns a newly
Evan@653
   938
 * allocated string.
Evan@653
   939
 *
Evan@653
   940
 * @param in The string which might contain utf-8 substrings
Evan@653
   941
 *
Evan@653
   942
 * @return A new string, with utf-8 replaced with numerical character
Evan@653
   943
 *         references, free this with g_free()
Evan@653
   944
*/
Evan@653
   945
char *purple_utf8_ncr_encode(const char *in);
Evan@653
   946
Evan@653
   947
Evan@653
   948
/**
Evan@653
   949
 * Given a string, this replaces any numerical character references
Evan@653
   950
 * in that string with the corresponding actual utf-8 substrings,
Evan@653
   951
 * and returns a newly allocated string.
Evan@653
   952
 *
Evan@653
   953
 * @param in The string which might contain numerical character references.
Evan@653
   954
 *
Evan@653
   955
 * @return A new string, with numerical character references
Evan@653
   956
 *         replaced with actual utf-8, free this with g_free().
Evan@653
   957
 */
Evan@653
   958
char *purple_utf8_ncr_decode(const char *in);
Evan@653
   959
Evan@653
   960
Evan@653
   961
/**
Evan@653
   962
 * Given a string, this replaces one substring with another
Evan@653
   963
 * ignoring case and returns a newly allocated string.
Evan@653
   964
 *
Evan@653
   965
 * @param string The string from which to replace stuff.
Evan@653
   966
 * @param delimiter The substring you want replaced.
Evan@653
   967
 * @param replacement The substring you want inserted in place
Evan@653
   968
 *        of the delimiting substring.
Evan@653
   969
 *
Evan@653
   970
 * @return A new string, after performing the substitution.
Evan@653
   971
 *         free this with g_free().
Evan@653
   972
 */
Evan@653
   973
gchar *purple_strcasereplace(const char *string, const char *delimiter,
Evan@653
   974
						   const char *replacement);
Evan@653
   975
Evan@653
   976
/**
Evan@653
   977
 * This is like strstr, except that it ignores ASCII case in
Evan@653
   978
 * searching for the substring.
Evan@653
   979
 *
Evan@653
   980
 * @param haystack The string to search in.
Evan@653
   981
 * @param needle   The substring to find.
Evan@653
   982
 *
Evan@653
   983
 * @return the location of the substring if found, or NULL if not
Evan@653
   984
 */
Evan@653
   985
const char *purple_strcasestr(const char *haystack, const char *needle);
Evan@653
   986
Evan@653
   987
/**
Evan@653
   988
 * Returns a string representing a filesize in the appropriate
Evan@653
   989
 * units (MB, KB, GB, etc.)
Evan@653
   990
 *
Evan@653
   991
 * @param size The size
Evan@653
   992
 *
Evan@653
   993
 * @return The string in units form. This must be freed.
Evan@653
   994
 */
Evan@653
   995
char *purple_str_size_to_units(size_t size);
Evan@653
   996
Evan@653
   997
/**
Evan@653
   998
 * Converts seconds into a human-readable form.
Evan@653
   999
 *
Evan@653
  1000
 * @param sec The seconds.
Evan@653
  1001
 *
Evan@653
  1002
 * @return A human-readable form, containing days, hours, minutes, and
Evan@653
  1003
 *         seconds.
Evan@653
  1004
 */
Evan@653
  1005
char *purple_str_seconds_to_string(guint sec);
Evan@653
  1006
Evan@653
  1007
/**
Evan@653
  1008
 * Converts a binary string into a NUL terminated ascii string,
Evan@653
  1009
 * replacing nonascii characters and characters below SPACE (including
Evan@653
  1010
 * NUL) into \\xyy, where yy are two hex digits. Also backslashes are
Evan@653
  1011
 * changed into two backslashes (\\\\). The returned, newly allocated
Evan@653
  1012
 * string can be outputted to the console, and must be g_free()d.
Evan@653
  1013
 *
Evan@653
  1014
 * @param binary A string of random data, possibly with embedded NULs
Evan@653
  1015
 *               and such.
Evan@653
  1016
 * @param len The length in bytes of the input string. Must not be 0.
Evan@653
  1017
 *
Evan@653
  1018
 * @return A newly allocated ASCIIZ string.
Evan@653
  1019
 */
Evan@653
  1020
char *purple_str_binary_to_ascii(const unsigned char *binary, guint len);
Evan@653
  1021
/*@}*/
Evan@653
  1022
Evan@653
  1023
Evan@653
  1024
/**************************************************************************/
Evan@653
  1025
/** @name URI/URL Functions                                               */
Evan@653
  1026
/**************************************************************************/
Evan@653
  1027
/*@{*/
Evan@653
  1028
Evan@653
  1029
void purple_got_protocol_handler_uri(const char *uri);
Evan@653
  1030
Evan@653
  1031
/**
Evan@653
  1032
 * Parses a URL, returning its host, port, file path, username and password.
Evan@653
  1033
 *
Evan@653
  1034
 * The returned data must be freed.
Evan@653
  1035
 *
Evan@653
  1036
 * @param url      The URL to parse.
Evan@653
  1037
 * @param ret_host The returned host.
Evan@653
  1038
 * @param ret_port The returned port.
Evan@653
  1039
 * @param ret_path The returned path.
Evan@653
  1040
 * @param ret_user The returned username.
Evan@653
  1041
 * @param ret_passwd The returned password.
Evan@653
  1042
 */
Evan@653
  1043
gboolean purple_url_parse(const char *url, char **ret_host, int *ret_port,
Evan@653
  1044
						char **ret_path, char **ret_user, char **ret_passwd);
Evan@653
  1045
Evan@653
  1046
/**
Evan@653
  1047
 * This is the signature used for functions that act as the callback
Evan@653
  1048
 * to purple_util_fetch_url() or purple_util_fetch_url_request().
Evan@653
  1049
 *
Evan@653
  1050
 * @param url_data      The same value that was returned when you called
Evan@653
  1051
 *                      purple_fetch_url() or purple_fetch_url_request().
Evan@653
  1052
 * @param user_data     The user data that your code passed into either
Evan@653
  1053
 *                      purple_util_fetch_url() or purple_util_fetch_url_request().
Evan@653
  1054
 * @param url_text      This will be NULL on error.  Otherwise this
Evan@653
  1055
 *                      will contain the contents of the URL.
Evan@653
  1056
 * @param len           0 on error, otherwise this is the length of buf.
Evan@653
  1057
 * @param error_message If something went wrong then this will contain
Evan@653
  1058
 *                      a descriptive error message, and buf will be
Evan@653
  1059
 *                      NULL and len will be 0.
Evan@653
  1060
 */
Evan@653
  1061
typedef void (*PurpleUtilFetchUrlCallback)(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message);
Evan@653
  1062
Evan@653
  1063
/**
Evan@653
  1064
 * Fetches the data from a URL, and passes it to a callback function.
Evan@653
  1065
 *
Evan@653
  1066
 * @param url        The URL.
Evan@653
  1067
 * @param full       TRUE if this is the full URL, or FALSE if it's a
Evan@653
  1068
 *                   partial URL.
Evan@653
  1069
 * @param user_agent The user agent field to use, or NULL.
Evan@653
  1070
 * @param http11     TRUE if HTTP/1.1 should be used to download the file.
Evan@653
  1071
 * @param cb         The callback function.
Evan@653
  1072
 * @param data       The user data to pass to the callback function.
Evan@653
  1073
 */
Evan@653
  1074
#define purple_util_fetch_url(url, full, user_agent, http11, cb, data) \
Evan@653
  1075
	purple_util_fetch_url_request(url, full, user_agent, http11, NULL, \
Evan@653
  1076
		FALSE, cb, data);
Evan@653
  1077
Evan@653
  1078
/**
Evan@653
  1079
 * Fetches the data from a URL, and passes it to a callback function.
Evan@653
  1080
 *
Evan@653
  1081
 * @param url        The URL.
Evan@653
  1082
 * @param full       TRUE if this is the full URL, or FALSE if it's a
Evan@653
  1083
 *                   partial URL.
Evan@653
  1084
 * @param user_agent The user agent field to use, or NULL.
Evan@653
  1085
 * @param http11     TRUE if HTTP/1.1 should be used to download the file.
Evan@653
  1086
 * @param max_len    The maximum number of bytes to retrieve (-1 for unlimited)
Evan@653
  1087
 * @param cb         The callback function.
Evan@653
  1088
 * @param data       The user data to pass to the callback function.
Evan@653
  1089
 * @deprecated       In 3.0.0, we'll rename this to "purple_util_fetch_url" and get rid of the old one
Evan@653
  1090
 */
Evan@653
  1091
#define purple_util_fetch_url_len(url, full, user_agent, http11, max_len, cb, data) \
Evan@653
  1092
	purple_util_fetch_url_request_len(url, full, user_agent, http11, NULL, \
Evan@653
  1093
		FALSE, max_len, cb, data);
Evan@653
  1094
Evan@653
  1095
/**
Evan@653
  1096
 * Fetches the data from a URL, and passes it to a callback function.
Evan@653
  1097
 *
Evan@653
  1098
 * @param url        The URL.
Evan@653
  1099
 * @param full       TRUE if this is the full URL, or FALSE if it's a
Evan@653
  1100
 *                   partial URL.
Evan@653
  1101
 * @param user_agent The user agent field to use, or NULL.
Evan@653
  1102
 * @param http11     TRUE if HTTP/1.1 should be used to download the file.
Evan@653
  1103
 * @param request    A HTTP request to send to the server instead of the
Evan@653
  1104
 *                   standard GET
Evan@653
  1105
 * @param include_headers
Evan@653
  1106
 *                   If TRUE, include the HTTP headers in the response.
Evan@653
  1107
 * @param callback   The callback function.
Evan@653
  1108
 * @param data       The user data to pass to the callback function.
Evan@653
  1109
 */
Evan@653
  1110
PurpleUtilFetchUrlData *purple_util_fetch_url_request(const gchar *url,
Evan@653
  1111
		gboolean full, const gchar *user_agent, gboolean http11,
Evan@653
  1112
		const gchar *request, gboolean include_headers,
Evan@653
  1113
		PurpleUtilFetchUrlCallback callback, gpointer data);
Evan@653
  1114
Evan@653
  1115
/**
Evan@653
  1116
 * Fetches the data from a URL, and passes it to a callback function.
Evan@653
  1117
 *
Evan@653
  1118
 * @param url        The URL.
Evan@653
  1119
 * @param full       TRUE if this is the full URL, or FALSE if it's a
Evan@653
  1120
 *                   partial URL.
Evan@653
  1121
 * @param user_agent The user agent field to use, or NULL.
Evan@653
  1122
 * @param http11     TRUE if HTTP/1.1 should be used to download the file.
Evan@653
  1123
 * @param request    A HTTP request to send to the server instead of the
Evan@653
  1124
 *                   standard GET
Evan@653
  1125
 * @param include_headers
Evan@653
  1126
 *                   If TRUE, include the HTTP headers in the response.
Evan@653
  1127
 * @param max_len    The maximum number of bytes to retrieve (-1 for unlimited)
Evan@653
  1128
 * @param callback   The callback function.
Evan@653
  1129
 * @param data       The user data to pass to the callback function.
zacw@2409
  1130
 * @deprecated       In 3.0.0, this will go away.
zacw@2409
  1131
 */
zacw@2409
  1132
PurpleUtilFetchUrlData *purple_util_fetch_url_request_len(const gchar *url,
zacw@2409
  1133
		gboolean full, const gchar *user_agent, gboolean http11,
zacw@2409
  1134
		const gchar *request, gboolean include_headers, gssize max_len,
zacw@2409
  1135
		PurpleUtilFetchUrlCallback callback, gpointer data);
zacw@2409
  1136
zacw@2409
  1137
/**
zacw@2409
  1138
 * Fetches the data from a URL, and passes it to a callback function.
zacw@2409
  1139
 *
zacw@2409
  1140
 * @param account    The account for which the request is needed, or NULL.
zacw@2409
  1141
 * @param url        The URL.
zacw@2409
  1142
 * @param full       TRUE if this is the full URL, or FALSE if it's a
zacw@2409
  1143
 *                   partial URL.
zacw@2409
  1144
 * @param user_agent The user agent field to use, or NULL.
zacw@2409
  1145
 * @param http11     TRUE if HTTP/1.1 should be used to download the file.
zacw@2409
  1146
 * @param request    A HTTP request to send to the server instead of the
zacw@2409
  1147
 *                   standard GET
zacw@2409
  1148
 * @param include_headers
zacw@2409
  1149
 *                   If TRUE, include the HTTP headers in the response.
zacw@2409
  1150
 * @param max_len    The maximum number of bytes to retrieve (-1 for unlimited)
zacw@2409
  1151
 * @param callback   The callback function.
zacw@2409
  1152
 * @param data       The user data to pass to the callback function.
Evan@653
  1153
 * @deprecated       In 3.0.0, we'll rename this to "purple_util_fetch_url_request" and get rid of the old one
Evan@653
  1154
 */
zacw@2409
  1155
PurpleUtilFetchUrlData *purple_util_fetch_url_request_len_with_account(
zacw@2409
  1156
		PurpleAccount *account, const gchar *url,
Evan@653
  1157
		gboolean full, const gchar *user_agent, gboolean http11,
Evan@653
  1158
		const gchar *request, gboolean include_headers, gssize max_len,
Evan@653
  1159
		PurpleUtilFetchUrlCallback callback, gpointer data);
Evan@653
  1160
Evan@653
  1161
/**
Evan@653
  1162
 * Cancel a pending URL request started with either
Evan@653
  1163
 * purple_util_fetch_url_request() or purple_util_fetch_url().
Evan@653
  1164
 *
Evan@653
  1165
 * @param url_data The data returned when you initiated the URL fetch.
Evan@653
  1166
 */
Evan@653
  1167
void purple_util_fetch_url_cancel(PurpleUtilFetchUrlData *url_data);
Evan@653
  1168
Evan@653
  1169
/**
Evan@653
  1170
 * Decodes a URL into a plain string.
Evan@653
  1171
 *
Evan@653
  1172
 * This will change hex codes and such to their ascii equivalents.
Evan@653
  1173
 *
Evan@653
  1174
 * @param str The string to translate.
Evan@653
  1175
 *
Evan@653
  1176
 * @return The resulting string.
Evan@653
  1177
 */
Evan@653
  1178
const char *purple_url_decode(const char *str);
Evan@653
  1179
Evan@653
  1180
/**
Evan@653
  1181
 * Encodes a URL into an escaped string.
Evan@653
  1182
 *
Evan@653
  1183
 * This will change non-alphanumeric characters to hex codes.
Evan@653
  1184
 *
Evan@653
  1185
 * @param str The string to translate.
Evan@653
  1186
 *
Evan@653
  1187
 * @return The resulting string.
Evan@653
  1188
 */
Evan@653
  1189
const char *purple_url_encode(const char *str);
Evan@653
  1190
Evan@653
  1191
/**
Evan@653
  1192
 * Checks if the given email address is syntactically valid.
Evan@653
  1193
 *
Evan@653
  1194
 * @param address The email address to validate.
Evan@653
  1195
 *
Evan@653
  1196
 * @return True if the email address is syntactically correct.
Evan@653
  1197
 */
Evan@653
  1198
gboolean purple_email_is_valid(const char *address);
Evan@653
  1199
Evan@653
  1200
/**
Evan@653
  1201
 * Checks if the given IP address is a syntactically valid IPv4 address.
Evan@653
  1202
 *
Evan@653
  1203
 * @param ip The IP address to validate.
Evan@653
  1204
 *
Evan@653
  1205
 * @return True if the IP address is syntactically correct.
zacw@2535
  1206
 * @deprecated This function will be replaced with one that validates
zacw@2535
  1207
 *             as either IPv4 or IPv6 in 3.0.0. If you don't want this,
zacw@2535
  1208
 *             behavior, use one of the more specific functions.
Evan@653
  1209
 */
Evan@653
  1210
gboolean purple_ip_address_is_valid(const char *ip);
Evan@653
  1211
Evan@653
  1212
/**
zacw@2535
  1213
 * Checks if the given IP address is a syntactically valid IPv4 address.
zacw@2535
  1214
 *
zacw@2535
  1215
 * @param ip The IP address to validate.
zacw@2535
  1216
 *
zacw@2535
  1217
 * @return True if the IP address is syntactically correct.
zacw@2535
  1218
 * @since 2.6.0
zacw@2535
  1219
 */
zacw@2535
  1220
gboolean purple_ipv4_address_is_valid(const char *ip);
zacw@2535
  1221
zacw@2535
  1222
/**
zacw@2535
  1223
 * Checks if the given IP address is a syntactically valid IPv6 address.
zacw@2535
  1224
 *
zacw@2535
  1225
 * @param ip The IP address to validate.
zacw@2535
  1226
 *
zacw@2535
  1227
 * @return True if the IP address is syntactically correct.
zacw@2535
  1228
 * @since 2.6.0
zacw@2535
  1229
 */
zacw@2535
  1230
gboolean purple_ipv6_address_is_valid(const char *ip);
zacw@2535
  1231
zacw@2535
  1232
/**
Evan@653
  1233
 * This function extracts a list of URIs from the a "text/uri-list"
Evan@653
  1234
 * string.  It was "borrowed" from gnome_uri_list_extract_uris
Evan@653
  1235
 *
Evan@653
  1236
 * @param uri_list An uri-list in the standard format.
Evan@653
  1237
 *
Evan@653
  1238
 * @return A GList containing strings allocated with g_malloc
Evan@653
  1239
 *         that have been splitted from uri-list.
Evan@653
  1240
 */
Evan@653
  1241
GList *purple_uri_list_extract_uris(const gchar *uri_list);
Evan@653
  1242
Evan@653
  1243
/**
Evan@653
  1244
 * This function extracts a list of filenames from a
Evan@653
  1245
 * "text/uri-list" string.  It was "borrowed" from
Evan@653
  1246
 * gnome_uri_list_extract_filenames
Evan@653
  1247
 *
Evan@653
  1248
 * @param uri_list A uri-list in the standard format.
Evan@653
  1249
 *
Evan@653
  1250
 * @return A GList containing strings allocated with g_malloc that
Evan@653
  1251
 *         contain the filenames in the uri-list. Note that unlike
Evan@653
  1252
 *         purple_uri_list_extract_uris() function, this will discard
Evan@653
  1253
 *         any non-file uri from the result value.
Evan@653
  1254
 */
Evan@653
  1255
GList *purple_uri_list_extract_filenames(const gchar *uri_list);
Evan@653
  1256
Evan@653
  1257
/*@}*/
Evan@653
  1258
Evan@653
  1259
/**************************************************************************
Evan@653
  1260
 * UTF8 String Functions
Evan@653
  1261
 **************************************************************************/
Evan@653
  1262
/*@{*/
Evan@653
  1263
Evan@653
  1264
/**
Evan@653
  1265
 * Attempts to convert a string to UTF-8 from an unknown encoding.
Evan@653
  1266
 *
Evan@653
  1267
 * This function checks the locale and tries sane defaults.
Evan@653
  1268
 *
Evan@653
  1269
 * @param str The source string.
Evan@653
  1270
 *
Evan@653
  1271
 * @return The UTF-8 string, or @c NULL if it could not be converted.
Evan@653
  1272
 */
Evan@653
  1273
gchar *purple_utf8_try_convert(const char *str);
Evan@653
  1274
Evan@653
  1275
/**
Evan@653
  1276
 * Salvages the valid UTF-8 characters from a string, replacing any
Evan@653
  1277
 * invalid characters with a filler character (currently hardcoded to
Evan@653
  1278
 * '?').
Evan@653
  1279
 *
Evan@653
  1280
 * @param str The source string.
Evan@653
  1281
 *
Evan@653
  1282
 * @return A valid UTF-8 string.
Evan@653
  1283
 */
Evan@653
  1284
gchar *purple_utf8_salvage(const char *str);
Evan@653
  1285
Evan@653
  1286
/**
zacw@2490
  1287
 * Removes unprintable characters from a UTF-8 string. These characters
zacw@2490
  1288
 * (in particular low-ASCII characters) are invalid in XML 1.0 and thus
zacw@2490
  1289
 * are not allowed in XMPP and are rejected by libxml2 by default. This
zacw@2490
  1290
 * function uses g_unichar_isprint to determine what characters should
zacw@2490
  1291
 * be stripped. The returned string must be freed by the caller.
zacw@2490
  1292
 *
zacw@2490
  1293
 * @param str A valid UTF-8 string.
zacw@2490
  1294
 *
zacw@2490
  1295
 * @return A newly allocated UTF-8 string without the unprintable characters.
zacw@2490
  1296
 * @since 2.6.0
zacw@2490
  1297
 *
zacw@2490
  1298
 * @see g_unichar_isprint
zacw@2490
  1299
 */
zacw@2490
  1300
gchar *purple_utf8_strip_unprintables(const gchar *str);
zacw@2490
  1301
zacw@2490
  1302
/**
Evan@653
  1303
 * Return the UTF-8 version of gai_strerror().  It calls gai_strerror()
Evan@653
  1304
 * then converts the result to UTF-8.  This function is analogous to
Evan@653
  1305
 * g_strerror().
Evan@653
  1306
 *
Evan@653
  1307
 * @param errnum The error code.
Evan@653
  1308
 *
Evan@653
  1309
 * @return The UTF-8 error message.
Evan@653
  1310
 * @since 2.4.0
Evan@653
  1311
 */
Evan@653
  1312
G_CONST_RETURN gchar *purple_gai_strerror(gint errnum);
Evan@653
  1313
Evan@653
  1314
/**
Evan@770
  1315
 * Compares two UTF-8 strings case-insensitively.  This comparison is
Evan@653
  1316
 * more expensive than a simple g_utf8_collate() comparison because
Evan@653
  1317
 * it calls g_utf8_casefold() on each string, which allocates new
Evan@653
  1318
 * strings.
Evan@653
  1319
 *
Evan@653
  1320
 * @param a The first string.
Evan@653
  1321
 * @param b The second string.
Evan@653
  1322
 *
Evan@653
  1323
 * @return -1 if @a is less than @a b.
Evan@653
  1324
 *          0 if @a is equal to @a b.
Evan@653
  1325
 *          1 if @a is greater than @a b.
Evan@653
  1326
 */
Evan@653
  1327
int purple_utf8_strcasecmp(const char *a, const char *b);
Evan@653
  1328
Evan@653
  1329
/**
Evan@653
  1330
 * Case insensitive search for a word in a string. The needle string
Evan@653
  1331
 * must be contained in the haystack string and not be immediately
Evan@653
  1332
 * preceded or immediately followed by another alpha-numeric character.
Evan@653
  1333
 *
Evan@653
  1334
 * @param haystack The string to search in.
Evan@653
  1335
 * @param needle   The substring to find.
Evan@653
  1336
 *
Evan@653
  1337
 * @return TRUE if haystack has the word, otherwise FALSE
Evan@653
  1338
 */
Evan@653
  1339
gboolean purple_utf8_has_word(const char *haystack, const char *needle);
Evan@653
  1340
Evan@653
  1341
/**
Evan@653
  1342
 * Prints a UTF-8 message to the given file stream. The function
Evan@653
  1343
 * tries to convert the UTF-8 message to user's locale. If this
Evan@653
  1344
 * is not possible, the original UTF-8 text will be printed.
Evan@653
  1345
 *
Evan@653
  1346
 * @param filestream The file stream (e.g. STDOUT or STDERR)
Evan@653
  1347
 * @param message    The message to print.
Evan@653
  1348
 */
Evan@653
  1349
void purple_print_utf8_to_console(FILE *filestream, char *message);
Evan@653
  1350
Evan@653
  1351
/**
Evan@653
  1352
 * Checks for messages starting (post-HTML) with "/me ", including the space.
Evan@653
  1353
 *
Evan@653
  1354
 * @param message The message to check
Evan@653
  1355
 * @param len     The message length, or -1
Evan@653
  1356
 *
Evan@653
  1357
 * @return TRUE if it starts with "/me ", and it has been removed, otherwise
Evan@653
  1358
 *         FALSE
Evan@653
  1359
 */
Evan@653
  1360
gboolean purple_message_meify(char *message, gssize len);
Evan@653
  1361
Evan@653
  1362
/**
Evan@653
  1363
 * Removes the underscore characters from a string used identify the mnemonic
Evan@653
  1364
 * character.
Evan@653
  1365
 *
Evan@653
  1366
 * @param in  The string to strip
Evan@653
  1367
 *
Evan@653
  1368
 * @return The stripped string
Evan@653
  1369
 */
Evan@653
  1370
char *purple_text_strip_mnemonic(const char *in);
Evan@653
  1371
Evan@653
  1372
/*@}*/
Evan@653
  1373
Evan@653
  1374
/**
Evan@653
  1375
 * Adds 8 to something.
Evan@653
  1376
 *
Evan@653
  1377
 * Blame SimGuy.
Evan@653
  1378
 *
Evan@653
  1379
 * @param x The number to add 8 to.
Evan@653
  1380
 *
Evan@653
  1381
 * @return x + 8
Evan@653
  1382
 */
Evan@653
  1383
#define purple_add_eight(x) ((x)+8)
Evan@653
  1384
Evan@653
  1385
/**
Evan@653
  1386
 * Does the reverse of purple_escape_filename
Evan@653
  1387
 *
Evan@653
  1388
 * This will change hex codes and such to their ascii equivalents.
Evan@653
  1389
 *
Evan@653
  1390
 * @param str The string to translate.
Evan@653
  1391
 *
Evan@653
  1392
 * @return The resulting string.
Evan@653
  1393
 */
Evan@653
  1394
const char *purple_unescape_filename(const char *str);
Evan@653
  1395
Evan@653
  1396
/**
Evan@653
  1397
 * Escapes filesystem-unfriendly characters from a filename
Evan@653
  1398
 *
Evan@653
  1399
 * @param str The string to translate.
Evan@653
  1400
 *
Evan@653
  1401
 * @return The resulting string.
Evan@653
  1402
 */
Evan@653
  1403
const char *purple_escape_filename(const char *str);
Evan@653
  1404
Evan@653
  1405
/**
Evan@653
  1406
 * This is added temporarily to assist the split of oscar into aim and icq.
Evan@653
  1407
 * This should not be used by plugins.
Evan@653
  1408
 */
Evan@653
  1409
const char *_purple_oscar_convert(const char *act, const char *protocol);
Evan@653
  1410
Evan@653
  1411
/**
Evan@653
  1412
 * Restore default signal handlers for signals which might reasonably have
Evan@653
  1413
 * handlers. This should be called by a fork()'d child process, since child processes
Evan@653
  1414
 * inherit the handlers of the parent.
Evan@653
  1415
 */
Evan@653
  1416
void purple_restore_default_signal_handlers(void);
Evan@653
  1417
Evan@653
  1418
/**
Evan@653
  1419
 * Gets the host name of the machine. If it not possible to determine the
Evan@653
  1420
 * host name, "localhost" is returned
Evan@653
  1421
 *
Evan@653
  1422
 * @constreturn The hostname
Evan@653
  1423
 */
Evan@653
  1424
const gchar *purple_get_host_name(void);
Evan@653
  1425
Evan@653
  1426
#ifdef __cplusplus
Evan@653
  1427
}
Evan@653
  1428
#endif
Evan@653
  1429
Evan@653
  1430
#endif /* _PURPLE_UTIL_H_ */