Home Libraries Author Links

cpipe.h

Go to the documentation of this file.
00001 /* ***** BEGIN LICENSE BLOCK *****
00002  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00003  *
00004  * The contents of this file are subject to the Mozilla Public License Version
00005  * 1.1 (the "License"); you may not use this file except in compliance with
00006  * the License. You may obtain a copy of the License at
00007  * http://www.mozilla.org/MPL/
00008  *
00009  * Software distributed under the License is distributed on an "AS IS" basis,
00010  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00011  * for the specific language governing rights and limitations under the
00012  * License.
00013  *
00014  * The Original Code is the SysToMath C Libraries package (LibStmC).
00015  *
00016  * The Initial Developer of the Original Code is
00017  * Tom Michaelis, SysToMath.
00018  * Portions created by the Initial Developer are Copyright (C) 1993-2006
00019  * the Initial Developer. All Rights Reserved.
00020  *
00021  * Contributor(s):
00022  *
00023  * Alternatively, the contents of this file may be used under the terms of
00024  * either the GNU General Public License Version 2 or later (the "GPL"), or
00025  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00026  * in which case the provisions of the GPL or the LGPL are applicable instead
00027  * of those above. If you wish to allow use of your version of this file only
00028  * under the terms of either the GPL or the LGPL, and not to allow others to
00029  * use your version of this file under the terms of the MPL, indicate your
00030  * decision by deleting the provisions above and replace them with the notice
00031  * and other provisions required by the GPL or the LGPL. If you do not delete
00032  * the provisions above, a recipient may use your version of this file under
00033  * the terms of any one of the MPL, the GPL or the LGPL.
00034  *
00035  * ***** END LICENSE BLOCK ***** */
00036 
00037 /******************************************************************************
00038  *                       First Release 1993-05-02
00039  ******************************************************************************/
00040 
00041 
00079 #ifndef STM_CPIPE_H
00080 #define STM_CPIPE_H
00081 
00082 
00083 /* Include header files and macro definitions. */
00084 #include <stm/internal/_cpipe.h>
00085 
00086 
00087 #ifdef __cplusplus
00088 extern "C" {
00089 #endif
00090 
00091 
00111 StmAbstractType (StmPipe)  /* Pipe */
00112 
00113 
00114 
00138 typedef struct StmPipeWord StmPipeWord;  
00147 enum StmPipeWordStatus
00148 {
00149     StmPipeNormal   = 0,     
00150     StmPipeAgain    = 1,     
00151     StmPipeNeedItem = 2,     
00152     StmPipeError    = 3,     
00153     StmPipeCtrl     = 0x80,  
00154     StmPipeAllCtrl  = 0xff,  
00155 };
00156 
00157 
00161 /* Include StmPipeWord implementation. */
00162 #include <stm/internal/_cpipe.h>
00163 
00164 
00179 StmDllSpec
00180 stm_inline StmPipeWord stmPipeWordMake (StmWord word);
00181 
00182 
00193 StmDllSpec
00194 stm_inline StmPipeWord stmPipeWordLoMake (StmByte lo);
00195 
00196 
00207 StmDllSpec
00208 stm_inline StmPipeWord stmPipeWordHiMake (StmByte hi);
00209 
00210 
00224 StmDllSpec
00225 stm_inline StmPipeWord stmPipeWordHiLoMake (StmByte hi, StmByte lo);
00226 
00227 
00239 StmDllSpec
00240 stm_inline StmPipeWord stmPipeWordErrNoMake (StmByte errNo);
00241 
00242 
00252 StmDllSpec
00253 stm_inline StmPipeWord stmPipeWordEofMake (void);
00254 
00255 
00272 StmDllSpec
00273 stm_inline StmWord stmPipeWord (StmPipeWord item);
00274 
00275 
00285 StmDllSpec
00286 stm_inline StmByte stmPipeWordLo (StmPipeWord item);
00287 
00288 
00298 StmDllSpec
00299 stm_inline StmByte stmPipeWordHi (StmPipeWord item);
00300 
00301 
00314 StmDllSpec
00315 stm_inline StmBool stmPipeWordIsEof (StmPipeWord item);
00316 
00317 
00351 StmAbstractType (StmPipeStream)  /* PipeStream */
00352 
00353 
00354 
00375 StmDllSpec
00376 StmPipeStream stmPipeStreamFileDrainCreate (FILE *file);
00377 
00378 
00396 StmDllSpec
00397 StmPipeStream stmPipeStreamFdDrainCreate (int fd);
00398 
00399 
00424 StmDllSpec
00425 StmPipeStream stmPipeStreamAppDrainCreate
00426 (
00427     void *data,
00428     StmBool (*isByteAvailable) (void *data),
00429     int (*deliverByte) (void *data)
00430 );
00431 
00432 
00450 StmDllSpec
00451 StmPipeStream stmPipeStreamFileSinkCreate (FILE *file);
00452 
00453 
00471 StmDllSpec
00472 StmPipeStream stmPipeStreamFdSinkCreate (int fd);
00473 
00474 
00499 StmDllSpec
00500 StmPipeStream stmPipeStreamAppSinkCreate
00501 (
00502     void *data,
00503     StmBool (*isByteWelcome) (void *data),
00504     int (*acceptByte) (void *data, StmByte byte)
00505 );
00506 
00507 
00522 StmDllSpec
00523 stm_inline void stmPipeStreamDestroy (StmPipeStream stream);
00524 
00525 
00545 StmDllSpec
00546 stm_inline StmBool stmPipeStreamIsItemAvailable (StmPipeStream stream);
00547 
00548 
00564 StmDllSpec
00565 stm_inline StmPipeWord stmPipeStreamDeliverItem (StmPipeStream stream);
00566 
00567 
00580 StmDllSpec
00581 stm_inline StmBool stmPipeStreamIsItemWelcome (StmPipeStream stream);
00582 
00583 
00601 StmDllSpec
00602 stm_inline StmPipeWord stmPipeStreamAcceptItem
00603 (
00604     StmPipeStream stream,
00605     StmPipeWord item
00606 );
00607 
00608 
00634 StmAbstractType (StmPipeFilter)  /* PipeFilter */
00635 
00636 
00802 StmDllSpec
00803 StmPipeFilter stmPipeFilterCreate
00804 (
00805     StmPipeWord (*operate) (StmPipeFilter filter, StmPipeWord item),
00806     void * (*createData) (StmPipeFilter filter),
00807     void (*destroyData) (StmPipeFilter filter),
00808     void *env
00809 );
00810 
00811 
00830 StmDllSpec
00831 int stmPipeFilterDestroy (StmPipeFilter filter);
00832 
00833 
00852 StmDllSpec
00853 StmPipe stmPipeFilterGetPipe (StmPipeFilter filter);
00854 
00855 
00871 StmDllSpec
00872 stm_inline StmPipeStream stmPipeFilterGetInput (StmPipeFilter filter);
00873 
00874 
00891 StmDllSpec
00892 stm_inline StmPipeStream stmPipeFilterGetOutput (StmPipeFilter filter);
00893 
00894 
00911 StmDllSpec
00912 stm_inline int stmPipeFilterGetStage (StmPipeFilter filter);
00913 
00914 
00931 StmDllSpec
00932 stm_inline void *stmPipeFilterGetData (StmPipeFilter filter);
00933 
00934 
00950 StmDllSpec
00951 stm_inline void *stmPipeFilterGetEnv (StmPipeFilter filter);
00952 
00953 
01003 StmDllSpec
01004 StmPipe stmPipeCreate (StmPipeStream input, StmPipeStream output, FILE *debug,
01005                        StmPipeFilter *filters, size_t order, size_t bufferSize);
01006 
01007 
01021 StmDllSpec
01022 void stmPipeDestroy (StmPipe pipe);
01023 
01024 
01044 StmDllSpec
01045 stm_inline StmPipeStream stmPipeGetInput (StmPipe pipe);
01046 
01047 
01060 StmDllSpec
01061 stm_inline StmPipeStream stmPipeGetOutput (StmPipe pipe);
01062 
01063 
01077 StmDllSpec
01078 stm_inline FILE *stmPipeGetDebug (StmPipe pipe);
01079 
01080 
01094 StmDllSpec
01095 stm_inline int stmPipeGetOrder (StmPipe pipe);
01096 
01097 
01118 StmDllSpec
01119 stm_inline StmPipeFilter stmPipeGetFilter (StmPipe pipe, size_t stage);
01120 
01121 
01138 StmDllSpec
01139 stm_inline int stmPipeGetBufferSize (StmPipe pipe);
01140 
01141 
01166 StmDllSpec
01167 int stmPipeExec (StmPipe pipe);
01168 
01169 
01183 #define StmPipeErrors                                                          \
01184 /*          Error number         Error message text                         */ \
01185 StmPipeErr (StmPipeErrOk,        "no error"),                                  \
01186 StmPipeErr (StmPipeErrInval,     "invalid argument"),                          \
01187 StmPipeErr (StmPipeErrNoMem,     "no more memory on heap"),                    \
01188 StmPipeErr (StmPipeErrDeadlock,  "deadlock"),                                  \
01189 StmPipeErr (StmPipeErrRead,      "read error"),                                \
01190 StmPipeErr (StmPipeErrWrite,     "write error"),                               \
01191 StmPipeErr (StmPipeErrCreate,    "error in user function create"),             \
01192 StmPipeErr (StmPipeErrCtrl,      "invalid control code"),                      \
01193 StmPipeErr (StmPipeErrOperate,   "error in user function operate"),            \
01194 
01195 
01200 #define StmPipeErr(nr, txt)      nr
01201 
01202 
01206 enum StmPipeErrnos
01207 {
01208     StmPipeErrors
01209     StmPipeErrCount
01210 };
01211 #undef StmPipeErr
01212 
01213 
01235 StmDllSpec
01236 stm_inline int stmPipeGetErrno (StmPipe pipe);
01237 
01238 
01252 StmDllSpec
01253 stm_inline int stmPipeClearErrno (StmPipe pipe);
01254 
01255 
01271 StmDllSpec
01272 const char *stmPipeGetErrorMsg (StmPipe pipe);
01273 
01274 
01287 StmDllSpec
01288 stm_inline const char *stmPipeGetDebugMsg (StmPipe pipe);
01289 
01290 
01309 StmDllSpec
01310 int stmPipeSetDebugMsg (StmPipe pipe, const char *debugMsg);
01311 
01312 
01319 #ifdef __cplusplus
01320 }
01321 #endif
01322 
01323 
01324 /* Include inline implementation. */
01325 #include <stm/internal/_cpipe.h>
01326 
01327 
01328 #endif

© Copyright Tom Michaelis 2002-2007

Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).