Rizin
unix-like reverse engineering framework and cli tools
tuklib_progname.c File Reference

Program name to be displayed in messages. More...

#include "tuklib_progname.h"
#include <string.h>

Go to the source code of this file.

Functions

void tuklib_progname_init (char **argv)
 

Variables

char * progname = NULL
 

Detailed Description

Program name to be displayed in messages.

Definition in file tuklib_progname.c.

Function Documentation

◆ tuklib_progname_init()

void tuklib_progname_init ( char **  argv)

Definition at line 23 of file tuklib_progname.c.

24 {
25 #ifdef TUKLIB_DOSLIKE
26  // On these systems, argv[0] always has the full path and .exe
27  // suffix even if the user just types the plain program name.
28  // We modify argv[0] to make it nicer to read.
29 
30  // Strip the leading path.
31  char *p = argv[0] + strlen(argv[0]);
32  while (argv[0] < p && p[-1] != '/' && p[-1] != '\\')
33  --p;
34 
35  argv[0] = p;
36 
37  // Strip the .exe suffix.
38  p = strrchr(p, '.');
39  if (p != NULL)
40  *p = '\0';
41 
42  // Make it lowercase.
43  for (p = argv[0]; *p != '\0'; ++p)
44  if (*p >= 'A' && *p <= 'Z')
45  *p = *p - 'A' + 'a';
46 #endif
47 
48  progname = argv[0];
49  return;
50 }
#define NULL
Definition: cris-opc.c:27
void * p
Definition: libc.cpp:67
static static fork const void static count static fd const char const char static newpath char char argv
Definition: sflib.h:40
char * progname

References argv, NULL, p, and progname.

Variable Documentation

◆ progname

char* progname = NULL

Definition at line 18 of file tuklib_progname.c.

Referenced by tuklib_progname_init().