MCPcopy Create free account
hub / github.com/NetHack/NetHack / port_insert_pastebuf

Function port_insert_pastebuf

sys/unix/unixmain.c:778–809  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

776extern int errno;
777
778void
779port_insert_pastebuf(char *buf)
780{
781 /* This should be replaced when there is a Cocoa port. */
782 const char *errarg;
783 size_t len;
784 FILE *PB = popen("/usr/bin/pbcopy", "w");
785
786 if (!PB) {
787 errarg = "Unable to start pbcopy";
788 goto error;
789 }
790
791 len = strlen(buf);
792 /* Remove the trailing \n, carefully. */
793 if (len > 0 && buf[len - 1] == '\n')
794 len--;
795
796 /* XXX Sorry, I'm too lazy to write a loop for output this short. */
797 if (len != fwrite(buf, 1, len, PB)) {
798 errarg = "Error sending data to pbcopy";
799 goto error;
800 }
801
802 if (pclose(PB) != -1) {
803 return;
804 }
805 errarg = "Error finishing pbcopy";
806
807 error:
808 raw_printf("%s: %s (%d)\n", errarg, strerror(errno), errno);
809}
810#endif /* __APPLE__ */
811
812unsigned long

Callers 1

early_version_infoFunction · 0.50

Calls 2

fwriteFunction · 0.85
raw_printfFunction · 0.50

Tested by

no test coverage detected