libk  Artifact [0c79e2a160]

Artifact 0c79e2a160010584dee791cac4a8d72feebc095da16279d46693b491cacc8744:


#ifndef KIstr
#define KIstr

#include <k/mem.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct kstr {
	sz size;
	kmptr ptr;
} kstr;

typedef struct ksraw {
	sz size;
	const char* ptr;
} ksraw;

typedef struct ksmut {
	sz size;
	char* ptr;
} ksmut;

#include <k/internal.egroup.h>
typedef enum kscond {
	kscond_ok = kscond_id,
	kscond_fail,
	kscond_unimplemented,
	kscond_nonnumeric,
} 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,
};

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);

#ifdef __cplusplus
}
#endif

#endif