LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   segmentation error (core dumped) Linux in c (http://www.linuxquestions.org/questions/programming-9/segmentation-error-core-dumped-linux-in-c-616541/)

nasim751 01-26-2008 10:03 PM

segmentation error (core dumped) Linux in c
 
Hello HKO,
i did one mistake from my previous code. this code after modification that part basically that was like.

int
main(int argc, char *argv[])
{
int c;
u_char flags;
char *device;
char *capture_file;
struct descry_pack *gp;
printf("Descry 1.0 [TCP port scan detection tool]\n");

flags = 0;
device = NULL;
capture_file = NULL;
while ((c = getopt(argc, argv,"ahf:i:vs]")) != EOF) <previous was "afi:vs:h and if use while ((c ==getopt(argc, argv,"ahf:i:vs]")) then no SEG PROB but not getting result behest of choice >
{
switch (c)
{
case 'a':
flags |= ALL_HOSTS;
break;
case 'f':
capture_file = optarg; [in here i cant undestood from ur feedback feedback, pls do explain. i am not very good in c]
break;
case 'i':
device = optarg;
break;
case 'v':
break;
case 's':
flags |= DO_SYSLOG;
break;
case 'h':
default:
usage(argv[0]);
return (EXIT_FAILURE);
}
}

/* either read from a capture file OR run on the network */
if (capture_file && device)
{
usage(argv[0]);
return (EXIT_FAILURE);
}

if (descry_init(&gp, device, capture_file, flags) == 0)
{
fprintf(stderr, "descry_init(): catastrophic failure\n");
return (EXIT_FAILURE);
}

while (pcap_dispatch(gp->p, 0, (pcap_handler)descry, (u_char*)gp));

descry_destroy(gp);

return (EXIT_SUCCESS);
}

rubadub 01-27-2008 05:12 PM

Someone once told me to have a go with gdb, I soon mixed it up with a bit of electricfence and hey presto, I see where i'm going wrong...


All times are GMT -5. The time now is 03:26 PM.