/* gcc -O2 -Wall sp.c -o sp */ #include #include #include #include void create_sockpath (const char *sockdir, const char *filename, char (*sockpath)[UNIX_PATH_MAX]) { if (strlen (sockdir) + 1 + strlen (filename) > UNIX_PATH_MAX - 1) abort (); snprintf (*sockpath, UNIX_PATH_MAX, "%s/%s", sockdir, filename); } int main (int argc, char *argv[]) { char sockpath[UNIX_PATH_MAX]; if (argc != 3) { fprintf (stderr, "%s sockdir filename\n", argv[0]); exit (EXIT_FAILURE); } create_sockpath (argv[1], argv[2], &sockpath); printf ("sockpath = %s\n", sockpath); exit (EXIT_SUCCESS); }