Sorry for the double posting...
Regards
Patrik Astrom
---------- Forwarded message ----------
Date: Sun, 28 Nov 1999 22:59:29 +0100 (CET)
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Error compiling..
Hi everyone...
First of all I would like to state that IM not a programmer.
Im trying to compile a program and IM getting a errormessage, I have
included the error message bellow.
viking# cc emsg1.c
emsg1.c: In function `main':
emsg1.c:197: warning: passing arg 2 of `connect' from incompatible pointer
type
/var/tmp/ccRu22801.o: In function `main':
/var/tmp/ccRu22801.o(.text+0x5bb): undefined reference to `cuserid'
viking#
The software IM trying to compile is a network monitoring tool named
"EMU", I've found it at "http://www.jarrix.com.au".
At line 197 it looks like this...
if( connect(s, &sin, sizeof(sin)) < 0) {
close(s);
sleep(rand[count]);
count++;
}
else {
send(s, msg, strlen(msg), 0);
if(q_option) {
fp = fdopen(s, "r");
while ((c = fgetc(fp)) != EOF) {
putchar(c);
}
close(s);
exit(0);
}
close(s);
exit(0);
}
And where it complains about the "cuserid" bit it looks like this...
/* get my user name */
if (u_flag == 0) {
cuserid(myuser);
}
As stated above IM not a programmer and I would be most grateful for any
hints or suggestions.
Im attaching the emsg1.c file to if someone should get intressted.
Regards
Patrik Astrom
/* emsg.c - send log messages to the EMU event manager
VERSION 1.1
# Copyright 1999
# by Jarrix Systems Pty Ltd. All rights reserved. Some individual
# files in this distribution may be covered
# by other copyrights, as noted in their embedded comments.
#
# Redistribution and use in source and binary forms are permitted
# provided that this entire copyright notice is duplicated in all such
# copies, and that any documentation, announcements, and other
# materials related to such distribution and use acknowledge that the
# software was developed at Jarrix Systems Pty Ltd by Jarra and Anna
# Voleynik.
#
# No charge, other than an "at-cost" distribution fee, may be charged
# for copies, derivations, or distributions of this material without
# the express written consent of the copyright holder.
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR
# PURPOSE.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
extern int errno;
#define ARGS "o:h:u:n:p:m:t:w:s:c:"
main(argc,argv)
int argc;
char **argv;
{
int c;
FILE *fp;
char hostname[65];
char myhost[65];
char myuser[25];
char type[25];
char ttl[13]="none";
int port;
int s;
int ret;
time_t t;
char mtime[13];
char severity[13]="none";
char class[129]="none";
char password[25];
char message[257];
char msg[1024];
int rand[7]={3,6,9,12,15,18,21};
struct hostent *hp;
struct sockaddr_in sin;
extern char *optarg;
extern int optind;
int errflg=0;
int count=0;
int h_flag=0;
int u_flag=0;
int o_flag=0;
int n_flag=0;
int p_flag=0;
int t_flag=0;
int w_flag=0;
int s_flag=0;
int m_flag=0;
int c_flag=0;
int q_option=0;
struct tm *mytime;
optarg = NULL;
while (!errflg && (c = getopt(argc, argv, ARGS)) != EOF)
switch (c) {
case 'n' :
n_flag = 1;
strcpy(hostname,optarg);
break;
case 'p' :
p_flag = 1;
port = atoi(optarg);
break;
case 't' :
t_flag = 1;
strcpy(ttl,optarg);
break;
case 'w' :
w_flag = 1;
strcpy(password,optarg);
break;
case 'm' :
m_flag = 1;
strcpy(message,optarg);
break;
case 's' :
s_flag = 1;
strcpy(severity,optarg);
break;
case 'c' :
c_flag = 1;
strcpy(class,optarg);
break;
case 'o' :
o_flag = 1;
strcpy(type,optarg);
break;
case 'h' :
h_flag = 1;
strcpy(myhost,optarg);
break;
case 'u' :
u_flag = 1;
strcpy(myuser,optarg);
break;
default :
errflg++;
syntax();
exit(2);
}
/* if -o not specified, assume type normal */
if (o_flag == 0) {
strcpy(type,"normal");
}
if (!strcmp("query",type) || !strcmp("suspend",type) || !strcmp("delete",type)
|| !strcmp("comment",type) || !strcmp("wakeup",type)) {
if(n_flag == 0 || p_flag == 0 || w_flag == 0 || m_flag == 0) {
syntax();
exit(2);
}
}
else if (!strncmp("count",type,5) || !strcmp("normal",type) ||
!strcmp("sleep",type) || !strcmp("mask",type) || !strcmp("event",type)) {
if(n_flag == 0 || p_flag == 0 || w_flag == 0 || m_flag == 0 ||
t_flag == 0 || s_flag == 0 || c_flag == 0) {
syntax();
exit(2);
}
}
else if(n_flag == 0 || p_flag == 0 || w_flag == 0 || m_flag == 0 || t_flag ==
0 || s_flag == 0 || c_flag == 0) {
syntax();
exit(2);
}
if (!strcmp("query",type)) {
q_option = 1;
}
/* get my host name */
if (h_flag == 0) {
gethostname(myhost,sizeof(myhost));
}
/* get my user name */
if (u_flag == 0) {
cuserid(myuser);
}
/* get my time */
time(&t);
mytime=localtime(&t);
if((hp = gethostbyname(hostname)) == NULL) {
fprintf(stderr, "%s: unknown host.\n", hostname);
exit(1);
}
sprintf(mtime,"%02d/%02d
%02d:%02d",mytime->tm_mday,mytime->tm_mon+1,mytime->tm_hour,mytime->tm_min);
sprintf(msg,"%-12s%-64s%-24s%-12s%-12s%-24s%-128s%-256s%-24s\n",mtime,myhost,myuser,ttl,severity,password,class,message,type);
/*
printf("msg=%s\n",msg);
exit(1);
*/
/* in case the server is single-threaded, back off if the connection
fails and try later - up to 7 times */
count=0;
while(count < 7) {
if((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
perror("client: socket");
exit(1);
}
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
bcopy(hp->h_addr, &sin.sin_addr, hp->h_length);
if( connect(s, &sin, sizeof(sin)) < 0) {
close(s);
sleep(rand[count]);
count++;
}
else {
send(s, msg, strlen(msg), 0);
if(q_option) {
fp = fdopen(s, "r");
while ((c = fgetc(fp)) != EOF) {
putchar(c);
}
close(s);
exit(0);
}
close(s);
exit(0);
}
/* close(s); */
}
exit(1);
}
syntax()
{
puts("Copyright (C) 1999 Jarrix Systems v1.1");
puts(" ");
puts("emsg1 [-h <hostname>] [-u <user>] [-o <normal|sleep|mask|count|event>]
-n<host> -p<port> -t<time-to-live> -s<severity> -w<password> -c <class>
-m<message>\n");
puts("emsg1 [-h <hostname>] [-u <user>] [-o
<wakeup|query|comment|delete|suspend>] -n<host> -p<port> -w<password>
-m<hostname:object ........>\n");
}