LCOV - app.info - nsprpub/pr/src/misc/pripc.c

LCOV - code coverage report
| Current view: | directory - nsprpub/pr/src/misc - pripc.c (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 15 | 0 | 0.0 %
| Date: | 2012-06-02 | Functions: | 3 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is the Netscape Portable Runtime (NSPR).
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * Netscape Communications Corporation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 1999-2000
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *
          24                 :  * Alternatively, the contents of this file may be used under the terms of
          25                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          26                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          28                 :  * of those above. If you wish to allow use of your version of this file only
          29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          30                 :  * use your version of this file under the terms of the MPL, indicate your
          31                 :  * decision by deleting the provisions above and replace them with the notice
          32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          33                 :  * the provisions above, a recipient may use your version of this file under
          34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          35                 :  *
          36                 :  * ***** END LICENSE BLOCK ***** */
          37                 :
          38                 : /*
          39                 :  * File: pripc.c
          40                 :  *
          41                 :  * Description: functions for IPC support
          42                 :  */
          43                 :
          44                 : #include "primpl.h"
          45                 :
          46                 : #include <string.h>
          47                 :
          48                 : /*
          49                 :  * A POSIX IPC name must begin with a '/'.
          50                 :  * A POSIX IPC name on Solaris cannot contain any '/' except
          51                 :  * the required leading '/'.
          52                 :  * A POSIX IPC name on HP-UX and OSF1 must be a valid pathname
          53                 :  * in the file system.
          54                 :  *
          55                 :  * The ftok() function for System V IPC requires a valid pathname
          56                 :  * in the file system.
          57                 :  *
          58                 :  * A Win32 IPC name cannot contain '\'.
          59                 :  */
          60                 :
          61               0 : static void _pr_ConvertSemName(char *result)
          62                 : {
          63                 : #ifdef _PR_HAVE_POSIX_SEMAPHORES
          64                 : #if defined(SOLARIS)
          65                 :     char *p;
          66                 :
          67                 :     /* Convert '/' to '_' except for the leading '/' */
          68                 :     for (p = result+1; *p; p++) {
          69                 :         if (*p == '/') {
          70                 :             *p = '_';
          71                 :         }
          72                 :     }
          73                 :     return;
          74                 : #else
          75                 :     return;
          76                 : #endif
          77                 : #elif defined(_PR_HAVE_SYSV_SEMAPHORES)
          78                 :     return;
          79                 : #elif defined(WIN32)
          80                 :     return;
          81                 : #endif
          82                 : }
          83                 :
          84               0 : static void _pr_ConvertShmName(char *result)
          85                 : {
          86                 : #if defined(PR_HAVE_POSIX_NAMED_SHARED_MEMORY)
          87                 : #if defined(SOLARIS)
          88                 :     char *p;
          89                 :
          90                 :     /* Convert '/' to '_' except for the leading '/' */
          91                 :     for (p = result+1; *p; p++) {
          92                 :         if (*p == '/') {
          93                 :             *p = '_';
          94                 :         }
          95                 :     }
          96                 :     return;
          97                 : #else
          98                 :     return;
          99                 : #endif
         100                 : #elif defined(PR_HAVE_SYSV_NAMED_SHARED_MEMORY)
         101                 :     return;
         102                 : #elif defined(WIN32)
         103                 :     return;
         104                 : #else
         105                 :     return;
         106                 : #endif
         107                 : }
         108                 :
         109               0 : PRStatus _PR_MakeNativeIPCName(
         110                 :     const char *name,
         111                 :     char *result,
         112                 :     PRIntn size,
         113                 :     _PRIPCType type)
         114                 : {
         115               0 :     if (strlen(name) >= (PRSize)size) {
         116               0 :         PR_SetError(PR_BUFFER_OVERFLOW_ERROR, 0);
         117               0 :         return PR_FAILURE;
         118                 :     }
         119               0 :     strcpy(result, name);
         120               0 :     switch (type) {
         121                 :         case _PRIPCSem:
         122               0 :             _pr_ConvertSemName(result);
         123               0 :             break;
         124                 :         case _PRIPCShm:
         125               0 :             _pr_ConvertShmName(result);
         126               0 :             break;
         127                 :         default:
         128               0 :             PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
         129               0 :             return PR_FAILURE;
         130                 :     }
         131               0 :     return PR_SUCCESS;
         132                 : }

Generated by: LCOV version 1.7