⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 streams.c

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 C
📖 第 1 页 / 共 2 页
字号:
#line 119 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#include "mal_config.h"#include <mal.h>#include "streams.h"#include <stdio.h>/*int io_stdin (Stream *ret) { *(stream**)ret = GDKin;  return GDK_SUCCEED; }int io_stdout(Stream *ret) { *(stream**)ret = GDKout; return GDK_SUCCEED; }int io_stderr(Stream *ret) { *(stream**)ret = GDKerr; return GDK_SUCCEED; }*/#ifdef WIN32#ifndef LIBSTREAMS#define streams_export extern __declspec(dllimport)#else#define streams_export extern __declspec(dllexport)#endif#else#define streams_export extern#endifstreams_export int stream_write_string(Stream *S, str data);streams_export int stream_writeInt_wrap(Stream *S, int *data);streams_export int stream_readInt_wrap(int *data, Stream *S);streams_export int stream_read_string(str *res, Stream *S);streams_export int stream_flush_stream(Stream *S);streams_export int stream_close_stream(Stream *S);streams_export int open_block_stream(Stream *S, Stream *is);streams_export int bstream_create_wrap(Bstream *BS, Stream *S, int *bufsize);streams_export int bstream_destroy_wrap(Bstream *BS);streams_export int bstream_read_wrap(int *res, Bstream *BS, int *size);streams_export str stream_write_stringwrap(int *ret, Stream *S, str *data);streams_export str stream_writeIntwrap(int *ret, Stream *S, int *data);streams_export str stream_readIntwrap(int *ret, Stream *S);streams_export str stream_read_stringwrap(str *res, Stream *s);streams_export str stream_flush_streamwrap(int *ret, Stream *s);streams_export str stream_close_streamwrap(int *ret, Stream *s);streams_export str open_block_streamwrap(Stream *S, Stream *is);streams_export str bstream_create_wrapwrap(Bstream *Bs, Stream *S, int *bufsize);streams_export str bstream_destroy_wrapwrap(int *ret, Bstream *BS);streams_export str bstream_read_wrapwrap(int *res, Bstream *BS, int *size);streams_export str stream_readIntwrap(int *ret, Stream *S);streams_export str stream_read_stringwrap(str *res, Stream *s);#line 181 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 164 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_open_rstream(Stream *S, str filename);intstream_open_rstream(Stream *S, str filename){	stream *s;	if ((s = open_rstream( filename )) == NULL || stream_errnr(s)) {		if (s)			stream_destroy(s);		GDKerror("stream_open: could not open file '%s'\n", filename);		return GDK_FAIL;	} else {		*(stream**)S = s;		return GDK_SUCCEED;	}}#line 181 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 164 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_open_wstream(Stream *S, str filename);intstream_open_wstream(Stream *S, str filename){	stream *s;	if ((s = open_wstream( filename )) == NULL || stream_errnr(s)) {		if (s)			stream_destroy(s);		GDKerror("stream_open: could not open file '%s'\n", filename);		return GDK_FAIL;	} else {		*(stream**)S = s;		return GDK_SUCCEED;	}}#line 182 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 164 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_open_rastream(Stream *S, str filename);intstream_open_rastream(Stream *S, str filename){	stream *s;	if ((s = open_rastream( filename )) == NULL || stream_errnr(s)) {		if (s)			stream_destroy(s);		GDKerror("stream_open: could not open file '%s'\n", filename);		return GDK_FAIL;	} else {		*(stream**)S = s;		return GDK_SUCCEED;	}}#line 183 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 164 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_open_wastream(Stream *S, str filename);intstream_open_wastream(Stream *S, str filename){	stream *s;	if ((s = open_wastream( filename )) == NULL || stream_errnr(s)) {		if (s)			stream_destroy(s);		GDKerror("stream_open: could not open file '%s'\n", filename);		return GDK_FAIL;	} else {		*(stream**)S = s;		return GDK_SUCCEED;	}}#line 184 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 195 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 187 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_stream_rstream(Stream *Sout, Stream *Sin);intstream_stream_rstream(Stream *Sout, Stream *Sin){	*(stream**)Sout = stream_rstream(*(stream**)Sin);	return GDK_SUCCEED;}#line 195 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 187 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_stream_wstream(Stream *Sout, Stream *Sin);intstream_stream_wstream(Stream *Sout, Stream *Sin){	*(stream**)Sout = stream_wstream(*(stream**)Sin);	return GDK_SUCCEED;}#line 196 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 216 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 199 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_socket_rstream(Stream *S, int *socket, str name);intstream_socket_rstream(Stream *S, int *socket, str name){	stream *s;	if ((s = socket_rstream( *socket, name )) == NULL || stream_errnr(s)) {		if (s)			stream_destroy(s);		GDKerror("Could not open socket %s\n", name );		return GDK_FAIL;	} else {		*(stream**)S = s;		return GDK_SUCCEED;	}}#line 216 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 199 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_socket_wstream(Stream *S, int *socket, str name);intstream_socket_wstream(Stream *S, int *socket, str name){	stream *s;	if ((s = socket_wstream( *socket, name )) == NULL || stream_errnr(s)) {		if (s)			stream_destroy(s);		GDKerror("Could not open socket %s\n", name );		return GDK_FAIL;	} else {		*(stream**)S = s;		return GDK_SUCCEED;	}}#line 217 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 199 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_socket_rastream(Stream *S, int *socket, str name);intstream_socket_rastream(Stream *S, int *socket, str name){	stream *s;	if ((s = socket_rastream( *socket, name )) == NULL || stream_errnr(s)) {		if (s)			stream_destroy(s);		GDKerror("Could not open socket %s\n", name );		return GDK_FAIL;	} else {		*(stream**)S = s;		return GDK_SUCCEED;	}}#line 218 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 199 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"streams_export int stream_socket_wastream(Stream *S, int *socket, str name);intstream_socket_wastream(Stream *S, int *socket, str name){	stream *s;	if ((s = socket_wastream( *socket, name )) == NULL || stream_errnr(s)) {		if (s)			stream_destroy(s);		GDKerror("Could not open socket %s\n", name );		return GDK_FAIL;	} else {		*(stream**)S = s;		return GDK_SUCCEED;	}}#line 219 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"#line 222 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/atoms/streams.mx"intstream_write_string(Stream *S, str data){	stream *s = *(stream **) S;	return stream_write(s, data, 1, strlen(data)) < 0 ? GDK_FAIL : GDK_SUCCEED;}intstream_writeInt_wrap(Stream *S, int *data){	stream *s = *(stream **) S;	return stream_writeInt(s, *data) ? GDK_SUCCEED : GDK_FAIL;}intstream_readInt_wrap(int *data, Stream *S){	stream *s = *(stream **) S;	return stream_readInt(s, data) ? GDK_SUCCEED : GDK_FAIL;}#define CHUNK (64*1024)int

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -