projects
/
runtime.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed SILC Stream API implementation static inline functions.
[runtime.git]
/
lib
/
silcutil
/
silcstream.h
diff --git
a/lib/silcutil/silcstream.h
b/lib/silcutil/silcstream.h
index 85364d2a08cd316127ffeedd689738e99736f52d..b6d82d90009489e0b050ba1beaafa3c47a4a2bd5 100644
(file)
--- a/
lib/silcutil/silcstream.h
+++ b/
lib/silcutil/silcstream.h
@@
-4,7
+4,7
@@
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2005 - 200
7
Pekka Riikonen
+ Copyright (C) 2005 - 200
8
Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-17,7
+17,7
@@
*/
*/
-/****h* silcutil/S
ILC S
tream Interface
+/****h* silcutil/Stream Interface
*
* DESCRIPTION
*
*
* DESCRIPTION
*
@@
-26,6
+26,10
@@
* other stream API derived from this API can use this same interface for
* reading and writing.
*
* other stream API derived from this API can use this same interface for
* reading and writing.
*
+ * The SilcStream is an abstraction. It can represent any stream; socket
+ * stream, file descriptor stream, packet stream, etc. See examples in
+ * silcsocketstream.h and silcfdstream.h.
+ *
* Note that stream implementations usually are not thread-safe. Always
* verify whether a stream implementation is thread-safe by checking their
* corresponding documentation.
* Note that stream implementations usually are not thread-safe. Always
* verify whether a stream implementation is thread-safe by checking their
* corresponding documentation.
@@
-35,7
+39,7
@@
#ifndef SILCSTREAM_H
#define SILCSTREAM_H
#ifndef SILCSTREAM_H
#define SILCSTREAM_H
-/****s* silcutil/SilcStream
API/SilcStream
+/****s* silcutil/SilcStream
*
* NAME
*
*
* NAME
*
@@
-51,7
+55,7
@@
***/
typedef void *SilcStream;
***/
typedef void *SilcStream;
-/****d* silcutil/SilcStream
API/SilcStream
Status
+/****d* silcutil/SilcStreamStatus
*
* NAME
*
*
* NAME
*
@@
-71,7
+75,7
@@
typedef enum {
} SilcStreamStatus;
/***/
} SilcStreamStatus;
/***/
-/****f* silcutil/SilcStream
API/SilcStream
Notifier
+/****f* silcutil/SilcStreamNotifier
*
* SYNOPSIS
*
*
* SYNOPSIS
*
@@
-91,7
+95,7
@@
typedef void (*SilcStreamNotifier)(SilcStream stream,
SilcStreamStatus status,
void *context);
SilcStreamStatus status,
void *context);
-/****s* silcutil/SilcStream
API/SilcStream
Ops
+/****s* silcutil/SilcStreamOps
*
* NAME
*
*
* NAME
*
@@
-117,7
+121,7
@@
typedef void (*SilcStreamNotifier)(SilcStream stream,
* } *SilcFooStream;
*
* SilcFooStream foo;
* } *SilcFooStream;
*
* SilcFooStream foo;
- * silc_stream_write(foo, data, data_len);
+ * silc_stream_write(
(SilcStream)
foo, data, data_len);
*
* SOURCE
*/
*
* SOURCE
*/
@@
-153,7
+157,12
@@
typedef struct {
} SilcStreamOps;
/***/
} SilcStreamOps;
/***/
-/****f* silcutil/SilcStreamAPI/silc_stream_read
+/* Stream header */
+typedef struct SilcStreamHeaderObject {
+ SilcStreamOps *ops;
+} *SilcStreamHeader, SilcStreamHeaderStruct;
+
+/****f* silcutil/silc_stream_read
*
* SYNOPSIS
*
*
* SYNOPSIS
*
@@
-172,10
+181,15
@@
typedef struct {
* If error occurred the error code can be retrieved with silc_errno.
*
***/
* If error occurred the error code can be retrieved with silc_errno.
*
***/
+static inline
int silc_stream_read(SilcStream stream, unsigned char *buf,
int silc_stream_read(SilcStream stream, unsigned char *buf,
- SilcUInt32 buf_len);
+ SilcUInt32 buf_len)
+{
+ SilcStreamHeader h = stream;
+ return h->ops->read(stream, buf, buf_len);
+}
-/****f* silcutil/
SilcStreamAPI/
silc_stream_write
+/****f* silcutil/silc_stream_write
*
* SYNOPSIS
*
*
* SYNOPSIS
*
@@
-194,10
+208,15
@@
int silc_stream_read(SilcStream stream, unsigned char *buf,
* If error occurred the error code can be retrieved with silc_errno.
*
***/
* If error occurred the error code can be retrieved with silc_errno.
*
***/
+static inline
int silc_stream_write(SilcStream stream, const unsigned char *data,
int silc_stream_write(SilcStream stream, const unsigned char *data,
- SilcUInt32 data_len);
+ SilcUInt32 data_len)
+{
+ SilcStreamHeader h = stream;
+ return h->ops->write(stream, data, data_len);
+}
-/****f* silcutil/
SilcStreamAPI/
silc_stream_close
+/****f* silcutil/silc_stream_close
*
* SYNOPSIS
*
*
* SYNOPSIS
*
@@
-211,9
+230,14
@@
int silc_stream_write(SilcStream stream, const unsigned char *data,
* callback may be called with an error status.
*
***/
* callback may be called with an error status.
*
***/
-SilcBool silc_stream_close(SilcStream stream);
+static inline
+SilcBool silc_stream_close(SilcStream stream)
+{
+ SilcStreamHeader h = stream;
+ return h->ops->close(stream);
+}
-/****f* silcutil/
SilcStreamAPI/
silc_stream_destroy
+/****f* silcutil/silc_stream_destroy
*
* SYNOPSIS
*
*
* SYNOPSIS
*
@@
-228,9
+252,14
@@
SilcBool silc_stream_close(SilcStream stream);
* function will call it.
*
***/
* function will call it.
*
***/
-void silc_stream_destroy(SilcStream stream);
+static inline
+void silc_stream_destroy(SilcStream stream)
+{
+ SilcStreamHeader h = stream;
+ h->ops->destroy(stream);
+}
-/****f* silcutil/
SilcStreamAPI/
silc_stream_set_notifier
+/****f* silcutil/silc_stream_set_notifier
*
* SYNOPSIS
*
*
* SYNOPSIS
*
@@
-255,10
+284,15
@@
void silc_stream_destroy(SilcStream stream);
* Returns TRUE on success. The `schedule' must always be non-NULL.
*
***/
* Returns TRUE on success. The `schedule' must always be non-NULL.
*
***/
+static inline
SilcBool silc_stream_set_notifier(SilcStream stream, SilcSchedule schedule,
SilcBool silc_stream_set_notifier(SilcStream stream, SilcSchedule schedule,
- SilcStreamNotifier notifier, void *context);
+ SilcStreamNotifier notifier, void *context)
+{
+ SilcStreamHeader h = stream;
+ return h->ops->notifier(stream, schedule, notifier, context);
+}
-/****f* silcutil/
SilcStreamAPI/
silc_stream_get_schedule
+/****f* silcutil/silc_stream_get_schedule
*
* SYNOPSIS
*
*
* SYNOPSIS
*
@@
-270,6
+304,11
@@
SilcBool silc_stream_set_notifier(SilcStream stream, SilcSchedule schedule,
* NULL if one has not been set for the `stream'.
*
***/
* NULL if one has not been set for the `stream'.
*
***/
-SilcSchedule silc_stream_get_schedule(SilcStream stream);
+static inline
+SilcSchedule silc_stream_get_schedule(SilcStream stream)
+{
+ SilcStreamHeader h = stream;
+ return h->ops->get_schedule(stream);
+}
#endif /* SILCSTREAM_H */
#endif /* SILCSTREAM_H */