annotate src/libident/support.c @ 222:8cddc65765bd
added support for STARTTLS wrappers
added the route config option `instant_helo' which
causes masqmail, as SMTP client, not to wait for the
server's 220 greeting. Instead if says EHLO right at
once. You'll need this for STARTTLS wrappers that
usually eat the greeting line.
author |
meillo@marmaro.de |
date |
Fri, 23 Jul 2010 10:57:53 +0200 |
parents |
08114f7dcc23 |
children |
|
rev |
line source |
meillo@0
|
1 /*
|
meillo@0
|
2 ** support.c
|
meillo@0
|
3 **
|
meillo@0
|
4 ** Author: Pr Emanuelsson <pell@lysator.liu.se>
|
meillo@0
|
5 ** Hacked by: Peter Eriksson <pen@lysator.liu.se>
|
meillo@0
|
6 */
|
meillo@0
|
7 #include <stdio.h>
|
meillo@0
|
8 #include <ctype.h>
|
meillo@0
|
9
|
meillo@0
|
10 #ifdef HAVE_ANSIHEADERS
|
meillo@0
|
11 # include <stdlib.h>
|
meillo@0
|
12 # include <string.h>
|
meillo@0
|
13 #else
|
meillo@0
|
14 # define strchr(str, c) index(str, c)
|
meillo@0
|
15 #endif
|
meillo@0
|
16
|
meillo@0
|
17 #define IN_LIBIDENT_SRC
|
meillo@0
|
18 #include "ident.h"
|
meillo@0
|
19
|
meillo@0
|
20
|
meillo@10
|
21 char*
|
meillo@10
|
22 id_strdup __P1(char *, str)
|
meillo@0
|
23 {
|
meillo@10
|
24 char *cp;
|
meillo@0
|
25
|
meillo@10
|
26 cp = (char *) malloc(strlen(str) + 1);
|
meillo@10
|
27 if (cp == NULL) {
|
meillo@0
|
28 #ifdef DEBUG
|
meillo@10
|
29 perror("libident: malloc");
|
meillo@0
|
30 #endif
|
meillo@10
|
31 return NULL;
|
meillo@10
|
32 }
|
meillo@0
|
33
|
meillo@10
|
34 strcpy(cp, str);
|
meillo@0
|
35
|
meillo@10
|
36 return cp;
|
meillo@0
|
37 }
|
meillo@0
|
38
|
meillo@0
|
39
|
meillo@10
|
40 char*
|
meillo@10
|
41 id_strtok __P3(char *, cp, char *, cs, char *, dc)
|
meillo@0
|
42 {
|
meillo@10
|
43 static char *bp = 0;
|
meillo@10
|
44
|
meillo@10
|
45 if (cp)
|
meillo@10
|
46 bp = cp;
|
meillo@10
|
47
|
meillo@10
|
48 /*
|
meillo@10
|
49 ** No delimitor cs - return whole buffer and point at end
|
meillo@10
|
50 */
|
meillo@10
|
51 if (!cs) {
|
meillo@10
|
52 while (*bp)
|
meillo@10
|
53 bp++;
|
meillo@10
|
54 return cs;
|
meillo@10
|
55 }
|
meillo@10
|
56
|
meillo@10
|
57 /*
|
meillo@10
|
58 ** Skip leading spaces
|
meillo@10
|
59 */
|
meillo@10
|
60 while (isspace(*bp))
|
meillo@10
|
61 bp++;
|
meillo@10
|
62
|
meillo@10
|
63 /*
|
meillo@10
|
64 ** No token found?
|
meillo@10
|
65 */
|
meillo@10
|
66 if (!*bp)
|
meillo@10
|
67 return 0;
|
meillo@10
|
68
|
meillo@10
|
69 cp = bp;
|
meillo@10
|
70 while (*bp && !strchr(cs, *bp))
|
meillo@10
|
71 bp++;
|
meillo@10
|
72
|
meillo@10
|
73 /*
|
meillo@10
|
74 ** Remove trailing spaces
|
meillo@10
|
75 */
|
meillo@10
|
76 *dc = *bp;
|
meillo@10
|
77 for (dc = bp - 1; dc > cp && isspace(*dc); dc--);
|
meillo@10
|
78 *++dc = '\0';
|
meillo@10
|
79
|
meillo@0
|
80 bp++;
|
meillo@10
|
81
|
meillo@10
|
82 return cp;
|
meillo@0
|
83 }
|