Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@ This repository is a C client for [SpringQL](https://github.com/SpringQL/SpringQ

You can link your application with the shared library and run SpringQL in embedded mode.

### Getting Started
## Documentation

#### APIs

Take a short look to [springql.h](https://github.com/SpringQL/SpringQL-client-c/blob/main/springql.h), which declares all of C APIs and types to use from your application.

#### Installation

All you need to do are:

- Download latest header file and shared library from [release page](https://github.com/SpringQL/SpringQL-client-c/releases).
- Put `springql.h` to somewhere where your compiler recognize as an include path.
- Put `libspringql_client.{so,dylib}` to somewhere where your compiler recognize as a library path (one in `$LD_LIBRARY_PATH` is a good option).

#### Example application

See [`c_example/`](https://github.com/SpringQL/SpringQL-client-c/tree/main/c_example) for how to write and build a SpringQL embedded application.
Read <https://SpringQL.github.io/> for installation guide, tutorials, and references.

## Versioning

Expand Down
47 changes: 3 additions & 44 deletions c_example/README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,8 @@
## Writing an SpringQL C application (embedded mode)
## Example C applications

See [`example.c`](example.c)
Most of applications under this directory are introduced in a [documentation page](https://springql.github.io/get-started/write-basic-apps).

## Building

You need to put `springql.h` to an include path and `libspringql_client.{so,dylib}` to a library path first. Then,

```bash
gcc example.c -lspringql_client -o run_example
```

If you haven't downloaded the header and shared library files, then,

```bash
(cd ..; cargo build) # build shared library
gcc example.c -lspringql_client -o run_example -I.. -L../target/debug
```

You can also use CMake here.

```bash
(cd ..; cargo build) # build shared library
cmake . && make
```

## Running the sample application

First, you need to run a source server to generate trade data.
You may need to install `nc` (netcat) to your system.

```bash
python print_trade.py | nc -l 19876 # running a source server on TCP port 19876
```

Finally the example app runs.

```bash
./run_example

[row#0] ts=2021-11-23 05:38:32.589299000 amount=200
[row#1] ts=2021-11-23 05:38:32.590267000 amount=100
[row#2] ts=2021-11-23 05:38:32.590284000 amount=900
[row#3] ts=2021-11-23 05:38:32.590295000 amount=500
[row#4] ts=2021-11-23 05:38:32.590305000 amount=100
```
Read it for building, running the apps.

## License

Expand Down
5 changes: 5 additions & 0 deletions c_example/trade_projection/trade_projection.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
// This file is part of https://github.com/SpringQL/SpringQL-client-c which is licensed under MIT OR Apache-2.0. See file LICENSE-MIT or LICENSE-APACHE for full license details.

// Usage:
//
// $ python print_trade.py | nc -l 19876 # running a source server on TCP port 19876
// $ ./a.out

#include <springql.h>
#include <assert.h>
#include <string.h>
Expand Down