3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 * TODO Rename the functions so that they live somewhere in the purple
25 #ifndef _PURPLE_UTIL_H_
26 #define _PURPLE_UTIL_H_
29 * @section_id: libpurple-util
30 * @short_description: <filename>util.h</filename>
31 * @title: Utility Functions
39 * A generic structure that contains information about an "action." One
40 * place this is is used is by protocols to tell the core the list of available
41 * right-click actions for a buddy list row.
43 typedef struct _PurpleMenuAction PurpleMenuAction
;
52 * This is used by, among other things, purple_gtk_combo* functions to pass in a
53 * list of key-value pairs so it can display a user-friendly value.
55 typedef struct _PurpleKeyValuePair PurpleKeyValuePair
;
61 #include "protocols.h"
64 typedef char *(*PurpleInfoFieldFormatCallback
)(const char *field
, size_t len
);
66 struct _PurpleKeyValuePair
76 * purple_menu_action_new:
77 * @label: The text label to display for this action.
78 * @callback: The function to be called when the action is used on
80 * @data: Additional data to be passed to the callback.
81 * @children: (element-type PurpleMenuAction) (transfer full): Menu actions to
82 * be added as a submenu of this action.
84 * Creates a new PurpleMenuAction.
86 * Returns: The PurpleMenuAction.
88 PurpleMenuAction
*purple_menu_action_new(const char *label
, PurpleCallback callback
,
89 gpointer data
, GList
*children
);
92 * purple_menu_action_free:
93 * @act: The PurpleMenuAction to free.
95 * Frees a PurpleMenuAction
97 void purple_menu_action_free(PurpleMenuAction
*act
);
100 * purple_menu_action_get_label:
101 * @act: The PurpleMenuAction.
103 * Returns the label of the PurpleMenuAction.
105 * Returns: The label string.
107 char * purple_menu_action_get_label(const PurpleMenuAction
*act
);
110 * purple_menu_action_get_callback:
111 * @act: The PurpleMenuAction.
113 * Returns the callback of the PurpleMenuAction.
115 * Returns: The callback function.
117 PurpleCallback
purple_menu_action_get_callback(const PurpleMenuAction
*act
);
120 * purple_menu_action_get_data:
121 * @act: The PurpleMenuAction.
123 * Returns the data stored in the PurpleMenuAction.
127 gpointer
purple_menu_action_get_data(const PurpleMenuAction
*act
);
130 * purple_menu_action_get_children:
131 * @act: The PurpleMenuAction.
133 * Returns the children of the PurpleMenuAction.
135 * Returns: (element-type PurpleMenuAction) (transfer none): The menu children.
137 GList
* purple_menu_action_get_children(const PurpleMenuAction
*act
);
140 * purple_menu_action_set_label:
141 * @act: The menu action.
142 * @label: The label for the menu action.
144 * Set the label to the PurpleMenuAction.
146 void purple_menu_action_set_label(PurpleMenuAction
*act
, char *label
);
149 * purple_menu_action_set_callback:
150 * @act: The menu action.
151 * @callback: The callback.
153 * Set the callback that will be used by the PurpleMenuAction.
155 void purple_menu_action_set_callback(PurpleMenuAction
*act
, PurpleCallback callback
);
158 * purple_menu_action_set_data:
159 * @act: The menu action.
160 * @data: The data used by this PurpleMenuAction
162 * Set the label to the PurpleMenuAction.
164 void purple_menu_action_set_data(PurpleMenuAction
*act
, gpointer data
);
167 * purple_menu_action_set_children:
168 * @act: The menu action.
169 * @children: (element-type PurpleMenuAction) (transfer full): The menu children
171 * Set the children of the PurpleMenuAction.
173 void purple_menu_action_set_children(PurpleMenuAction
*act
, GList
*children
);
176 * purple_menu_action_set_stock_icon:
177 * @act: The menu action.
178 * @stock: The stock icon identifier.
180 * Sets the icon for the PurpleMenuAction.
182 void purple_menu_action_set_stock_icon(PurpleMenuAction
*act
,
186 * purple_menu_action_get_stock_icon:
187 * @act: The menu action.
189 * Gets the stock icon of the PurpleMenuAction.
191 * Returns: The stock icon identifier.
194 purple_menu_action_get_stock_icon(PurpleMenuAction
*act
);
197 * purple_util_set_current_song:
198 * @title: The title of the song, %NULL to unset the value.
199 * @artist: The artist of the song, can be %NULL.
200 * @album: The album of the song, can be %NULL.
202 * Set the appropriate presence values for the currently playing song.
204 void purple_util_set_current_song(const char *title
, const char *artist
,
208 * purple_util_format_song_info:
209 * @title: The title of the song, %NULL to unset the value.
210 * @artist: The artist of the song, can be %NULL.
211 * @album: The album of the song, can be %NULL.
212 * @unused: Currently unused, must be %NULL.
214 * Format song information.
216 * Returns: The formatted string. The caller must g_free the returned string.
218 char * purple_util_format_song_info(const char *title
, const char *artist
,
219 const char *album
, gpointer unused
);
221 /**************************************************************************/
222 /* Utility Subsystem */
223 /**************************************************************************/
228 * Initializes the utility subsystem.
230 void purple_util_init(void);
233 * purple_util_uninit:
235 * Uninitializes the util subsystem.
237 void purple_util_uninit(void);
239 /**************************************************************************/
240 /* Base16 Functions */
241 /**************************************************************************/
244 * purple_base16_encode:
245 * @data: The data to convert.
246 * @len: The length of the data.
248 * Converts a chunk of binary data to its base-16 equivalent.
250 * See purple_base16_decode()
252 * Returns: The base-16 string in the ASCII encoding. Must be
253 * g_free'd when no longer needed.
255 gchar
*purple_base16_encode(const guchar
*data
, gsize len
);
258 * purple_base16_decode:
259 * @str: The base-16 string to convert to raw data.
260 * @ret_len: The length of the returned data. You can
261 * pass in NULL if you're sure that you know
262 * the length of the decoded data, or if you
263 * know you'll be able to use strlen to
264 * determine the length, etc.
266 * Converts an ASCII string of base-16 encoded data to
267 * the binary equivalent.
269 * See purple_base16_encode()
271 * Returns: The raw data. Must be g_free'd when no longer needed.
273 guchar
*purple_base16_decode(const char *str
, gsize
*ret_len
);
276 * purple_base16_encode_chunked:
277 * @data: The data to convert.
278 * @len: The length of the data.
280 * Converts a chunk of binary data to a chunked base-16 representation
281 * (handy for key fingerprints)
283 * Example output: 01:23:45:67:89:AB:CD:EF
285 * Returns: The base-16 string in the ASCII chunked encoding. Must be
286 * g_free'd when no longer needed.
288 gchar
*purple_base16_encode_chunked(const guchar
*data
, gsize len
);
290 /**************************************************************************/
291 /* Quoted Printable Functions */
292 /**************************************************************************/
295 * purple_quotedp_decode:
296 * @str: The quoted printable ASCII string to convert to raw data.
297 * @ret_len: The length of the returned data.
299 * Converts a quoted printable string back to its readable equivalent.
300 * What is a quoted printable string, you ask? It's an encoding used
301 * to transmit binary data as ASCII. It's intended purpose is to send
302 * emails containing non-ASCII characters. Wikipedia has a pretty good
303 * explanation. Also see RFC 2045.
305 * Returns: The readable string. Must be g_free'd when no longer needed.
307 guchar
*purple_quotedp_decode(const char *str
, gsize
*ret_len
);
309 /**************************************************************************/
311 /**************************************************************************/
314 * purple_mime_decode_field:
315 * @str: The ASCII string, possibly containing any number of
316 * encoded-word sections.
318 * Converts a MIME header field string back to its readable equivalent
319 * according to RFC 2047. Basically, a header is plain ASCII and can
320 * contain any number of sections called "encoded-words." The format
321 * of an encoded word is =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?=
322 * =? designates the beginning of the encoded-word
323 * ?= designates the end of the encoded-word
325 * An encoded word is segmented into three pieces by the use of a
326 * question mark. The first piece is the character set, the second
327 * piece is the encoding, and the third piece is the encoded text.
329 * Returns: The string, with any encoded-word sections decoded and
330 * converted to UTF-8. Must be g_free'd when no longer
333 char *purple_mime_decode_field(const char *str
);
336 /**************************************************************************/
337 /* Date/Time Functions */
338 /**************************************************************************/
341 * purple_utf8_strftime:
342 * @format: The format string, in UTF-8
343 * @tm: The time to format, or %NULL to use the current local time
345 * Formats a time into the specified format.
347 * This is essentially strftime(), but it has a static buffer
348 * and handles the UTF-8 conversion for the caller.
350 * This function also provides the GNU \%z formatter if the underlying C
351 * library doesn't. However, the format string parser is very naive, which
352 * means that conversions specifiers to \%z cannot be guaranteed. The GNU
353 * strftime(3) man page describes \%z as: 'The time-zone as hour offset from
354 * GMT. Required to emit RFC822-conformant dates
355 * (using "\%a, \%d \%b \%Y \%H:\%M:\%S \%z"). (GNU)'
357 * On Windows, this function also converts the results for \%Z from a timezone
358 * name (as returned by the system strftime() \%Z format string) to a timezone
359 * abbreviation (as is the case on Unix). As with \%z, conversion specifiers
360 * should not be used.
362 * Note: @format is required to be in UTF-8. This differs from strftime(),
363 * where the format is provided in the locale charset.
365 * Returns: The formatted time, in UTF-8.
367 const char *purple_utf8_strftime(const char *format
, const struct tm
*tm
);
370 * purple_date_format_short:
371 * @tm: The time to format, or %NULL to use the current local time
373 * Formats a time into the user's preferred short date format.
375 * The returned string is stored in a static buffer, so the result
376 * should be g_strdup()'d if it's going to be kept.
378 * Returns: The date, formatted as per the user's settings. In the USA this
379 * is something like "02/18/13"
381 const char *purple_date_format_short(const struct tm
*tm
);
384 * purple_date_format_long:
385 * @tm: The time to format, or %NULL to use the current local time
387 * Formats a time into the user's preferred short date plus time format.
389 * The returned string is stored in a static buffer, so the result
390 * should be g_strdup()'d if it's going to be kept.
392 * Returns: The timestamp, formatted as per the user's settings. In the USA
393 * this is something like "02/18/13 15:26:44"
395 const char *purple_date_format_long(const struct tm
*tm
);
398 * purple_date_format_full:
399 * @tm: The time to format, or %NULL to use the current local time
401 * Formats a time into the user's preferred full date and time format.
403 * The returned string is stored in a static buffer, so the result
404 * should be g_strdup()'d if it's going to be kept.
406 * Returns: The date and time, formatted as per the user's settings. In the
407 * USA this is something like "Mon Feb 18 15:26:44 2013"
409 const char *purple_date_format_full(const struct tm
*tm
);
412 * purple_time_format:
413 * @tm: The time to format, or %NULL to use the current local time
415 * Formats a time into the user's preferred time format.
417 * The returned string is stored in a static buffer, so the result
418 * should be g_strdup()'d if it's going to be kept.
420 * Returns: The time, formatted as per the user's settings. In the USA this
421 * is something like "15:26:44"
423 const char *purple_time_format(const struct tm
*tm
);
434 * Builds a time_t from the supplied information.
438 time_t purple_time_build(int year
, int month
, int day
, int hour
,
444 * Used by purple_str_to_time to indicate no timezone offset was
445 * specified in the timestamp string.
447 #define PURPLE_NO_TZ_OFF -500000
450 * purple_str_to_time:
451 * @timestamp: The timestamp
452 * @utc: Assume UTC if no timezone specified
453 * @tm: If not %NULL, the caller can get a copy of the
454 * struct tm used to calculate the time_t return value.
455 * @tz_off: If not %NULL, the caller can get a copy of the
456 * timezone offset (from UTC) used to calculate the time_t
457 * return value. Note: Zero is a valid offset. As such,
458 * the value of the macro PURPLE_NO_TZ_OFF indicates no
459 * offset was specified (which means that the local
460 * timezone was used in the calculation).
461 * @rest: If not %NULL, the caller can get a pointer to the
462 * part of @timestamp left over after parsing is
463 * completed, if it's not the end of @timestamp.
465 * Parses a timestamp in jabber, ISO8601, or MM/DD/YYYY format and returns
470 time_t purple_str_to_time(const char *timestamp
, gboolean utc
,
471 struct tm
*tm
, long *tz_off
, const char **rest
);
474 * purple_str_to_date_time:
475 * @timestamp: The timestamp
476 * @utc: Assume UTC if no timezone specified
478 * Parses a timestamp in jabber, ISO8601, or MM/DD/YYYY format and returns
481 * Returns: (transfer full): A GDateTime.
483 GDateTime
*purple_str_to_date_time(const char *timestamp
, gboolean utc
);
486 * purple_uts35_to_str:
487 * @format: The formatting string, according to UTS \#35
488 * See http://unicode.org/reports/tr35/
489 * (NOTE: not all formats are supported)
490 * @len: The length of the formatting string
491 * @tm: The time to format, or %NULL to use the current local time
493 * Formats a datetime according to a UTS-35 Date Format Pattern.
495 * Returns: The time, formatted as per the user's settings.
497 char *purple_uts35_to_str(const char *format
, size_t len
, struct tm
*tm
);
500 /**************************************************************************/
501 /* Markup Functions */
502 /**************************************************************************/
505 * purple_markup_escape_text:
506 * @text: The text to escape
507 * @length: The length of the text, or -1 if #NULL terminated
509 * Escapes special characters in a plain-text string so they display
510 * correctly as HTML. For example, & is replaced with &amp; and < is
511 * replaced with &lt;
513 * This is exactly the same as g_markup_escape_text(), except that it
514 * does not change ' to &apos; because &apos; is not a valid HTML 4 entity,
515 * and is displayed literally in IE7.
517 gchar
*purple_markup_escape_text(const gchar
*text
, gssize length
);
520 * purple_markup_find_tag:
521 * @needle: The name of the tag
522 * @haystack: The null-delimited string to search in
523 * @start: A pointer to the start of the tag if found
524 * @end: A pointer to the end of the tag if found
525 * @attributes: The attributes, if the tag was found. This should
526 * be freed with g_datalist_clear().
528 * Finds an HTML tag matching the given name.
530 * This locates an HTML tag's start and end, and stores its attributes
531 * in a GData hash table. The names of the attributes are lower-cased
532 * in the hash table, and the name of the tag is case insensitive.
534 * Returns: TRUE if the tag was found
536 gboolean
purple_markup_find_tag(const char *needle
, const char *haystack
,
537 const char **start
, const char **end
,
541 * purple_markup_extract_info_field:
542 * @str: The string to parse.
543 * @len: The size of str.
544 * @user_info: The destination PurpleNotifyUserInfo to which the new
545 * field info should be added.
546 * @start_token: The beginning token.
547 * @skip: The number of characters to skip after the
549 * @end_token: The ending token.
550 * @check_value: The value that the last character must meet.
551 * @no_value_token: The token indicating no value is given.
552 * @display_name: The short descriptive name to display for this token.
553 * @is_link: TRUE if this should be a link, or FALSE otherwise.
554 * @link_prefix: The prefix for the link.
555 * @format_cb: A callback to format the value before adding it.
557 * Extracts a field of data from HTML.
559 * This is a scary function. It used to be used for MSN and Yahoo prpls,
560 * but since those prpls have been removed, this is now deprecated.
562 * Returns: TRUE if successful, or FALSE otherwise.
564 gboolean
purple_markup_extract_info_field(const char *str
, int len
, PurpleNotifyUserInfo
*user_info
,
565 const char *start_token
, int skip
,
566 const char *end_token
, char check_value
,
567 const char *no_value_token
,
568 const char *display_name
, gboolean is_link
,
569 const char *link_prefix
,
570 PurpleInfoFieldFormatCallback format_cb
);
573 * purple_markup_html_to_xhtml:
574 * @html: The HTML markup.
575 * @dest_xhtml: The destination XHTML output.
576 * @dest_plain: The destination plain-text output.
578 * Converts HTML markup to XHTML.
580 void purple_markup_html_to_xhtml(const char *html
, char **dest_xhtml
,
584 * purple_markup_strip_html:
585 * @str: The string to strip HTML from.
587 * Strips HTML tags from a string.
589 * Returns: The new string without HTML. You must g_free this string
590 * when finished with it.
592 char *purple_markup_strip_html(const char *str
);
595 * purple_markup_linkify:
596 * @str: The string to linkify.
598 * Adds the necessary HTML code to turn URIs into HTML links in a string.
600 * Returns: The new string with all URIs surrounded in standard
601 * HTML <a href="whatever"></a> tags. You must g_free()
602 * this string when finished with it.
604 char *purple_markup_linkify(const char *str
);
607 * purple_unescape_text:
608 * @text: The string in which to unescape any HTML entities
610 * Unescapes HTML entities to their literal characters in the text.
611 * For example "&amp;" is replaced by '&' and so on. Also converts
612 * numerical entities (e.g. "&\#38;" is also '&').
614 * This function currently supports the following named entities:
615 * "&amp;", "&lt;", "&gt;", "&copy;", "&quot;",
616 * "&reg;", "&apos;"
618 * purple_unescape_html() is similar, but also converts "<br>" into "\n".
620 * See purple_unescape_html()
622 * Returns: The text with HTML entities literalized. You must g_free
623 * this string when finished with it.
625 char *purple_unescape_text(const char *text
);
628 * purple_unescape_html:
629 * @html: The string in which to unescape any HTML entities
631 * Unescapes HTML entities to their literal characters and converts
632 * "<br>" to "\n". See purple_unescape_text() for more details.
634 * See purple_unescape_text()
636 * Returns: The text with HTML entities literalized. You must g_free
637 * this string when finished with it.
639 char *purple_unescape_html(const char *html
);
642 * purple_markup_slice:
643 * @str: The input NUL terminated, HTML, UTF-8 (or ASCII) string.
644 * @x: The character offset into an unformatted version of str to
646 * @y: The character offset (into an unformatted vesion of str) of
647 * one past the last character to include in the slice.
649 * Returns a newly allocated substring of the HTML UTF-8 string "str".
650 * The markup is preserved such that the substring will have the same
651 * formatting as original string, even though some tags may have been
652 * opened before "x", or may close after "y". All open tags are closed
653 * at the end of the returned string, in the proper order.
655 * Note that x and y are in character offsets, not byte offsets, and
656 * are offsets into an unformatted version of str. Because of this,
657 * this function may be sensitive to changes in GtkIMHtml and may break
658 * when used with other UI's. libpurple users are encouraged to report and
659 * work out any problems encountered.
661 * Returns: The HTML slice of string, with all formatting retained.
663 char *purple_markup_slice(const char *str
, guint x
, guint y
);
666 * purple_markup_get_tag_name:
667 * @tag: The string starting a HTML tag.
669 * Returns a newly allocated string containing the name of the tag
670 * located at "tag". Tag is expected to point to a '<', and contain
671 * a '>' sometime after that. If there is no '>' and the string is
672 * not NUL terminated, this function can be expected to segfault.
674 * Returns: A string containing the name of the tag.
676 char *purple_markup_get_tag_name(const char *tag
);
679 * purple_markup_unescape_entity:
680 * @text: A string containing an HTML entity.
681 * @length: If not %NULL, the string length of the entity is stored in this location.
683 * Returns a constant string of the character representation of the HTML
684 * entity pointed to by @text. For example, purple_markup_unescape_entity("&amp;")
685 * will return "&". The @text variable is expected to point to an '&',
686 * the first character of the entity. If given an unrecognized entity, the function
689 * Note that this function, unlike purple_unescape_html(), does not search
690 * the string for the entity, does not replace the entity, and does not
691 * return a newly allocated string.
693 * Returns: A constant string containing the character representation of the given entity.
695 const char * purple_markup_unescape_entity(const char *text
, int *length
);
698 * purple_markup_get_css_property:
699 * @style: A string containing the inline CSS text.
700 * @opt: The requested CSS property.
702 * Returns a newly allocated string containing the value of the CSS property specified
703 * in opt. The @style argument is expected to point to a HTML inline CSS.
704 * The function will seek for the CSS property and return its value.
706 * For example, purple_markup_get_css_property("direction:rtl;color:#dc4d1b;",
707 * "color") would return "#dc4d1b".
709 * On error or if the requested property was not found, the function returns
712 * Returns: The value of the requested CSS property.
714 char * purple_markup_get_css_property(const gchar
*style
, const gchar
*opt
);
717 * purple_markup_is_rtl:
718 * @html: The HTML text.
720 * Check if the given HTML contains RTL text.
722 * Returns: TRUE if the text contains RTL text, FALSE otherwise.
724 gboolean
purple_markup_is_rtl(const char *html
);
727 /**************************************************************************/
728 /* Path/Filename Functions */
729 /**************************************************************************/
734 * Returns the user's home directory.
736 * See purple_user_dir()
738 * Returns: The user's home directory.
740 const gchar
*purple_home_dir(void);
745 * Returns the purple settings directory in the user's home directory.
746 * This is usually $HOME/.purple
748 * See purple_home_dir()
750 * Returns: The purple settings directory.
752 * Deprecated: Use purple_cache_dir(), purple_config_dir() or
753 * purple_data_dir() instead.
755 const char *purple_user_dir(void);
760 * Returns the purple cache directory according to XDG Base Directory Specification.
761 * This is usually $HOME/.cache/purple.
762 * If custom user dir was specified then this is cache
763 * sub-directory of DIR argument passed to -c option.
765 * Returns: The purple cache directory.
767 const gchar
*purple_cache_dir(void);
772 * Returns the purple configuration directory according to XDG Base Directory Specification.
773 * This is usually $HOME/.config/purple.
774 * If custom user dir was specified then this is config
775 * sub-directory of DIR argument passed to -c option.
777 * Returns: The purple configuration directory.
779 const gchar
*purple_config_dir(void);
784 * Returns the purple data directory according to XDG Base Directory Specification.
785 * This is usually $HOME/.local/share/purple.
786 * If custom user dir was specified then this is data
787 * sub-directory of DIR argument passed to -c option.
789 * Returns: The purple data directory.
791 const gchar
*purple_data_dir(void);
794 * purple_move_to_xdg_base_dir:
795 * @purple_xdg_dir: The path to cache, config or data dir.
796 * Use respective function
797 * @path: File or directory in purple_user_dir
799 * Moves file or directory from legacy user dir to XDG
802 * Returns: TRUE if moved successfully, FALSE otherwise
805 purple_move_to_xdg_base_dir(const char *purple_xdg_dir
, char *path
);
808 * purple_util_set_user_dir:
809 * @dir: The custom settings directory
811 * Define a custom purple settings directory, overriding the default (user's home directory/.purple)
813 void purple_util_set_user_dir(const char *dir
);
817 * @path: The path you wish to create. Note that it must start
818 * from the root or this function will fail.
819 * @mode: Unix-style permissions for this directory.
821 * Builds a complete path from the root, making any directories along
822 * the path which do not already exist.
824 * Returns: 0 for success, nonzero on any error.
826 int purple_build_dir(const char *path
, int mode
);
829 * purple_util_write_data_to_file:
830 * @filename: The basename of the file to write in the purple_user_dir.
831 * @data: A string of data to write.
832 * @size: The size of the data to save. If data is
833 * null-terminated you can pass in -1.
835 * Write a string of data to a file of the given name in the Purple
836 * user directory ($HOME/.purple by default). The data is typically
837 * a serialized version of one of Purple's config files, such as
838 * prefs.xml, accounts.xml, etc. And the string is typically
839 * obtained using purple_xmlnode_to_formatted_str. However, this function
840 * should work fine for saving binary files as well.
842 * Returns: TRUE if the file was written successfully. FALSE otherwise.
844 * Deprecated: Use purple_util_write_data_to_cache_file(),
845 * purple_util_write_data_to_config_file() or
846 * purple_util_write_data_to_data_file() instead.
848 gboolean
purple_util_write_data_to_file(const char *filename
, const char *data
,
852 * purple_util_write_data_to_cache_file:
853 * @filename: The basename of the file to write in the purple_cache_dir.
854 * @data: A string of data to write.
855 * @size: The size of the data to save. If data is
856 * null-terminated you can pass in -1.
858 * Write a string of data to a file of the given name in the Purple
859 * cache directory ($HOME/.cache/purple by default).
861 * See purple_util_write_data_to_file()
863 * Returns: TRUE if the file was written successfully. FALSE otherwise.
866 purple_util_write_data_to_cache_file(const char *filename
, const char *data
, gssize size
);
869 * purple_util_write_data_to_config_file:
870 * @filename: The basename of the file to write in the purple_config_dir.
871 * @data: A string of data to write.
872 * @size: The size of the data to save. If data is
873 * null-terminated you can pass in -1.
875 * Write a string of data to a file of the given name in the Purple
876 * config directory ($HOME/.config/purple by default).
878 * See purple_util_write_data_to_file()
880 * Returns: TRUE if the file was written successfully. FALSE otherwise.
883 purple_util_write_data_to_config_file(const char *filename
, const char *data
, gssize size
);
886 * purple_util_write_data_to_data_file:
887 * @filename: The basename of the file to write in the purple_data_dir.
888 * @data: A string of data to write.
889 * @size: The size of the data to save. If data is
890 * null-terminated you can pass in -1.
892 * Write a string of data to a file of the given name in the Purple
893 * data directory ($HOME/.local/share/purple by default).
895 * See purple_util_write_data_to_file()
897 * Returns: TRUE if the file was written successfully. FALSE otherwise.
900 purple_util_write_data_to_data_file(const char *filename
, const char *data
, gssize size
);
903 * purple_util_write_data_to_file_absolute:
904 * @filename_full: Filename to write to
905 * @data: A string of data to write.
906 * @size: The size of the data to save. If data is
907 * null-terminated you can pass in -1.
909 * Write data to a file using the absolute path.
911 * This exists for Glib backwards compatibility reasons.
913 * See purple_util_write_data_to_file()
915 * Returns: TRUE if the file was written successfully. FALSE otherwise.
917 /* TODO: Remove this function (use g_file_set_contents instead) when 3.0.0
920 purple_util_write_data_to_file_absolute(const char *filename_full
, const char *data
, gssize size
);
923 * purple_util_read_xml_from_file:
924 * @filename: The basename of the file to open in the purple_user_dir.
925 * @description: A very short description of the contents of this
926 * file. This is used in error messages shown to the
927 * user when the file can not be opened. For example,
928 * "preferences," or "buddy pounces."
930 * Read the contents of a given file and parse the results into an
931 * PurpleXmlNode tree structure. This is intended to be used to read
932 * Purple's configuration xml files (prefs.xml, pounces.xml, etc.)
934 * Returns: An PurpleXmlNode tree of the contents of the given file. Or NULL, if
935 * the file does not exist or there was an error reading the file.
937 * Deprecated: Use purple_util_read_xml_from_cache_file(),
938 * purple_util_read_xml_from_config_file() or
939 * purple_util_read_xml_from_data_file() instead.
941 PurpleXmlNode
*purple_util_read_xml_from_file(const char *filename
,
942 const char *description
);
945 * purple_util_read_xml_from_cache_file:
946 * @filename: The basename of the file to open in the purple_cache_dir.
947 * @description: A very short description of the contents of this
948 * file. This is used in error messages shown to the
949 * user when the file can not be opened. For example,
950 * "preferences," or "buddy pounces."
952 * Read the contents of a given file and parse the results into an
953 * PurpleXmlNode tree structure. This is intended to be used to read
954 * Purple's cache xml files (xmpp-caps.xml, etc.)
956 * Returns: An PurpleXmlNode tree of the contents of the given file. Or NULL, if
957 * the file does not exist or there was an error reading the file.
960 purple_util_read_xml_from_cache_file(const char *filename
, const char *description
);
963 * purple_util_read_xml_from_config_file:
964 * @filename: The basename of the file to open in the purple_config_dir.
965 * @description: A very short description of the contents of this
966 * file. This is used in error messages shown to the
967 * user when the file can not be opened. For example,
968 * "preferences," or "buddy pounces."
970 * Read the contents of a given file and parse the results into an
971 * PurpleXmlNode tree structure. This is intended to be used to read
972 * Purple's config xml files (prefs.xml, pounces.xml, etc.)
974 * Returns: An PurpleXmlNode tree of the contents of the given file. Or NULL, if
975 * the file does not exist or there was an error reading the file.
978 purple_util_read_xml_from_config_file(const char *filename
, const char *description
);
981 * purple_util_read_xml_from_data_file:
982 * @filename: The basename of the file to open in the purple_data_dir.
983 * @description: A very short description of the contents of this
984 * file. This is used in error messages shown to the
985 * user when the file can not be opened. For example,
986 * "preferences," or "buddy pounces."
988 * Read the contents of a given file and parse the results into an
989 * PurpleXmlNode tree structure. This is intended to be used to read
990 * Purple's cache xml files (accounts.xml, etc.)
992 * Returns: An PurpleXmlNode tree of the contents of the given file. Or NULL, if
993 * the file does not exist or there was an error reading the file.
996 purple_util_read_xml_from_data_file(const char *filename
, const char *description
);
1000 * @path: The returned path to the temp file.
1001 * @binary: Text or binary, for platforms where it matters.
1003 * Creates a temporary file and returns a file pointer to it.
1005 * This is like mkstemp(), but returns a file pointer and uses a
1006 * pre-set template. It uses the semantics of tempnam() for the
1007 * directory to use and allocates the space for the file path.
1009 * The caller is responsible for closing the file and removing it when
1010 * done, as well as freeing the space pointed to by @path with
1013 * Returns: A file pointer to the temporary file, or %NULL on failure.
1015 FILE *purple_mkstemp(char **path
, gboolean binary
);
1018 /**************************************************************************/
1019 /* Environment Detection Functions */
1020 /**************************************************************************/
1023 * purple_program_is_valid:
1024 * @program: The file name of the application.
1026 * Checks if the given program name is valid and executable.
1028 * Returns: TRUE if the program is runable.
1030 gboolean
purple_program_is_valid(const char *program
);
1033 * purple_running_gnome:
1035 * Check if running GNOME.
1037 * Returns: TRUE if running GNOME, FALSE otherwise.
1039 gboolean
purple_running_gnome(void);
1042 * purple_running_kde:
1044 * Check if running KDE.
1046 * Returns: TRUE if running KDE, FALSE otherwise.
1048 gboolean
purple_running_kde(void);
1051 * purple_running_osx:
1053 * Check if running OS X.
1055 * Returns: TRUE if running OS X, FALSE otherwise.
1057 gboolean
purple_running_osx(void);
1061 * @fd: The socket file descriptor.
1063 * Returns the IP address from a socket file descriptor.
1065 * Returns: The IP address, or %NULL on error.
1067 char *purple_fd_get_ip(int fd
);
1070 * purple_socket_get_family:
1071 * @fd: The socket file descriptor.
1073 * Returns the address family of a socket.
1075 * Returns: The address family of the socket (AF_INET, AF_INET6, etc) or -1
1078 int purple_socket_get_family(int fd
);
1081 * purple_socket_speaks_ipv4:
1082 * @fd: The socket file descriptor
1084 * Returns TRUE if a socket is capable of speaking IPv4.
1086 * This is the case for IPv4 sockets and, on some systems, IPv6 sockets
1087 * (due to the IPv4-mapped address functionality).
1089 * Returns: TRUE if a socket can speak IPv4.
1091 gboolean
purple_socket_speaks_ipv4(int fd
);
1094 /**************************************************************************/
1095 /* String Functions */
1096 /**************************************************************************/
1101 * @right: A string to compare with left
1103 * Tests two strings for equality.
1105 * Unlike strcmp(), this function will not crash if one or both of the
1106 * strings are %NULL.
1108 * Returns: %TRUE if the strings are the same, else %FALSE.
1110 gboolean
purple_strequal(const gchar
*left
, const gchar
*right
);
1114 * @account: The account the string belongs to, or NULL if you do
1115 * not know the account. If you use NULL, the string
1116 * will still be normalized, but if the protocol uses a
1117 * custom normalization function then the string may
1118 * not be normalized correctly.
1119 * @str: The string to normalize.
1121 * Normalizes a string, so that it is suitable for comparison.
1123 * The returned string will point to a static buffer, so if the
1124 * string is intended to be kept long-term, you <emphasis>must</emphasis>
1125 * g_strdup() it. Also, calling normalize() twice in the same line
1126 * will lead to problems.
1128 * Returns: A pointer to the normalized version stored in a static buffer.
1130 const char *purple_normalize(const PurpleAccount
*account
, const char *str
);
1133 * purple_normalize_nocase:
1134 * @account: The account the string belongs to.
1135 * @str: The string to normalize.
1137 * Normalizes a string, so that it is suitable for comparison.
1139 * This is one possible implementation for the protocol callback
1140 * function "normalize." It returns a lowercase and UTF-8
1141 * normalized version of the string.
1143 * Returns: A pointer to the normalized version stored in a static buffer.
1145 const char *purple_normalize_nocase(const PurpleAccount
*account
, const char *str
);
1149 * @protocol: The protocol the string belongs to.
1150 * @str: The string to validate.
1152 * Checks, if a string is valid.
1154 * Returns: TRUE, if string is valid, otherwise FALSE.
1156 gboolean
purple_validate(const PurpleProtocol
*protocol
, const char *str
);
1159 * purple_str_has_prefix:
1160 * @s: The string to check.
1161 * @p: The prefix in question.
1163 * Compares two strings to see if the first contains the second as
1166 * Returns: TRUE if p is a prefix of s, otherwise FALSE.
1168 gboolean
purple_str_has_prefix(const char *s
, const char *p
);
1171 * purple_str_has_caseprefix:
1172 * @s: The string to check.
1173 * @p: The prefix in question.
1175 * Compares two strings to see if the first contains the second as
1176 * a proper case-insensitive prefix.
1178 * Returns: %TRUE if @p is a prefix of @s, otherwise %FALSE.
1181 purple_str_has_caseprefix(const gchar
*s
, const gchar
*p
);
1184 * purple_str_has_suffix:
1185 * @s: The string to check.
1186 * @x: The suffix in question.
1188 * Compares two strings to see if the second is a proper suffix
1191 * Returns: TRUE if x is a a suffix of s, otherwise FALSE.
1193 gboolean
purple_str_has_suffix(const char *s
, const char *x
);
1196 * purple_strdup_withhtml:
1197 * @src: The source string.
1199 * Duplicates a string and replaces all newline characters from the
1200 * source string with HTML linebreaks.
1202 * Returns: The new string. Must be g_free'd by the caller.
1204 gchar
*purple_strdup_withhtml(const gchar
*src
);
1207 * purple_str_add_cr:
1208 * @str: The source string.
1210 * Ensures that all linefeeds have a matching carriage return.
1212 * Returns: The string with carriage returns.
1214 char *purple_str_add_cr(const char *str
);
1217 * purple_str_strip_char:
1218 * @str: The string to strip characters from.
1219 * @thechar: The character to strip from the given string.
1221 * Strips all instances of the given character from the
1222 * given string. The string is modified in place. This
1223 * is useful for stripping new line characters, for example.
1226 * purple_str_strip_char(my_dumb_string, '\n');
1228 void purple_str_strip_char(char *str
, char thechar
);
1231 * purple_util_chrreplace:
1232 * @string: The string from which to replace stuff.
1233 * @delimiter: The character you want replaced.
1234 * @replacement: The character you want inserted in place
1235 * of the delimiting character.
1237 * Given a string, this replaces all instances of one character
1238 * with another. This happens inline (the original string IS
1241 void purple_util_chrreplace(char *string
, char delimiter
,
1245 * purple_strreplace:
1246 * @string: The string from which to replace stuff.
1247 * @delimiter: The substring you want replaced.
1248 * @replacement: The substring you want inserted in place
1249 * of the delimiting substring.
1251 * Given a string, this replaces one substring with another
1252 * and returns a newly allocated string.
1254 * Returns: A new string, after performing the substitution.
1255 * free this with g_free().
1257 gchar
*purple_strreplace(const char *string
, const char *delimiter
,
1258 const char *replacement
);
1262 * purple_utf8_ncr_encode:
1263 * @in: The string which might contain utf-8 substrings
1265 * Given a string, this replaces any utf-8 substrings in that string with
1266 * the corresponding numerical character reference, and returns a newly
1269 * Returns: A new string, with utf-8 replaced with numerical character
1270 * references, free this with g_free()
1272 char *purple_utf8_ncr_encode(const char *in
);
1276 * purple_utf8_ncr_decode:
1277 * @in: The string which might contain numerical character references.
1279 * Given a string, this replaces any numerical character references
1280 * in that string with the corresponding actual utf-8 substrings,
1281 * and returns a newly allocated string.
1283 * Returns: A new string, with numerical character references
1284 * replaced with actual utf-8, free this with g_free().
1286 char *purple_utf8_ncr_decode(const char *in
);
1290 * purple_strcasereplace:
1291 * @string: The string from which to replace stuff.
1292 * @delimiter: The substring you want replaced.
1293 * @replacement: The substring you want inserted in place
1294 * of the delimiting substring.
1296 * Given a string, this replaces one substring with another
1297 * ignoring case and returns a newly allocated string.
1299 * Returns: A new string, after performing the substitution.
1300 * free this with g_free().
1302 gchar
*purple_strcasereplace(const char *string
, const char *delimiter
,
1303 const char *replacement
);
1306 * purple_strcasestr:
1307 * @haystack: The string to search in.
1308 * @needle: The substring to find.
1310 * This is like strstr, except that it ignores ASCII case in
1311 * searching for the substring.
1313 * Returns: the location of the substring if found, or NULL if not
1315 const char *purple_strcasestr(const char *haystack
, const char *needle
);
1318 * purple_str_size_to_units:
1321 * Returns a string representing a filesize in the appropriate
1322 * units (MB, KB, GB, etc.)
1324 * Returns: The string in units form. This must be freed.
1326 char *purple_str_size_to_units(goffset size
);
1329 * purple_str_seconds_to_string:
1330 * @sec: The seconds.
1332 * Converts seconds into a human-readable form.
1334 * Returns: A human-readable form, containing days, hours, minutes, and
1337 char *purple_str_seconds_to_string(guint sec
);
1340 * purple_str_binary_to_ascii:
1341 * @binary: A string of random data, possibly with embedded NULs
1343 * @len: The length in bytes of the input string. Must not be 0.
1345 * Converts a binary string into a NUL terminated ascii string,
1346 * replacing nonascii characters and characters below SPACE (including
1347 * NUL) into \\xyy, where yy are two hex digits. Also backslashes are
1348 * changed into two backslashes (\\\\). The returned, newly allocated
1349 * string can be outputted to the console, and must be g_free()d.
1351 * Returns: A newly allocated ASCIIZ string.
1353 char *purple_str_binary_to_ascii(const unsigned char *binary
, guint len
);
1356 * purple_utf16_size:
1357 * @str: String to check.
1359 * Calculates UTF-16 string size (in bytes).
1361 * Returns: Number of bytes (including NUL character) that string occupies.
1363 size_t purple_utf16_size(const gunichar2
*str
);
1367 * @str: A NUL-terminated string to free, or a NULL-pointer.
1369 * Fills a NUL-terminated string with zeros and frees it.
1371 * It should be used to free sensitive data, like passwords.
1373 void purple_str_wipe(gchar
*str
);
1376 * purple_utf16_wipe:
1377 * @str: A NUL-terminated string to free, or a NULL-pointer.
1379 * Fills a NUL-terminated UTF-16 string with zeros and frees it.
1381 * It should be used to free sensitive data, like passwords.
1383 void purple_utf16_wipe(gunichar2
*str
);
1386 /**************************************************************************/
1387 /* URI/URL Functions */
1388 /**************************************************************************/
1390 void purple_got_protocol_handler_uri(const char *uri
);
1393 * purple_url_decode:
1394 * @str: The string to translate.
1396 * Decodes a URL into a plain string.
1398 * This will change hex codes and such to their ascii equivalents.
1400 * Returns: The resulting string.
1402 const char *purple_url_decode(const char *str
);
1405 * purple_url_encode:
1406 * @str: The string to translate.
1408 * Encodes a URL into an escaped string.
1410 * This will change non-alphanumeric characters to hex codes.
1412 * Returns: The resulting string.
1414 const char *purple_url_encode(const char *str
);
1417 * purple_email_is_valid:
1418 * @address: The email address to validate.
1420 * Checks if the given email address is syntactically valid.
1422 * Returns: True if the email address is syntactically correct.
1424 gboolean
purple_email_is_valid(const char *address
);
1427 * purple_ip_address_is_valid:
1428 * @ip: The IP address to validate.
1430 * Checks if the given IP address is a syntactically valid IPv4 or
1432 * If you specifically want to check for an IPv4 address use
1433 * purple_ipv4_address_is_valid(), or for an IPv6 address use
1434 * purple_ipv6_address_is_valid().
1436 * Returns: True if the IP address is syntactically correct.
1438 gboolean
purple_ip_address_is_valid(const char *ip
);
1441 * purple_ipv4_address_is_valid:
1442 * @ip: The IP address to validate.
1444 * Checks if the given IP address is a syntactically valid IPv4 address.
1446 * Returns: True if the IP address is syntactically correct.
1448 gboolean
purple_ipv4_address_is_valid(const char *ip
);
1451 * purple_ipv6_address_is_valid:
1452 * @ip: The IP address to validate.
1454 * Checks if the given IP address is a syntactically valid IPv6 address.
1456 * Returns: True if the IP address is syntactically correct.
1458 gboolean
purple_ipv6_address_is_valid(const char *ip
);
1461 * purple_uri_list_extract_uris:
1462 * @uri_list: An uri-list in the standard format.
1464 * This function extracts a list of URIs from the a "text/uri-list"
1465 * string. It was "borrowed" from gnome_uri_list_extract_uris
1467 * Returns: (element-type utf8): A GList containing strings allocated with
1468 * g_malloc that have been split from uri-list.
1470 GList
*purple_uri_list_extract_uris(const gchar
*uri_list
);
1473 * purple_uri_list_extract_filenames:
1474 * @uri_list: A uri-list in the standard format.
1476 * This function extracts a list of filenames from a
1477 * "text/uri-list" string. It was "borrowed" from
1478 * gnome_uri_list_extract_filenames
1480 * Returns: (element-type utf8): A GList containing strings allocated with
1481 * g_malloc that contain the filenames in the uri-list. Note that
1482 * unlike the purple_uri_list_extract_uris() function, this will
1483 * discard any non-file uri from the result value.
1485 GList
*purple_uri_list_extract_filenames(const gchar
*uri_list
);
1488 * purple_uri_escape_for_open:
1489 * @unescaped: The unescaped URI.
1491 * This function escapes any characters that might be interpreted by the shell
1492 * when executing a program to open a URI on some systems.
1494 * Returns: A newly allocated string with any shell metacharacters replaced
1495 * with their escaped equivalents.
1497 char *purple_uri_escape_for_open(const char *unescaped
);
1500 * This function escapes any characters that might be interpreted by the shell
1501 * when executing a program to open a URI on some systems.
1503 * @param unescaped The unescaped URI.
1505 * @return A newly allocated string with any shell metacharacters replaced with
1506 * their escaped equivalents.
1508 char *purple_uri_escape_for_open(const char *unescaped
);
1510 /**************************************************************************
1511 * UTF8 String Functions
1512 **************************************************************************/
1515 * purple_utf8_try_convert:
1516 * @str: The source string.
1518 * Attempts to convert a string to UTF-8 from an unknown encoding.
1520 * This function checks the locale and tries sane defaults.
1522 * Returns: The UTF-8 string, or %NULL if it could not be converted.
1524 gchar
*purple_utf8_try_convert(const char *str
);
1527 * purple_utf8_salvage:
1528 * @str: The source string.
1530 * Salvages the valid UTF-8 characters from a string, replacing any
1531 * invalid characters with a filler character (currently hardcoded to
1534 * Returns: A valid UTF-8 string.
1536 gchar
*purple_utf8_salvage(const char *str
);
1539 * purple_utf8_strip_unprintables:
1540 * @str: A valid UTF-8 string.
1542 * Removes unprintable characters from a UTF-8 string. These characters
1543 * (in particular low-ASCII characters) are invalid in XML 1.0 and thus
1544 * are not allowed in XMPP and are rejected by libxml2 by default.
1546 * The returned string must be freed by the caller.
1548 * Returns: A newly allocated UTF-8 string without the unprintable characters.
1550 gchar
*purple_utf8_strip_unprintables(const gchar
*str
);
1553 * purple_gai_strerror:
1554 * @errnum: The error code.
1556 * Return the UTF-8 version of #gai_strerror. It calls #gai_strerror
1557 * then converts the result to UTF-8. This function is analogous to
1560 * Returns: The UTF-8 error message.
1562 const gchar
*purple_gai_strerror(gint errnum
);
1565 * purple_utf8_strcasecmp:
1566 * @a: The first string.
1567 * @b: The second string.
1569 * Compares two UTF-8 strings case-insensitively. This comparison is
1570 * more expensive than a simple g_utf8_collate() comparison because
1571 * it calls g_utf8_casefold() on each string, which allocates new
1574 * Returns: -1 if @a is less than @b.
1575 * 0 if @a is equal to @b.
1576 * 1 if @a is greater than @b.
1578 int purple_utf8_strcasecmp(const char *a
, const char *b
);
1581 * purple_utf8_has_word:
1582 * @haystack: The string to search in.
1583 * @needle: The substring to find.
1585 * Case insensitive search for a word in a string. The needle string
1586 * must be contained in the haystack string and not be immediately
1587 * preceded or immediately followed by another alpha-numeric character.
1589 * Returns: TRUE if haystack has the word, otherwise FALSE
1591 gboolean
purple_utf8_has_word(const char *haystack
, const char *needle
);
1594 * purple_message_meify:
1595 * @message: The message to check
1596 * @len: The message length, or -1
1598 * Checks for messages starting (post-HTML) with "/me ", including the space.
1600 * Returns: TRUE if it starts with "/me ", and it has been removed, otherwise
1603 gboolean
purple_message_meify(char *message
, gssize len
);
1606 * purple_text_strip_mnemonic:
1607 * @in: The string to strip
1609 * Removes the underscore characters from a string used identify the mnemonic
1612 * Returns: The stripped string
1614 char *purple_text_strip_mnemonic(const char *in
);
1617 * purple_unescape_filename:
1618 * @str: The string to translate.
1620 * Does the reverse of purple_escape_filename
1622 * This will change hex codes and such to their ascii equivalents.
1624 * Returns: The resulting string.
1626 const char *purple_unescape_filename(const char *str
);
1629 * purple_escape_filename:
1630 * @str: The string to translate.
1632 * Escapes filesystem-unfriendly characters from a filename
1634 * Returns: The resulting string.
1636 const char *purple_escape_filename(const char *str
);
1640 * @str: The string to escape.
1642 * Escapes javascript-unfriendly substrings from a string.
1644 * Returns: The javascript-safe string (must be g_free'd after use).
1646 gchar
* purple_escape_js(const gchar
*str
);
1649 * purple_restore_default_signal_handlers:
1651 * Restore default signal handlers for signals which might reasonably have
1652 * handlers. This should be called by a fork()'d child process, since child processes
1653 * inherit the handlers of the parent.
1655 void purple_restore_default_signal_handlers(void);
1658 * purple_get_host_name:
1660 * Gets the host name of the machine. If it not possible to determine the
1661 * host name, "localhost" is returned
1663 * Returns: The hostname
1665 const gchar
*purple_get_host_name(void);
1668 * purple_uuid_random:
1670 * Returns a type 4 (random) UUID
1672 * Returns: A UUID, caller is responsible for freeing it
1674 gchar
*purple_uuid_random(void);
1677 * purple_callback_set_zero:
1678 * @data: A pointer to variable, which should be set to NULL.
1680 * Sets given pointer to NULL.
1682 * Function designed to be used as a GDestroyNotify callback.
1684 void purple_callback_set_zero(gpointer data
);
1688 * @type: The type of data to be held by the GValue
1690 * Creates a new GValue of the specified type.
1692 * Returns: The created GValue
1694 GValue
*purple_value_new(GType type
);
1698 * @value: The GValue to duplicate
1700 * Duplicates a GValue.
1702 * Returns: The duplicated GValue
1704 GValue
*purple_value_dup(GValue
*value
);
1707 * purple_value_free:
1708 * @value: The GValue to free.
1712 void purple_value_free(GValue
*value
);
1715 * purple_http_digest_calculate_session_key:
1716 * @algorithm: The hash algorithm to use
1717 * @username: The username provided by the user
1718 * @realm: The authentication realm provided by the server
1719 * @password: The password provided by the user
1720 * @nonce: The nonce provided by the server
1721 * @client_nonce: The nonce provided by the client
1723 * Calculates a session key for HTTP Digest authentation
1725 * See RFC 2617 for more information.
1727 * Returns: The session key, or %NULL if an error occurred.
1729 gchar
*purple_http_digest_calculate_session_key(
1730 const gchar
*algorithm
, const gchar
*username
,
1731 const gchar
*realm
, const gchar
*password
,
1732 const gchar
*nonce
, const gchar
*client_nonce
);
1735 * purple_http_digest_calculate_response:
1736 * @algorithm: The hash algorithm to use
1737 * @method: The HTTP method in use
1738 * @digest_uri: The URI from the initial request
1739 * @qop: The "quality of protection"
1740 * @entity: The entity body
1741 * @nonce: The nonce provided by the server
1742 * @nonce_count: The nonce count
1743 * @client_nonce: The nonce provided by the client
1744 * @session_key: The session key from purple_http_digest_calculate_session_key()
1746 * Calculate a response for HTTP Digest authentication
1748 * See RFC 2617 for more information.
1750 * Returns: The hashed response, or %NULL if an error occurred.
1752 gchar
*purple_http_digest_calculate_response(
1753 const gchar
*algorithm
, const gchar
*method
,
1754 const gchar
*digest_uri
, const gchar
*qop
,
1755 const gchar
*entity
, const gchar
*nonce
,
1756 const gchar
*nonce_count
, const gchar
*client_nonce
,
1757 const gchar
*session_key
);
1761 #endif /* _PURPLE_UTIL_H_ */