Imported Upstream version 2.9.0
[debian/cc1111] / device / lib / pic16 / libc / string / memchrpgm.c
1 /*-------------------------------------------------------------------------
2    memchrpgm.c - part of string library functions
3
4    Written by Vangelis Rokas 2004 <vrokas AT otenet.gr>
5
6    Based on source
7         Written By -  Sandeep Dutta . sandeep.dutta@usa.net (1999)
8
9    This library is free software; you can redistribute it and/or modify it
10    under the terms of the GNU Library General Public License as published by the
11    Free Software Foundation; either version 2, or (at your option) any
12    later version.
13
14    This library is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU Library General Public License for more details.
18
19    You should have received a copy of the GNU Library General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23    In other words, you are welcome to use, share and improve this program.
24    You are forbidden to forbid anyone else to use, share and improve
25    what you give them.   Help stamp out software-hoarding!
26 -------------------------------------------------------------------------*/
27
28 #include <string.h>
29
30 __code void *memchrpgm(__code void *s, char c, size_t count)
31 {
32   if(!count)return (void *)0x00;
33         
34   while((*(__code char *)s != c) && (count)) {
35     s = (__code char *)s + sizeof(__code char *);
36     count--;
37   }
38
39   if(count)return s;
40   else return (void *)0x00;
41 }