summaryrefslogtreecommitdiffstats
path: root/private/os2/client/os2test.c
blob: 690e9273b786e3e071023700234328c7bcdb0d93 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*++

Copyright (c) 1989  Microsoft Corporation

Module Name:

    os2test.c

Abstract:

    This is a test OS/2 application

Author:

    Steve Wood (stevewo) 22-Aug-1989

Environment:

    User Mode Only

Revision History:

--*/

#define OS2_API32
#define INCL_OS2V20_ERRORS
#define INCL_OS2V20_MEMORY
#define INCL_OS2V20_TASKING
#include <os2.h>

VOID
CloneTest( PPID ChildPid );

BOOLEAN
IsClonedTest( VOID );

VOID
CloneTest(
    PPID ChildPid
    )
{
    PPIB Pib;
    PNT_TIB NtTib;
    APIRET rc;
    PCH src, Variables, ImageFileName, CommandLine;
    CHAR ErrorBuffer[ 32 ];
    RESULTCODES ResultCodes;

    rc = DosGetThreadInfo( &NtTib, &Pib );
    if (rc != NO_ERROR) {
        DbgPrint( "*** DosGetThreadInfo failed - rc == %ld\n", rc );
        return;
        }

    src = Pib->Environment;
    Variables = src;
    while (*src) {
        while (*src) {
            src++;
            }
        src++;
        }
    src++;
    ImageFileName = src;
    CommandLine = "CLONETEST\000";
    rc = DosExecPgm( ErrorBuffer,
                     sizeof( ErrorBuffer ),
                     ChildPid == NULL ? EXEC_SYNC : EXEC_ASYNC,
                     CommandLine,
                     Variables,
                     &ResultCodes,
                     ImageFileName
                   );
    if (rc != NO_ERROR) {
        DbgPrint( "*** DosExecPgm( %s, %s failed  - rc == %ld\n",
                  ImageFileName, CommandLine, rc
                );
        }
    else {
        if (ChildPid != NULL) {
            *ChildPid = (PID)ResultCodes.ExitReason;
            }
        }
}


BOOLEAN
IsClonedTest( VOID )
{
    PPIB Pib;
    PNT_TIB NtTib;
    APIRET rc;

    rc = DosGetThreadInfo( &NtTib, &Pib );
    if (rc != NO_ERROR) {
        DbgPrint( "*** DosGetThreadInfo failed - rc == %ld\n", rc );
        return( FALSE );
        }

    if (!strcmp( Pib->CommandLine, "CLONETEST" )) {
        return( TRUE );
        }
    else {
        return( FALSE );
        }
}


int
main(
    int argc,
    char *argv[],
    char *envp[]
    )
{
    return( 0 );
}