Frameworks/libpurple.framework/Versions/2.10.12r8d2874a79747/Headers/msnutils.h
branchadium-1.5.11
changeset 6014 fcb71cb71a3d
parent 5941 307f53385811
parent 6013 f8d0dc659e3f
child 6016 325e2ab3406f
equal deleted inserted replaced
5941:307f53385811 6014:fcb71cb71a3d
     1 /**
       
     2  * @file msnutils.h Utility functions
       
     3  *
       
     4  * purple
       
     5  *
       
     6  * Purple is the legal property of its developers, whose names are too numerous
       
     7  * to list here.  Please refer to the COPYRIGHT file distributed with this
       
     8  * source distribution.
       
     9  *
       
    10  * This program is free software; you can redistribute it and/or modify
       
    11  * it under the terms of the GNU General Public License as published by
       
    12  * the Free Software Foundation; either version 2 of the License, or
       
    13  * (at your option) any later version.
       
    14  *
       
    15  * This program is distributed in the hope that it will be useful,
       
    16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    18  * GNU General Public License for more details.
       
    19  *
       
    20  * You should have received a copy of the GNU General Public License
       
    21  * along with this program; if not, write to the Free Software
       
    22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
       
    23  */
       
    24 #ifndef MSN_UTILS_H
       
    25 #define MSN_UTILS_H
       
    26 
       
    27 /*encode the str to RFC2047 style*/
       
    28 char *msn_encode_mime(const char *str);
       
    29 
       
    30 /**
       
    31  * Generate the Random GUID
       
    32  */
       
    33 char *rand_guid(void);
       
    34 
       
    35 /**
       
    36  * Encodes the spaces in a string
       
    37  *
       
    38  * @param str The string to be encoded.
       
    39  * @param buf The buffer to hold the encoded string.
       
    40  * @param len The maximum length (including NUL) to put in @buf.
       
    41  *
       
    42  * @return Whether @str was able to fit in @buf.
       
    43  */
       
    44 gboolean
       
    45 msn_encode_spaces(const char *str, char *buf, size_t len);
       
    46 
       
    47 /**
       
    48  * Parses the MSN message formatting into a format compatible with Purple.
       
    49  *
       
    50  * @param mime     The mime header with the formatting.
       
    51  * @param pre_ret  The returned prefix string.
       
    52  * @param post_ret The returned postfix string.
       
    53  *
       
    54  * @return The new message.
       
    55  */
       
    56 void msn_parse_format(const char *mime, char **pre_ret, char **post_ret);
       
    57 
       
    58 /**
       
    59  * Parses the Purple message formatting (html) into the MSN format.
       
    60  *
       
    61  * @param html			The html message to format.
       
    62  * @param attributes	The returned attributes string.
       
    63  * @param message		The returned message string.
       
    64  *
       
    65  * @return The new message.
       
    66  */
       
    67 void msn_import_html(const char *html, char **attributes, char **message);
       
    68 
       
    69 /**
       
    70  * Parses a socket string.
       
    71  *
       
    72  * @param str		A host:port string.
       
    73  * @param ret_host 	Return string value of the host.
       
    74  * @param ret_port	Return integer value of the port.
       
    75  */
       
    76 void msn_parse_socket(const char *str, char **ret_host, int *ret_port);
       
    77 
       
    78 /**
       
    79  * Parses a user name
       
    80  *
       
    81  * @param str         A network:username string.
       
    82  * @param ret_user    Return of the user's passport.
       
    83  * @param ret_network Return of the user's network.
       
    84  */
       
    85 void msn_parse_user(const char *str, char **ret_user, int *ret_network);
       
    86 
       
    87 /**
       
    88  * Verify if the email is a vaild passport.
       
    89  *
       
    90  * @param passport 	The email
       
    91  *
       
    92  * @return True if it is a valid passport, else FALSE
       
    93  */
       
    94 gboolean msn_email_is_valid(const char *passport);
       
    95 
       
    96 /**
       
    97  * Handle MSN Challenge Computation
       
    98  * This algorithm references
       
    99  * http://imfreedom.org/wiki/index.php/MSN:NS/Challenges
       
   100  *
       
   101  * @param input 	Challenge input.
       
   102  * @param output 	Callenge output.
       
   103  */
       
   104 void msn_handle_chl(char *input, char *output);
       
   105 
       
   106 /**
       
   107  * Read a byte from a buffer
       
   108  *
       
   109  * @param buf Pointer to buffer.
       
   110  *
       
   111  * @return 8-bit byte
       
   112  */
       
   113 guint8 msn_read8(const char *buf);
       
   114 
       
   115 /**
       
   116  * Read a little-endian short from a buffer
       
   117  *
       
   118  * @param buf Pointer to buffer.
       
   119  *
       
   120  * @return 16-bit short
       
   121  */
       
   122 guint16 msn_read16le(const char *buf);
       
   123 
       
   124 /**
       
   125  * Read a big-endian short from a buffer
       
   126  *
       
   127  * @param buf Pointer to buffer.
       
   128  *
       
   129  * @return 16-bit short
       
   130  */
       
   131 guint16 msn_read16be(const char *buf);
       
   132 
       
   133 /**
       
   134  * Read a little-endian int from a buffer
       
   135  *
       
   136  * @param buf Pointer to buffer.
       
   137  *
       
   138  * @return 32-bit int
       
   139  */
       
   140 guint32 msn_read32le(const char *buf);
       
   141 
       
   142 /**
       
   143  * Read a big-endian int from a buffer
       
   144  *
       
   145  * @param buf Pointer to buffer.
       
   146  *
       
   147  * @return 32-bit int
       
   148  */
       
   149 guint32 msn_read32be(const char *buf);
       
   150 
       
   151 /**
       
   152  * Read a little-endian long from a buffer
       
   153  *
       
   154  * @param buf Pointer to buffer.
       
   155  *
       
   156  * @return 64-bit long
       
   157  */
       
   158 guint64 msn_read64le(const char *buf);
       
   159 
       
   160 /**
       
   161  * Read a big-endian long from a buffer
       
   162  *
       
   163  * @param buf Pointer to buffer.
       
   164  *
       
   165  * @return 64-bit long
       
   166  */
       
   167 guint64 msn_read64be(const char *buf);
       
   168 
       
   169 /**
       
   170  * Write a byte to a buffer
       
   171  *
       
   172  * @param buf  Pointer to buffer.
       
   173  * @param data 8-bit byte.
       
   174  */
       
   175 void msn_write8(char *buf, guint8 data);
       
   176 
       
   177 /**
       
   178  * Write a little-endian short to a buffer
       
   179  *
       
   180  * @param buf  Pointer to buffer.
       
   181  * @param data short.
       
   182  */
       
   183 void msn_write16le(char *buf, guint16 data);
       
   184 
       
   185 /**
       
   186  * Write a big-endian short to a buffer
       
   187  *
       
   188  * @param buf  Pointer to buffer.
       
   189  * @param data short.
       
   190  */
       
   191 void msn_write16be(char *buf, guint16 data);
       
   192 
       
   193 /**
       
   194  * Write a little-endian int to a buffer
       
   195  *
       
   196  * @param buf  Pointer to buffer.
       
   197  * @param data int.
       
   198  */
       
   199 void msn_write32le(char *buf, guint32 data);
       
   200 
       
   201 /**
       
   202  * Write a big-endian int to a buffer
       
   203  *
       
   204  * @param buf  Pointer to buffer.
       
   205  * @param data int.
       
   206  */
       
   207 void msn_write32be(char *buf, guint32 data);
       
   208 
       
   209 /**
       
   210  * Write a little-endian long to a buffer
       
   211  *
       
   212  * @param buf  Pointer to buffer.
       
   213  * @param data long.
       
   214  */
       
   215 void msn_write64le(char *buf, guint64 data);
       
   216 
       
   217 /**
       
   218  * Write a big-endian long to a buffer
       
   219  *
       
   220  * @param buf  Pointer to buffer.
       
   221  * @param data short
       
   222  */
       
   223 void msn_write64be(char *buf, guint64 data);
       
   224 
       
   225 /**
       
   226  * Same as above, but these increment the buf pointer.
       
   227  */
       
   228 #define msn_pop8(buf)    msn_read8((buf+=1)-1)
       
   229 #define msn_pop16le(buf) msn_read16le((buf+=2)-2)
       
   230 #define msn_pop16be(buf) msn_read16be((buf+=2)-2)
       
   231 #define msn_pop32le(buf) msn_read32le((buf+=4)-4)
       
   232 #define msn_pop32be(buf) msn_read32be((buf+=4)-4)
       
   233 #define msn_pop64le(buf) msn_read64le((buf+=8)-8)
       
   234 #define msn_pop64be(buf) msn_read64be((buf+=8)-8)
       
   235 #define msn_push8(buf, data)    msn_write8(buf, data),    buf+=1
       
   236 #define msn_push16le(buf, data) msn_write16le(buf, data), buf+=2
       
   237 #define msn_push16be(buf, data) msn_write16be(buf, data), buf+=2
       
   238 #define msn_push32le(buf, data) msn_write32le(buf, data), buf+=4
       
   239 #define msn_push32be(buf, data) msn_write32be(buf, data), buf+=4
       
   240 #define msn_push64le(buf, data) msn_write64le(buf, data), buf+=8
       
   241 #define msn_push64be(buf, data) msn_write64be(buf, data), buf+=8
       
   242 
       
   243 #endif /* MSN_UTILS_H */
       
   244