Skip to content

Commit 3b45993

Browse files
initial version
1 parent 7bc0849 commit 3b45993

5 files changed

Lines changed: 131 additions & 0 deletions

File tree

‎.gitattributes‎

Whitespace-only changes.

‎.gitignore‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
*~
3+
*.*~
4+
*.exe
5+
*.ilk
6+
*.obj
7+
*.map
8+
*.pdb
9+
*.swp
10+
*.tmp
11+
*.zip
12+

‎.vscode/settings.json‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"editor.detectIndentation": false,
3+
"editor.insertSpaces": true,
4+
"editor.tabSize": 4,
5+
"files.associations": {
6+
"format": "cpp",
7+
"istream": "cpp",
8+
"memory": "cpp",
9+
"tuple": "cpp",
10+
"type_traits": "cpp",
11+
"utility": "cpp",
12+
"xlocmes": "cpp",
13+
"xlocmon": "cpp",
14+
"xlocnum": "cpp",
15+
"xloctime": "cpp",
16+
"xutility": "cpp",
17+
},
18+
}

‎Makefile‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
!ifndef STLSOFT
3+
!error Environment variable STLSOFT is not defined
4+
!endif # STLSOFT
5+
6+
CC=cl.exe
7+
LINK=link.exe
8+
9+
CFLAGS=/EHsc /Zi /nologo /std:c++17 /Zc:__cplusplus /I "$(STLSOFT)/include"
10+
11+
LDFLAGS=/NOLOGO
12+
13+
SRCS=main.cpp
14+
15+
OBJS=$(SRCS:.cpp=.obj)
16+
17+
all: build
18+
19+
build: WriteDebugString.exe
20+
21+
WriteDebugString.exe: main.obj
22+
$(LINK) $(LDFLAGS) /OUT:$@ $(OBJS)
23+
24+
.cpp.obj:
25+
$(CC) $(CFLAGS) /c $<
26+
27+
clean:
28+
@del /Q *.obj *.exe
29+

‎main.c‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
#include <winstl/diagnostics/output_debug_line.h>
3+
#include <platformstl/filesystem/path_functions.h>
4+
5+
#include <stdio.h>
6+
#include <stdlib.h>
7+
#include <string.h>
8+
9+
int main(int argc, char* argv[])
10+
{
11+
stlsoft_C_string_slice_m_t const program_name = platformstl_C_get_executable_name_from_path(argv[0]);
12+
13+
if (1 == argc)
14+
{
15+
missing_arguments:
16+
17+
fprintf(
18+
stderr
19+
, "%.*s: missing arguments; use --help for usage\n"
20+
, (int)program_name.len, program_name.ptr
21+
);
22+
23+
return EXIT_FAILURE;
24+
}
25+
26+
if (0 == strcmp("--help", argv[1]))
27+
{
28+
fprintf(
29+
stdout
30+
, "USAGE: %.*s { --help | [ --sleep-after-writes ] <msg-1> [ ... <msg-N> ] }\n"
31+
, (int)program_name.len, program_name.ptr
32+
);
33+
34+
return EXIT_SUCCESS;
35+
}
36+
else
37+
{
38+
int n = 0;
39+
int do_sleep = 0;
40+
41+
for (int i = 1; argc != i; ++i)
42+
{
43+
char const* const arg = argv[i];
44+
45+
if (0 == strcmp("--sleep-after-writes", argv[i]))
46+
{
47+
do_sleep = 1;
48+
}
49+
else
50+
{
51+
winstl_C_diagnostics_output_debug_line_1_m(arg);
52+
53+
++n;
54+
}
55+
}
56+
57+
if (0 == n)
58+
{
59+
goto missing_arguments;
60+
}
61+
62+
printf("wrote %d message(s) to debug stream\n", n);
63+
64+
if (do_sleep)
65+
{
66+
Sleep(5000);
67+
}
68+
69+
return EXIT_SUCCESS;
70+
}
71+
}
72+

0 commit comments

Comments
 (0)