My first PHP Extension.

Avatar von manfred

This is my first contribution to writing php extensions. Extractor interfaces the libextractor library which offered some nice functionality to a project I am currently working on. Libextractor is used to extract meta-data from files of arbitrary type. Ext_skel and the pear packaging system came really handy during the development process.
Following Filetypes are supported: HTML, PDF, PS, OLE2 (DOC, XLS, PPT), OpenOffice (sxw), StarOffice (sdw), DVI, MAN, MP3 (ID3v1 and ID3v2), OGG, WAV, JPEG, GIF, PNG, TIFF, DEB, RPM, TAR(.GZ), ZIP, ELF, REAL, RIFF (AVI), MPEG, QT and ASF

Avatar von manfred

Kommentare

3 Antworten zu „My first PHP Extension.“

  1. Ok, two things.

    First, this is not a good idea:

    keywords = EXTRACTOR_getKeywords (extractors, filename);
    array_init(return_value);
    while (keywords != NULL)
    {
    add_next_index_string(return_value,keywords->keyword,1);
    keywords = keywords->next;
    }
    EXTRACTOR_freeKeywords(keywords);

    since it is one big memory leak. You ought to store the head of the linked list and free that in the end:

    head
    = keywords
    = EXTRACTOR_getKeywords (extractors,
    filename);
    array_init(return_value);
    while (keywords != NULL)
    {
    add_next_index_string(return_value,keywords->keyword,1);
    keywords = keywords->next;
    }
    EXTRACTOR_freeKeywords(head); // !!!

    Also, there maybe a licensing issue here.
    libextractor is released under the GNU GPL, which according to the FSF (IANAL, but they have some) is incompatible with the PHP License. Now, before you even ask if I could make an exception for you guys, I must tell you that I cannot, simply because libextractor uses plenty of GPL’ed code that I did not write — and the authors of some of that code have already declined to LGPL it.

    So while I personally will certainly not go after any _free_ software using my code, you’re on rather shaky ground and other people (namely the author of xpdf) could theoretically (see also: FUD) give you trouble here. You might want to put your code under the GPL to avoid this — and of course you might want to consider to lobby within the PHP community to make their licenses GPL-compatible (again), for example by putting the code under two licenses… :-).

    1. Avatar von Manfred

      Hello Christian,
      thanks for reply. Actually I primary wrote this extension to make myself familair with php extension stuff and this library seemed to be a good start to me. So I will make the codechange like you told me.
      Well I already licensed it to GPL but my colleguage Johannes now told me that it still conflicts with PHP License.
      So I guess right now I will leave it like it is and make some special note about licensing in case someone wants to use it.
      Btw. nice photo on grothoff. ;-)
      Thank you!
      Manfred

  2. Avatar von zemzemi

    Hi,
    I want to know if your library can retrieve bibtex data from PDF. Indeed, I’m developping web application based on php that manage bibtex entries.

    Thanks

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert


Für das Handling unseres Newsletters nutzen wir den Dienst HubSpot. Mehr Informationen, insbesondere auch zu Deinem Widerrufsrecht, kannst Du jederzeit unserer Datenschutzerklärung entnehmen.