Ot ten Thije | 2ff39a3 | 2010-10-06 17:48:15 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #ifndef _OUTPUTCHANNEL_H |
| 17 | #define _OUTPUTCHANNEL_H |
| 18 | |
| 19 | #include <stdarg.h> |
| 20 | |
| 21 | /* Callback function to print a printf-formatted string to a channel */ |
| 22 | typedef int (*OutputChannelPrintf) (void* opaque, const char* fmt, va_list ap); |
| 23 | |
| 24 | typedef struct OutputChannel OutputChannel; |
| 25 | |
| 26 | /* Allocates a new output channel */ |
| 27 | OutputChannel* output_channel_alloc(void* opaque, OutputChannelPrintf cb); |
| 28 | |
| 29 | /* Prints a printf-formatted string to the output channel */ |
| 30 | int output_channel_printf(OutputChannel* oc, const char* fmt, ...); |
| 31 | |
| 32 | /* Frees an output channel */ |
| 33 | void output_channel_free(OutputChannel* oc); |
| 34 | |
| 35 | /* Returns the number of bytes written to the channel */ |
| 36 | unsigned int output_channel_written(OutputChannel* oc); |
| 37 | |
| 38 | #endif /* _OUTPUTCHANNEL_H */ |