Skip to content

Commit

Permalink
Error message if NCP environment variable isn't set.
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbrinkhoff committed Jan 29, 2025
1 parent e3651bc commit 48e0b52
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/discard.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ int main (int argc, char **argv)
fprintf (stderr, "NCP initialization error: %s.\n", strerror (errno));
if (errno == ECONNREFUSED)
fprintf (stderr, "Is the NCP server started?\n");
else if (errno == EFAULT)
fprintf (stderr, "Is the NCP environment variable set?\n");
exit (1);
}

Expand Down
2 changes: 2 additions & 0 deletions apps/echo.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ int main (int argc, char **argv)
fprintf (stderr, "NCP initialization error: %s.\n", strerror (errno));
if (errno == ECONNREFUSED)
fprintf (stderr, "Is the NCP server started?\n");
else if (errno == EFAULT)
fprintf (stderr, "Is the NCP environment variable set?\n");
exit (1);
}

Expand Down
2 changes: 2 additions & 0 deletions apps/finger.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ int main (int argc, char **argv)
fprintf (stderr, "NCP initialization error: %s.\n", strerror (errno));
if (errno == ECONNREFUSED)
fprintf (stderr, "Is the NCP server started?\n");
else if (errno == EFAULT)
fprintf (stderr, "Is the NCP environment variable set?\n");
exit (1);
}

Expand Down
2 changes: 2 additions & 0 deletions apps/finser.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ int main (int argc, char **argv)
fprintf (stderr, "NCP initialization error: %s.\n", strerror (errno));
if (errno == ECONNREFUSED)
fprintf (stderr, "Is the NCP server started?\n");
else if (errno == EFAULT)
fprintf (stderr, "Is the NCP environment variable set?\n");
exit (1);
}

Expand Down
2 changes: 2 additions & 0 deletions apps/gateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ int main (int argc, char **argv)
fprintf (stderr, "NCP initialization error: %s.\n", strerror (errno));
if (errno == ECONNREFUSED)
fprintf (stderr, "Is the NCP server started?\n");
else if (errno == EFAULT)
fprintf (stderr, "Is the NCP environment variable set?\n");
exit (1);
}

Expand Down
2 changes: 2 additions & 0 deletions apps/ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ int main (int argc, char **argv)
fprintf (stderr, "NCP initialization error: %s.\n", strerror (errno));
if (errno == ECONNREFUSED)
fprintf (stderr, "Is the NCP server started?\n");
else if (errno == EFAULT)
fprintf (stderr, "Is the NCP environment variable set?\n");
exit (1);
}

Expand Down
2 changes: 2 additions & 0 deletions apps/telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ int main (int argc, char **argv)
fprintf (stderr, "NCP initialization error: %s.\n", strerror (errno));
if (errno == ECONNREFUSED)
fprintf (stderr, "Is the NCP server started?\n");
else if (errno == EFAULT)
fprintf (stderr, "Is the NCP environment variable set?\n");
exit (1);
}

Expand Down
4 changes: 4 additions & 0 deletions src/libncp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
Expand Down Expand Up @@ -52,6 +53,9 @@ int ncp_init (const char *path)
server.sun_family = AF_UNIX;
if (path == NULL)
path = getenv ("NCP");
errno = EFAULT;
if (path == NULL)
return -1;
strncpy (server.sun_path, path, sizeof server.sun_path - 1);
if (connect (fd, (struct sockaddr *) &server, sizeof server) == -1)
return -1;
Expand Down

0 comments on commit 48e0b52

Please sign in to comment.