LCOV - code coverage report
Current view: top level - sal/qa/osl/process - osl_process_child.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 11 15 73.3 %
Date: 2015-06-13 12:38:46 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #if ( defined WNT )                     // Windows
      21             : #   define UNICODE
      22             : #   define _UNICODE
      23             : #   define WIN32_LEAN_AND_MEAN
      24             : #   include <windows.h>
      25             : #   include <tchar.h>
      26             : #else
      27             : #   include <unistd.h>
      28             : #endif
      29             : 
      30             : #include <stdio.h>
      31             : #include <stdlib.h>
      32             : #include <fstream>
      33             : #include <string.h>
      34             : 
      35             : 
      36             : #ifdef UNX
      37             : #if defined( MACOSX )
      38             : # include <crt_externs.h>
      39             : # define environ (*_NSGetEnviron())
      40             : # else
      41             :     extern char** environ;
      42             : # endif
      43             : #endif
      44             : 
      45             : #ifdef WNT
      46             : #   define SLEEP(t) (Sleep((t)*1000))
      47             : #else
      48             : #   define SLEEP(t) (sleep((t)))
      49             : #endif
      50             : 
      51           0 : void wait_for_seconds(char* time)
      52             : {
      53           0 :     SLEEP(atoi(time));
      54           0 : }
      55             : 
      56             : #ifdef WNT
      57             : 
      58             : void w_to_a(LPCTSTR _strW, LPSTR strA, DWORD size)
      59             : {
      60             :     LPCWSTR strW = reinterpret_cast<LPCWSTR>(_strW);
      61             :     WideCharToMultiByte(CP_ACP, 0, strW, -1, strA, size, NULL, NULL);
      62             : }
      63             : 
      64             :     void dump_env(char* file_path)
      65             :     {
      66             :         LPTSTR env = reinterpret_cast<LPTSTR>(
      67             :             GetEnvironmentStrings());
      68             :         LPTSTR p   = env;
      69             : 
      70             :         std::ofstream file(file_path);
      71             : 
      72             :         char buffer[32767];
      73             :         while (size_t l = _tcslen(reinterpret_cast<wchar_t*>(p)))
      74             :         {
      75             :             w_to_a(p, buffer, sizeof(buffer));
      76             :             file << buffer << '\0';
      77             :             p += l + 1;
      78             :         }
      79             :         FreeEnvironmentStrings(env);
      80             :     }
      81             : #else
      82           2 :     void dump_env(char* file_path)
      83             :     {
      84           2 :         std::ofstream file(file_path);
      85        1727 :         for (int i = 0; NULL != environ[i]; ++i)
      86        1727 :             file << environ[i] << '\0';
      87           2 :     }
      88             : #endif
      89             : 
      90           2 : int main(int argc, char* argv[])
      91             : {
      92           2 :     if (argc > 2)
      93             :     {
      94           2 :         if (0 == strcmp("-join", argv[1]))
      95             :         {
      96             :             // coverity[tainted_data] - this is a build-time only test tool
      97           0 :             wait_for_seconds(argv[2]);
      98             :         }
      99           2 :         else if (0 == strcmp("-env", argv[1]))
     100           2 :             dump_env(argv[2]);
     101             :     }
     102             : 
     103           2 :     return 0;
     104             : }
     105             : 
     106             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11