Re: [gmime-devel] Need code snippet for MIME decoding
- From: prasad antony <prasadantonymad gmail com>
- To: Jeffrey Stedfast <fejj gnome org>
- Cc: gmime-devel-list gnome org
- Subject: Re: [gmime-devel] Need code snippet for MIME decoding
- Date: Thu, 21 Feb 2013 11:35:47 +0530
Hi Jeff,
Here is my code snippet. I was not using gmime APIs to create my file path location.
const char* outputfile = "/home/prasad/filepathdir/"
char *temp = NULL;
const char* name;
char *tempfile = NULL;
name = g_mime_part_get_filename ((GMimePart *) part);
temp = (char *)malloc(strlen(name) + 1); --------> In this line itself I am getting segmentation fault because of strlen(name)--------->
strcpy(temp,name);
printf("%s\n",temp);
tempfile = (char*)malloc(strlen(outputfile) + strlen(name) + 1);
strcpy(tempfile,outputfile);
strcat(tempfile,temp);
if ((fd = open (tempfile, O_CREAT | O_WRONLY, 0666)) != -1) {
content = g_mime_part_get_content_object ((GMimePart *) part);
stream = g_mime_stream_fs_new (fd);
I can do this even without temp variable. strcat(tempfile,name). While accessing the variable name to standard C functions it is giving segmentation fault.
In parallel let me try with your suggestion to do it with gmime APIs....But I would like to understand why the segmentation fault with my code....
Thanks so much Jeff for your quick reply....
Thanks
Prasad.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]