LCOV - code coverage report
Current view: directory - xpcom/glue - nsCRTGlue.h (source / functions) Found Hit Coverage
Test: app.info Lines: 4 2 50.0 %
Date: 2012-06-02 Functions: 2 1 50.0 %

       1                 : /* ***** BEGIN LICENSE BLOCK *****
       2                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       3                 :  *
       4                 :  * The contents of this file are subject to the Mozilla Public License Version
       5                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       6                 :  * the License. You may obtain a copy of the License at
       7                 :  * http://www.mozilla.org/MPL/
       8                 :  *
       9                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      10                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      11                 :  * for the specific language governing rights and limitations under the
      12                 :  * License.
      13                 :  *
      14                 :  * The Original Code is Mozilla XPCOM Glue.
      15                 :  *
      16                 :  * The Initial Developer of the Original Code is
      17                 :  * the Mozilla Foundation <http://www.mozilla.org/>.
      18                 :  *
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2005
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Benjamin Smedberg <benjamin@smedbergs.us>
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef nsCRTGlue_h__
      40                 : #define nsCRTGlue_h__
      41                 : 
      42                 : #include "nscore.h"
      43                 : 
      44                 : /**
      45                 :  * Scan a string for the first character that is *not* in a set of
      46                 :  * delimiters.  If the string is only delimiter characters, the end of the
      47                 :  * string is returned.
      48                 :  *
      49                 :  * @param delims The set of delimiters (null-terminated)
      50                 :  * @param str    The string to search (null-terminated)
      51                 :  */
      52                 : NS_COM_GLUE const char*
      53                 : NS_strspnp(const char *delims, const char *str);
      54                 : 
      55                 : /**
      56                 :  * Tokenize a string. This function is similar to the strtok function in the
      57                 :  * C standard library, but it does not use static variables to maintain state
      58                 :  * and is therefore thread and reentrancy-safe.
      59                 :  *
      60                 :  * Any leading delimiters in str are skipped. Then the string is scanned
      61                 :  * until an additional delimiter or end-of-string is found. The final
      62                 :  * delimiter is set to '\0'.
      63                 :  *
      64                 :  * @param delims The set of delimiters.
      65                 :  * @param str    The string to search. This is an in-out parameter; it is
      66                 :  *               reset to the end of the found token + 1, or to the
      67                 :  *               end-of-string if there are no more tokens.
      68                 :  * @return       The token. If no token is found (the string is only
      69                 :  *               delimiter characters), NULL is returned.
      70                 :  */
      71                 : NS_COM_GLUE char*
      72                 : NS_strtok(const char *delims, char **str);
      73                 : 
      74                 : /**
      75                 :  * "strlen" for PRUnichar strings
      76                 :  */
      77                 : NS_COM_GLUE PRUint32
      78                 : NS_strlen(const PRUnichar *aString);
      79                 : 
      80                 : /**
      81                 :  * "strcmp" for PRUnichar strings
      82                 :  */
      83                 : NS_COM_GLUE int
      84                 : NS_strcmp(const PRUnichar *a, const PRUnichar *b);
      85                 : 
      86                 : /**
      87                 :  * "strdup" for PRUnichar strings, uses the NS_Alloc allocator.
      88                 :  */
      89                 : NS_COM_GLUE PRUnichar*
      90                 : NS_strdup(const PRUnichar *aString);
      91                 : 
      92                 : /**
      93                 :  * "strdup", but using the NS_Alloc allocator.
      94                 :  */
      95                 : NS_COM_GLUE char*
      96                 : NS_strdup(const char *aString);
      97                 : 
      98                 : /**
      99                 :  * strndup for PRUnichar strings... this function will ensure that the
     100                 :  * new string is null-terminated. Uses the NS_Alloc allocator.
     101                 :  */
     102                 : NS_COM_GLUE PRUnichar*
     103                 : NS_strndup(const PRUnichar *aString, PRUint32 aLen);
     104                 : 
     105                 : // The following case-conversion methods only deal in the ascii repertoire
     106                 : // A-Z and a-z
     107                 : 
     108                 : // semi-private data declarations... don't use these directly.
     109                 : class NS_COM_GLUE nsLowerUpperUtils {
     110                 : public:
     111                 :   static const unsigned char kLower2Upper[256];
     112                 :   static const unsigned char kUpper2Lower[256];
     113                 : };
     114                 : 
     115               0 : inline char NS_ToUpper(char aChar)
     116                 : {
     117               0 :   return (char)nsLowerUpperUtils::kLower2Upper[(unsigned char)aChar];
     118                 : }
     119                 : 
     120             230 : inline char NS_ToLower(char aChar)
     121                 : {
     122             230 :   return (char)nsLowerUpperUtils::kUpper2Lower[(unsigned char)aChar];
     123                 : }
     124                 :   
     125                 : NS_COM_GLUE bool NS_IsUpper(char aChar);
     126                 : NS_COM_GLUE bool NS_IsLower(char aChar);
     127                 : 
     128                 : NS_COM_GLUE bool NS_IsAscii(PRUnichar aChar);
     129                 : NS_COM_GLUE bool NS_IsAscii(const PRUnichar* aString);
     130                 : NS_COM_GLUE bool NS_IsAsciiAlpha(PRUnichar aChar);
     131                 : NS_COM_GLUE bool NS_IsAsciiDigit(PRUnichar aChar);
     132                 : NS_COM_GLUE bool NS_IsAsciiWhitespace(PRUnichar aChar);
     133                 : NS_COM_GLUE bool NS_IsAscii(const char* aString);
     134                 : NS_COM_GLUE bool NS_IsAscii(const char* aString, PRUint32 aLength);
     135                 : 
     136                 : #define FF '\f'
     137                 : #define TAB '\t'
     138                 : 
     139                 : #define CRSTR "\015"
     140                 : #define LFSTR "\012"
     141                 : #define CRLF "\015\012"     /* A CR LF equivalent string */
     142                 : 
     143                 : #if defined(XP_MACOSX)
     144                 :   #define FILE_PATH_SEPARATOR        "/"
     145                 :   #define OS_FILE_ILLEGAL_CHARACTERS ":"
     146                 : #elif defined(XP_WIN) || defined(XP_OS2)
     147                 :   #define FILE_PATH_SEPARATOR        "\\"
     148                 :   #define OS_FILE_ILLEGAL_CHARACTERS "/:*?\"<>|"
     149                 : #elif defined(XP_UNIX)
     150                 :   #define FILE_PATH_SEPARATOR        "/"
     151                 :   #define OS_FILE_ILLEGAL_CHARACTERS ""
     152                 : #else
     153                 :   #error need_to_define_your_file_path_separator_and_illegal_characters
     154                 : #endif
     155                 : 
     156                 : // Not all these control characters are illegal in all OSs, but we don't really
     157                 : // want them appearing in filenames
     158                 : #define CONTROL_CHARACTERS     "\001\002\003\004\005\006\007" \
     159                 :                            "\010\011\012\013\014\015\016\017" \
     160                 :                            "\020\021\022\023\024\025\026\027" \
     161                 :                            "\030\031\032\033\034\035\036\037"
     162                 : 
     163                 : #define FILE_ILLEGAL_CHARACTERS CONTROL_CHARACTERS OS_FILE_ILLEGAL_CHARACTERS
     164                 : 
     165                 : #endif // nsCRTGlue_h__

Generated by: LCOV version 1.7