#ifdef HAVE_CONFIG_H
#include <config.h>
RCSID("$Id: setprogname.c 15955 2005-08-23 10:19:20Z lha $");
#endif
#include "roken.h"
#ifndef HAVE___PROGNAME
extern const char *__progname;
#endif
#ifndef HAVE_SETPROGNAME
void ROKEN_LIB_FUNCTION
setprogname(const char *argv0)
{
#ifndef HAVE___PROGNAME
const char *p;
if(argv0 == NULL)
return;
//从argv0的右侧查找'/'第一次出现的地方,然后将指针指向p,
//这里的功能是从假设带有'/'的可执行文件中获取可执行文件名。
p = strrchr(argv0, '/');
if(p == NULL)
p = argv0;
else
p++;
__progname = p;
#endif
}
#endif /** HAVE_SETPROGNAME */