archiecobbs/logwarn

Possible to compile on Solaris

GoogleCodeExporter opened this issue · 7 comments

I've used this utility before on linux and it works very well.  I am trying to 
get it to compile on solaris 10, and running into a lot of errors.  Are there 
any plans to port it to solaris?


Original issue reported on code.google.com by pldvo...@gmail.com on 16 Nov 2011 at 6:11

Original comment by archie.c...@gmail.com on 16 Nov 2011 at 7:36

  • Changed state: Feedback
I discovered a large part of the issue was that I needed gcc4 to get rid of 
most of those errors.  After getting that running, the errors that I have run 
into are around the inclusion of err.h (which doesn't exist on Solaris) and the 
err, errx, warn, warnx functions.  I initially tried to use the libnbcompat 
package from netbsd, but still had issues.  I was able to hack through some of 
the issues and remove the references to err.h by adding the following code:


static const char *__getprogname() {
        return
                getexecname()
        ;
}
void
err(int eval, const char *fmt, ...)
{
        va_list ap;
        int     sverrno;

        sverrno = errno;
        (void)fprintf(stderr, "%s: ", __getprogname());
        va_start(ap, fmt);
        if (fmt != NULL) {
                (void)vfprintf(stderr, fmt, ap);
                (void)fprintf(stderr, ": ");
        }
        va_end(ap);
        (void)fprintf(stderr, "%s\n", strerror(sverrno));
        exit(eval);
}

void
errx(int eval, const char *fmt, ...)
{
        va_list ap;

        (void)fprintf(stderr, "%s: ", __getprogname());
        va_start(ap, fmt);
        if (fmt != NULL)
                (void)vfprintf(stderr, fmt, ap);
        va_end(ap);
        (void)fprintf(stderr, "\n");
        exit(eval);
}

void
warn(const char *fmt, ...)
{
        va_list ap;
        int     sverrno;

        sverrno = errno;
        (void)fprintf(stderr, "%s: ", __getprogname());
        va_start(ap, fmt);
        if (fmt != NULL) {
                (void)vfprintf(stderr, fmt, ap);
                (void)fprintf(stderr, ": ");
        }
        va_end(ap);
        (void)fprintf(stderr, "%s\n", strerror(sverrno));
}

void
warnx(const char *fmt, ...)
{
        va_list ap;

        (void)fprintf(stderr, "%s: ", __getprogname());
        va_start(ap, fmt);
        if (fmt != NULL)
                (void)vfprintf(stderr, fmt, ap);
        va_end(ap);
        (void)fprintf(stderr, "\n");
}


I am by no means a developer, I appreciate your quick response, you may know of 
a better way to do this than what I threw together.


Original comment by pldvo...@gmail.com on 17 Nov 2011 at 4:32

Adding the output of the make command:

bash-3.00# make
make  all-am
source='main.c' object='main.o' libtool=no \
DEPDIR=.deps depmode=none /bin/bash ./scripts/depcomp \
gcc -DHAVE_CONFIG_H -I.      -g -O3 -pipe -Wall -Waggregate-return -Wcast-align 
-Wchar-subscripts -Wcomment -Wformat -Wimplicit -Wmissing-declarations 
-Wmissing-prototypes -Wnested-externs -Wno-long-long -Wparentheses 
-Wpointer-arith -Wredundant-decls -Wreturn-type -Wswitch -Wtrigraphs 
-Wuninitialized -Wunused -Wwrite-strings -Wshadow -Wstrict-prototypes 
-Wcast-qual  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -c main.c
In file included from main.c:39:
logwarn.h:30: error: syntax error before "u_char"
logwarn.h:30: warning: no semicolon at end of struct or union
main.c:53: error: syntax error before "u_char"
main.c:53: warning: no semicolon at end of struct or union
main.c: In function `main':
main.c:78: error: storage size of 'state' isn't known
main.c:149: error: dereferencing pointer to incomplete type
main.c:151: error: dereferencing pointer to incomplete type
main.c:153: error: invalid use of undefined type `struct repat'
main.c:153: error: dereferencing pointer to incomplete type
main.c:158: error: dereferencing pointer to incomplete type
main.c:251: error: invalid use of undefined type `struct repat'
main.c:78: warning: unused variable `state'
main.c: In function `scan_file':
main.c:331: error: dereferencing pointer to incomplete type
main.c:332: error: dereferencing pointer to incomplete type
main.c:333: error: dereferencing pointer to incomplete type
main.c:375: error: dereferencing pointer to incomplete type
main.c:376: error: dereferencing pointer to incomplete type
main.c:379: error: invalid use of undefined type `struct repat'
main.c:379: error: invalid use of undefined type `struct repat'
main.c:386: error: invalid use of undefined type `struct repat'
main.c:386: error: dereferencing pointer to incomplete type
main.c:388: error: dereferencing pointer to incomplete type
main.c:389: error: dereferencing pointer to incomplete type
main.c:395: error: dereferencing pointer to incomplete type
main.c:399: error: dereferencing pointer to incomplete type
main.c: In function `parse_pattern':
main.c:425: error: dereferencing pointer to incomplete type
main.c:426: error: dereferencing pointer to incomplete type
main.c:430: error: dereferencing pointer to incomplete type
main.c: At top level:
main.c:59: error: storage size of `log_pattern' isn't known
main.c:60: error: storage size of `rot_pattern' isn't known
*** Error code 1
make: Fatal error: Command failed for target `main.o'
Current working directory /var/tmp/logwarn-1.0.7
*** Error code 1
make: Fatal error: Command failed for target `all'

Original comment by pldvo...@gmail.com on 16 Nov 2011 at 6:12

I don't have access to a Solaris machine.

However, try running this command and rebuilding:

  find . -name '*.[ch]' -print | while read FILE; do sed 's/u_char/unsigned char/g' < $FILE > xx && mv xx $FILE; done

That should at least fix the 'u_char' problem.

Original comment by archie.c...@gmail.com on 16 Nov 2011 at 7:35

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect
One other thing, I also had to add:
typedef char u_char;
to both logwarn.h and main.c, not sure if thats a solaris specific issue again 
or not...

Original comment by pldvo...@gmail.com on 17 Nov 2011 at 4:33

If I removed the typedef command and ran the find command you listed, that did 
resolve the u_char issue.

Original comment by pldvo...@gmail.com on 17 Nov 2011 at 4:35

Thanks. Should all be fixed now in r83.

Original comment by archie.c...@gmail.com on 18 Nov 2011 at 9:26

  • Changed state: Fixed