More files.

More files.
This commit is contained in:
rsc 2004-03-25 23:08:53 +00:00
parent a27e20579c
commit 70bcc7804e
5 changed files with 1561 additions and 0 deletions

17
include/ar.h Normal file
View file

@ -0,0 +1,17 @@
#define ARMAG "!<arch>\n"
#define SARMAG 8
#define ARFMAG "`\n"
#define SARNAME 16
struct ar_hdr
{
char name[SARNAME];
char date[12];
char uid[6];
char gid[6];
char mode[8];
char size[10];
char fmag[2];
};
#define SAR_HDR (SARNAME+44)

1447
src/cmd/9sed.c Normal file

File diff suppressed because it is too large Load diff

13
src/lib9/get9root.c Normal file
View file

@ -0,0 +1,13 @@
#include <u.h>
#include <libc.h>
char*
get9root(void)
{
char *s;
if((s = getenv("PLAN9")) != 0)
return s;
return "/usr/local/plan9";
}

44
src/lib9/unsharp.c Normal file
View file

@ -0,0 +1,44 @@
#include <u.h>
#include <libc.h>
/*
* I don't want too many of these,
* but the ones we have are just too useful.
*/
static struct {
char *old;
char *new;
} replace[] = {
"#9", nil, /* must be first */
"#d", "/dev/fd",
};
char*
unsharp(char *old)
{
char *new;
int i, olen, nlen, len;
if(replace[0].new == nil)
replace[0].new = get9root();
for(i=0; i<nelem(replace); i++){
if(!replace[i].new)
continue;
olen = strlen(replace[i].old);
if(strncmp(old, replace[i].old, olen) != 0
|| (old[olen] != '\0' && old[olen] != '/'))
continue;
nlen = strlen(replace[i].new);
len = strlen(old)+nlen-olen;
new = malloc(len+1);
if(new == nil)
/* Most callers won't check the return value... */
sysfatal("out of memory translating %s to %s%s", old, replace[i].new, old+olen);
strcpy(new, replace[i].new);
strcpy(new+nlen, old+olen);
assert(strlen(new) == len);
return new;
}
return old;
}

40
src/libventi/parsescore.c Normal file
View file

@ -0,0 +1,40 @@
#include <u.h>
#include <libc.h>
#include <venti.h>
int
vtparsescore(char *s, char **prefix, uchar score[VtScoreSize])
{
int i, c;
char *buf, *colon;
if((colon = strchr(s, ':')) != nil)
buf = colon+1;
else
buf = s;
if(strlen(buf) != 2*VtScoreSize)
return -1;
memset(score, 0, VtScoreSize);
for(i=0; i<2*VtScoreSize; i++){
if(buf[i] >= '0' && buf[i] <= '9')
c = buf[i] - '0';
else if(buf[i] >= 'a' && buf[i] <= 'z')
c = buf[i] - 'a' + 10;
else if(buf[i] >= 'A' && buf[i] <= 'Z')
c = buf[i] - 'A' + 10;
else
return -1;
if((i & 1) == 0)
c <<= 4;
score[i>>1] |= c;
}
if(colon){
*colon = 0;
*prefix = s;
}else
*prefix = nil;
return 0;
}