all repos — kuro @ 5040da40fc3dfc7f26527ba52a866e960eb5f83a

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

util.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
#include "dat.h"
#include "fns.h"

int strequ(char* s1, char* s2) {
  return strcmp(s1, s2) == 0;
}

char* strcsw(char* s, char a, char b) {
  int i = 0;
  char c;
  while ((c = s[i])) {
    s[i++] = c == a ? b : c;
  }
  return s;
}

char* uvlong_to_hex(uvlong input, char* buf) {
  sprintf(buf, "%08x\0", input);
  return buf;
}

int ensure(char* path) {
    int f = create(path, OREAD, DMDIR | 0777);
    if (f < 0) {
      return 0;
    } else {
      close(f);
      return 1;
    }
}