Back to index

courier  0.68.2
Defines | Functions
maildirsearch.c File Reference
#include "config.h"
#include "maildirsearch.h"

Go to the source code of this file.

Defines

#define SPC(s)   ((s) == ' '|| (s) == '\t' || (s) == '\r' || (s) == '\n')

Functions

int maildir_search_start_unicode (struct maildir_searchengine *sei, const unicode_char *s)
int maildir_search_start_str (struct maildir_searchengine *sei, const char *s)
int maildir_search_start_str_chset (struct maildir_searchengine *engine, const char *string, const char *chset)

Define Documentation

#define SPC (   s)    ((s) == ' '|| (s) == '\t' || (s) == '\r' || (s) == '\n')

Function Documentation

int maildir_search_start_str ( struct maildir_searchengine sei,
const char *  s 
)

Definition at line 54 of file maildirsearch.c.

{
       unicode_char *uc=malloc((strlen(s)+1) * sizeof(unicode_char));
       size_t n;
       int rc;

       if (!uc)
              return -1;

       for (n=0; (uc[n]=(unsigned char)s[n]) != 0; ++n)
              ;

       rc=maildir_search_start_unicode(sei, uc);
       free(uc);
       return rc;
}

Here is the call graph for this function:

int maildir_search_start_str_chset ( struct maildir_searchengine engine,
const char *  string,
const char *  chset 
)

Definition at line 72 of file maildirsearch.c.

{
#define SPC(s) ((s) == ' '|| (s) == '\t' || (s) == '\r' || (s) == '\n')

       unicode_char *ucptr;
       size_t ucsize;
       libmail_u_convert_handle_t h=libmail_u_convert_tou_init(chset, &ucptr,
                                                        &ucsize, 1);
       size_t i, j;
       int rc;

       if (h == NULL)
              return -1;

       if (libmail_u_convert(h, string, strlen(string)))
       {
              libmail_u_convert_deinit(h, NULL);
              return -1;
       }

       if (libmail_u_convert_deinit(h, NULL))
              return -1;

       for (i=j=0; ucptr[i]; )
       {
              while (SPC(ucptr[i]))
                     ++i;

              if (!ucptr[i])
                     break;

              while (ucptr[i])
              {
                     ucptr[j]=unicode_lc(ucptr[i]);
                     ++j;
                     if (SPC(ucptr[i]))
                            break;

                     ++i;
              }
       }

       while (j > 0 && SPC(ucptr[j-1]))
              --j;
       ucptr[j]=0;

       rc=maildir_search_start_unicode(engine, ucptr);
       free(ucptr);
       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int maildir_search_start_unicode ( struct maildir_searchengine sei,
const unicode_char s 
)

Definition at line 10 of file maildirsearch.c.

{
       unsigned i, j, *r;

       size_t n;

       for (n=0; s[n]; ++n)
              ;
       ++n;

       if (sei->string)
              free(sei->string);

       sei->string=malloc(n * sizeof(*s));
       if (!sei->string)
              return (-1);
       sei->string_l=n-1;

       memcpy(sei->string, s, n * sizeof(*s));

       if (sei->r)
              free(sei->r);

       sei->i=0;
       if ((sei->r=r=(unsigned *)malloc(sizeof(unsigned)*n)) == 0)
              return (-1);

       for (i=0; s[i]; i++)
              r[i]=0;

       for (i=0; s[i]; i++)
              for (j=0; s[i+j]; j++)
                     if (s[j] != s[i+j])
                     {
                            if (r[i+j] < j)
                                   r[i+j]=j;
                            break;
                     }

       maildir_search_reset(sei);
       return (0);
}

Here is the caller graph for this function: