Skip to content

Commit 5a72194

Browse files
committed
further links added to api doc
1 parent cef6bef commit 5a72194

File tree

1 file changed

+43
-27
lines changed

1 file changed

+43
-27
lines changed

docs/interfaces/c-client-for-q.md

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -317,22 +317,22 @@ To create atom values the following functions are available. Function `ka` creat
317317

318318
purpose | call
319319
-----------------------|-----------------
320-
Create an atom of type | `K ka(I);`
321-
Create a boolean | `K kb(I);`
322-
Create a guid | `K ku(U);`
323-
Create a byte | `K kg(I);`
324-
Create a short | `K kh(I);`
325-
Create an int | `K ki(I);`
326-
Create a long | `K kj(J);`
327-
Create a real | `K ke(F);`
328-
Create a float | `K kf(F);`
329-
Create a char | `K kc(I);`
330-
Create a symbol | `K ks(S);`
331-
Create a timestamp | `K ktj(-KP,J);`
332-
Create a time | `K kt(I);`
333-
Create a date | `K kd(I);`
334-
Create a timespan | `K ktj(-KN,J);`
335-
Create a datetime | `K kz(F);`
320+
Create an atom of type | [`K ka(I);`](capiref.md#ka-create-atom)
321+
Create a boolean | [`K kb(I);`](capiref.md#kb-create-boolean)
322+
Create a guid | [`K ku(U);`](capiref.md#ku-create-guid)
323+
Create a byte | [`K kg(I);`](capiref.md#kg-create-byte)
324+
Create a short | [`K kh(I);`](capiref.md#kh-create-short)
325+
Create an int | [`K ki(I);`](capiref.md#ki-create-int)
326+
Create a long | [`K kj(J);`](capiref.md#kj-create-long)
327+
Create a real | [`K ke(F);`](capiref.md#ke-create-real)
328+
Create a float | [`K kf(F);`](capiref.md#kf-create-float)
329+
Create a char | [`K kc(I);`](capiref.md#kc-create-char)
330+
Create a symbol | [`K ks(S);`](capiref.md#ks-create-symbol)
331+
Create a timestamp | [`K ktj(-KP,J);`](capiref.md#ktj-create-timestamp)
332+
Create a time | [`K kt(I);`](capiref.md#kt-create-time)
333+
Create a date | [`K kd(I);`](capiref.md#kd-create-date)
334+
Create a timespan | [`K ktj(-KN,J);`](capiref.md#ktj-create-timespan)
335+
Create a datetime | [`K kz(F);`](capiref.md#kz-create-datetime)
336336

337337
An example of creating an atom:
338338

@@ -474,12 +474,12 @@ The following example shows the steps to create a keyed table:
474474
```c
475475
K maketable(){
476476
K c,d,e,v,key,val;
477-
/* table of primary keys */
477+
/* table of primary keys */
478478
c=ktn(KS,1);kS(c)[0]=ss("sid");
479479
d=ktn(KS,3);kS(d)[0]=ss("ibm");kS(d)[1]=ss("gte");kS(d)[2]=ss("kvm");
480480
v=knk(1,d);
481481
key=xT(xD(c,v));
482-
/* table of values */
482+
/* table of values */
483483
c=ktn(KS,2);kS(c)[0]=ss("amt");kS(c)[1]=ss("date");
484484
d=ktn(KI,3);kI(d)[0]=100;kI(d)[1]=300;kI(d)[2]=200;
485485
e=ktn(KD,3);kI(e)[0]=2;kI(e)[1]=3;kI(e)[2]=5;
@@ -511,7 +511,7 @@ else
511511
512512
## Connecting to a q server
513513
514-
We use the `int khpu(host, port,username)` function to connect to a q server.
514+
We use the [`int khpu(host, port,username)`](capiref.md#khpu-connect-no-timeout) function to connect to a q server.
515515
Note you _must_ call `khpu` before generating any q data, and the very first call to `khpu` must not be concurrent to other `khpu` calls.
516516
To initialize memory without making a connection, use `khp("",-1);`
517517
@@ -536,7 +536,7 @@ Return values for `khp`/`khpu`/`khpun` are:
536536

537537
Note that with the release of `c.o` with V2.6, `c.o` now tracks the connection type (pre-V2.6, or V2.6+). Hence to close the connection you must call [`kclose`](capiref.md#kclose-disconnect) (instead of `close` or `closeSocket`) – this will clean up the connection tracking and close the socket.
538538

539-
The `k` function is used to send messages over the connection. If a positive handle is used then the call is synchronous, otherwise it is an asynchronous call.
539+
The [`k`](capiref.md#k-evaluate) function is used to send messages over the connection. If a positive handle is used then the call is synchronous, otherwise it is an asynchronous call.
540540

541541
```c
542542
// Connect to a q server on the localhost port 1234.
@@ -577,7 +577,11 @@ There’s an additional return value for TLS connections, `-3`, which indicates
577577
578578
```c
579579
extern K sslInfo(K x); // returns an error if init fails, or a dict of settings similar to -26!x
580-
if(handle==-3){K x=ee(sslInfo((K)0));printf("Init error %s\n",xt==-128?x->s:"unknown");r0(x);}
580+
if(handle==-3){
581+
K x=ee(sslInfo((K)0));
582+
printf("Init error %s\n",xt==-128?x->s:"unknown");
583+
r0(x);
584+
}
581585
```
582586

583587
Prior to 4.1t 2023.11.10, SSL/TLS connections can be used from the initialization thread only, i.e. the thread which first calls any `khp` function since the start of the application. It can now be used for one-shot synchronous requests.
@@ -618,7 +622,6 @@ if(c>0) sst(c,30000,45000); // timeout sends with 30s, receives with 45s
618622
```
619623

620624

621-
622625
## Bulk transfers
623626

624627
A kdb+tick feed handler can send one record at a time, like this
@@ -715,7 +718,7 @@ sd0(d);
715718
sd0x(d,1);
716719
```
717720

718-
Each of the above calls removes the callback on `d` and calls `kclose(d)`. `sd0x(I d,I f)` was introduced in V3.0 2013.04.04: its second argument indicates whether to call `kclose(d)`.
721+
Each of the above calls removes the callback on `d` and calls `kclose(d)`. [`sd0x(I d,I f)`](capiref.md#sd0x-remove-callback-conditional) was introduced in V3.0 2013.04.04: its second argument indicates whether to call `kclose(d)`.
719722

720723
On Linux, `eventfd` can be used with `sd1` and `sd0`. Given a file efd.c
721724

@@ -797,22 +800,35 @@ q).[{x+y};(1 2;3 4)]
797800
4 6
798801
```
799802

800-
The dynamic link, `K dl(V* f, I n)`, function takes a C function that would take _n_ K objects as arguments and return a new K object, and returns a q function.
803+
The dynamic link, [`K dl(V* f, I n)`](capiref.md#dl-dynamic-link), function takes a C function that would take _n_ K objects as arguments and return a new K object, and returns a q function.
801804
It is useful, for example, to expose more than one function from an extension module.
802805

803806
```c
804807
#include "k.h"
805808
Z K1(f1){R r1(x);}
806809
Z K2(f2){R r1(y);}
807-
K1(lib){K y=ktn(0,2);x=ktn(KS,2);xS[0]=ss("f1");xS[1]=ss("f2");
808-
kK(y)[0]=dl(f1,1);kK(y)[1]=dl(f2,2);R xD(x,y);}
810+
K1(lib){
811+
K y=ktn(0,2);
812+
x=ktn(KS,2);
813+
xS[0]=ss("f1");
814+
xS[1]=ss("f2");
815+
kK(y)[0]=dl(f1,1);
816+
kK(y)[1]=dl(f2,2);
817+
R xD(x,y);
818+
}
809819
```
810820
811821
Alternatively, for simpler editing of your lib API:
812822
813823
```c
814824
#define sdl(f,n) (js(&x,ss(#f)),jk(&y,dl(f,n)))
815-
K1(lib){K y=ktn(0,0);x=ktn(KS,0);sdl(f1,1);sdl(f2,2);R xD(x,y);}
825+
K1(lib){
826+
K y=ktn(0,0);
827+
x=ktn(KS,0);
828+
sdl(f1,1);
829+
sdl(f2,2);
830+
R xD(x,y);
831+
}
816832
```
817833

818834
With the above compiled into `lib.so`:

0 commit comments

Comments
 (0)