1 #define WIN32_LEAN_AND_MEAN
7 #define NORETURN __declspec (noreturn)
9 #define NORETURN __attribute__ ((noreturn))
14 static void NORETURN
winerr (int exitcode
, const char *fmt
, ...)
19 vfprintf (stderr
, fmt
, ap
);
21 fprintf (stderr
, ": winerror 0x%lx\n", GetLastError ());
32 if (!OpenClipboard (NULL
)) winerr (1, "OpenClipboard");
35 n
= fread (buf
, 1, 4096, stdin
);
37 fprintf (stderr
, "fread failed: %s\n", strerror (errno
));
42 m
= MultiByteToWideChar (
50 if (m
<= 0) winerr (4, "MultiByteToWideChar %d", m
);
52 h
= GlobalAlloc (GMEM_MOVEABLE
, (m
+1) * sizeof (*tp
));
53 if (!h
) winerr (5, "GlobalAlloc");
56 k
= MultiByteToWideChar (
64 if (k
!= m
) winerr (6, "MultiByteToWideChar %d %d", k
, m
);
67 if (!SetClipboardData (CF_UNICODETEXT
, h
)) winerr (7, "SetClipboardData");
68 if (GlobalFree (h
)) winerr (8, "GlobalFree");
69 if (!CloseClipboard ()) winerr (9, "CloseClipboard");