Back to index

courier  0.68.2
comfax.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 2002 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #include "courier_lib_config.h"
00007 #include "comfax.h"
00008 #include <stdio.h>
00009 #include <string.h>
00010 
00011 
00012 /*
00013 **   @fax is the domain for the courierfax module.
00014 **
00015 **   @fax may be followed by:
00016 **
00017 **     -lowres    - send a low-resolution fax.
00018 **     -ignore    - ignore unknown MIME types.
00019 **     -cover     - generate a cover page only.
00020 */
00021 
00022 int comgetfaxopts(const char *s, int *flags)
00023 {
00024        return (comgetfaxoptsn(s, strlen(s), flags));
00025 }
00026 
00027 /*
00028 **   Return 0 if s/sl specifies a valid domain for the courierfax module.
00029 */
00030 
00031 int comgetfaxoptsn(const char *s, int sl, int *flags)
00032 {
00033        *flags=0;
00034 
00035        if (sl < 3)
00036               return (-1);
00037 
00038        if (strncasecmp(s, "fax", 3))
00039               return (-1);
00040 
00041        s += 3;
00042        sl -= 3;
00043 
00044        while (sl)
00045        {
00046               if (*s != '-')
00047                      return (-1);
00048 
00049               ++s;
00050               --sl;
00051               if (!sl)
00052                      return (-1);
00053 
00054               if (sl >= 6 && strncasecmp(s, "lowres", 6) == 0)
00055               {
00056                      s += 6;
00057                      sl -= 6;
00058                      *flags |= FAX_LOWRES;
00059               }
00060               else if (sl >= 6 && strncasecmp(s, "ignore", 6) == 0)
00061               {
00062                      s += 6;
00063                      sl -= 6;
00064                      *flags |= FAX_OKUNKNOWN;
00065               }
00066               else if (sl >= 5 && strncasecmp(s, "cover", 5) == 0)
00067               {
00068                      s += 5;
00069                      sl -= 5;
00070                      *flags |= FAX_COVERONLY;
00071               }
00072               else
00073                      return (-1);
00074        }
00075 
00076        return (0);
00077 }