]> err.no Git - sope/blob - sope-core/NGStreams/NGTaskStream.m
minor code cleanups
[sope] / sope-core / NGStreams / NGTaskStream.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include "config.h"
23 #include "common.h"
24 #include "NGTaskStream.h"
25
26 @implementation NGTaskStream
27
28 - (id)initWithPath:(NSString *)_executable
29   arguments:(NSArray *)_args
30   environment:(NSDictionary *)_env
31 {
32   return nil;
33 }
34
35 - (void)dealloc {
36   [super dealloc];
37 }
38
39 /* state */
40
41 - (BOOL)isOpen {
42   return [self->task isRunning];
43 }
44
45 /* primitives */
46
47 - (unsigned)readBytes:(void *)_buf count:(unsigned)_len {
48   return NGStreamError;
49 }
50 - (unsigned)writeBytes:(const void *)_buf count:(unsigned)_len {
51   return NGStreamError;
52 }
53
54 - (BOOL)close {
55   if (![self isOpen]) {
56     NSLog(@"tried to close already closed stream %@", self);
57     return NO;
58   }
59   [self->task terminate];
60   return YES;
61 }
62
63 - (NGStreamMode)mode {
64   return NGStreamMode_readWrite;
65 }
66 - (BOOL)isRootStream {
67   return YES;
68 }
69
70 /* marking */
71
72 - (BOOL)mark {
73   NSLog(@"WARNING: called mark on a stream which doesn't support marking !");
74   return NO;
75 }
76 - (BOOL)rewind {
77   [[[NGStreamException alloc] initWithStream:self
78                               reason:@"marking not supported"] raise];
79   return NO;
80 }
81 - (BOOL)markSupported {
82   return -1;
83 }
84
85 /* description */
86
87 - (NSString *)description {
88   return [NSString stringWithFormat:
89                      @"<%@[0x%08X] task=%@ mode=%@>",
90                      NSStringFromClass([self class]), (unsigned)self,
91                      self->task,
92                      [self modeDescription]];
93 }
94
95 @end /* NGTaskStream */