Skip to content

Commit

Permalink
Add ability to get defaults from environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
dtechsrv committed Dec 13, 2023
1 parent c148bed commit b4fbba5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions vncserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ void printUsage(char *str) {
int main(int argc, char **argv) {
long usec;

// Set the default server name based on the hostname
gethostname(VNC_SERVERNAME, sizeof(VNC_SERVERNAME));

// Preset values from environment variables (However, the values specified in the arguments have priority.)
if (getenv("VNC_SERVERNAME"))
strcpy(VNC_SERVERNAME, getenv("VNC_SERVERNAME"));
if (getenv("VNC_PASSWORD"))
strcpy(VNC_PASSWORD, getenv("VNC_PASSWORD"));
if (getenv("VNC_PORT"))
VNC_PORT = atoi(getenv("VNC_PORT"));

if(argc > 1) {
int i = 1;
while(i < argc) {
Expand Down

0 comments on commit b4fbba5

Please sign in to comment.