Re: On Digital Unix V4.0F

Stanley Hopcroft <[email protected]>
Newsgroups gmane.network.netsaint.user
Message-ID <[email protected]>
Dear Sir,

I am writing to thank you for your letter and apologise for posting
about what I have so littel knowledge of.

On Thu, Nov 07, 2002 at 03:57:42PM +0100, [email protected] wrote:
> Dear,
> Thank you first for your help.
> Let me be a little more specific.
> 
> The error I have got from the make is following:
> -----------------------------------------------
> netsaint.c: In function `main':
> netsaint.c:289: elements of array `long_options' have incomplete type
> netsaint.c:291: warning: excess elements in struct initializer
> netsaint.c:291: warning: (near initialization for `long_options[0]')
> netsaint.c:291: `no_argument' undeclared (first use in this function)
> -----------------------------------------------
> 
> What we have at the netsaint.c:289 is followings:
> -----------------------------------------------
> #ifdef HAVE_GETOPT_H
>         int option_index=0;
>         static struct option long_options[]=
>         {
>                 {"help",no_argument,0,'h'},
> -----------------------------------------------
> 
> Since it's so famous that, with GNU getopt, we can use long option names,
> I could imagine what's going wrong.
> In the GNU's(or POSIX's, if you'd like) getopt.h, you have:
> -----------------------------------------------
> struct option
> {
> #if defined (__STDC__) && __STDC__
>   const char *name;
> #else
>   char *name;
> #endif
>   /* has_arg can't be an enum because some compilers complain about
>      type mismatches in all the code that assumes it is an int.  */
>   int has_arg;
>   int *flag;
>   int val;
> };
> 
> /* Names for the values of the `has_arg' field of `struct option'.  */
> 
> #define no_argument             0
> -----------------------------------------------
> This has come with GNU glibc.
> 

> As everybody knows, with getopt which comes with conventional UNIX,
> no "struct option", and "no_argument" and other constants are defined.
> 
> > Wherever getop_long is called out in the nagios/netsaint code, it is
> > ifdef'd so it should only be compiled if getopt_long exists. 
> > But it does require a POSIX getopt. Is there no getopt at all in Digital
> Unix?
> 
> Yeah, it's ifdef'd but looks like enabled checking only if getopt.h ever
> exists.
> The getopt.h does exists but different one. Doesn't define things like
> "struct option".
>
 
> > You may be able to install getopt (download from GNU; 
> > ./configure; make etc)
> 
> Can I? But so far I haven't find a way to install only that separately from
> the library. Please show me if you know where I can get more information on
> this.
>

I have no information but it sounds  feasable to me, but with a painful
amount of hacking.

To summarise the problem description :

Digital Unix will not compile Netsaint 0.0.7 because it fails to have
the same struct option as the GNU getopt: The getopt.h that it has,
fails to define this structure in the same way as GNU.

The solution sounds like getting Netsaint to find and link
another getopt.h (and the appropriate library), ignoring the header and
library in the 'standard' locations.

This __may__ be possible by hacking configure/configure.in to find the
new/non system getopt.

You may have to add a section that processes this library exclusively.

Again, I think that this is not totally an unfamiliar process: the
wonderful ntop program used to jump through hoops choosing between
system and ported/packaged OpenSSL.

Maybe there is some clues on how to do this in a pre 2.1 ntop. The
plugins also have to deal with SSL so they may suggest some ways ahead.

Here is part of the plugins configure.in (older plugins) that deals with
OpenSSL.

AC_PATH_PROG(OPENSSL,openssl)
AC_MSG_WARN(found OPENSSL in $OPENSSL)
if test "$OPENSSL" = "/usr/bin/openssl"; then
  OPENSSL=/usr
elif test "$OPENSSL" = "/opt/bin/openssl"; then
  OPENSSL=/opt
elif test "$OPENSSL" = "/opt/openssl/bin/openssl"; then
  OPENSSL=/opt/openssl
elif test "$OPENSSL" = "/usr/slocal/bin/openssl"; then
  OPENSSL=/usr/slocal
elif test "$OPENSSL" = "/usr/local/bin/openssl"; then
  OPENSSL=/usr/local
elif test "$OPENSSL" = "/usr/local/ssl/bin/openssl"; then
  OPENSSL=/usr/local/ssl
fi
AC_ARG_WITH(openssl,--with-openssl=<dir> sets path to openssl
installation,[OPENSSL=$withval])

dnl Check for OpenSSL header files
FOUNDINCLUDE=yes
CPPFLAGS="-I$OPENSSL/include"
AC_CHECK_HEADERS(openssl/x509.h openssl/ssl.h openssl/rsa.h
openssl/pem.h openssl/crypto.h
openssl/err.h,SSLINCLUDE="-I$OPENSSL/include",FOUNDINCLUDE=no)
if test "$FOUNDINCLUDE" = "no"; then
  FOUNDINCLUDE=yes
  AC_CHECK_HEADERS(x509.h ssl.h rsa.h pem.h crypto.h
err.h,SSLINCLUDE="-I$OPENSSL/include",FOUNDINCLUDE=no)
fi
AC_SUBST(SSLINCLUDE)
CPPFLAGS="$_SAVEDCPPFLAGS $SSLINCLUDE"


Does this sound reasonable ?

> Thank you very much in advance.
> 

Yours sincerely.
-- 
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.


-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.