UNIXworkcode

1 /******************************************************************************* 2 * * 3 * Copyright 2004 The NEdit Developers * 4 * * 5 * This is free software; you can redistribute it and/or modify it under the * 6 * terms of the GNU General Public License as published by the Free Software * 7 * Foundation; either version 2 of the License, or (at your option) any later * 8 * version. In addition, you may distribute versions of this program linked to * 9 * Motif or Open Motif. See README for details. * 10 * * 11 * This software is distributed in the hope that it will be useful, but WITHOUT * 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * 14 * more details. * 15 * * 16 * You should have received a copy of the GNU General Public License along with * 17 * software; if not, write to the Free Software Foundation, Inc., 59 Temple * 18 * Place, Suite 330, Boston, MA 02111-1307 USA * * 19 * * 20 *******************************************************************************/ 21 22 #ifndef XNEDIT_FILTER_H 23 #define XNEDIT_FILTER_H 24 25 #include "nedit.h" 26 27 #include <X11/Intrinsic.h> 28 #include <X11/Xresource.h> 29 #include <Xm/Xm.h> 30 #include <X11/Xlib.h> 31 32 typedef struct IOFilter IOFilter; 33 struct IOFilter { 34 char *name; 35 char *pattern; 36 char *ext; 37 char *cmdin; 38 char *cmdout; 39 char *ec_pattern; 40 }; 41 42 #define FILESTREAM_HDR_BUFLEN 32768 43 typedef struct FileStream { 44 FILE *file; 45 int pin[2]; 46 int pout[2]; 47 pid_t pid; 48 char *filter_cmd; 49 char hdrbuf[FILESTREAM_HDR_BUFLEN]; 50 size_t hdrbuflen; 51 size_t hdrbufpos; 52 int mode; 53 } FileStream; 54 55 void FilterSettings(WindowInfo *window); 56 57 void ParseFilterSettings(char *str); 58 59 char* WriteFilterString(void); 60 61 IOFilter** GetFilterList(size_t *num); 62 63 IOFilter* GetFilterFromName(const char *name); 64 65 IOFilter* GetFilterForPath(const char *path); 66 67 FileStream* filestream_open_r(Widget w, FILE *f, const char *filter_cmd); 68 FileStream* filestream_open_w(Widget w, FILE *f, const char *filter_cmd); 69 int filestream_reset(FileStream *stream, int pos); 70 size_t filestream_read(void *buffer, size_t nbytes, FileStream *stream); 71 size_t filestream_write(const void *buffer, size_t nbytes, FileStream *stream); 72 int filestream_close(FileStream *stream); 73 74 75 76 #endif //XNEDIT_FILTER_H 77