home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Contrib / Makensisw / noclib.cpp < prev    next >
C/C++ Source or Header  |  2003-11-21  |  2KB  |  73 lines

  1. /* 
  2.   Copyright (c) 2002 Robert Rainwater
  3.   Contributors: Justin Frankel, Fritz Elfert, and Amir Szekely
  4.  
  5.   This software is provided 'as-is', without any express or implied
  6.   warranty.  In no event will the authors be held liable for any damages
  7.   arising from the use of this software.
  8.  
  9.   Permission is granted to anyone to use this software for any purpose,
  10.   including commercial applications, and to alter it and redistribute it
  11.   freely, subject to the following restrictions:
  12.  
  13.   1. The origin of this software must not be misrepresented; you must not
  14.    claim that you wrote the original software. If you use this software
  15.    in a product, an acknowledgment in the product documentation would be
  16.    appreciated but is not required.
  17.   2. Altered source versions must be plainly marked as such, and must not be
  18.    misrepresented as being the original software.
  19.   3. This notice may not be removed or altered from any source distribution.
  20.  
  21. */
  22. #include <windows.h>
  23. #include "noclib.h"
  24.  
  25. // kickik's clib methods
  26. char *my_strrchr(const char *string, int c) {
  27.   for (int i=lstrlen(string); i>=0; i--)
  28.     if (string[i]==c) return (char*)&string[i];
  29.   return 0;
  30. }
  31.  
  32. char *my_strstr(char *i, char *s) {
  33.   if (lstrlen(i)>=lstrlen(s)) while (i[lstrlen(s)-1])  {
  34.     int l=lstrlen(s)+1;
  35.     char *ii=i;
  36.     char *is=s;
  37.     while (--l>0) {
  38.       if (*ii != *is) break;
  39.       ii++;
  40.       is++;
  41.     }
  42.     if (l==0) return i;
  43.     i++;
  44.   }
  45.   return NULL;
  46. }
  47.  
  48. void *my_memset(void *dest, int c, size_t count) {
  49.   for (size_t i=0; i<count;i++) ((char*)dest)[i]=c;
  50.   return dest;
  51. }
  52.  
  53. // iceman_k's clib methods
  54. int lstrncmp(char *s1, const char *s2, int chars)
  55. {
  56.     while ((chars > 0) && (*s1) && (*s2) && (*(s1) == *(s2))) chars--, s1++, s2++;
  57.     if ((chars == 0) || (*s1 == *s2)) return 0;
  58.     return (*s1 - *s2);
  59. }
  60.  
  61. int lstrncmpi(char *s1, const char *s2, int chars)
  62. {
  63.   while (chars-- && *s1 && *s2)
  64.   {
  65.     char ss1=*s1++;
  66.     char ss2=*s2++;
  67.     if (ss1>='a' && ss1 <= 'z') ss1+='A'-'a';
  68.     if (ss2>='a' && ss2 <= 'z') ss2+='A'-'a';
  69.     if (ss1 != ss2) return ss1-ss2;
  70.   }
  71.   return 0;
  72. }
  73.