Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 12 Aug 2012 02:47:16 +0800
From: orc <orc@...server.ru>
To: musl@...ts.openwall.com
Subject: Re: Priorities for next release?

On Sat, 11 Aug 2012 20:41:57 +0200
Daniel Cegiełka <daniel.cegielka@...il.com> wrote:

> >> Couldn't this code just be fixed to add an argument to usage() and
> >> call usage(argv[0]) or even usage(basename(argv[0])) if preferred?
> >>
> >> Rich
> >
> > Or even progname = basename(argv[0]) with global char *progname ?
> 
> Usually it looks like this:
> 
> extern char *__progname;
> 
> 'extern' means __progname must be available to external objects, so in
> code with main():
> 
> #include <stdio.h>
> 
> char *__progname;
> 
> int main(int argc, char *argv[])
> {
>         __progname = argv[0];
>         printf("%s\n", __progname);
>         return 0;
> }
> 
> what you think? It works for me... so why basename(argv[0])?
> 
> Daniel

basename() is for stripping path objects, for example, when you run
prog via full path, /bin/true, basename("/bin/true") = "true"

See man 3 basename

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.