Initial kermit

This commit is contained in:
1024x2 2024-07-16 02:03:54 +01:00
commit 2283a9e345
5 changed files with 8032 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
vexnc
compile_commands.json

7
Makefile Normal file
View File

@ -0,0 +1,7 @@
LIBS := $(shell pkg-config --cflags --libs libvncserver) -lm -Ivendor/
vexnc: vexnc.c
$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
clean:
rm vexnc

2
README.md Normal file
View File

@ -0,0 +1,2 @@
# vexnc
Single-purpose VNC server that simply displays a static image to all clients.

7988
stb_image.h Normal file

File diff suppressed because it is too large Load Diff

33
vexnc.c Normal file
View File

@ -0,0 +1,33 @@
// gcc -O2 -march=native -o vexnc vexnc.c -lvncserver -lm
#include <rfb/rfb.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
int main(int argc, char const *argv[]) {
if (argc < 3) {
printf("usage: %s IMAGEFILE TITLE\n", argv[0]);
return 0;
}
int imx, imy, imc;
unsigned char *im = stbi_load(argv[1], &imx, &imy, &imc, 4);
if (im == NULL) {
printf("bad image: %s\n", stbi_failure_reason());
return 1;
}
rfbScreenInfoPtr rfbScreen = rfbGetScreen(NULL, NULL, imx, imy, 8, 3, 4);
rfbScreen->desktopName = argv[2] ? argv[2] : "";
rfbScreen->frameBuffer = (char*)im;
rfbScreen->alwaysShared = TRUE;
rfbInitServer(rfbScreen);
rfbRunEventLoop(rfbScreen, -1, FALSE);
stbi_image_free(im);
rfbScreenCleanup(rfbScreen);
return 0;
}