content stringlengths 263 5.24M | pred_label stringclasses 1
value | pred_score_pos float64 0.6 1 |
|---|---|---|
/***** tl_spin: tl_cache.c *****/
/*
* This file is part of the public release of Spin. It is subject to the
* terms in the LICENSE file that is included in this source directory.
* Tool documentation is available at http://spinroot.com
*
* Based on the translation algorithm by Gerth, Peled, Vardi, and Wolper,
*... | __label__POS | 0.621308 |
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <mp.h>
#include <libsec.h>
enum {
TLSFinishedLen = 12,
HFinished = 20,
};
static int
finished(int hand, int isclient)
{
int i, n;
uchar buf[500], buf2[500];
buf[0] = HFinished;
buf[1] = TLSFinishedLen>>16;
buf[2] = TLSFinishedLen>>8;
buf[3] = TLSFin... | __label__POS | 0.696984 |
#include <u.h>
#include <libc.h>
#define VLONG_MAX ((vlong)~(((uvlong)1)<<63))
#define VLONG_MIN ((vlong)(((uvlong)1)<<63))
vlong
strtoll(const char *nptr, char **endptr, int base)
{
char *p;
vlong n, nn, m;
int c, ovfl, v, neg, ndig;
p = (char*)nptr;
neg = 0;
n = 0;
ndig = 0;
ovfl = 0;
/*
* White space
*/... | __label__POS | 0.743866 |
#include "os.h"
#include <libsec.h>
/* rfc2104 */
static DigestState*
hmac_x(uchar *p, ulong len, uchar *key, ulong klen, uchar *digest, DigestState *s,
DigestState*(*x)(uchar*, ulong, uchar*, DigestState*), int xlen)
{
int i;
uchar pad[65], innerdigest[256];
if(xlen > sizeof(innerdigest))
return nil;
if(klen... | __label__POS | 0.67602 |
#include "os.h"
#include <mp.h>
#include <libsec.h>
// Miller-Rabin probabilistic primality testing
// Knuth (1981) Seminumerical Algorithms, p.379
// Menezes et al () Handbook, p.39
// 0 if composite; 1 if almost surely prime, Pr(err)<1/4**nrep
int
probably_prime(mpint *n, int nrep)
{
int j, k, rep, nbits, isprime =... | __label__POS | 0.904553 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include "snap.h"
void
panic(char *s)
{
fprint(2, "%s\n", s);
abort();
exits(s);
}
static Proc*
findpid(Proc *plist, long pid)
{
while(plist) {
if(plist->pid == pid)
break;
plist = plist->link;
}
return plist;
}
Page*
findpage(Proc *plist, long pid, int ... | __label__POS | 0.787165 |
#include "os.h"
#include <mp.h>
#include <libsec.h>
typedef struct State{
QLock lock;
int seeded;
uvlong seed;
DES3state des3;
} State;
static State x917state;
static void
X917(uchar *rand, int nrand)
{
int i, m, n8;
uvlong I, x;
/* 1. Compute intermediate value I = Ek(time). */
I = nsec();
triple_block_... | __label__POS | 0.601398 |
#include "os.h"
#include <mp.h>
// extended euclid
//
// For a and b it solves, d = gcd(a,b) and finds x and y s.t.
// ax + by = d
//
// Handbook of Applied Cryptography, Menezes et al, 1997, pg 67
void
mpeuclid(mpint *a, mpint *b, mpint *d, mpint *x, mpint *y)
{
mpint *tmp, *x0, *x1, *x2, *y0, *y1, *y2, *q, *r;
i... | __label__POS | 0.754288 |
#include "os.h"
#include <mp.h>
#include "dat.h"
static mpdigit _mptwodata[1] = { 2 };
static mpint _mptwo =
{
1,
1,
1,
_mptwodata,
MPstatic
};
mpint *mptwo = &_mptwo;
static mpdigit _mponedata[1] = { 1 };
static mpint _mpone =
{
1,
1,
1,
_mponedata,
MPstatic
};
mpint *mpone = &_mpone;
static mpdigit _mpze... | __label__POS | 0.941159 |
#include "os.h"
#include <mp.h>
#include <libsec.h>
#include "dat.h"
static int
to64(mpint *b, char *buf, int len)
{
uchar *p;
int n, rv;
p = nil;
n = mptobe(b, nil, 0, &p);
if(n < 0)
return -1;
rv = enc64(buf, len, p, n);
free(p);
return rv;
}
static int
to32(mpint *b, char *buf, int len)
{
uchar *p;
in... | __label__POS | 0.907585 |
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <thread.h>
#include <mouse.h>
#include <keyboard.h>
#include <frame.h>
#include "flayer.h"
#include "samterm.h"
int cursorfd;
int plumbfd = -1;
int input;
int got;
int block;
int kbdc;
int resized;
uchar *hostp;
uchar *hoststop;
uchar *plumbbase;
uchar *plumb... | __label__POS | 0.639078 |
#include "os.h"
#include <mp.h>
#include "dat.h"
#define LO(x) ((x) & ((1<<(Dbits/2))-1))
#define HI(x) ((x) >> (Dbits/2))
static void
mpdigmul(mpdigit a, mpdigit b, mpdigit *p)
{
mpdigit x, ah, al, bh, bl, p1, p2, p3, p4;
int carry;
// half digits
ah = HI(a);
al = LO(a);
bh = HI(b);
bl = LO(b);
// partial ... | __label__POS | 0.791357 |
#include "os.h"
#include <mp.h>
#include <libsec.h>
// chinese remainder theorem
//
// handbook of applied cryptography, menezes et al, 1997, pp 610 - 613
struct CRTpre
{
int n; // number of moduli
mpint **m; // pointer to moduli
mpint **c; // precomputed coefficients
mpint **p; // precomputed products
mpint... | __label__POS | 0.72987 |
#include <u.h>
#include <libc.h>
#include <draw.h>
static char channames[] = "rgbkamx";
char*
chantostr(char *buf, ulong cc)
{
ulong c, rc;
char *p;
if(chantodepth(cc) == 0)
return nil;
/* reverse the channel descriptor so we can easily generate the string in the right order */
rc = 0;
for(c=cc; c; c>>=8){
... | __label__POS | 0.905406 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include "modem.h"
int
initfaxmodem(Modem *m)
{
m->fax = 1;
m->phase = 'A';
m->valid = 0;
return Eok;
}
static int
parameters(long a[], char *s)
{
char *p;
int i;
i = 0;
if((p = strchr(s, ':')) == 0)
return 0;
p++;
while(s = strchr(p, ',')){
a[i++] = ... | __label__POS | 0.985523 |
#include "u.h"
#include "lib.h"
#include "dat.h"
#include "fns.h"
#include "error.h"
#include "draw.h"
#include "memdraw.h"
#include "screen.h"
int mousequeue = 1;
Mouseinfo mouse;
Cursorinfo cursor;
static int mousechanged(void*);
enum{
Qdir,
Qcursor,
Qmouse
};
Dirtab mousedir[]={
".", {Qdir, 0, QTDIR}, 0, ... | __label__POS | 0.664997 |
/*
* Linux and BSD
*/
#include <sys/ioctl.h>
#ifdef __linux__
#include <linux/soundcard.h>
#else
#include <sys/soundcard.h>
#endif
#include "u.h"
#include "lib.h"
#include "dat.h"
#include "fns.h"
#include "error.h"
#include "devaudio.h"
enum
{
Channels = 2,
Rate = 44100,
Bits = 16,
Bigendian = 1,
};
static int... | __label__POS | 0.830161 |
#include "u.h"
#include "lib.h"
#include "dat.h"
#include "fns.h"
#include "error.h"
#include "user.h"
#undef open
#undef mount
#undef read
#undef write
#undef seek
#undef stat
#undef wstat
#undef remove
#undef close
#undef fstat
#undef fwstat
/*
* The sys*() routines needn't poperror() as they return directly to sy... | __label__POS | 0.69681 |
#include "u.h"
#include "lib.h"
#include "dat.h"
#include "fns.h"
#include "error.h"
void
mallocsummary(void)
{
}
void
pagersummary(void)
{
}
int
iseve(void)
{
return 1;
}
void
setswapchan(Chan *c)
{
USED(c);
}
void
splx(int x)
{
USED(x);
}
int
splhi(void)
{
return 0;
}
int
spllo(void)
{
return 0;
}
void
p... | __label__POS | 0.725525 |
#include "gc.h"
/*
* Based on: Granlund, T.; Montgomery, P.L.
* "Division by Invariant Integers using Multiplication".
* SIGPLAN Notices, Vol. 29, June 1994, page 61.
*/
#define TN(n) ((uvlong)1 << (n))
#define T31 TN(31)
#define T32 TN(32)
int
multiplier(ulong d, int p, uvlong *mp)
{
int l;
uvlong mlo, mhi, t... | __label__POS | 0.94619 |
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <memdraw.h>
#include <memlayer.h>
int
memload(Memimage *dst, Rectangle r, uchar *data, int n, int iscompressed)
{
int (*loadfn)(Memimage*, Rectangle, uchar*, int);
Memimage *tmp;
Memlayer *dl;
Rectangle lr;
int dx;
loadfn = loadmemimage;
if(iscompress... | __label__POS | 0.724744 |
#include "u.h"
#include "lib.h"
#include "dat.h"
#include "fns.h"
#include "error.h"
Chan*
fdtochan(int fd, int mode, int chkmnt, int iref)
{
Fgrp *f;
Chan *c;
c = 0;
f = up->fgrp;
lock(&f->ref.lk);
if(fd<0 || NFD<=fd || (c = f->fd[fd])==0) {
unlock(&f->ref.lk);
error(Ebadfd);
}
if(iref)
refinc(&c->ref... | __label__POS | 0.887468 |
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <fcall.h>
#include <thread.h>
#include <9p.h>
#include "cifs.h"
struct {
char *name;
int (*func)(Fmt *f);
char *buf;
int len;
} Infdir[] = {
{ "Users", userinfo },
{ "Groups", groupinfo },
{ "Shares", shareinfo },
{ "Connection", conninfo },
{ "... | __label__POS | 0.976228 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>
#include "authcmdlib.h"
#define TABLEN 8
static char*
defreadln(char *prompt, char *def, int must, int *changed)
{
char pr[512];
char reply[256];
do {
if(def && *def){
if(must)
snprint(pr, sizeof pr, "%s[return = %s]: ", prompt, def);
... | __label__POS | 0.706073 |
#include <u.h>
#include <libc.h>
#include <authsrv.h>
#include <bio.h>
#include "authcmdlib.h"
int
readfile(char *file, char *buf, int n)
{
int fd;
fd = open(file, OREAD);
if(fd < 0){
werrstr("%s: %r", file);
return -1;
}
n = read(fd, buf, n);
close(fd);
return n;
}
int
writefile(char *file, char *buf, in... | __label__POS | 0.999772 |
#include <u.h>
#include <libc.h>
#include <authsrv.h>
#include <bio.h>
#include "authcmdlib.h"
void
getpass(char *key, char *pass, int check, int confirm)
{
char rpass[32], npass[32];
char *err;
if(pass == nil)
pass = npass;
for(;;){
readln("Password: ", pass, sizeof npass, 1);
if(confirm){
readln("Conf... | __label__POS | 0.69827 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>
#include <mach.h>
#define Extern extern
#include "acid.h"
#include "y.tab.h"
static int syren;
Lsym*
unique(char *buf, Sym *s)
{
Lsym *l;
int i, renamed;
renamed = 0;
strcpy(buf, s->name);
for(;;) {
l = look(buf);
if(l == 0 || (l->lexval =... | __label__POS | 0.640302 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>
#include <mach.h>
#define Extern extern
#include "acid.h"
static List **tail;
List*
construct(Node *l)
{
List *lh, **save;
save = tail;
lh = 0;
tail = &lh;
build(l);
tail = save;
return lh;
}
int
listlen(List *l)
{
int len;
len = 0;
wh... | __label__POS | 0.933435 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>
#include <mach.h>
#define Extern extern
#include "acid.h"
#include "y.tab.h"
struct keywd
{
char *name;
int terminal;
}
keywds[] =
{
"do", Tdo,
"if", Tif,
"then", Tthen,
"else", Telse,
"while", Twhile,
"loop", Tloop,
"head", Thead,
"t... | __label__POS | 0.857974 |
#include <u.h>
#include <libc.h>
#include <mp.h>
#include <libsec.h>
#include "SConn.h"
static long
ls(char *p, Dir **dirbuf)
{
int fd;
long n;
Dir *db;
if((db = dirstat(p)) == nil ||
!(db->qid.type & QTDIR) ||
(fd = open(p, OREAD)) < 0 )
return -1;
free(db);
n = dirreadall(fd, dirbuf);
close(fd);
retur... | __label__POS | 0.680554 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>
#include <mach.h>
#define Extern extern
#include "acid.h"
#include "y.tab.h"
static void install(int);
void
nocore(void)
{
int i;
if(cormap == 0)
return;
for (i = 0; i < cormap->nsegs; i++)
if (cormap->seg[i].inuse && cormap->seg[i].fd >= 0... | __label__POS | 0.716071 |
#include <u.h>
#include <libc.h>
#include <mp.h>
#include <libsec.h>
#include "SConn.h"
extern int verbose;
typedef struct ConnState {
uchar secret[SHA1dlen];
ulong seqno;
RC4state rc4;
} ConnState;
typedef struct SS{
int fd; // file descriptor for read/write of encrypted data
int alg; // if nonzero, "alg sha ... | __label__POS | 0.756253 |
#include "dat.h"
Logbuf confbuf;
Req *cusewait; /* requests waiting for confirmation */
Req **cuselast = &cusewait;
void
confirmread(Req *r)
{
logbufread(&confbuf, r);
}
void
confirmflush(Req *r)
{
Req **l;
for(l=&cusewait; *l; l=&(*l)->aux){
if(*l == r){
*l = r->aux;
if(r->aux == nil)
cuselast = l... | __label__POS | 0.96747 |
#include <u.h>
#include <libc.h>
#include <String.h>
#include "ftpfs.h"
enum
{
Chunk= 1024, /* chunk size for buffered data */
Nfile= 128, /* maximum number of cached files */
};
/* a file (with cached data) */
struct File
{
char *mem; /* part of file cached in memory */
ulong len; /* length of cached data ... | __label__POS | 0.638632 |
#include "all.h"
static int
readmsg(Chan *c, void *abuf, int n, int *ninep)
{
int fd, len;
uchar *buf;
buf = abuf;
fd = c->chan;
qlock(&c->rlock);
if(readn(fd, buf, 3) != 3){
qunlock(&c->rlock);
print("readn(3) fails: %r\n");
return -1;
}
if((50 <= buf[0] && buf[0] <= 87 && (buf[0]&1)==0 && GBIT16(buf+1... | __label__POS | 0.85152 |
#include <u.h>
#include <libc.h>
#include <ip.h>
#include <bio.h>
#include <ndb.h>
static uchar noether[6];
Ndb *db;
static void
recursesubnet(Ndb *db, uchar *addr, uchar *mask, char *attr, char *name, char *name1)
{
Ndbs s;
Ndbtuple *t, *nt;
uchar submask[IPaddrlen], net[IPaddrlen];
char ip[Ndbvlen];
int found... | __label__POS | 0.605807 |
#include <u.h>
#include <libc.h>
#include "dat.h"
Place nowhere = {
Undef, Undef
};
static void
setlat(Place *p, double lat)
{
p->lat = lat;
}
static void
setlon(Place *p, double lon)
{
p->lon = lon;
}
static int
printlatlon(char *p, int n, double lat, char po, char ne)
{
char c;
double d;
int deg, min, sec;
... | __label__POS | 0.608519 |
/*
* sorted by 4,/^$/|sort -bd +1
*/
int fqid(int fd, Qid *qid);
int BNList(Biobuf *b, NList *nl, char *sep);
int BSList(Biobuf *b, SList *sl, char *sep);
int BimapMimeParams(Biobuf *b, MimeHdr *mh);
int Bimapaddr(Biobuf *b, MAddr *a);
int Bimapdate(Biobuf *b, Tm *tm);
int Bimapstr(Biobuf *b, char *s);
int Brfc822dat... | __label__POS | 0.942644 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include "imap4d.h"
static int copyData(int ffd, int tfd, MbLock *ml);
static MbLock mLock =
{
.fd = -1
};
static char curDir[MboxNameLen];
void
resetCurDir(void)
{
curDir[0] = '\0';
}
int
myChdir(char *dir)
{
if(strcmp(dir, curDir) == 0)
retu... | __label__POS | 0.908011 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include <libsec.h>
#include "imap4d.h"
static int saveMsg(char *dst, char *digest, int flags, char *head, int nhead, Biobuf *b, long n);
static int saveb(int fd, DigestState *dstate, char *buf, int nr, int nw);
static long appSpool(Biobuf *bout, Biob... | __label__POS | 0.866377 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include "imap4d.h"
#define SUBSCRIBED "imap.subscribed"
static int matches(char *ref, char *pat, char *name);
static int mayMatch(char *pat, char *name, int star);
static int checkMatch(char *cmd, char *ref, char *pat, char *mbox, long mtime, int is... | __label__POS | 0.800635 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include "imap4d.h"
/*
* reverse string [s:e) in place
*/
void
strrev(char *s, char *e)
{
int c;
while(--e > s){
c = *s;
*s++ = *e;
*e = c;
}
}
int
isdotdot(char *s)
{
return s[0] == '.' && s[1] == '.' && (s[2] == '/' || s[2] == '\0');
}... | __label__POS | 0.989109 |
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <bio.h>
#include "imap4d.h"
void
debuglog(char *fmt, ...)
{
va_list arg;
static int logfd;
if(debug == 0)
return;
if(logfd == 0)
logfd = open("/sys/log/imap4d", OWRITE);
if(logfd > 0){
va_start(arg, fmt);
fprint(logfd, "%s: ", username);
vfpri... | __label__POS | 0.604651 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include "imap4d.h"
/*
* modified utf-7, as per imap4 spec
* like utf-7, but substitues , for / in base 64,
* does not allow escaped ascii characters.
*
* /lib/rfc/rfc2152 is utf-7
* /lib/rfc/rfc1642 is obsolete utf-7
*
* test sequences from r... | __label__POS | 0.895959 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <auth.h>
#include "imap4d.h"
/*
* iterated over all of the items in the message set.
* errors are accumulated, but processing continues.
* if uids, then ignore non-existent messages.
* otherwise, that's an error
*/
int
forMsgs(Box *box, MsgSet *ms, ulong ... | __label__POS | 0.916475 |
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <libsec.h>
#include <bio.h>
#include "imap4d.h"
/*
* hack to allow smtp forwarding.
* hide the peer IP address under a rock in the ratifier FS.
*/
void
enableForwarding(void)
{
char buf[64], peer[64], *p;
static ulong last;
ulong now;
int fd;
if(remo... | __label__POS | 0.662016 |
#include "common.h"
#include <auth.h>
#include <fcall.h>
#include <libsec.h>
#include <ctype.h>
#include "dat.h"
enum
{
OPERM = 0x3, // mask of all permission types in open mode
};
typedef struct Fid Fid;
struct Fid
{
Qid qid;
short busy;
short open;
int fid;
Fid *next;
Mailbox *mb;
Message *m;
Message *mt... | __label__POS | 0.656299 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include "hash.h"
/***
* String hash tables.
*/
Stringtab *tfree;
Stringtab*
taballoc(void)
{
static Stringtab *t;
static uint nt;
if(tfree){
Stringtab *tt = tfree;
tfree = tt->link;
return tt;
}
if(nt == 0){
t = malloc(64000*sizeof(Stringtab));
if... | __label__POS | 0.91733 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <regexp.h>
#include "/sys/src/libregexp/regcomp.h"
#include "dfa.h"
#define DUMP
void
dump(Dreprog *pp)
{
int i, j;
Dreinst *l;
print("start %ld %ld %ld %ld\n",
pp->start[0]-pp->inst,
pp->start[1]-pp->inst,
pp->start[2]-pp->inst,
pp->start[3]-pp->... | __label__POS | 0.750548 |
#include <u.h>
#include <libc.h>
#include <db.h>
#include "msgdb.h"
struct Msgdb
{
DB *db;
int reset;
};
Msgdb*
mdopen(char *file, int create)
{
Msgdb *mdb;
DB *db;
HASHINFO h;
if((mdb = mallocz(sizeof(Msgdb), 1)) == nil)
return nil;
memset(&h, 0, sizeof h);
h.cachesize = 2*1024*1024;
if((db = dbopen(file... | __label__POS | 0.840656 |
#include "common.h"
#include "send.h"
/* dispose of local addresses */
int
cat_mail(dest *dp, message *mp)
{
Biobuf *fp;
char *rcvr, *cp;
Mlock *l;
String *tmp, *s;
int i, n;
s = unescapespecial(s_clone(dp->repl1));
if (nflg) {
if(!xflg)
print("cat >> %s\n", s_to_c(s));
else
print("%s\n", s_to_c(dp-... | __label__POS | 0.784657 |
#include <u.h>
#include <libc.h>
#include "dat.h"
void*
emalloc(int size)
{
void *a;
a = mallocz(size, 1);
if(a == nil)
sysfatal("%r");
return a;
}
char*
estrdup(char *s)
{
s = strdup(s);
if(s == nil)
sysfatal("%r");
return s;
}
/*
* like tokenize but obey "" quoting
*/
int
tokenize822(char *str, char ... | __label__POS | 0.877755 |
#include "common.h"
/* expand a path relative to some `.' */
extern String *
abspath(char *path, char *dot, String *to)
{
if (*path == '/') {
to = s_append(to, path);
} else {
to = s_append(to, dot);
to = s_append(to, "/");
to = s_append(to, path);
}
return to;
}
/* return a pointer to the base component ... | __label__POS | 0.750023 |
#include "common.h"
#include "smtpd.h"
#include <ip.h>
enum {
NORELAY = 0,
DNSVERIFY,
SAVEBLOCK,
DOMNAME,
OURNETS,
OURDOMS,
IP = 0,
STRING,
};
typedef struct Keyword Keyword;
struct Keyword {
char *name;
int code;
};
static Keyword options[] = {
"norelay", NORELAY,
"verifysenderdom", DNSVERIFY,
"sav... | __label__POS | 0.650299 |
#include "common.h"
#include "dat.h"
int cflag;
int aflag;
int rflag;
int createpipeto(char *alfile, char *user, char *listname, int owner);
void
usage(void)
{
fprint(2, "usage:\t%s -c listname\n", argv0);
fprint(2, "\t%s -[ar] listname addr\n", argv0);
exits("usage");
}
void
main(int argc, char **argv)
{
char ... | __label__POS | 0.710607 |
# Binary-Security-Advanced-References
本仓库内容旨在收集二进制安全相关的精品阅读材料,供学习者深入参考学习所用
## 资源介绍
### ctf-all-in-one
`《CTF All in One》`是一本媲美CTF-Wiki的,对CTF所有领域有着百科全书一样介绍的开源书籍,除此之外,本书还介绍了大量领域内的优秀学术论文,对寻找研究方向、拓宽研究思路也大有益处。只是内容还不完整,有些主题还留有空白,作者会不定期更新。原出处及最新更新请参考[Github仓库](https://github.com/firmianay/CTF-All-In-One)
### SymbolicExecut... | __label__POS | 0.92789 |
#include "sys.h"
#include "spam.h"
int debug;
Biobuf bin;
char patfile[128], header[Hdrsize+2];
char cmd[1024];
char* canon(Biobuf*, char*, char*, int*);
int matcher(char *, Pattern*, char*, Resub*);
int matchaction(Patterns*, char*);
void
usage(void)
{
fprint(2, "missing or bad arguments to qer\n");
exits("usage... | __label__POS | 0.909019 |
#include <u.h>
#include <libc.h>
#include "flashfs.h"
int
convJ2M(Jrec *j, uchar *buff)
{
int m, n;
switch(j->type) {
case FT_create:
if(j->mode & (1 << 8)) {
if(j->mode & DMDIR)
j->type = FT_DCREATE1;
else
j->type = FT_FCREATE1;
}
else {
if(j->mode & DMDIR)
j->type = FT_DCREATE0;
els... | __label__POS | 0.646462 |
#ifndef _POSIX_SOURCE
#include <u.h>
#include <libc.h>
#else
#define _BSD_EXTENSION
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#endif
#include <stdio.h>
#define ERR(str, chr) if(opterr){fprintf(stderr, "%s%s%c\n", argv[0], str, chr);}
int opterr = 1;
int optind = 1;
int optopt;
char ... | __label__POS | 0.746507 |
/*
* usb/print - usb printer file server
* BUG: Assumes the printer will be always connected and
* not hot-plugged. (Otherwise should stay running and
* listen to errors to keep the device there as long as it has
* not failed). Also, this is untested and done ad-hoc to
* replace the print script.
*/
#include <u.... | __label__POS | 0.776688 |
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>
#include "common.h"
#include "comments.h"
#include "path.h"
struct strtab charcode[FONTSIZE] = {
{4, "\\000"}, {4, "\\001"}, {4, "\\002"}, {4, "\\003"},
{4, "\\004"}, {4, "\\005"}, {4, "\\006"}, {4, "\\007"},
{4, "\\010"}, {4, "\\011"}, {4, "\\012... | __label__POS | 0.972287 |
#include <u.h>
#include <libc.h>
#include <ctype.h>
#include <bio.h>
#include <comments.h>
#include <path.h>
#define UNKNOWNCHAR "/sys/lib/postscript/prologues/pjw.char.ps"
char *optnames = "a:c:f:l:m:n:o:p:s:t:x:y:P:";
double aspectratio = 1.0;
Biobuf inbuf, outbuf;
Biobuf *bin, *bout;
int char_no = 0; /* characte... | __label__POS | 0.611259 |
package org.overengineer.inlineproblems;
import com.intellij.openapi.application.ApplicationInfo;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.startup.StartupActivity;
import org.jetbrains.annotations.NotNull;
import org.overengineer.inlineproblems.entities.IDE;
import org.overengineer.inli... | __label__POS | 0.908962 |
package org.overengineer.inlineproblems;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
import java.util.Objects;
public class GutterRenderer extends GutterIconRenderer {
private final String text;
private final Icon icon;
p... | __label__POS | 0.984813 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
void
waitforkick(Round *r)
{
int n;
qlock(&r->lock);
r->last = r->current;
assert(r->current+1 == r->next);
rwakeupall(&r->finish);
while(!r->doanother)
rsleep(&r->start);
n = r->next++;
r->current = n;
r->doanother = 0;
qunlock(&r->lock);
}
static vo... | __label__POS | 0.82689 |
package org.overengineer.inlineproblems;
import com.intellij.lang.annotation.HighlightSeverity;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import lombok.Getter;
import org.overengineer.in... | __label__POS | 0.787301 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
static int verbose;
static int fd;
static int fd1;
static uchar *data;
static uchar *data1;
static int blocksize;
static int sleepms;
void
usage(void)
{
fprint(2, "usage: cmparenas [-b blocksize] [-s ms] [-v] arenapart1 arenapart2 [name...]]\n");
threadexitsall(... | __label__POS | 0.821657 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
static uchar *data;
static uchar *data1;
static int blocksize;
static int sleepms;
static int fd;
static int force;
static vlong offset0;
void
usage(void)
{
fprint(2, "usage: reseal [-f] [-b blocksize] [-s ms] arenapart1 [name...]]\n");
threadexitsall(0);
}
sta... | __label__POS | 0.758606 |
package org.overengineer.inlineproblems.listeners;
import com.intellij.ide.plugins.DynamicPluginListener;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.openapi.application.ApplicationInfo;
import org.jetbrains.annotations.NotNull;
import org.overengineer.inlineproblems.ListenerManager;
impo... | __label__POS | 0.714065 |
package org.overengineer.inlineproblems.listeners;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.HighlightInfoFilter;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileE... | __label__POS | 0.634084 |
package org.overengineer.inlineproblems.scanners;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import java.io.*;
public class UnityProjectScanner {
Logger logger = Logger.getInstance(UnityProjectScanner.class);
private final String[] unityReferences = {
... | __label__POS | 0.997671 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
static char vcmagic[] = "venti config\n";
enum {
Maxconfig = 8 * 1024,
Maglen = sizeof vcmagic - 1,
};
int
readifile(IFile *f, char *name)
{
Part *p;
ZBlock *b;
u8int *z;
p = initpart(name, OREAD);
if(p == nil)
return -1;
b = alloczblock(Maxconfig+1, 1... | __label__POS | 0.807801 |
package org.overengineer.inlineproblems.entities;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.openapi.editor.markup.RangeHighlighter;
import com.intellij.openapi.fileEditor.TextEditor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
impo... | __label__POS | 0.891888 |
package org.overengineer.inlineproblems.settings;
import com.intellij.openapi.ui.ComboBox;
import com.intellij.ui.ColorPanel;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBTextField;
import com.intellij.util.ui.FormBuilder;
import lombok.Ge... | __label__POS | 0.608279 |
package minigrad
import (
"fmt"
"math/rand"
"strings"
)
// Neuron
type Neuron struct {
w []*Value
b *Value
nonlin bool
}
func NewNeuron(nin int, nonlin bool) *Neuron {
w := make([]*Value, nin)
for i := range w {
w[i] = NewValue(rand.Float64()*2-1, nil, "")
}
return &Neuron{
w: w,
b:... | __label__POS | 0.918693 |
package minigrad
import (
"fmt"
"math"
)
type Value struct {
data float64
grad float64
backward func()
prev []*Value
op string
}
func NewValue(data float64, children []*Value, op string) *Value {
return &Value {
data: data,
grad: 0,
backward: func () {},
prev: children,
op: op,
... | __label__POS | 0.842425 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
static int
syncarenaindex(Arena *arena, u64int a0)
{
int ok;
u32int clump;
u64int a;
ClumpInfo ci;
IAddr ia;
AState as;
if(arena->diskstats.clumps == arena->memstats.clumps)
return 0;
memset(&as, 0, sizeof as);
as.arena = arena;
as.stats = arena->di... | __label__POS | 0.837321 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
int
namecmp(char *s, char *t)
{
return strncmp(s, t, ANameSize);
}
void
namecp(char *dst, char *src)
{
strncpy(dst, src, ANameSize - 1);
dst[ANameSize - 1] = '\0';
}
int
nameok(char *name)
{
char *t;
int c;
if(name == nil)
return -1;
for(t = name; c = *... | __label__POS | 0.95916 |
package org.overengineer.inlineproblems.utils;
import org.overengineer.inlineproblems.settings.SettingsState;
public class FileUtil {
/**
* Returns true if the file should be ignored, current checks involve the file name and the line count
* @param fileName can be null to ignore
* @param lineCount... | __label__POS | 0.989926 |
/*
* Mirror one arena partition onto another.
* Be careful to copy only new data.
*/
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
Channel *writechan;
typedef struct Write Write;
struct Write
{
uchar *p;
int n;
uvlong o;
int error;
};
Part *src;
Part *dst;
int force;
int verbose;
int dosha1 = 1;
ch... | __label__POS | 0.66083 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
static int verbose;
static int fd;
static uchar *data;
static int blocksize;
static int sleepms;
static vlong offset0;
void
usage(void)
{
fprint(2, "usage: verifyarena [-b blocksize] [-s ms] [-v] [arenapart [name...]]\n");
threadexitsall(0);
}
static int
preadb... | __label__POS | 0.789727 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
static int extra, missing, wrong;
static void
phdr(DBlock *eb)
{
static int did;
if(!did){
did = 1;
print("# diff actual correct\n");
}
print("%s block 0x%llux\n", eb->part->name, eb->addr);
}
static void
pie(IEntry *ie, char c)
{
print("%c %V %22lld %3... | __label__POS | 0.636724 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
/*
* disk structure conversion routines
*/
#define U8GET(p) ((p)[0])
#define U16GET(p) (((p)[0]<<8)|(p)[1])
#define U32GET(p) ((u32int)(((p)[0]<<24)|((p)[1]<<16)|((p)[2]<<8)|(p)[3]))
#define U64GET(p) (((u64int)U32GET(p)<<32)|(u64int)U32GET((p)+4))
#define U8PUT... | __label__POS | 0.751365 |
#include "stdinc.h"
#include "dat.h"
#include "fns.h"
typedef struct AHash AHash;
/*
* hash table for finding arena's based on their names.
*/
struct AHash
{
AHash *next;
Arena *arena;
};
enum
{
AHashSize = 512,
Emergency = 0, /* flag: performing emergency surgery */
};
static AHash *ahash[AHashSize];
stati... | __label__POS | 0.874916 |
#include <plan9.h>
#include <fcall.h>
static
uchar*
gstring(uchar *p, uchar *ep, char **s)
{
uint n;
if(p+BIT16SZ > ep)
return nil;
n = GBIT16(p);
p += BIT16SZ - 1;
if(p+n+1 > ep)
return nil;
/* move it down, on top of count, to make room for '\0' */
memmove(p, p + 1, n);
p[n] = '\0';
*s = (char*)p;
p +... | __label__POS | 0.864933 |
#include <plan9.h>
#include <fcall.h>
int
statcheck(uchar *buf, uint nbuf)
{
uchar *ebuf;
int i;
ebuf = buf + nbuf;
buf += STATFIXLEN - 4 * BIT16SZ;
for(i = 0; i < 4; i++){
if(buf + BIT16SZ > ebuf)
return -1;
buf += BIT16SZ + GBIT16(buf);
}
if(buf != ebuf)
return -1;
return 0;
}
static char null... | __label__POS | 0.710425 |
#include <plan9.h>
#include <fcall.h>
static
uchar*
pstring(uchar *p, char *s)
{
uint n;
n = strlen(s);
PBIT16(p, n);
p += BIT16SZ;
memmove(p, s, n);
p += n;
return p;
}
static
uchar*
pqid(uchar *p, Qid *q)
{
PBIT8(p, q->type);
p += BIT8SZ;
PBIT32(p, q->vers);
p += BIT32SZ;
PBIT64(p, q->path);
p += BIT6... | __label__POS | 0.904444 |
#include <plan9.h>
#include <fcall.h>
uint
sizeD2M(Dir *d)
{
char *sv[4];
int i, ns;
sv[0] = d->name;
sv[1] = d->uid;
sv[2] = d->gid;
sv[3] = d->muid;
ns = 0;
for(i = 0; i < 4; i++)
ns += strlen(sv[i]);
return STATFIXLEN + ns;
}
uint
convD2M(Dir *d, uchar *buf, uint nbuf)
{
uchar *p, *ebuf;
char *sv[4... | __label__POS | 0.823594 |
#include <plan9.h>
#define SIZE 4096
extern int printcol;
int
print(char *fmt, ...)
{
char buf[SIZE], *out;
va_list arg, temp;
int n;
va_start(arg, fmt);
va_copy(temp, arg);
out = doprint(buf, buf+SIZE, fmt, &temp);
va_end(temp);
va_end(arg);
n = write(1, buf, (long)(out-buf));
return n;
}
int
fprint(int ... | __label__POS | 0.92068 |
#include <u.h>
#include <libc.h>
#include "drawterm.h"
void*
erealloc(void *v, ulong n)
{
v = realloc(v, n);
if(v == nil)
sysfatal("out of memory");
return v;
}
char*
estrdup(char *s)
{
s = strdup(s);
if(s == nil)
sysfatal("out of memory");
return s;
}
char*
estrappend(char *s, char *fmt, ...)
{
char *t;
... | __label__POS | 0.768637 |
#include "u.h"
#include "lib.h"
#include "kern/dat.h"
#include "kern/fns.h"
#include "user.h"
#include "drawterm.h"
char *argv0;
char *user;
extern int errfmt(Fmt*);
void
sizebug(void)
{
/*
* Needed by various parts of the code.
* This is a huge bug.
*/
assert(sizeof(char)==1);
assert(sizeof(short)==2);
as... | __label__POS | 0.608395 |
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <memdraw.h>
int
_loadmemimage(Memimage *i, Rectangle r, uchar *data, int ndata)
{
int y, l, lpart, rpart, mx, m, mr;
uchar *q;
if(!rectinrect(r, i->r))
return -1;
l = bytesperline(r, i->depth);
if(ndata < l*Dy(r))
return -1;
ndata = l*Dy(r);
q = b... | __label__POS | 0.720823 |
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <memdraw.h>
#include <memlayer.h>
Point
memimagestring(Memimage *b, Point p, Memimage *color, Point cp, Memsubfont *f, char *cs)
{
int w, width;
uchar *s;
Rune c;
Fontchar *i;
s = (uchar*)cs;
for(; (c=*s); p.x+=width, cp.x+=width){
width = 0;
if(c ... | __label__POS | 0.907451 |
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <memdraw.h>
#define poolalloc(a, b) malloc(b)
#define poolfree(a, b) free(b)
void
memimagemove(void *from, void *to)
{
Memdata *md;
md = *(Memdata**)to;
if(md->base != from){
print("compacted data not right: #%p\n", md->base);
abort();
}
md->base =... | __label__POS | 0.654518 |
#include <u.h>
#include <libc.h>
#include <auth.h>
#include <authsrv.h>
#include "authlocal.h"
enum {
ARgiveup = 100,
};
static int
dorpc(AuthRpc *rpc, char *verb, char *val, int len, AuthGetkey *getkey)
{
int ret;
for(;;){
if((ret = auth_rpc(rpc, verb, val, len)) != ARneedkey && ret != ARbadkey)
return ret;... | __label__POS | 0.773996 |
#include <u.h>
#include <libc.h>
#include <fcall.h>
static
uchar*
gstring(uchar *p, uchar *ep, char **s)
{
uint n;
if(p+BIT16SZ > ep)
return nil;
n = GBIT16(p);
p += BIT16SZ - 1;
if(p+n+1 > ep)
return nil;
/* move it down, on top of count, to make room for '\0' */
memmove(p, p + 1, n);
p[n] = '\0';
*s = ... | __label__POS | 0.817847 |
#include <u.h>
#include <libc.h>
#include "fmtdef.h"
/*
* Reads a floating-point number by interpreting successive characters
* returned by (*f)(vp). The last call it makes to f terminates the
* scan, so is not a character in the number. It may therefore be
* necessary to back up the input stream up one byte aft... | __label__POS | 0.824269 |
#include <u.h>
#include <libc.h>
#define Bit(i) (7-(i))
/* N 0's preceded by i 1's, T(Bit(2)) is 1100 0000 */
#define T(i) (((1 << (Bit(i)+1))-1) ^ 0xFF)
/* 0000 0000 0000 0111 1111 1111 */
#define RuneX(i) ((1 << (Bit(i) + ((i)-1)*Bitx))-1)
enum
{
Bitx = Bit(1),
Tx = T(1), /* 1000 0000 */
Rune1 = (1<<(Bit(0)+0... | __label__POS | 0.903177 |
#include <u.h>
#include <libc.h>
#include "fmtdef.h"
static int
runeFmtStrFlush(Fmt *f)
{
Rune *s;
int n;
if(f->start == nil)
return 0;
n = (uintptr)f->farg;
n *= 2;
s = (Rune*)f->start;
f->start = realloc(s, sizeof(Rune)*n);
if(f->start == nil){
f->farg = nil;
f->to = nil;
f->stop = nil;
free(s);
... | __label__POS | 0.989841 |
#include <u.h>
#include <libc.h>
static uvlong order = (uvlong) 0x0001020304050607ULL;
static void
be2vlong(vlong *to, uchar *f)
{
uchar *t, *o;
int i;
t = (uchar*)to;
o = (uchar*)ℴ
for(i = 0; i < 8; i++)
t[o[i]] = f[i];
}
/*
* After a fork with fd's copied, both fd's are pointing to
* the same Cha... | __label__POS | 0.681612 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.