Flowgrind
Advanced TCP traffic generator
fg_progname.c
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2014 Alexander Zimmermann <alexander.zimmermann@netapp.com
8  *
9  * This file is part of Flowgrind.
10  *
11  * Flowgrind is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * Flowgrind is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with Flowgrind. If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif /* HAVE_CONFIG_H */
29 
30 #include <string.h>
31 
32 #include "fg_progname.h"
33 #include "fg_error.h"
34 
35 const char *progname = NULL;
36 
37 void set_progname(const char *argv0)
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 }
void set_progname(const char *argv0)
Set global variable &#39;progname&#39;, based on argv[0].
Definition: fg_progname.c:37
Program name management.
#define errx(...)
To report an error w/o a system error message.
Definition: fg_error.h:47
Error-reporting routines used by Flowgrind.
const char * progname
String containing name the program is called with.
Definition: fg_progname.c:35