fix read/write to scope

This commit is contained in:
Iris Lightshard 2021-07-28 23:19:17 -06:00
parent 41c96c5127
commit b457e6ea2f
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398

9
xrxs.c
View file

@ -160,6 +160,7 @@ void write_scope(Req* r) {
s_putc(scope, *c++);
}
s_terminate(scope);
fprintf(stderr, scope->base);
if (u != nil && u->realm != nil && u->realm->universe != nil) {
u->scope = malloc(r->ifcall.count);
@ -182,6 +183,7 @@ void xrxs_write(Req* r) {
break;
case SCOPE:
write_scope(r);
break;
default:
respond(r, nil);
break;
@ -398,13 +400,14 @@ void read_scope(Req* r) {
Universe* universe;
Atom* a;
char key[16] = {0};
char* c = u->scope;
char* c;
if (u == nil || u->scope == nil || u->realm == nil) {
respond(r, nil);
return;
}
c = u->scope;
universe = u->realm->universe;
if (universe == nil) {
respond(r, ENOUNI);
@ -421,6 +424,8 @@ void read_scope(Req* r) {
s_putc(data, '\n');
}
*key = '\0';
if (*c == '\0')
break;
c++;
}
@ -435,6 +440,7 @@ void read_random(Req* r) {
srand(rand());
sprintf(buf, "%d\n", rand() % 100);
readstr(r, buf);
respond(r, nil);
}
void read_grandom(Req* r) {
@ -478,6 +484,7 @@ void read_grandom(Req* r) {
sprintf(buf, "%d\n", u->random);
u->random = -1;
readstr(r, buf);
respond(r, nil);
}
void xrxs_read(Req* r) {