create a lib-hash.a with sha1 and md5.
[apps/madmutt.git] / color.c
diff --git a/color.c b/color.c
index 5484bba..dd29b7f 100644 (file)
--- a/color.c
+++ b/color.c
 # include "config.h"
 #endif
 
+#include <lib-lib/mem.h>
+#include <lib-lib/ascii.h>
+#include <lib-lib/str.h>
+#include <lib-lib/macros.h>
+#include <lib-lib/buffer.h>
+
 #include "mutt.h"
-#include "buffer.h"
-#include "ascii.h"
 #include "mutt_curses.h"
 #include "mapping.h"
 
-#include "lib/mem.h"
-#include "lib/intl.h"
-#include "lib/str.h"
 #include "lib/debug.h"
 
 #include <string.h>
@@ -98,7 +99,7 @@ static struct mapping_t Fields[] = {
 
 static COLOR_LINE *mutt_new_color_line (void)
 {
-  COLOR_LINE *p = mem_calloc (1, sizeof (COLOR_LINE));
+  COLOR_LINE *p = p_new(COLOR_LINE, 1);
 
   p->fg = p->bg = -1;
 
@@ -125,29 +126,29 @@ static void mutt_free_color_line (COLOR_LINE ** l, int free_colors)
 
   regfree (&tmp->rx);
   mutt_pattern_free (&tmp->color_pattern);
-  mem_free (&tmp->pattern);
-  mem_free (l);
+  p_delete(&tmp->pattern);
+  p_delete(l);
 }
 
 void ci_start_color (void)
 {
-  memset (ColorDefs, A_NORMAL, sizeof (int) * MT_COLOR_MAX);
-  ColorQuote = (int *) mem_malloc (COLOR_QUOTE_INIT * sizeof (int));
-  memset (ColorQuote, A_NORMAL, sizeof (int) * COLOR_QUOTE_INIT);
-  ColorQuoteSize = COLOR_QUOTE_INIT;
-  ColorQuoteUsed = 0;
-
-  /* set some defaults */
-  ColorDefs[MT_COLOR_STATUS] = A_REVERSE;
-  ColorDefs[MT_COLOR_INDICATOR] = A_REVERSE;
-  ColorDefs[MT_COLOR_SEARCH] = A_REVERSE;
-  ColorDefs[MT_COLOR_MARKERS] = A_REVERSE;
-  /* special meaning: toggle the relevant attribute */
-  ColorDefs[MT_COLOR_BOLD] = 0;
-  ColorDefs[MT_COLOR_UNDERLINE] = 0;
+    memset(ColorDefs, A_NORMAL, sizeof(int) * MT_COLOR_MAX);
+    ColorQuote = p_new(int, COLOR_QUOTE_INIT);
+    memset(ColorQuote, A_NORMAL, sizeof(int) * COLOR_QUOTE_INIT);
+    ColorQuoteSize = COLOR_QUOTE_INIT;
+    ColorQuoteUsed = 0;
+
+    /* set some defaults */
+    ColorDefs[MT_COLOR_STATUS] = A_REVERSE;
+    ColorDefs[MT_COLOR_INDICATOR] = A_REVERSE;
+    ColorDefs[MT_COLOR_SEARCH] = A_REVERSE;
+    ColorDefs[MT_COLOR_MARKERS] = A_REVERSE;
+    /* special meaning: toggle the relevant attribute */
+    ColorDefs[MT_COLOR_BOLD] = 0;
+    ColorDefs[MT_COLOR_UNDERLINE] = 0;
 
 #ifdef HAVE_COLOR
-  start_color ();
+    start_color ();
 #endif
 }
 
@@ -225,7 +226,7 @@ int mutt_alloc_color (int fg, int bg)
     i++;
   }
 
-  p = (COLOR_LIST *) mem_malloc (sizeof (COLOR_LIST));
+  p = p_new(COLOR_LIST, 1);
   p->next = ColorList;
   ColorList = p;
 
@@ -269,14 +270,14 @@ void mutt_free_color (int fg, int bg)
 
       if (p == ColorList) {
         ColorList = ColorList->next;
-        mem_free (&p);
+        p_delete(&p);
         return;
       }
       q = ColorList;
       while (q) {
         if (q->next == p) {
           q->next = p->next;
-          mem_free (&p);
+          p_delete(&p);
           return;
         }
         q = q->next;
@@ -401,7 +402,7 @@ _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
 
   do {
     mutt_extract_token (buf, s, 0);
-    if (!str_cmp ("*", buf->data)) {
+    if (!m_strcmp("*", buf->data)) {
       for (tmp = ColorIndexList; tmp;) {
         if (!do_cache)
           do_cache = 1;
@@ -414,7 +415,7 @@ _mutt_parse_uncolor (BUFFER * buf, BUFFER * s, unsigned long data,
     else {
       for (last = NULL, tmp = ColorIndexList; tmp;
            last = tmp, tmp = tmp->next) {
-        if (!str_cmp (buf->data, tmp->pattern)) {
+        if (!m_strcmp(buf->data, tmp->pattern)) {
           if (!do_cache)
             do_cache = 1;
           debug_print (1, ("Freeing pattern \"%s\" from ColorIndexList\n", tmp->pattern));
@@ -456,7 +457,7 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive,
 
   while (tmp) {
     if (sensitive) {
-      if (str_cmp (s, tmp->pattern) == 0)
+      if (m_strcmp(s, tmp->pattern) == 0)
         break;
     }
     else {
@@ -509,7 +510,7 @@ add_pattern (COLOR_LINE ** top, const char *s, int sensitive,
       return (-1);
     }
     tmp->next = *top;
-    tmp->pattern = str_dup (s);
+    tmp->pattern = m_strdup(s);
 #ifdef HAVE_COLOR
     if (fg != -1 && bg != -1) {
       tmp->fg = fg;
@@ -700,7 +701,7 @@ _mutt_parse_color (BUFFER * buf, BUFFER * s, BUFFER * err,
   }
   else if (object == MT_COLOR_QUOTED) {
     if (q_level >= ColorQuoteSize) {
-      mem_realloc (&ColorQuote, (ColorQuoteSize += 2) * sizeof (int));
+      p_realloc(&ColorQuote, ColorQuoteSize += 2);
       ColorQuote[ColorQuoteSize - 2] = ColorDefs[MT_COLOR_QUOTED];
       ColorQuote[ColorQuoteSize - 1] = ColorDefs[MT_COLOR_QUOTED];
     }