str.c - bmf - bmf (Bayesian Mail Filter) 0.9.4 fork + patches
 (HTM) git clone git://git.codemadness.org/bmf
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       str.c (729B)
       ---
            1 /* $Id: str.c,v 1.2 2002/10/14 07:09:51 tommy Exp $ */
            2 
            3 /*
            4  * Copyright (c) 2002 Tom Marshall <tommy@tig-grr.com>
            5  *
            6  * This program is free software.  It may be distributed under the terms
            7  * in the file LICENSE, found in the top level of the distribution.
            8  */
            9 
           10 #include "config.h"
           11 #include "dbg.h"
           12 #include "str.h"
           13 
           14 void
           15 strncpylwr(char *d, const char *s, int n)
           16 {
           17         while (n--) {
           18                 *d++ = tolower(*s++);
           19         }
           20 }
           21 
           22 void
           23 str_create(str_t *pthis)
           24 {
           25         pthis->p = NULL;
           26         pthis->len = 0;
           27 }
           28 
           29 int
           30 str_casecmp(const str_t *pthis, const str_t * pother)
           31 {
           32         int cmp;
           33 
           34         cmp = strncasecmp(pthis->p, pother->p, min(pthis->len, pother->len));
           35         if (cmp == 0 && pthis->len != pother->len)
           36                 cmp = (pthis->len < pother->len) ? -1 : 1;
           37 
           38         return cmp;
           39 }