This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NyLPC_cStr.c Source File

NyLPC_cStr.c

00001 /*********************************************************************************
00002  * PROJECT: MiMic
00003  * --------------------------------------------------------------------------------
00004  *
00005  * This file is part of MiMic
00006  * Copyright (C)2011 Ryo Iizuka
00007  *
00008  * MiMic is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published
00010  * by the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  * For further information please contact.
00022  *  http://nyatla.jp/
00023  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
00024  *
00025  *********************************************************************************/
00026 #include "NyLPC_cStr.h"
00027 #include <ctype.h>
00028 
00029 void NyLPC_cStr_initialize(NyLPC_TcStr_t* i_inst,void* i_buf,int sizeof_buf)
00030 {
00031     i_inst->s=(NyLPC_TInt16)(sizeof_buf-1);
00032     i_inst->l=0;
00033     i_inst->buf=i_buf;
00034     *((NyLPC_TChar*)(i_inst->buf))=0;
00035 }
00036 
00037 NyLPC_TBool NyLPC_cStr_put(NyLPC_TcStr_t* i_inst,NyLPC_TChar i_c)
00038 {
00039     NyLPC_TChar* p=(NyLPC_TChar*)(i_inst->buf)+i_inst->l;
00040     if(i_inst->s-i_inst->l>0){
00041         *p=i_c;
00042         i_inst->l++;
00043         *(++p)=0;
00044         return NyLPC_TBool_TRUE;
00045     }
00046     return NyLPC_TBool_FALSE;
00047 }
00048 
00049 void NyLPC_cStr_toUpper(NyLPC_TcStr_t* i_inst)
00050 {
00051     NyLPC_TChar* p;
00052     for(p=NyLPC_cStr_str(i_inst);*p!=0;p++){
00053         *p=(NyLPC_TChar)toupper((int)*p);
00054     }
00055     return;
00056 }