1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5/*
6
7 *
8 * Example of minimal program running under PAL.
9 *
10 * Run it using:
11 * export PAL_DBG_CHANNELS="+all.all"
12 * ./example1
13 *
14 * With the PAL_DEBUG_CHANNELS environment variable set as above you
15 * should see a trace output when the program runs.
16 *
17 * Build notes :
18 * Since the PAL uses pthreads, some options must be passed to gcc to tell it
19 * to link against thread-safe versions of the standard libraries.
20 * On FreeBSD, use gcc -pthread
21 *
22 */
23
24#include <pal.h>
25extern void *dlopen(const char *file, int mode);
26
27int main(int argc, char *argv[])
28{
29 WCHAR src[4] = {'f', 'o', 'o', '\0'};
30 WCHAR dest[4] = {'b', 'a', 'r', '\0'};
31 WCHAR dir[5] = {'/', 't', 'm', 'p', '\0'};
32 HANDLE h;
33 unsigned int b;
34
35 PAL_Initialize(argc, (const char**)argv);
36 SetCurrentDirectoryW(dir);
37 SetCurrentDirectoryW(dir);
38 h = CreateFileW(src, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL);
39 WriteFile(h, "Testing\n", 8, &b, FALSE);
40 CloseHandle(h);
41 CopyFileW(src, dest, FALSE);
42 DeleteFileW(src);
43 PAL_Terminate();
44 return 0;
45}
46
47