Changeset 549
- Timestamp:
- 03/23/07 17:55:13 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src-c/xmldsig-signing-ebXML-user-message/hefeweizen_sign_ebXML_user_message.c
r445 r549 119 119 int replace_soap_header(const char* multipart_mime_file, xmlChar* signed_soap_mem, const char* output_file_name); 120 120 int replace_soap_header_y(const char* multipart_mime_file, const char* temp_output_file_name, const char* output_file_name); 121 int replace_soap_header_x(const char* original_multipart_mime_file, const char* signed_soap_file_name, const char* final_output_file_name);122 121 123 122 /** … … 150 149 151 150 void* cidOpenFunction_real(const char* filename){ 152 c har* content_id = NULL;151 const char* content_id = NULL; 153 152 154 153 if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "cid:", 4)) { … … 448 447 GMimePart* soap = (GMimePart*) g_mime_multipart_get_part(multipart, 0); 449 448 449 fprintf(stdout, "Before strln: replace_soap_header"); 450 450 g_mime_part_set_content(soap, (char*)signed_soap_mem, strlen(signed_soap_mem)); 451 451 // g_mime_multipart_set_boundary(multipart, "dddddddddddddddddddddddddd^M"); … … 518 518 519 519 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 520 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 521 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 522 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 523 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 524 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n"); 525 520 fprintf(stdout, "Before strlen: replace soap header_y"); 526 521 g_mime_part_set_content(soap, buffer, strlen(buffer)); 527 522 … … 548 543 } 549 544 550 int replace_soap_header_x(const char* original_multipart_mime_file, const char* signed_soap_file_name, const char* final_output_file_name){551 GMimeMessage* message;552 int fd;553 554 if ((fd = open (multipart_mime_file, O_RDONLY)) == -1) {555 fprintf (stderr, "Cannot open message `%s': %s to write soap message.\n", multipart_mime_file, strerror (errno));556 // return -1;557 }558 559 message = parse_message(fd);560 close(fd);561 562 GMimeObject* part = NULL;563 part = g_mime_message_get_mime_part(message);564 GMimeMultipart* multipart = (GMimeMultipart*) part;565 566 567 g_mime_multipart_remove_part_at(multipart, 0);568 569 /* create the new part that we are going to add... */570 GMimePart *mime_part;571 mime_part = g_mime_part_new_with_type ("text", "xml");572 g_mime_part_set_encoding(mime_part, GMIME_PART_ENCODING_BINARY);573 574 575 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n");576 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n");577 fprintf(stdout, "HHHHHHHHHHHHHHHELO\n");578 579 FILE * pFile;580 long lSize;581 char * buffer;582 size_t result;583 584 pFile = fopen ( signed_soap_file_name , "rb" );585 if (pFile==NULL) {fputs ("File error",stderr); return (-1);}586 587 // obtain file size:588 fseek (pFile , 0 , SEEK_END);589 lSize = ftell (pFile);590 rewind (pFile);591 592 // allocate memory to contain the whole file:593 buffer = (char*) malloc (sizeof(char)*lSize);594 if (buffer == NULL) {fputs ("Memory error",stderr); return (-2);}595 596 // copy the file into the buffer:597 result = fread (buffer,1,lSize,pFile);598 if (result != lSize) {fputs ("Reading error",stderr); return (-3);}599 600 /* the whole file is now loaded in the memory buffer. */601 602 // fprintf(stdout, "Signed shitr: %s\n", buffer);603 604 // return(0);605 606 g_mime_part_set_content (mime_part, buffer, strlen(buffer));607 608 609 g_mime_multipart_add_part_at(multipart, mime_part, 0);610 611 char* text;612 text = g_mime_message_to_string (message);613 614 FILE* output_file = NULL;615 // char* file_name = "/tmp/final_output_soap_file";616 if ((output_file = fopen(final_output_file_name, "w")) == NULL)617 fprintf(stderr, "Cannot open %s to write soap message.\n", final_output_file_name);618 fprintf(output_file, "%s", text);619 fclose(output_file);620 621 g_free (text);622 g_mime_object_unref (GMIME_OBJECT (message));623 624 // terminate625 fclose (pFile);626 free (buffer);627 return 0;628 629 }630 545 631 546 static void 632 547 foreach_callback_payload(GMimeObject *part, gpointer user_data) 633 548 { 549 634 550 const char* content_id = NULL; 635 551 int compare; 636 GMimeDataWrapper *content; 637 const char *filename; 638 GMimeStream *stream; 552 GMimeDataWrapper* content =NULL; 553 GMimeStream *stream = NULL; 639 554 int fd2; 640 555 556 if (debug == 1){ 557 fprintf(stdout, "Getting content id of given mime part"); 558 } 641 559 content_id = g_mime_part_get_content_id((GMimePart *)part); 642 560 … … 644 562 return; 645 563 } 564 565 if (debug == 1) 566 fprintf(stdout, "The content id is '%s' .\n", content_id ); 646 567 647 568 /* lets see if this is the required content id */ … … 653 574 } 654 575 655 if (debug == 1){656 fprintf(stdout, "The file name for the mime part with id '%s' is '%s'.\n", content_id, filename );657 }658 576 // if ((fd2 = open (filename, O_CREAT | O_WRONLY, 0666)) == -1) { 659 577 if ((fd2 = open (payload_message_filename, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == -1) { … … 712 630 fprintf(stdout, "new filename %s\n", payload_message_filename); 713 631 632 //nnnnnnnnnnnnnnnnnnnnnn 633 fprintf(stdout, "Message %s", message); 714 634 715 635 g_mime_message_foreach_part (message, foreach_callback_payload, &count); trunk/src-c/xmldsig-validate-signature-ebXML-user-message/hefeweizen_validate_signature_ebXML_user_message.c
r426 r549 69 69 char* file_path; 70 70 71 72 71 char* get_temp_filename(); 73 72 void set_root_path(); … … 111 110 112 111 void* cidOpenFunction_real(const char* filename){ 113 c har* content_id = NULL;112 const char* content_id = NULL; 114 113 115 114 if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "cid:", 4)) { 116 115 116 content_id = &filename[4]; 117 /* 117 118 #if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__) 118 119 content_id = &filename[5]; … … 120 121 content_id = &filename[4]; 121 122 #endif 123 */ 122 124 } else 123 125 content_id = filename; … … 529 531 int compare; 530 532 GMimeDataWrapper *content; 531 const char *filename;532 533 GMimeStream *stream; 533 534 int fd2; … … 537 538 if (content_id == NULL) { 538 539 return; 540 } 541 542 if (debug == 1){ 543 fprintf(stdout, "The content id is '%s'.\n", content_id ); 539 544 } 540 545 … … 547 552 } 548 553 549 if (debug == 1){550 fprintf(stdout, "The file name for the mime part with id '%s' is '%s'.\n", content_id, filename );551 }552 554 // if ((fd2 = open (filename, O_CREAT | O_WRONLY, 0666)) == -1) { 553 555 if ((fd2 = open (payload_message_filename, O_CREAT | O_WRONLY | O_TRUNC, 0666)) == -1) {
