Flowgrind
Advanced TCP traffic generator
fg_progname.c File Reference

Program name management. More...

#include "config.h"
#include <string.h>
#include "fg_progname.h"
#include "fg_error.h"

Go to the source code of this file.

Functions

void set_progname (const char *argv0)
 Set global variable 'progname', based on argv[0]. More...
 

Variables

const char * progname = NULL
 String containing name the program is called with. More...
 

Detailed Description

Program name management.

Definition in file fg_progname.c.

Function Documentation

◆ set_progname()

void set_progname ( const char *  argv0)

Set global variable 'progname', based on argv[0].

Parameters
[in]argv0the name by which the program was called (argv[0])

Definition at line 37 of file fg_progname.c.

38 {
39  /* Sanity check. POSIX requires the invoking process to pass a non-NULL
40  * argv[0] */
41  if (argv0 == NULL)
42  errx("a NULL argv[0] was passed through an exec system call");
43 
44  /* Strip path */
45  const char *slash = strrchr(argv0, '/');
46  const char *base = (slash != NULL ? slash + 1 : argv0);
47  progname = base;
48 }

Variable Documentation

◆ progname

const char* progname = NULL

String containing name the program is called with.

Definition at line 35 of file fg_progname.c.

errx
#define errx(...)
To report an error w/o a system error message.
Definition: fg_error.h:47
progname
const char * progname
String containing name the program is called with.
Definition: fg_progname.c:35