#ifndef KIstr
#define KIstr
#include <k/type.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct ksraw {
sz size;
const char* ptr;
} ksraw;
#define Ksraw(str) ((ksraw){sizeof(str),str})
typedef struct ksmut {
sz size;
char* ptr;
} ksmut;
sz kssz(const char* str, sz max);
#include <k/mem.h>
typedef struct kstr {
sz size;
kmptr ptr;
} kstr;
#include <k/io.h>
#include <k/internal.egroup.h>
typedef enum kscond {
kscond_ok = kscond_id,
kscond_partial,
kscond_fail,
kscond_unimplemented,
kscond_nonnumeric,
kscond_no_room,
kscond_null,
} kscond;
enum ksconv {
ksconv_default = 0,
ksconv_raw = 1,
ksconv_bin = 2,
ksconv_oct = 8,
ksconv_dec = 10,
ksconv_hex = 16,
ksconv_b32 = 32,
ksconv_partial = 1 << 7,
ksconv_nopfx = 1 << 8,
ksconv_endh = 1 << 9,
ksconv_endl = 1 << 10,
};
typedef struct ksbuf {
sz run;
kiochan channel;
char* cur;
char buf [];
} ksbuf;
/* functions */
kscond ks_to_int(ksraw str,
enum ksconv mode,
u8* dest, sz size);
kscond ks_of_int(u8* number, sz size,
enum ksconv mode,
char* bufstart, sz bufsize);
kscond kscp(ksraw str, ksmut dest, sz* len);
ksbuf* ksbufmk(void* where, kiochan channel, sz run);
#include <k/core.h>
kcond ksbufput(ksbuf*, ksraw);
kiocond ksbufflush(ksbuf*);
kcond ksbufwrite(ksbuf*, const char** array);
kcond ksemitc(const char** array, sz bufsz, kiochan channel);
#ifdef __cplusplus
}
#endif
#endif