LCOV - code coverage report
Current view: top level - sal/qa/osl/process - osl_process_child.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 12 16 75.0 %
Date: 2012-08-25 Functions: 4 5 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 11 20 55.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : //########################################
      31                 :            : 
      32                 :            : 
      33                 :            : #if ( defined WNT )                     // Windows
      34                 :            : #   define UNICODE
      35                 :            : #   define _UNICODE
      36                 :            : #   define WIN32_LEAN_AND_MEAN
      37                 :            : #   include <windows.h>
      38                 :            : #   include <tchar.h>
      39                 :            : #else
      40                 :            : #   include <unistd.h>
      41                 :            : #endif
      42                 :            : 
      43                 :            : #include <stdio.h>
      44                 :            : #include <stdlib.h>
      45                 :            : #include <iostream>
      46                 :            : #include <fstream>
      47                 :            : #include <string.h>
      48                 :            : 
      49                 :            : #include <rtl/ustring.hxx>
      50                 :            : 
      51                 :            : #ifdef UNX
      52                 :            : #if defined( MACOSX )
      53                 :            : # include <crt_externs.h>
      54                 :            : # define environ (*_NSGetEnviron())
      55                 :            : # else
      56                 :            :     extern char** environ;
      57                 :            : # endif
      58                 :            : #endif
      59                 :            : 
      60                 :            : //########################################
      61                 :            : 
      62                 :            : 
      63                 :            : #ifdef WNT
      64                 :            : #   define SLEEP(t) (Sleep((t)*1000))
      65                 :            : #else
      66                 :            : #   define SLEEP(t) (sleep((t)))
      67                 :            : #endif
      68                 :            : 
      69                 :            : //########################################
      70                 :          0 : void wait_for_seconds(char* time)
      71                 :            : {
      72                 :          0 :     SLEEP(atoi(time));
      73                 :          0 : }
      74                 :            : 
      75                 :            : //########################################
      76                 :            : 
      77                 :            : #ifdef WNT
      78                 :            : //########################################
      79                 :            : void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size)
      80                 :            : {
      81                 :            :     LPCWSTR strW = reinterpret_cast<LPCWSTR>(_strW);
      82                 :            :     WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, size, NULL, NULL);
      83                 :            : }
      84                 :            : //########################################
      85                 :            :     void dump_env(char* file_path)
      86                 :            :     {
      87                 :            :         LPTSTR env = reinterpret_cast<LPTSTR>(
      88                 :            :             GetEnvironmentStrings());
      89                 :            :         LPTSTR p   = env;
      90                 :            : 
      91                 :            :         std::ofstream file(file_path);
      92                 :            : 
      93                 :            :         char buffer[32767];
      94                 :            :         while (size_t l = _tcslen(reinterpret_cast<wchar_t*>(p)))
      95                 :            :         {
      96                 :            :             w_to_a(p, buffer, sizeof(buffer));
      97                 :            :             file << buffer << '\0';
      98                 :            :             p += l + 1;
      99                 :            :         }
     100                 :            :         FreeEnvironmentStrings(env);
     101                 :            :     }
     102                 :            : #else
     103                 :         10 :     void dump_env(char* file_path)
     104                 :            :     {
     105         [ +  - ]:         10 :         std::ofstream file(file_path);
     106         [ +  + ]:       6507 :         for (int i = 0; NULL != environ[i]; ++i)
     107 [ +  - ][ +  - ]:       6507 :             file << environ[i] << '\0';
                 [ +  - ]
     108                 :         10 :     }
     109                 :            : #endif
     110                 :            : 
     111                 :            : //########################################
     112                 :         10 : int main(int argc, char* argv[])
     113                 :            : {
     114         [ +  - ]:         10 :     if (argc > 2)
     115                 :            :     {
     116         [ -  + ]:         10 :         if (0 == strcmp("-join", argv[1]))
     117                 :          0 :             wait_for_seconds(argv[2]);
     118         [ +  - ]:         10 :         else if (0 == strcmp("-env", argv[1]))
     119                 :         10 :             dump_env(argv[2]);
     120                 :            :     }
     121                 :            : 
     122                 :         10 :     return 0;
     123 [ +  - ][ +  - ]:         30 : }
     124                 :            : 
     125                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10