Amiga.org

The "Not Quite Amiga but still computer related category" => Alternative Operating Systems => Topic started by: LoadWB on December 03, 2007, 08:18:33 AM

Title: Quick question on C string comparison (resolved)
Post by: LoadWB on December 03, 2007, 08:18:33 AM
I'm farting around with UW's imap kit, imap-2006i.  I want to have the syslog facility set based on the running service.

Here's the call to server_init() from imap.c:

  server_init (pgmname,"imap","imaps",clkint,kodint,hupint,trmint);


Here's the function definition from env_unix.c:

void server_init (char *server,char *service,char *sslservice,
                  void *clkint,void *kodint,void *hupint,void *trmint)


The line I'm trying to get to make work looks like this:

openlog (myServerName = cpystr (server), LOG_PID, (service=="imap") ? LOG_LOCAL2 : LOG_LOCAL0);


The ternary always returns the false value, LOG_LOCAL0.  It's been forever since I did anything useful with C... what am I missing here?
Title: Re: Quick question on C string comparison
Post by: Piru on December 03, 2007, 08:21:38 AM
service=="imap" does not compare strings, but string pointers.

look into strcmp.
Title: Re: Quick question on C string comparison
Post by: LoadWB on December 03, 2007, 08:38:01 AM
Bingo.  Darned pointers.  I knew I was missing something easy.

Piru, I *knew* you'd have the answer.  Thanks!  :pint:

This did it

openlog (myServerName = cpystr (server), LOG_PID, strcmp(service,"imap") ? LOG_LOCAL0 : LOG_LOCAL2 );

Now this is fixed, I need to get to bed.  Tomorrow I get to figure out what Mark changed in dmail between 2004f and 2006i so I can make port my symlink hack :-D