1 /* Misc utility functions for the Pidgin-Encryption plugin */ 2 /* Copyright (C) 2001-2003 William Tompkins */ 3 4 /* This plugin is free software, distributed under the GNU General Public */ 5 /* License. */ 6 /* Please see the file "COPYING" distributed with this source code */ 7 /* for more details */ 8 /* */ 9 /* */ 10 /* This software is distributed in the hope that it will be useful, */ 11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 13 /* General Public License for more details. */ 14 15 /* To compile and use: */ 16 /* See INSTALL file. */ 17 18 #ifndef CRYPTUTIL_H 19 #define CRYPTUTIL_H 20 21 #include "debug.h" 22 23 #define MSG_HUNK_SIZE 126 24 #define CRYPT_HUNK_SIZE 256 25 26 /* Utility Functions: */ 27 28 /* Convert a byte array to ascii-encoded character array. */ 29 void PE_bytes_to_str(char* str, unsigned char* bytes, int numbytes); 30 31 /* Convert a byte array to hex like a5:38:49:... . */ 32 /* returns number of chars in char array. No null termination! */ 33 /* int PE_bytes_to_colonstr(unsigned char* hex, unsigned char* bytes, int numbytes); */ 34 35 /* Convert ascii-encoded bytes in a null terminated char* into a byte array */ 36 unsigned int PE_str_to_bytes(unsigned char* bytes, char* hex); 37 38 /* Strip returns from a block encoded string */ 39 GString* PE_strip_returns(GString* s); 40 41 /* Zero out a string (use for plaintext before freeing memory) */ 42 void PE_clear_string(char* s); 43 44 /* Escape all spaces in name so it can go in a key file */ 45 void PE_escape_name(GString* name); 46 47 /* Reverse the previous escaping. Since it will only get shorter, allow char* */ 48 void PE_unescape_name(char* name); 49 50 /* Returns true if the message starts with an HTML link */ 51 gboolean PE_msg_starts_with_link(const char* c); 52 53 /* Split a message (hopefully on a space) so we can send it in pieces */ 54 GSList *PE_message_split(char *message, int limit); 55 #endif 56