head 1.2; access; symbols PETIDOMO_4_0b6:1.2 PETIDOMO_4_0b5:1.2 PETIDOMO_4_0b4:1.2 PETIDOMO_4_0b3:1.2 BEFORETHL:1.2 petidomo-2-2:1.1.1.1 petidomo:1.1.1; locks; strict; comment @ * @; 1.2 date 2000.12.16.13.06.12; author simons; state Exp; branches; next 1.1; 1.1 date 2000.12.16.12.38.21; author simons; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2000.12.16.12.38.21; author simons; state Exp; branches; next ; desc @@ 1.2 log @- Added GNU GPL copyright headers. - Cleaned build process up. @ text @/* $Source: /d1/e/petidomo/cvs/petidomo/source/Attic/main.c,v $ $Revision: 1.2 $ Copyright (C) 2000 by CyberSolutions GmbH, Germany. This file is part of OpenPetidomo. OpenPetidomo is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. OpenPetidomo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ #include #include #include #include #ifdef DEBUG_DMALLOC # include #endif #include "rfc822.h" static char * read_until_next_quote(char * p) { while (*p) { if (*p == '"') { p++; break; } if (*p == '\\' && p[1] != '\0') { p += 2; continue; } p++; } return p; } static char * read_until_close_bracket(char * p) { while (*p) { if (*p == ')') { p++; break; } if (*p == '(') { p = read_until_close_bracket(p+1); continue; } else if (*p == '\\' && p[1] != '\0') { p += 2; continue; } else if (*p == '"') { p = read_until_next_quote(p+1); continue; } p++; } return p; } static int is_source_routing(char * p) { while (*p) { if (*p == '(') p = read_until_close_bracket(p+1); else if (*p == ' ' || *p == '\t') p++; else if (*p == '@@' || *p == '<') return 1; else return 0; } return 0; } /* Split an RFC822 address line. This routine breaks an address line, as specified by RFC822, up into separate addresses. The used delimiter is the comma (","). The usage of the routine is very similar to strsep(3). More text to come. AUTHOR: Peter Simons */ char * rfc822_address_sep(struct rfc822_address_sep_state * state) { char * p, * old; int allow_groups; /* Sanity checks. */ assert(state != NULL); if (!state) { errno = EINVAL; return NULL; } if (*(state->address_line) == '\0') return NULL; old = p = state->address_line; allow_groups = !is_source_routing(p); while(*p) { if (*p == ',') { *p = '\0'; state->address_line = p+1; return old; } else if (*p == ':' && allow_groups) { old = p+1; state->group_nest++; allow_groups = !is_source_routing(p+1); } else if (*p == ';') { /* If we are inside an address group, the ';' character is interpreted like a comma. */ if (state->group_nest > 0) { state->group_nest--; *p = ','; continue; } else /* do nothing */; } else if (*p == '(') { p = read_until_close_bracket(p+1); continue; } else if (*p == '\\' && p[1] != '\0') p++; else if (*p == '"') { p = read_until_next_quote(p+1); continue; } p++; } state->address_line = p; return old; } @ 1.1 log @Initial revision @ text @d2 17 a18 7 * $Source: /usr/local/libdata/cvs/c-lib/librfc822/address_sep.c,v $ * $Revision: 1.10 $ * $Date: 1998/08/15 21:24:16 $ * * Copyright (C) 1997 by CyberSolutions GmbH. * All rights reserved. */ @ 1.1.1.1 log @Imported Petidomo 2.2 as found on www.petidomo.com. @ text @@