libk  Diff

Differences From Artifact [43535adcf4]:

To Artifact [18dd12a221]:


     1      1   #ifndef KIstr
     2      2   #define KIstr
     3      3   
     4         -#include <k/mem.h>
            4  +#include <k/type.h>
     5      5   
     6      6   #ifdef __cplusplus
     7      7   extern "C" {
     8      8   #endif
     9      9   
    10         -typedef struct kstr {
    11         -	sz size;
    12         -	kmptr ptr;
    13         -} kstr;
    14         -
    15     10   typedef struct ksraw {
    16     11   	sz size;
    17     12   	const char* ptr;
    18     13   } ksraw;
    19     14   
    20     15   typedef struct ksmut {
    21     16   	sz size;
    22     17   	char* ptr;
    23     18   } ksmut;
           19  +
           20  +sz kssz(const char* str, sz max);
           21  +
           22  +#include <k/mem.h>
           23  +
           24  +typedef struct kstr {
           25  +	sz size;
           26  +	kmptr ptr;
           27  +} kstr;
           28  +
           29  +#include <k/io.h>
    24     30   
    25     31   #include <k/internal.egroup.h>
    26     32   typedef enum kscond {
    27     33   	kscond_ok = kscond_id,
           34  +	kscond_partial,
    28     35   	kscond_fail,
    29     36   	kscond_unimplemented,
    30     37   	kscond_nonnumeric,
    31     38   	kscond_no_room,
    32     39   	kscond_null,
    33     40   } kscond;
    34     41   
................................................................................
    44     51   
    45     52   	ksconv_partial = 1 <<  7,
    46     53   	ksconv_nopfx   = 1 <<  8,
    47     54   	ksconv_endh    = 1 <<  9,
    48     55   	ksconv_endl    = 1 << 10,
    49     56   };
    50     57   
           58  +
           59  +typedef struct ksbuf {
           60  +	sz run;
           61  +	kiochan channel;
           62  +	char* cur;
           63  +	char buf [];
           64  +} ksbuf;
           65  +
           66  +/* functions */
           67  +
    51     68   kscond ks_to_int(ksraw str,
    52     69   		enum ksconv mode,
    53     70   		u8* dest, sz size);
    54     71   
    55     72   kscond ks_of_int(u8* number, sz size,
    56     73   		enum ksconv mode,
    57     74   		char* bufstart, sz bufsize);
    58     75   
    59     76   kscond kscp(ksraw str, ksmut dest, sz* len);
           77  +
           78  +ksbuf* ksbufmk(void* where, kiochan channel, sz run);
           79  +
           80  +#include <k/core.h>
           81  +
           82  +kcond ksbufput(ksbuf*, ksraw);
           83  +
           84  +kiocond ksbufflush(ksbuf*);
    60     85   
    61     86   #ifdef __cplusplus
    62     87   }
    63     88   #endif
    64     89   
    65     90   #endif