David d'Angers wrote:
hi group
the following lines are taken from basename.c of the linux coreutil
group of programs
i don't understand the meaning of several of the functions:
initialize_main (&argc, &argv); why initialize main ?
This functions apparently performs some operations on main's arguments.
It is very probably checking and parsing the program's invocation
arguments, i.e. command-line parameters.
atexit (close_stdout); when do we need to do a close stdout ?
No idea. atexit() registers a function to be called upon normal
termination. Presumably the close_stdout() function closes open streams
and does some clean-up. Refer to it's source for more information.
All open streams are automatically closed upon normal program
termination, but still, it is better form to explicitly close them
yourself, if only to detect and report on errors.
setlocale (LC_ALL, ""); why do we care about locale ?
Just because you don't care about locale doesn't mean that a widely used
piece of software like basename can be so cavalier. This particular
call sets the entire locale to values based on implementation specific
environment variables.
bindtextdomain (PACKAGE, LOCALEDIR); ??
man bindtextdomain
textdomain (PACKAGE); ??
man textdomain
btw: the coreutils are application level programs yet it seems to have
many elements only found in system level programs (a total newbie's
comment), and i find it quite hard to read and learn
They are arguably system level programs. There is no sharp demarcation
between application level and system level programs. Programs vary from
end-user applications to system utilities, (like coreutils), and
libraries, to the OS kernel proper and perhaps even lower level code.
Also the precise meaning of these terms depend on the architecture and
operating system in use.
<snipped incomplete code>