1 #define WIN32_LEAN_AND_MEAN
8 #define NORETURN __declspec (noreturn)
10 #define NORETURN __attribute__ ((noreturn))
15 static void NORETURN
winerr (int exitcode
, const char *fmt
, ...)
20 vfprintf (stderr
, fmt
, ap
);
22 fprintf (stderr
, ": winerror 0x%lx\n", GetLastError ());
33 if (!OpenClipboard (NULL
)) winerr (1, "OpenClipboard");
36 n
= fread (buf
, 1, 4096, stdin
);
38 fprintf (stderr
, "fread failed: %s\n", strerror (errno
));
43 m
= MultiByteToWideChar (
51 if (m
<= 0) winerr (4, "MultiByteToWideChar %d", m
);
53 h
= GlobalAlloc (GMEM_MOVEABLE
, (m
+1) * sizeof (*tp
));
54 if (!h
) winerr (5, "GlobalAlloc");
57 k
= MultiByteToWideChar (
65 if (k
!= m
) winerr (6, "MultiByteToWideChar %d %d", k
, m
);
68 if (!SetClipboardData (CF_UNICODETEXT
, h
)) winerr (7, "SetClipboardData");
69 if (GlobalFree (h
)) winerr (8, "GlobalFree");
70 if (!CloseClipboard ()) winerr (9, "CloseClipboard");