Mercurial > pidgin.yaz
annotate libgaim/stringref.h @ 15000:82d1a2fc6d25
[gaim-migrate @ 17778]
SF Patch #1598994 from lexande
Fixes SF Bug #1581999
Original Description:
"The gaim 2.0.0beta5 log reader plugin uses the "Date" XML field in MSN logs, the format of which varies between locales, leading to logs being displayed on incorrect/future dates in locales that do not use the MM/DD/YYYY format. This patch fixes the plugin to use the "DateTime" field which has YYYY-MM-DD date in all locales."
I totally Warmenhovened this patch. My approach:
"I'm using the Date, Time, and DateTime fields. If I can determine that the log matches the current timezone, it'll display 100% properly in the log viewer. If it has a reasonable offset, it'll display as the original time, sort in the right place, but not have a timezone abbreviation. If the offset is bogus or I can't parse the Date or Time field, it'll display in UTC, but still sort properly. I think this is as ideal as is possible, given the data we have to work with."
You don't have to understand this. ;)
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 19 Nov 2006 06:54:38 +0000 |
parents | 500a8f54354e |
children |
rev | line source |
---|---|
14192 | 1 /** |
2 * @file stringref.h Reference-counted immutable strings | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Gaim is the legal property of its developers, whose names are too numerous | |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
26 #ifndef _GAIM_STRINGREF_H_ | |
27 #define _GAIM_STRINGREF_H_ | |
28 | |
14926
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
29 #ifdef __cplusplus |
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
30 extern "C" { |
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
31 #endif |
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
32 |
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
33 typedef struct _GaimStringref GaimStringref; |
14192 | 34 |
35 /** | |
36 * Creates an immutable reference-counted string object. The newly | |
37 * created object will have a reference count of 1. | |
38 * | |
39 * @param value This will be the value of the string; it will be | |
40 * duplicated. | |
41 * | |
42 * @return A newly allocated string reference object with a refcount | |
43 * of 1. | |
44 */ | |
45 GaimStringref *gaim_stringref_new(const char *value); | |
46 | |
47 /** | |
48 * Creates an immutable reference-counted string object. The newly | |
49 * created object will have a reference count of zero, and if it is | |
50 * not referenced before the next iteration of the mainloop it will | |
51 * be freed at that time. | |
52 * | |
53 * @param value This will be the value of the string; it will be | |
54 * duplicated. | |
55 * | |
56 * @return A newly allocated string reference object with a refcount | |
57 * of zero. | |
58 */ | |
59 GaimStringref *gaim_stringref_new_noref(const char *value); | |
60 | |
61 /** | |
62 * Creates an immutable reference-counted string object from a printf | |
63 * format specification and arguments. The created object will have a | |
64 * reference count of 1. | |
65 * | |
66 * @param format A printf-style format specification. | |
67 * | |
68 * @return A newly allocated string reference object with a refcount | |
69 * of 1. | |
70 */ | |
71 GaimStringref *gaim_stringref_printf(const char *format, ...); | |
72 | |
73 /** | |
74 * Increase the reference count of the given stringref. | |
75 * | |
76 * @param stringref String to be referenced. | |
77 * | |
78 * @return A pointer to the referenced string. | |
79 */ | |
80 GaimStringref *gaim_stringref_ref(GaimStringref *stringref); | |
81 | |
82 /** | |
83 * Decrease the reference count of the given stringref. If this | |
84 * reference count reaches zero, the stringref will be freed; thus | |
85 * you MUST NOT use this string after dereferencing it. | |
86 * | |
87 * @param stringref String to be dereferenced. | |
88 */ | |
89 void gaim_stringref_unref(GaimStringref *stringref); | |
90 | |
91 /** | |
92 * Retrieve the value of a stringref. | |
93 * | |
94 * @note This value should not be cached or stored in a local variable. | |
95 * While there is nothing inherently incorrect about doing so, it | |
96 * is easy to forget that the cached value is in fact a | |
97 * reference-counted object and accidentally use it after | |
98 * dereferencing. This is more problematic for a reference- | |
99 * counted object than a heap-allocated object, as it may seem to | |
100 * be valid or invalid nondeterministically based on how many | |
101 * other references to it exist. | |
102 * | |
103 * @param stringref String reference from which to retrieve the value. | |
104 * | |
105 * @return The contents of the string reference. | |
106 */ | |
107 const char *gaim_stringref_value(const GaimStringref *stringref); | |
108 | |
109 /** | |
110 * Compare two stringrefs for string equality. This returns the same | |
111 * value as strcmp would, where <0 indicates that s1 is "less than" s2 | |
112 * in the ASCII lexicography, 0 indicates equality, etc. | |
113 * | |
114 * @param s1 The reference string. | |
115 * | |
116 * @param s2 The string to compare against the reference. | |
117 * | |
118 * @return An ordering indication on s1 and s2. | |
119 */ | |
120 int gaim_stringref_cmp(const GaimStringref *s1, const GaimStringref *s2); | |
121 | |
122 /** | |
123 * Find the length of the string inside a stringref. | |
124 * | |
125 * @param stringref The string in whose length we are interested. | |
126 * | |
127 * @return The length of the string in stringref | |
128 */ | |
129 size_t gaim_stringref_len(const GaimStringref *stringref); | |
130 | |
14926
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
131 #ifdef __cplusplus |
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
132 } |
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
133 #endif |
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14192
diff
changeset
|
134 |
14192 | 135 #endif /* _GAIM_STRINGREF_H_ */ |