patchunrtf - Patches: patch #7676, unrtf as a library (huge)

 
 

You are not allowed to post comments on this tracker with your current authentication level.

patch #7676: unrtf as a library (huge)

Submitter:  Wolfgang Sourdeau <wolfgang>
Submitted:  Thu 24 Nov 2011 02:49:56 PM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open

Fri 07 Sep 2012 04:50:42 PM UTC, comment #1: 

I have used your patch and proceeded with making a library from unrtf, see https://savannah.gnu.org/patch/index.php?7846 .
There were some mistakes: when you moved global variables to function arguments, you have forgotten to pass them in several places. That was leading to unpredictable behavior and sometimes even to segmentation faults. I tried to correct these mistakes, but I'm not sure that I have found all of them. However, thanks a lot for your patch -- it was very useful for my purposes!

Alexey Dobrov <adobrov>
Thu 24 Nov 2011 02:49:56 PM UTC, original submission:  

For the SOGo/OpenChange project, we are now using your converter for interpreting RTF content. In order to do so, I have modified the code of unrtf in order to let it built as a library. Mainly, this implied converting all global variables into members of structures that are passed from function to function. The structures in questions have been layed out as this: one for the conversion parameters inherited from the command line, another for all internal processing as well as the pre-existing one for the output personality.
I have not made changes to the existing code per se except for fixing a few leak here and there, however I have added an interface header (unrtf.h) with the public conversion functions, that main.c now invokes. Also, I have modified the code in parser.c to use a string as input rather than a FILE * and improved the "safe_printf" to make use of a configurable output method while keeping its safety purpose. Consequently, the public function for file handling first load the entire file in memory before passing its content to the string-based function, and the output can now be directed to a file, to screen or to another structure provided by the client of the library.

Besides all of that, I have also reindented most of the code in a way that's more compliant to the GNU coding standards, as it's my default editing setup for my projects. If it bothers you, I could probably produce another patch that ignores changes to whitespaces. I also remove the path.c module from the build as it was no longer required.

For the SOGo/OpenChange backend, I am using a special makefile that integrates with the GNUstep-based SOGo build. Therefore I made no modifications to the current build scripts of unrtf, besides removing path.c from the corresponding Makefile.am. This means that even though it's ready to be built as a library, it is not when built from the current scripts.

If you decide to go further with this, I think my patch is a good starting point. I can see other things that could be done beforehand: fix the code syntax to be more compliant with the GNU coding standards (with regards to the layout of braces for example), replace the loading of the input file with a mmap-based mechanism, in order to reduce memory usage for big files.
Also, the "ConversionContext" structure could be split in multiple substructures in order to organize its members.

Wolfgang Sourdeau <wolfgang>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #24441:  unrtf-0.21.2.diff added by wolfgang (361KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by adobrov (Posted a comment)
  • -email is unavailable- added by wolfgang (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-11-24 wolfgang Attached File- Added unrtf-0.21.2.diff, #24441

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code