Add -h to nginx

Hello,

I attach a small patch which add the -h argument to nginx. As common
programs, this arg show the available options.

[root@wp0men04s /LIBRE/nginx/nginx-0.7.44]# ./objs/nginx -h
Usage: nginx [-h] [-v] [-V] [-t] [-c filename] [-g param] [-d basedir]

Options:
-h : list available command line options (this page)
-v : show version then exit
-V : show version and configure options then exit
-c filename : set conf file (default:
/usr/local/nginx/conf/nginx.conf)
-g param : set conf directive out of conf file

nginx version: nginx/0.7.44

Don’t know if you’re interested in such a patch. But the first time I
tried nginx I was kind of lost on where to find available options.

And I ask myself a question, why use those lines:
p = "nginx version: " NGINX_VER CRLF;
n = sizeof("nginx version: " NGINX_VER CRLF) - 1;

    if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) {
        return 1;
    }

instead of

    p = "nginx version: " NGINX_VER CRLF;

    if (ngx_write_fd(ngx_stderr_fileno, p, strlen(p)) != n) {
        return 1;
    }

Thanks
++ Jerome

Le 24 mars 2009 14:15, Jérôme Loyet [email protected] a écrit :

    -v      : show version then exit
    p = "nginx version: " NGINX_VER CRLF;
    if (ngx_write_fd(ngx_stderr_fileno, p, strlen(p)) != n) {
      return 1;
    }

Sorry I sent the wrong version of the patch. The right version is
attached.
And in my previous question I meant:

instead of

    p = "nginx version: " NGINX_VER CRLF;
    n = strlen(p);

    if (ngx_write_fd(ngx_stderr_fileno, p, n) != n) {
        return 1;
    }

Shouldn’t -t and -d options also be explained?

On Tue, Mar 24, 2009 at 02:15:29PM +0100, J?r?me Loyet wrote:

    p = "nginx version: " NGINX_VER CRLF;

    if (ngx_write_fd(ngx_stderr_fileno, p, strlen(p)) != n) {
        return 1;
    }

Because strlen() finds a string length on run-time, scanning for
trailing
zero, while sizeof() return length of a known string on compile time.
For this reason I use strlen() only if it’s really needed.

However, here are two notes:

  1. modern compilers usually optimize such strlen()s to just sizeof()s,
  2. this place is not time critical, so strlen() can be used.

On Tue, Mar 24, 2009 at 04:11:50PM +0100, J?r?me Loyet wrote:

I’ve attached a new revision of the patch
Thank you.

Are any corrections regarding English part of the message:

-? : this help
-h : this help
-v : show version then exit
-V : show version and configure options then exit
-t : test configuration and exit
-c filename : set configuration file (default: …)
-g directives : set global configuration directives out of conf file

?

My mistake about the forgotten “-t” explanation.

but as far as I read the last sources well (0.7.44) there is no -d
options.

./objs/nginx -d

2009/03/24 16:11:01 [emerg] 16808#0: invalid option: “-d”

./objs/nginx -v

nginx version: nginx/0.7.44

I’ve attached a new revision of the patch

++ Jerome

2009/3/24 Juan Fco. Giordana [email protected]: