00001 /* 00002 * $Id$ 00003 * 00004 * MiniMIME - a library for handling MIME messages 00005 * 00006 * Copyright (C) 2003 Jann Fischer <rezine@mistrust.net> 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in the 00017 * documentation and/or other materials provided with the distribution. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY JANN FISCHER AND CONTRIBUTORS ``AS IS'' AND 00020 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00021 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00022 * ARE DISCLAIMED. IN NO EVENT SHALL JANN FISCHER OR THE VOICES IN HIS HEAD 00023 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00024 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00025 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00026 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00027 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00028 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 00029 * THE POSSIBILITY OF SUCH DAMAGE. 00030 */ 00031 #ifndef __MM_UTIL_H 00032 #define __MM_UTIL_H 00033 00034 #define STRIP_TRAILING(str, charset) do { \ 00035 size_t eos, i, hit; \ 00036 for (eos = strlen(str); eos > 0; eos--) { \ 00037 hit = 0; \ 00038 for (i = 0; i <= strlen(charset); i++) { \ 00039 if (str[eos] == charset[i]) {\ 00040 str[eos] = '\0'; \ 00041 hit = 1; \ 00042 break; \ 00043 } \ 00044 } \ 00045 if (!hit) \ 00046 break; \ 00047 } \ 00048 } while (0); 00049 00050 #endif /* ! __MM_UTIL_H */