Back to index

lightning-sunbird  0.9+nobinonly
mbstring.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org code, released
00017  * Jan 28, 2003.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 2003
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   Garrett Arch Blythe, 28-January-2003
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either the GNU General Public License Version 2 or later (the "GPL"), or
00029  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #include "mozce_internal.h"
00042 
00043 extern "C" {
00044 #if 0
00045 }
00046 #endif
00047 
00048 /*
00049 **  One day, these multi-byte routines will need to really do thier job.
00050 **
00051 **  Right now, bail with a default implementation.
00052 */
00053 
00054 #define LOG_CALLS
00055 
00056 MOZCE_SHUNT_API unsigned char* mozce_mbsinc(const unsigned char* inCurrent)
00057 {
00058     MOZCE_PRECHECK
00059 
00060 #ifdef LOG_CALLS
00061 #ifdef DEBUG
00062     mozce_printf("mozce_mbsinc called\n");
00063 #endif
00064 #endif
00065     //IsDBCSLeadByte(path[len-1])
00066     return (unsigned char*)(inCurrent + 1);
00067 }
00068 
00069 
00070 MOZCE_SHUNT_API unsigned char* mozce_mbspbrk(const unsigned char* inString, const unsigned char* inStrCharSet)
00071 {
00072     MOZCE_PRECHECK
00073 
00074 #ifdef LOG_CALLS
00075 #ifdef DEBUG
00076     mozce_printf("mozce_mbspbrk called\n");
00077 #endif
00078 #endif
00079 
00080     LPWSTR wstring = a2w_malloc((const char *)inString, -1, NULL);
00081     LPWSTR wset    = a2w_malloc((const char *)inStrCharSet, -1, NULL);
00082     LPWSTR result  = wcspbrk(wstring, wset);
00083     free(wstring);
00084     free(wset);
00085     return (unsigned char *)result;
00086 }
00087 
00088 
00089 MOZCE_SHUNT_API unsigned char* mozce_mbsrchr(const unsigned char* inString, unsigned int inC)
00090 {
00091     MOZCE_PRECHECK
00092 
00093 #ifdef LOG_CALLS
00094 #ifdef DEBUG
00095     mozce_printf("mozce_mbsrchr called\n");
00096 #endif
00097 #endif
00098 
00099     return (unsigned char*) strrchr((char*)inString, inC);
00100 }
00101 
00102 
00103 MOZCE_SHUNT_API unsigned char* mozce_mbschr(const unsigned char* inString, unsigned int inC)
00104 {
00105     MOZCE_PRECHECK
00106 
00107 #ifdef LOG_CALLS
00108 #ifdef DEBUG
00109     mozce_printf("mozce_mbschr called\n");
00110 #endif
00111 #endif
00112     return (unsigned char*)strchr((const char*)inString, (int)inC);
00113 }
00114 
00115 
00116 MOZCE_SHUNT_API int mozce_mbsicmp(const unsigned char *string1, const unsigned char *string2)
00117 {
00118     MOZCE_PRECHECK
00119 
00120 #ifdef LOG_CALLS
00121 #ifdef DEBUG
00122     mozce_printf("mozce_mbsicmp called\n");
00123 #endif
00124 #endif
00125     return _stricmp((const char*)string1, (const char*)string2);
00126 }
00127 
00128 MOZCE_SHUNT_API unsigned char* mozce_mbsdec(const unsigned char *string1, const unsigned char *string2)
00129 {
00130     MOZCE_PRECHECK
00131 
00132 #ifdef LOG_CALLS
00133 #ifdef DEBUG
00134     mozce_printf("mozce_mbsdec called\n");
00135 #endif
00136 #endif
00137     
00138     if (string1 == string2)
00139         return 0;
00140     
00141     return (unsigned char *)string2 - 1;
00142 }
00143 
00144 #if 0
00145 {
00146 #endif
00147 } /* extern "C" */
00148