1 /* 2 Copyright (C) 2005 Michael Hanselmann 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 8 9 $Id: case.c,v 1.2 2005/04/30 23:09:19 michael Exp $ 10 */ 11 12 #include <stdlib.h> 13 #include <ctype.h> 14 #include "pmt.h" 15 PMT_MODULE_INIT(tolower)16PMT_MODULE_INIT(tolower) { 17 return 1; 18 } 19 PMT_MODULE_INIT(toupper)20PMT_MODULE_INIT(toupper) { 21 return 1; 22 } 23 24 #define CASE_IMPL(func) \ 25 for(int i = 0; i < len; ++i) { \ 26 if(isalpha(buf[i])) { \ 27 buf[i] = func(buf[i]); \ 28 } \ 29 } 30 PMT_MODULE_IMPL(tolower)31PMT_MODULE_IMPL(tolower) { 32 CASE_IMPL(tolower); 33 } 34 PMT_MODULE_IMPL(toupper)35PMT_MODULE_IMPL(toupper) { 36 CASE_IMPL(toupper); 37 } 38 PMT_MODULE_END(tolower)39PMT_MODULE_END(tolower) { } PMT_MODULE_END(toupper)40PMT_MODULE_END(toupper) { } 41