00001 /* 00002 * $Id: fdbuf.h,v 1.7 2003/10/22 22:35:40 jasta Exp $ 00003 * 00004 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License as published by the 00008 * Free Software Foundation; either version 2, or (at your option) any 00009 * later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 */ 00016 00017 #ifndef __FDBUF_H 00018 #define __FDBUF_H 00019 00020 /*****************************************************************************/ 00021 00032 /*****************************************************************************/ 00033 00034 #define FDBUF_ERR (-1) 00035 #define FDBUF_AGAIN (-2) 00036 #define FDBUF_EOF (-3) 00037 #define FDBUF_NVAL (-4) 00050 typedef int (*FDBufRead) (int fd, void *buf, size_t len, void *udata); 00051 00055 typedef struct 00056 { 00060 int flag; 00061 void *udata; 00062 00066 int fd; 00071 FDBufRead readfn; 00072 FDBufRead peekfn; 00073 String *s; 00074 } FDBuf; 00075 00076 /*****************************************************************************/ 00077 00078 EXTERN_C_BEGIN 00079 00080 /*****************************************************************************/ 00081 00095 LIBGIFT_EXPORT 00096 FDBuf *fdbuf_new (int fd, FDBufRead readfn, FDBufRead peekfn, void *udata); 00097 00101 LIBGIFT_EXPORT 00102 void fdbuf_free (FDBuf *buf); 00103 00104 /*****************************************************************************/ 00105 00118 LIBGIFT_EXPORT 00119 int fdbuf_fill (FDBuf *buf, int bufsize); 00120 00133 LIBGIFT_EXPORT 00134 int fdbuf_delim (FDBuf *buf, char *delim); 00135 00140 LIBGIFT_EXPORT 00141 void fdbuf_release (FDBuf *buf); 00142 00143 /*****************************************************************************/ 00144 00152 LIBGIFT_EXPORT 00153 unsigned char *fdbuf_data (FDBuf *buf, size_t *len); 00154 00155 /*****************************************************************************/ 00156 00157 EXTERN_C_END 00158 00159 /*****************************************************************************/ 00160 00161 #endif /* __FDBUF_H */
1.3.7