all repos — kuro @ 6fa747864efcb84863d09a9a937315e748a9f040

multiwindow text editor thing for plan9 with simple client VM and 9p interface

client.c (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "dat.h"
#include "fns.h"

static char mtpt[256] = {0};

void kuro9p_set_mtpt(char* path) {
  strcpy(mtpt, path);
}

void kuro9p_write(char* path, char* data, int len) {
  int fd;
  char fullpath[256];
  strcpy(fullpath, mtpt);
  strcat(fullpath, path);

  fd = open(fullpath, OWRITE);
  if (fd >= 0) {
    write(fd, data, len);
    close(fd);
  }
}

char* kuro9p_read(char* path, char* buf, int len) {
  int fd;
  char fullpath[256];
  strcpy(fullpath, mtpt);
  strcat(fullpath, path);

  fd = open(fullpath, OREAD);
  if (fd >= 0) {
    read(fd, buf, len);
    close(fd);
  }
  return buf;
}