comparison libpurple/util.c @ 22311:02eda4bd2b22

Apply the custom smiley patches from #1187, from Jorge Villaseo (Masca) and Mauro Srgio Ferreira Brasil. I have not applied the bits on MSN yet. I will have to look at it later, but I would rather someone else more familiar with the MSN code look at it first. I changed some bits of the applied patch (whitespacing, camelcasing etc.), and the bit that required a major version bump (in gtkthemes.h). There are a few more things that need to be done for this to be merged back to i.p.p.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 19 Feb 2008 19:41:56 +0000
parents 3634d27ec6f1
children f1475ca224a8
comparison
equal deleted inserted replaced
22310:f463d54e606b 22311:02eda4bd2b22
919 const char * 919 const char *
920 purple_markup_unescape_entity(const char *text, int *length) 920 purple_markup_unescape_entity(const char *text, int *length)
921 { 921 {
922 const char *pln; 922 const char *pln;
923 int len, pound; 923 int len, pound;
924 char temp[2];
925 924
926 if (!text || *text != '&') 925 if (!text || *text != '&')
927 return NULL; 926 return NULL;
928 927
929 #define IS_ENTITY(s) (!g_ascii_strncasecmp(text, s, (len = sizeof(s) - 1))) 928 #define IS_ENTITY(s) (!g_ascii_strncasecmp(text, s, (len = sizeof(s) - 1)))
942 pln = "\""; 941 pln = "\"";
943 else if(IS_ENTITY("&reg;")) 942 else if(IS_ENTITY("&reg;"))
944 pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */ 943 pln = "\302\256"; /* or use g_unichar_to_utf8(0xae); */
945 else if(IS_ENTITY("&apos;")) 944 else if(IS_ENTITY("&apos;"))
946 pln = "\'"; 945 pln = "\'";
947 else if(*(text+1) == '#' && 946 else if(*(text+1) == '#' && (sscanf(text, "&#%u;", &pound) == 1) &&
948 (sscanf(text, "&#%u%1[;]", &pound, temp) == 2 || sscanf(text, "&#x%x%1[;]", &pound, temp) == 2) && 947 pound != 0 && *(text+3+(gint)log10(pound)) == ';') {
949 pound != 0) {
950 static char buf[7]; 948 static char buf[7];
951 int buflen = g_unichar_to_utf8((gunichar)pound, buf); 949 int buflen = g_unichar_to_utf8((gunichar)pound, buf);
952 buf[buflen] = '\0'; 950 buf[buflen] = '\0';
953 pln = buf; 951 pln = buf;
954 952
2887 2885
2888 return "icon"; 2886 return "icon";
2889 } 2887 }
2890 2888
2891 char * 2889 char *
2892 purple_util_get_image_filename(gconstpointer image_data, size_t image_len) 2890 purple_util_get_image_checksum(gconstpointer image_data, size_t image_len)
2893 { 2891 {
2894 PurpleCipherContext *context; 2892 PurpleCipherContext *context;
2895 gchar digest[41]; 2893 gchar digest[41];
2896 2894
2897 context = purple_cipher_context_new_by_name("sha1", NULL); 2895 context = purple_cipher_context_new_by_name("sha1", NULL);
2908 purple_debug_error("util", "Failed to get SHA-1 digest.\n"); 2906 purple_debug_error("util", "Failed to get SHA-1 digest.\n");
2909 g_return_val_if_reached(NULL); 2907 g_return_val_if_reached(NULL);
2910 } 2908 }
2911 purple_cipher_context_destroy(context); 2909 purple_cipher_context_destroy(context);
2912 2910
2911 return g_strdup(digest);
2912 }
2913
2914 char *
2915 purple_util_get_image_filename(gconstpointer image_data, size_t image_len)
2916 {
2913 /* Return the filename */ 2917 /* Return the filename */
2914 return g_strdup_printf("%s.%s", digest, 2918 return g_strdup_printf("%s.%s",
2919 purple_util_get_image_checksum(image_data, image_len),
2915 purple_util_get_image_extension(image_data, image_len)); 2920 purple_util_get_image_extension(image_data, image_len));
2916 } 2921 }
2917 2922
2918 gboolean 2923 gboolean
2919 purple_program_is_valid(const char *program) 2924 purple_program_is_valid(const char *program)