Hello all:
  I want to replace qmail-local.c with a simple program. and use the simple program to 
do local deliver.
But the progrm is named by qmail-local.c ,and It is work normal and appear "delivery 
10: success:" in /var/log/syslog file when use gcc compile .but appear "delivery 7: 
deferral: qmail-local_crashed/" message in /var/log/syslog file when use g++ compile.
It can'not get argv parameter when use g++ compile
what is this ? How to solve the problem ,if I want to use g++?


My opeeration is "SunOS www2 5.7 Generic_106541-08 sun4u sparc SUNW,Ultra-2" .

Thank you!

/**
This is my qmail-local.c source.
Compile command:

 gcc  -I../include qmail-local.c  -L../lib -lm -lsocket -lnsl -o qmail-local
 g++  -I../include qmail-local.c  -L../lib -lm -lsocket -lnsl -o qmail-local


*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>


int flagdoit;

char *user;
char *homedir;
char *local;
char *dash;
char *ext;
char *host;
char *sender;
char *aliasempty;
char *quota;


#define BUFLEN  1024


void logmsg( char *msg )
{
        FILE             *fp;
        char              buff[1024];


        fp = fopen("/tmp/qmaillog", "a+");//a+�Ѿ����Զ�create�ļ��ˡ�
        if (fp == NULL) {
                return;
        }
        sprintf(buff,"%s\n", msg);
        fputs(buff, fp);
        fclose(fp);
}

void usage() {
          logmsg(" usage: qmail-local [ -nN ] user homedir local dash ext domain 
sender aliasempty"     );
         }

//void main(int argc,char **argv)
void main(int argc,char *argv[])

{
 int opt;
 char temp[1024];
 char buff[1024];
 int  m,opteof=-1;

umask(077);

sprintf(temp,"enter main ...:%d", argc);
logmsg(temp);

 flagdoit = 1;
 while ((opt = getopt(argc,argv,"nN")) != opteof)
   switch(opt)
    {
     case 'n': flagdoit = 0;break;
     case 'N': flagdoit = 1; break;
     default:
       usage();
    }

 argc -= optind;
 argv += optind;


 if (!(user = *argv++)) usage();
 if (!(homedir = *argv++)) usage();
 if (!(local = *argv++)) usage();
 if (!(dash = *argv++)) usage();
 if (!(ext = *argv++)) usage();
 if (!(host = *argv++)) usage();
 if (!(sender = *argv++)) usage();
 if (!(aliasempty = *argv++)) usage();
 if (!(quota = *argv++)) usage();
 if (*argv) usage();


sprintf(temp,"usre:%s,homedir:%s,local:%s,dash:%s,ext:%s,host:%s,sender:%s,aliasempty:%s,quota:%s\n",user,homedir,local,dash,ext,host,sender,aliasempty,quota);

logmsg( temp );

 m=read(0,buff,1023);
  if(m<0) {
    exit(1);
  }

 logmsg("exit main\n");
 logmsg(buff);

 _exit(0);
}

Reply via email to