mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.
This commit is contained in:
parent
226d80b821
commit
cbeb0b26e4
492 changed files with 3218 additions and 3167 deletions
4
bin/9c
4
bin/9c
|
@ -8,6 +8,8 @@ usegcc()
|
||||||
-O2 \
|
-O2 \
|
||||||
-c \
|
-c \
|
||||||
-Wall \
|
-Wall \
|
||||||
|
-ansi \
|
||||||
|
-pedantic \
|
||||||
-Wno-parentheses \
|
-Wno-parentheses \
|
||||||
-Wno-missing-braces \
|
-Wno-missing-braces \
|
||||||
-Wno-switch \
|
-Wno-switch \
|
||||||
|
@ -67,7 +69,7 @@ xtmp=/tmp/9c.$$.$USER.out
|
||||||
$cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp
|
$cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp
|
||||||
status=$?
|
status=$?
|
||||||
grep -v '__p9l_autolib_' $xtmp |
|
grep -v '__p9l_autolib_' $xtmp |
|
||||||
egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:' |
|
egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:|support .long long.|In file included from| from|use of C99 long long|ISO C forbids conversion' |
|
||||||
sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
|
sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
|
||||||
uniq 1>&2
|
uniq 1>&2
|
||||||
rm -f $xtmp $xtmp.status
|
rm -f $xtmp $xtmp.status
|
||||||
|
|
|
@ -40,7 +40,7 @@ enum
|
||||||
ARrpcfailure,
|
ARrpcfailure,
|
||||||
ARphase,
|
ARphase,
|
||||||
|
|
||||||
AuthRpcMax = 4096,
|
AuthRpcMax = 4096
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AuthRpc
|
struct AuthRpc
|
||||||
|
@ -108,7 +108,7 @@ typedef struct Attr Attr;
|
||||||
enum {
|
enum {
|
||||||
AttrNameval, /* name=val -- when matching, must have name=val */
|
AttrNameval, /* name=val -- when matching, must have name=val */
|
||||||
AttrQuery, /* name? -- when matching, must be present */
|
AttrQuery, /* name? -- when matching, must be present */
|
||||||
AttrDefault, /* name:=val -- when matching, if present must match INTERNAL */
|
AttrDefault /* name:=val -- when matching, if present must match INTERNAL */
|
||||||
};
|
};
|
||||||
struct Attr
|
struct Attr
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,7 +34,7 @@ enum
|
||||||
KEYDBOFF= 8, /* length of random data at the start of key file */
|
KEYDBOFF= 8, /* length of random data at the start of key file */
|
||||||
OKEYDBLEN= ANAMELEN+DESKEYLEN+4+2, /* length of an entry in old key file */
|
OKEYDBLEN= ANAMELEN+DESKEYLEN+4+2, /* length of an entry in old key file */
|
||||||
KEYDBLEN= OKEYDBLEN+SECRETLEN, /* length of an entry in key file */
|
KEYDBLEN= OKEYDBLEN+SECRETLEN, /* length of an entry in key file */
|
||||||
OMD5LEN= 16,
|
OMD5LEN= 16
|
||||||
};
|
};
|
||||||
|
|
||||||
/* encryption numberings (anti-replay) */
|
/* encryption numberings (anti-replay) */
|
||||||
|
@ -60,7 +60,7 @@ enum
|
||||||
AuthAs, /* server generated authenticator */
|
AuthAs, /* server generated authenticator */
|
||||||
AuthAc, /* client generated authenticator */
|
AuthAc, /* client generated authenticator */
|
||||||
AuthTp, /* ticket encrypted with client's key for password change */
|
AuthTp, /* ticket encrypted with client's key for password change */
|
||||||
AuthHr, /* http reply */
|
AuthHr /* http reply */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Ticketreq
|
struct Ticketreq
|
||||||
|
@ -140,7 +140,7 @@ extern int passtokey(char*, char*);
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
NVwrite = 1<<0, /* always prompt and rewrite nvram */
|
NVwrite = 1<<0, /* always prompt and rewrite nvram */
|
||||||
NVwriteonerr = 1<<1, /* prompt and rewrite nvram when corrupt */
|
NVwriteonerr = 1<<1 /* prompt and rewrite nvram when corrupt */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Nvrsafe
|
struct Nvrsafe
|
||||||
|
|
|
@ -64,7 +64,7 @@ enum {
|
||||||
|
|
||||||
Gpart = 0, /* partition info source */
|
Gpart = 0, /* partition info source */
|
||||||
Gdisk,
|
Gdisk,
|
||||||
Gguess,
|
Gguess
|
||||||
};
|
};
|
||||||
|
|
||||||
/* proto file parsing */
|
/* proto file parsing */
|
||||||
|
|
|
@ -60,7 +60,7 @@ enum
|
||||||
{
|
{
|
||||||
Displaybufsize = 8000,
|
Displaybufsize = 8000,
|
||||||
ICOSSCALE = 1024,
|
ICOSSCALE = 1024,
|
||||||
Borderwidth = 4,
|
Borderwidth = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -103,7 +103,7 @@ typedef enum
|
||||||
DatopS = DinS|SoutD,
|
DatopS = DinS|SoutD,
|
||||||
DxorS = DoutS|SoutD, /* == SxorD */
|
DxorS = DoutS|SoutD, /* == SxorD */
|
||||||
|
|
||||||
Ncomp = 12,
|
Ncomp = 12
|
||||||
} Drawop;
|
} Drawop;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -117,7 +117,7 @@ enum {
|
||||||
CAlpha,
|
CAlpha,
|
||||||
CMap,
|
CMap,
|
||||||
CIgnore,
|
CIgnore,
|
||||||
NChan,
|
NChan
|
||||||
};
|
};
|
||||||
|
|
||||||
#define __DC(type, nbits) ((((type)&15)<<4)|((nbits)&15))
|
#define __DC(type, nbits) ((((type)&15)<<4)|((nbits)&15))
|
||||||
|
@ -143,7 +143,7 @@ enum {
|
||||||
ARGB32 = CHAN4(CAlpha, 8, CRed, 8, CGreen, 8, CBlue, 8), /* stupid VGAs */
|
ARGB32 = CHAN4(CAlpha, 8, CRed, 8, CGreen, 8, CBlue, 8), /* stupid VGAs */
|
||||||
ABGR32 = CHAN4(CAlpha, 8, CBlue, 8, CGreen, 8, CRed, 8),
|
ABGR32 = CHAN4(CAlpha, 8, CBlue, 8, CGreen, 8, CRed, 8),
|
||||||
XRGB32 = CHAN4(CIgnore, 8, CRed, 8, CGreen, 8, CBlue, 8),
|
XRGB32 = CHAN4(CIgnore, 8, CRed, 8, CGreen, 8, CBlue, 8),
|
||||||
XBGR32 = CHAN4(CIgnore, 8, CBlue, 8, CGreen, 8, CRed, 8),
|
XBGR32 = CHAN4(CIgnore, 8, CBlue, 8, CGreen, 8, CRed, 8)
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char* chantostr(char*, u32int);
|
extern char* chantostr(char*, u32int);
|
||||||
|
@ -526,7 +526,7 @@ extern void drawsetdebug(int);
|
||||||
*/
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SnarfSize = 64*1024,
|
SnarfSize = 64*1024
|
||||||
};
|
};
|
||||||
char *getsnarf(void);
|
char *getsnarf(void);
|
||||||
void putsnarf(char*);
|
void putsnarf(char*);
|
||||||
|
|
|
@ -10,13 +10,13 @@ typedef struct Menu Menu;
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Emouse = 1,
|
Emouse = 1,
|
||||||
Ekeyboard = 2,
|
Ekeyboard = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MAXSLAVE = 32,
|
MAXSLAVE = 32,
|
||||||
EMAXMSG = 128+8192, /* size of 9p header+data */
|
EMAXMSG = 128+8192 /* size of 9p header+data */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Mouse
|
struct Mouse
|
||||||
|
|
|
@ -108,7 +108,7 @@ enum
|
||||||
Tmax,
|
Tmax,
|
||||||
|
|
||||||
Topenfd = 98,
|
Topenfd = 98,
|
||||||
Ropenfd,
|
Ropenfd
|
||||||
};
|
};
|
||||||
|
|
||||||
uint convM2S(uchar*, uint, Fcall*);
|
uint convM2S(uchar*, uint, Fcall*);
|
||||||
|
|
|
@ -22,7 +22,7 @@ enum
|
||||||
FlateInputFail = -2,
|
FlateInputFail = -2,
|
||||||
FlateOutputFail = -3,
|
FlateOutputFail = -3,
|
||||||
FlateCorrupted = -4,
|
FlateCorrupted = -4,
|
||||||
FlateInternal = -5,
|
FlateInternal = -5
|
||||||
};
|
};
|
||||||
|
|
||||||
int deflateinit(void);
|
int deflateinit(void);
|
||||||
|
|
490
include/html.h
490
include/html.h
|
@ -10,13 +10,13 @@ AUTOLIB(html)
|
||||||
#pragma src "/sys/src/libhtml"
|
#pragma src "/sys/src/libhtml"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// UTILS
|
/* UTILS */
|
||||||
extern uchar* fromStr(Rune* buf, int n, int chset);
|
extern uchar* fromStr(Rune* buf, int n, int chset);
|
||||||
extern Rune* toStr(uchar* buf, int n, int chset);
|
extern Rune* toStr(uchar* buf, int n, int chset);
|
||||||
|
|
||||||
// Common LEX and BUILD enums
|
/* Common LEX and BUILD enums */
|
||||||
|
|
||||||
// Media types
|
/* Media types */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ApplMsword,
|
ApplMsword,
|
||||||
|
@ -58,14 +58,14 @@ enum
|
||||||
NMEDIATYPES
|
NMEDIATYPES
|
||||||
};
|
};
|
||||||
|
|
||||||
// HTTP methods
|
/* HTTP methods */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
HGet,
|
HGet,
|
||||||
HPost
|
HPost
|
||||||
};
|
};
|
||||||
|
|
||||||
// Charsets
|
/* Charsets */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
UnknownCharset,
|
UnknownCharset,
|
||||||
|
@ -76,7 +76,7 @@ enum
|
||||||
NCHARSETS
|
NCHARSETS
|
||||||
};
|
};
|
||||||
|
|
||||||
// Frame Target IDs
|
/* Frame Target IDs */
|
||||||
enum {
|
enum {
|
||||||
FTtop,
|
FTtop,
|
||||||
FTself,
|
FTself,
|
||||||
|
@ -84,11 +84,11 @@ enum {
|
||||||
FTblank
|
FTblank
|
||||||
};
|
};
|
||||||
|
|
||||||
// LEX
|
/* LEX */
|
||||||
typedef struct Token Token;
|
typedef struct Token Token;
|
||||||
typedef struct Attr Attr;
|
typedef struct Attr Attr;
|
||||||
|
|
||||||
// BUILD
|
/* BUILD */
|
||||||
|
|
||||||
typedef struct Item Item;
|
typedef struct Item Item;
|
||||||
typedef struct Itext Itext;
|
typedef struct Itext Itext;
|
||||||
|
@ -119,9 +119,9 @@ typedef struct Docinfo Docinfo;
|
||||||
typedef struct Stack Stack;
|
typedef struct Stack Stack;
|
||||||
typedef struct Pstate Pstate;
|
typedef struct Pstate Pstate;
|
||||||
typedef struct ItemSource ItemSource;
|
typedef struct ItemSource ItemSource;
|
||||||
typedef struct Lay Lay; // defined in Layout module
|
typedef struct Lay Lay; /* defined in Layout module */
|
||||||
|
|
||||||
// Alignment types
|
/* Alignment types */
|
||||||
enum {
|
enum {
|
||||||
ALnone = 0, ALleft, ALcenter, ALright, ALjustify,
|
ALnone = 0, ALleft, ALcenter, ALright, ALjustify,
|
||||||
ALchar, ALtop, ALmiddle, ALbottom, ALbaseline
|
ALchar, ALtop, ALmiddle, ALbottom, ALbaseline
|
||||||
|
@ -129,16 +129,16 @@ enum {
|
||||||
|
|
||||||
struct Align
|
struct Align
|
||||||
{
|
{
|
||||||
uchar halign; // one of ALnone, ALleft, etc.
|
uchar halign; /* one of ALnone, ALleft, etc. */
|
||||||
uchar valign; // one of ALnone, ALtop, etc.
|
uchar valign; /* one of ALnone, ALtop, etc. */
|
||||||
};
|
};
|
||||||
|
|
||||||
// A Dimen holds a dimension specification, especially for those
|
/* A Dimen holds a dimension specification, especially for those */
|
||||||
// cases when a number can be followed by a % or a * to indicate
|
/* cases when a number can be followed by a % or a * to indicate */
|
||||||
// percentage of total or relative weight.
|
/* percentage of total or relative weight. */
|
||||||
// Dnone means no dimension was specified
|
/* Dnone means no dimension was specified */
|
||||||
|
|
||||||
// To fit in a word, use top bits to identify kind, rest for value
|
/* To fit in a word, use top bits to identify kind, rest for value */
|
||||||
enum {
|
enum {
|
||||||
Dnone = 0,
|
Dnone = 0,
|
||||||
Dpixels = (1<<29),
|
Dpixels = (1<<29),
|
||||||
|
@ -150,36 +150,36 @@ enum {
|
||||||
|
|
||||||
struct Dimen
|
struct Dimen
|
||||||
{
|
{
|
||||||
int kindspec; // kind | spec
|
int kindspec; /* kind | spec */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Background is either an image or a color.
|
/* Background is either an image or a color. */
|
||||||
// If both are set, the image has precedence.
|
/* If both are set, the image has precedence. */
|
||||||
struct Background
|
struct Background
|
||||||
{
|
{
|
||||||
Rune* image; // url
|
Rune* image; /* url */
|
||||||
int color;
|
int color;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// There are about a half dozen Item variants.
|
/* There are about a half dozen Item variants. */
|
||||||
// The all look like this at the start (using Plan 9 C's
|
/* The all look like this at the start (using Plan 9 C's */
|
||||||
// anonymous structure member mechanism),
|
/* anonymous structure member mechanism), */
|
||||||
// and then the tag field dictates what extra fields there are.
|
/* and then the tag field dictates what extra fields there are. */
|
||||||
struct Item
|
struct Item
|
||||||
{
|
{
|
||||||
Item* next; // successor in list of items
|
Item* next; /* successor in list of items */
|
||||||
int width; // width in pixels (0 for floating items)
|
int width; /* width in pixels (0 for floating items) */
|
||||||
int height; // height in pixels
|
int height; /* height in pixels */
|
||||||
Rectangle r;
|
Rectangle r;
|
||||||
int ascent; // ascent (from top to baseline) in pixels
|
int ascent; /* ascent (from top to baseline) in pixels */
|
||||||
int anchorid; // if nonzero, which anchor we're in
|
int anchorid; /* if nonzero, which anchor we're in */
|
||||||
int state; // flags and values (see below)
|
int state; /* flags and values (see below) */
|
||||||
Genattr* genattr; // generic attributes and events
|
Genattr* genattr; /* generic attributes and events */
|
||||||
int tag; // variant discriminator: Itexttag, etc.
|
int tag; /* variant discriminator: Itexttag, etc. */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Item variant tags
|
/* Item variant tags */
|
||||||
enum {
|
enum {
|
||||||
Itexttag,
|
Itexttag,
|
||||||
Iruletag,
|
Iruletag,
|
||||||
|
@ -192,45 +192,45 @@ enum {
|
||||||
|
|
||||||
struct Itext
|
struct Itext
|
||||||
{
|
{
|
||||||
Item item; // (with tag ==Itexttag)
|
Item item; /* (with tag ==Itexttag) */
|
||||||
Rune* s; // the characters
|
Rune* s; /* the characters */
|
||||||
int fnt; // style*NumSize+size (see font stuff, below)
|
int fnt; /* style*NumSize+size (see font stuff, below) */
|
||||||
int fg; // Pixel (color) for text
|
int fg; /* Pixel (color) for text */
|
||||||
uchar voff; // Voffbias+vertical offset from baseline, in pixels (+ve == down)
|
uchar voff; /* Voffbias+vertical offset from baseline, in pixels (+ve == down) */
|
||||||
uchar ul; // ULnone, ULunder, or ULmid
|
uchar ul; /* ULnone, ULunder, or ULmid */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Irule
|
struct Irule
|
||||||
{
|
{
|
||||||
Item item; // (with tag ==Iruletag)
|
Item item; /* (with tag ==Iruletag) */
|
||||||
uchar align; // alignment spec
|
uchar align; /* alignment spec */
|
||||||
uchar noshade; // if true, don't shade
|
uchar noshade; /* if true, don't shade */
|
||||||
int size; // size attr (rule height)
|
int size; /* size attr (rule height) */
|
||||||
Dimen wspec; // width spec
|
Dimen wspec; /* width spec */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Iimage
|
struct Iimage
|
||||||
{
|
{
|
||||||
Item item; // (with tag ==Iimagetag)
|
Item item; /* (with tag ==Iimagetag) */
|
||||||
Rune* imsrc; // image src url
|
Rune* imsrc; /* image src url */
|
||||||
int imwidth; // spec width (actual, if no spec)
|
int imwidth; /* spec width (actual, if no spec) */
|
||||||
int imheight; // spec height (actual, if no spec)
|
int imheight; /* spec height (actual, if no spec) */
|
||||||
Rune* altrep; // alternate representation, in absence of image
|
Rune* altrep; /* alternate representation, in absence of image */
|
||||||
Map* map; // if non-nil, client side map
|
Map* map; /* if non-nil, client side map */
|
||||||
int ctlid; // if animated
|
int ctlid; /* if animated */
|
||||||
uchar align; // vertical alignment
|
uchar align; /* vertical alignment */
|
||||||
uchar hspace; // in pixels; buffer space on each side
|
uchar hspace; /* in pixels; buffer space on each side */
|
||||||
uchar vspace; // in pixels; buffer space on top and bottom
|
uchar vspace; /* in pixels; buffer space on top and bottom */
|
||||||
uchar border; // in pixels: border width to draw around image
|
uchar border; /* in pixels: border width to draw around image */
|
||||||
Iimage* nextimage; // next in list of document's images
|
Iimage* nextimage; /* next in list of document's images */
|
||||||
void *aux;
|
void *aux;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Iformfield
|
struct Iformfield
|
||||||
{
|
{
|
||||||
Item item; // (with tag ==Iformfieldtag)
|
Item item; /* (with tag ==Iformfieldtag) */
|
||||||
Formfield* formfield;
|
Formfield* formfield;
|
||||||
void *aux;
|
void *aux;
|
||||||
};
|
};
|
||||||
|
@ -238,59 +238,59 @@ struct Iformfield
|
||||||
|
|
||||||
struct Itable
|
struct Itable
|
||||||
{
|
{
|
||||||
Item item; // (with tag ==Itabletag)
|
Item item; /* (with tag ==Itabletag) */
|
||||||
Table* table;
|
Table* table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Ifloat
|
struct Ifloat
|
||||||
{
|
{
|
||||||
Item _item; // (with tag ==Ifloattag)
|
Item _item; /* (with tag ==Ifloattag) */
|
||||||
Item* item; // table or image item that floats
|
Item* item; /* table or image item that floats */
|
||||||
int x; // x coord of top (from right, if ALright)
|
int x; /* x coord of top (from right, if ALright) */
|
||||||
int y; // y coord of top
|
int y; /* y coord of top */
|
||||||
uchar side; // margin it floats to: ALleft or ALright
|
uchar side; /* margin it floats to: ALleft or ALright */
|
||||||
uchar infloats; // true if this has been added to a lay.floats
|
uchar infloats; /* true if this has been added to a lay.floats */
|
||||||
Ifloat* nextfloat; // in list of floats
|
Ifloat* nextfloat; /* in list of floats */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Ispacer
|
struct Ispacer
|
||||||
{
|
{
|
||||||
Item item; // (with tag ==Ispacertag)
|
Item item; /* (with tag ==Ispacertag) */
|
||||||
int spkind; // ISPnull, etc.
|
int spkind; /* ISPnull, etc. */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Item state flags and value fields
|
/* Item state flags and value fields */
|
||||||
enum {
|
enum {
|
||||||
// IFbrk = 0x80000000, // forced break before this item
|
/* IFbrk = 0x80000000, // forced break before this item */
|
||||||
#define IFbrk 0x80000000 /* too big for sun */
|
#define IFbrk 0x80000000 /* too big for sun */
|
||||||
IFbrksp = 0x40000000, // add 1 line space to break (IFbrk set too)
|
IFbrksp = 0x40000000, /* add 1 line space to break (IFbrk set too) */
|
||||||
IFnobrk = 0x20000000, // break not allowed before this item
|
IFnobrk = 0x20000000, /* break not allowed before this item */
|
||||||
IFcleft = 0x10000000, // clear left floats (IFbrk set too)
|
IFcleft = 0x10000000, /* clear left floats (IFbrk set too) */
|
||||||
IFcright = 0x08000000, // clear right floats (IFbrk set too)
|
IFcright = 0x08000000, /* clear right floats (IFbrk set too) */
|
||||||
IFwrap = 0x04000000, // in a wrapping (non-pre) line
|
IFwrap = 0x04000000, /* in a wrapping (non-pre) line */
|
||||||
IFhang = 0x02000000, // in a hanging (into left indent) item
|
IFhang = 0x02000000, /* in a hanging (into left indent) item */
|
||||||
IFrjust = 0x01000000, // right justify current line
|
IFrjust = 0x01000000, /* right justify current line */
|
||||||
IFcjust = 0x00800000, // center justify current line
|
IFcjust = 0x00800000, /* center justify current line */
|
||||||
IFsmap = 0x00400000, // image is server-side map
|
IFsmap = 0x00400000, /* image is server-side map */
|
||||||
IFindentshift = 8,
|
IFindentshift = 8,
|
||||||
IFindentmask = (255<<IFindentshift), // current indent, in tab stops
|
IFindentmask = (255<<IFindentshift), /* current indent, in tab stops */
|
||||||
IFhangmask = 255 // current hang into left indent, in 1/10th tabstops
|
IFhangmask = 255 /* current hang into left indent, in 1/10th tabstops */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bias added to Itext's voff field
|
/* Bias added to Itext's voff field */
|
||||||
enum { Voffbias = 128 };
|
enum { Voffbias = 128 };
|
||||||
|
|
||||||
// Spacer kinds
|
/* Spacer kinds */
|
||||||
enum {
|
enum {
|
||||||
ISPnull, // 0 height and width
|
ISPnull, /* 0 height and width */
|
||||||
ISPvline, // height and ascent of current font
|
ISPvline, /* height and ascent of current font */
|
||||||
ISPhspace, // width of space in current font
|
ISPhspace, /* width of space in current font */
|
||||||
ISPgeneral // other purposes (e.g., between markers and list)
|
ISPgeneral /* other purposes (e.g., between markers and list) */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generic attributes and events (not many elements will have any of these set)
|
/* Generic attributes and events (not many elements will have any of these set) */
|
||||||
struct Genattr
|
struct Genattr
|
||||||
{
|
{
|
||||||
Rune* id;
|
Rune* id;
|
||||||
|
@ -302,8 +302,8 @@ struct Genattr
|
||||||
|
|
||||||
struct SEvent
|
struct SEvent
|
||||||
{
|
{
|
||||||
SEvent* next; // in list of events
|
SEvent* next; /* in list of events */
|
||||||
int type; // SEonblur, etc.
|
int type; /* SEonblur, etc. */
|
||||||
Rune* script;
|
Rune* script;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -316,7 +316,7 @@ enum {
|
||||||
Numscriptev
|
Numscriptev
|
||||||
};
|
};
|
||||||
|
|
||||||
// Form field types
|
/* Form field types */
|
||||||
enum {
|
enum {
|
||||||
Ftext,
|
Ftext,
|
||||||
Fpassword,
|
Fpassword,
|
||||||
|
@ -332,24 +332,24 @@ enum {
|
||||||
Ftextarea
|
Ftextarea
|
||||||
};
|
};
|
||||||
|
|
||||||
// Information about a field in a form
|
/* Information about a field in a form */
|
||||||
struct Formfield
|
struct Formfield
|
||||||
{
|
{
|
||||||
Formfield* next; // in list of fields for a form
|
Formfield* next; /* in list of fields for a form */
|
||||||
int ftype; // Ftext, Fpassword, etc.
|
int ftype; /* Ftext, Fpassword, etc. */
|
||||||
int fieldid; // serial no. of field within its form
|
int fieldid; /* serial no. of field within its form */
|
||||||
Form* form; // containing form
|
Form* form; /* containing form */
|
||||||
Rune* name; // name attr
|
Rune* name; /* name attr */
|
||||||
Rune* value; // value attr
|
Rune* value; /* value attr */
|
||||||
int size; // size attr
|
int size; /* size attr */
|
||||||
int maxlength; // maxlength attr
|
int maxlength; /* maxlength attr */
|
||||||
int rows; // rows attr
|
int rows; /* rows attr */
|
||||||
int cols; // cols attr
|
int cols; /* cols attr */
|
||||||
uchar flags; // FFchecked, etc.
|
uchar flags; /* FFchecked, etc. */
|
||||||
Option* options; // for Fselect fields
|
Option* options; /* for Fselect fields */
|
||||||
Item* image; // image item, for Fimage fields
|
Item* image; /* image item, for Fimage fields */
|
||||||
int ctlid; // identifies control for this field in layout
|
int ctlid; /* identifies control for this field in layout */
|
||||||
SEvent* events; // same as genattr->events of containing item
|
SEvent* events; /* same as genattr->events of containing item */
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -357,29 +357,29 @@ enum {
|
||||||
FFmultiple = (1<<6)
|
FFmultiple = (1<<6)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Option holds info about an option in a "select" form field
|
/* Option holds info about an option in a "select" form field */
|
||||||
struct Option
|
struct Option
|
||||||
{
|
{
|
||||||
Option* next; // next in list of options for a field
|
Option* next; /* next in list of options for a field */
|
||||||
int selected; // true if selected initially
|
int selected; /* true if selected initially */
|
||||||
Rune* value; // value attr
|
Rune* value; /* value attr */
|
||||||
Rune* display; // display string
|
Rune* display; /* display string */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Form holds info about a form
|
/* Form holds info about a form */
|
||||||
struct Form
|
struct Form
|
||||||
{
|
{
|
||||||
Form* next; // in list of forms for document
|
Form* next; /* in list of forms for document */
|
||||||
int formid; // serial no. of form within its doc
|
int formid; /* serial no. of form within its doc */
|
||||||
Rune* name; // name or id attr (netscape uses name, HTML 4.0 uses id)
|
Rune* name; /* name or id attr (netscape uses name, HTML 4.0 uses id) */
|
||||||
Rune* action; // action attr
|
Rune* action; /* action attr */
|
||||||
int target; // target attr as targetid
|
int target; /* target attr as targetid */
|
||||||
int method; // HGet or HPost
|
int method; /* HGet or HPost */
|
||||||
int nfields; // number of fields
|
int nfields; /* number of fields */
|
||||||
Formfield* fields; // field's forms, in input order
|
Formfield* fields; /* field's forms, in input order */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Flags used in various table structures
|
/* Flags used in various table structures */
|
||||||
enum {
|
enum {
|
||||||
TFparsing = (1<<7),
|
TFparsing = (1<<7),
|
||||||
TFnowrap = (1<<6),
|
TFnowrap = (1<<6),
|
||||||
|
@ -387,33 +387,33 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Information about a table
|
/* Information about a table */
|
||||||
struct Table
|
struct Table
|
||||||
{
|
{
|
||||||
Table* next; // next in list of document's tables
|
Table* next; /* next in list of document's tables */
|
||||||
int tableid; // serial no. of table within its doc
|
int tableid; /* serial no. of table within its doc */
|
||||||
Tablerow* rows; // array of row specs (list during parsing)
|
Tablerow* rows; /* array of row specs (list during parsing) */
|
||||||
int nrow; // total number of rows
|
int nrow; /* total number of rows */
|
||||||
Tablecol* cols; // array of column specs
|
Tablecol* cols; /* array of column specs */
|
||||||
int ncol; // total number of columns
|
int ncol; /* total number of columns */
|
||||||
Tablecell* cells; // list of unique cells
|
Tablecell* cells; /* list of unique cells */
|
||||||
int ncell; // total number of cells
|
int ncell; /* total number of cells */
|
||||||
Tablecell*** grid; // 2-D array of cells
|
Tablecell*** grid; /* 2-D array of cells */
|
||||||
Align align; // alignment spec for whole table
|
Align align; /* alignment spec for whole table */
|
||||||
Dimen width; // width spec for whole table
|
Dimen width; /* width spec for whole table */
|
||||||
int border; // border attr
|
int border; /* border attr */
|
||||||
int cellspacing; // cellspacing attr
|
int cellspacing; /* cellspacing attr */
|
||||||
int cellpadding; // cellpadding attr
|
int cellpadding; /* cellpadding attr */
|
||||||
Background background; // table background
|
Background background; /* table background */
|
||||||
Item* caption; // linked list of Items, giving caption
|
Item* caption; /* linked list of Items, giving caption */
|
||||||
uchar caption_place; // ALtop or ALbottom
|
uchar caption_place; /* ALtop or ALbottom */
|
||||||
Lay* caption_lay; // layout of caption
|
Lay* caption_lay; /* layout of caption */
|
||||||
int totw; // total width
|
int totw; /* total width */
|
||||||
int toth; // total height
|
int toth; /* total height */
|
||||||
int caph; // caption height
|
int caph; /* caption height */
|
||||||
int availw; // used for previous 3 sizes
|
int availw; /* used for previous 3 sizes */
|
||||||
Token* tabletok; // token that started the table
|
Token* tabletok; /* token that started the table */
|
||||||
uchar flags; // Lchanged, perhaps
|
uchar flags; /* Lchanged, perhaps */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,101 +427,101 @@ struct Tablecol
|
||||||
|
|
||||||
struct Tablerow
|
struct Tablerow
|
||||||
{
|
{
|
||||||
Tablerow* next; // Next in list of rows, during parsing
|
Tablerow* next; /* Next in list of rows, during parsing */
|
||||||
Tablecell* cells; // Cells in row, linked through nextinrow
|
Tablecell* cells; /* Cells in row, linked through nextinrow */
|
||||||
int height;
|
int height;
|
||||||
int ascent;
|
int ascent;
|
||||||
Align align;
|
Align align;
|
||||||
Background background;
|
Background background;
|
||||||
Point pos;
|
Point pos;
|
||||||
uchar flags; // 0 or TFparsing
|
uchar flags; /* 0 or TFparsing */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// A Tablecell is one cell of a table.
|
/* A Tablecell is one cell of a table. */
|
||||||
// It may span multiple rows and multiple columns.
|
/* It may span multiple rows and multiple columns. */
|
||||||
// Cells are linked on two lists: the list for all the cells of
|
/* Cells are linked on two lists: the list for all the cells of */
|
||||||
// a document (the next pointers), and the list of all the
|
/* a document (the next pointers), and the list of all the */
|
||||||
// cells that start in a given row (the nextinrow pointers)
|
/* cells that start in a given row (the nextinrow pointers) */
|
||||||
struct Tablecell
|
struct Tablecell
|
||||||
{
|
{
|
||||||
Tablecell* next; // next in list of table's cells
|
Tablecell* next; /* next in list of table's cells */
|
||||||
Tablecell* nextinrow; // next in list of row's cells
|
Tablecell* nextinrow; /* next in list of row's cells */
|
||||||
int cellid; // serial no. of cell within table
|
int cellid; /* serial no. of cell within table */
|
||||||
Item* content; // contents before layout
|
Item* content; /* contents before layout */
|
||||||
Lay* lay; // layout of cell
|
Lay* lay; /* layout of cell */
|
||||||
int rowspan; // number of rows spanned by this cell
|
int rowspan; /* number of rows spanned by this cell */
|
||||||
int colspan; // number of cols spanned by this cell
|
int colspan; /* number of cols spanned by this cell */
|
||||||
Align align; // alignment spec
|
Align align; /* alignment spec */
|
||||||
uchar flags; // TFparsing, TFnowrap, TFisth
|
uchar flags; /* TFparsing, TFnowrap, TFisth */
|
||||||
Dimen wspec; // suggested width
|
Dimen wspec; /* suggested width */
|
||||||
int hspec; // suggested height
|
int hspec; /* suggested height */
|
||||||
Background background; // cell background
|
Background background; /* cell background */
|
||||||
int minw; // minimum possible width
|
int minw; /* minimum possible width */
|
||||||
int maxw; // maximum width
|
int maxw; /* maximum width */
|
||||||
int ascent; // cell's ascent
|
int ascent; /* cell's ascent */
|
||||||
int row; // row of upper left corner
|
int row; /* row of upper left corner */
|
||||||
int col; // col of upper left corner
|
int col; /* col of upper left corner */
|
||||||
Point pos; // nw corner of cell contents, in cell
|
Point pos; /* nw corner of cell contents, in cell */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Anchor is for info about hyperlinks that go somewhere
|
/* Anchor is for info about hyperlinks that go somewhere */
|
||||||
struct Anchor
|
struct Anchor
|
||||||
{
|
{
|
||||||
Anchor* next; // next in list of document's anchors
|
Anchor* next; /* next in list of document's anchors */
|
||||||
int index; // serial no. of anchor within its doc
|
int index; /* serial no. of anchor within its doc */
|
||||||
Rune* name; // name attr
|
Rune* name; /* name attr */
|
||||||
Rune* href; // href attr
|
Rune* href; /* href attr */
|
||||||
int target; // target attr as targetid
|
int target; /* target attr as targetid */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// DestAnchor is for info about hyperlinks that are destinations
|
/* DestAnchor is for info about hyperlinks that are destinations */
|
||||||
struct DestAnchor
|
struct DestAnchor
|
||||||
{
|
{
|
||||||
DestAnchor* next; // next in list of document's destanchors
|
DestAnchor* next; /* next in list of document's destanchors */
|
||||||
int index; // serial no. of anchor within its doc
|
int index; /* serial no. of anchor within its doc */
|
||||||
Rune* name; // name attr
|
Rune* name; /* name attr */
|
||||||
Item* item; // the destination
|
Item* item; /* the destination */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Maps (client side)
|
/* Maps (client side) */
|
||||||
struct Map
|
struct Map
|
||||||
{
|
{
|
||||||
Map* next; // next in list of document's maps
|
Map* next; /* next in list of document's maps */
|
||||||
Rune* name; // map name
|
Rune* name; /* map name */
|
||||||
Area* areas; // list of map areas
|
Area* areas; /* list of map areas */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Area
|
struct Area
|
||||||
{
|
{
|
||||||
Area* next; // next in list of a map's areas
|
Area* next; /* next in list of a map's areas */
|
||||||
int shape; // SHrect, etc.
|
int shape; /* SHrect, etc. */
|
||||||
Rune* href; // associated hypertext link
|
Rune* href; /* associated hypertext link */
|
||||||
int target; // associated target frame
|
int target; /* associated target frame */
|
||||||
Dimen* coords; // array of coords for shape
|
Dimen* coords; /* array of coords for shape */
|
||||||
int ncoords; // size of coords array
|
int ncoords; /* size of coords array */
|
||||||
};
|
};
|
||||||
|
|
||||||
// Area shapes
|
/* Area shapes */
|
||||||
enum {
|
enum {
|
||||||
SHrect, SHcircle, SHpoly
|
SHrect, SHcircle, SHpoly
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fonts are represented by integers: style*NumSize + size
|
/* Fonts are represented by integers: style*NumSize + size */
|
||||||
|
|
||||||
// Font styles
|
/* Font styles */
|
||||||
enum {
|
enum {
|
||||||
FntR, // roman
|
FntR, /* roman */
|
||||||
FntI, // italic
|
FntI, /* italic */
|
||||||
FntB, // bold
|
FntB, /* bold */
|
||||||
FntT, // typewriter
|
FntT, /* typewriter */
|
||||||
NumStyle
|
NumStyle
|
||||||
};
|
};
|
||||||
|
|
||||||
// Font sizes
|
/* Font sizes */
|
||||||
enum {
|
enum {
|
||||||
Tiny,
|
Tiny,
|
||||||
Small,
|
Small,
|
||||||
|
@ -536,12 +536,12 @@ enum {
|
||||||
DefFnt = (FntR*NumSize+Normal)
|
DefFnt = (FntR*NumSize+Normal)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Lines are needed through some text items, for underlining or strikethrough
|
/* Lines are needed through some text items, for underlining or strikethrough */
|
||||||
enum {
|
enum {
|
||||||
ULnone, ULunder, ULmid
|
ULnone, ULunder, ULmid
|
||||||
};
|
};
|
||||||
|
|
||||||
// Kidinfo flags
|
/* Kidinfo flags */
|
||||||
enum {
|
enum {
|
||||||
FRnoresize = (1<<0),
|
FRnoresize = (1<<0),
|
||||||
FRnoscroll = (1<<1),
|
FRnoscroll = (1<<1),
|
||||||
|
@ -551,59 +551,59 @@ enum {
|
||||||
FRvscrollauto = (1<<5)
|
FRvscrollauto = (1<<5)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Information about child frame or frameset
|
/* Information about child frame or frameset */
|
||||||
struct Kidinfo
|
struct Kidinfo
|
||||||
{
|
{
|
||||||
Kidinfo* next; // in list of kidinfos for a frameset
|
Kidinfo* next; /* in list of kidinfos for a frameset */
|
||||||
int isframeset;
|
int isframeset;
|
||||||
|
|
||||||
// fields for "frame"
|
/* fields for "frame" */
|
||||||
Rune* src; // only nil if a "dummy" frame or this is frameset
|
Rune* src; /* only nil if a "dummy" frame or this is frameset */
|
||||||
Rune* name; // always non-empty if this isn't frameset
|
Rune* name; /* always non-empty if this isn't frameset */
|
||||||
int marginw;
|
int marginw;
|
||||||
int marginh;
|
int marginh;
|
||||||
int framebd;
|
int framebd;
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
// fields for "frameset"
|
/* fields for "frameset" */
|
||||||
Dimen* rows; // array of row dimensions
|
Dimen* rows; /* array of row dimensions */
|
||||||
int nrows; // length of rows
|
int nrows; /* length of rows */
|
||||||
Dimen* cols; // array of col dimensions
|
Dimen* cols; /* array of col dimensions */
|
||||||
int ncols; // length of cols
|
int ncols; /* length of cols */
|
||||||
Kidinfo* kidinfos;
|
Kidinfo* kidinfos;
|
||||||
Kidinfo* nextframeset; // parsing stack
|
Kidinfo* nextframeset; /* parsing stack */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Document info (global information about HTML page)
|
/* Document info (global information about HTML page) */
|
||||||
struct Docinfo
|
struct Docinfo
|
||||||
{
|
{
|
||||||
// stuff from HTTP headers, doc head, and body tag
|
/* stuff from HTTP headers, doc head, and body tag */
|
||||||
Rune* src; // original source of doc
|
Rune* src; /* original source of doc */
|
||||||
Rune* base; // base URL of doc
|
Rune* base; /* base URL of doc */
|
||||||
Rune* doctitle; // from <title> element
|
Rune* doctitle; /* from <title> element */
|
||||||
Background background; // background specification
|
Background background; /* background specification */
|
||||||
Iimage* backgrounditem; // Image Item for doc background image, or nil
|
Iimage* backgrounditem; /* Image Item for doc background image, or nil */
|
||||||
int text; // doc foreground (text) color
|
int text; /* doc foreground (text) color */
|
||||||
int link; // unvisited hyperlink color
|
int link; /* unvisited hyperlink color */
|
||||||
int vlink; // visited hyperlink color
|
int vlink; /* visited hyperlink color */
|
||||||
int alink; // highlighting hyperlink color
|
int alink; /* highlighting hyperlink color */
|
||||||
int target; // target frame default
|
int target; /* target frame default */
|
||||||
int chset; // ISO_8859, etc.
|
int chset; /* ISO_8859, etc. */
|
||||||
int mediatype; // TextHtml, etc.
|
int mediatype; /* TextHtml, etc. */
|
||||||
int scripttype; // TextJavascript, etc.
|
int scripttype; /* TextJavascript, etc. */
|
||||||
int hasscripts; // true if scripts used
|
int hasscripts; /* true if scripts used */
|
||||||
Rune* refresh; // content of <http-equiv=Refresh ...>
|
Rune* refresh; /* content of <http-equiv=Refresh ...> */
|
||||||
Kidinfo* kidinfo; // if a frameset
|
Kidinfo* kidinfo; /* if a frameset */
|
||||||
int frameid; // id of document frame
|
int frameid; /* id of document frame */
|
||||||
|
|
||||||
// info needed to respond to user actions
|
/* info needed to respond to user actions */
|
||||||
Anchor* anchors; // list of href anchors
|
Anchor* anchors; /* list of href anchors */
|
||||||
DestAnchor* dests; // list of destination anchors
|
DestAnchor* dests; /* list of destination anchors */
|
||||||
Form* forms; // list of forms
|
Form* forms; /* list of forms */
|
||||||
Table* tables; // list of tables
|
Table* tables; /* list of tables */
|
||||||
Map* maps; // list of maps
|
Map* maps; /* list of maps */
|
||||||
Iimage* images; // list of image items (through nextimage links)
|
Iimage* images; /* list of image items (through nextimage links) */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int dimenkind(Dimen d);
|
extern int dimenkind(Dimen d);
|
||||||
|
@ -618,14 +618,14 @@ extern int validitems(Item* i);
|
||||||
|
|
||||||
/* #pragma varargck type "I" Item* */
|
/* #pragma varargck type "I" Item* */
|
||||||
|
|
||||||
// Control print output
|
/* Control print output */
|
||||||
extern int warn;
|
extern int warn;
|
||||||
extern int dbglex;
|
extern int dbglex;
|
||||||
extern int dbgbuild;
|
extern int dbgbuild;
|
||||||
|
|
||||||
// To be provided by caller
|
/* To be provided by caller */
|
||||||
// emalloc and erealloc should not return if can't get memory.
|
/* emalloc and erealloc should not return if can't get memory. */
|
||||||
// emalloc should zero its memory.
|
/* emalloc should zero its memory. */
|
||||||
extern void* emalloc(ulong);
|
extern void* emalloc(ulong);
|
||||||
extern void* erealloc(void* p, ulong size);
|
extern void* erealloc(void* p, ulong size);
|
||||||
#ifdef __cpluspplus
|
#ifdef __cpluspplus
|
||||||
|
|
|
@ -48,7 +48,7 @@ enum
|
||||||
HExpectFail,
|
HExpectFail,
|
||||||
HUnkVers,
|
HUnkVers,
|
||||||
HBadCont,
|
HBadCont,
|
||||||
HOK,
|
HOK
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -18,7 +18,7 @@ enum
|
||||||
IPaddrlen= 16,
|
IPaddrlen= 16,
|
||||||
IPv4addrlen= 4,
|
IPv4addrlen= 4,
|
||||||
IPv4off= 12,
|
IPv4off= 12,
|
||||||
IPllen= 4,
|
IPllen= 4
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -80,7 +80,7 @@ struct Ipifc
|
||||||
*/
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Udphdrsize= 52, /* size of a Udphdr */
|
Udphdrsize= 52 /* size of a Udphdr */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Udphdr Udphdr;
|
typedef struct Udphdr Udphdr;
|
||||||
|
|
|
@ -37,7 +37,7 @@ enum {
|
||||||
|
|
||||||
Kalt= KF|0x15,
|
Kalt= KF|0x15,
|
||||||
Kshift= KF|0x16,
|
Kshift= KF|0x16,
|
||||||
Kctl= KF|0x17,
|
Kctl= KF|0x17
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
|
@ -349,7 +349,7 @@ extern vlong p9nsec(void);
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PNPROC = 1,
|
PNPROC = 1,
|
||||||
PNGROUP = 2,
|
PNGROUP = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/* extern int abs(int); <stdlib.h> */
|
/* extern int abs(int); <stdlib.h> */
|
||||||
|
@ -671,7 +671,7 @@ enum
|
||||||
RFNOWAIT = (1<<6),
|
RFNOWAIT = (1<<6),
|
||||||
RFCNAMEG = (1<<10),
|
RFCNAMEG = (1<<10),
|
||||||
RFCENVG = (1<<11),
|
RFCENVG = (1<<11),
|
||||||
RFCFDG = (1<<12),
|
RFCFDG = (1<<12)
|
||||||
/* RFREND = (1<<13), */
|
/* RFREND = (1<<13), */
|
||||||
/* RFNOMNT = (1<<14) */
|
/* RFNOMNT = (1<<14) */
|
||||||
};
|
};
|
||||||
|
|
142
include/libsec.h
142
include/libsec.h
|
@ -14,9 +14,9 @@ AUTOLIB(sec)
|
||||||
typedef struct mpint mpint;
|
typedef struct mpint mpint;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// AES definitions
|
/* AES definitions */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -41,9 +41,9 @@ void setupAESstate(AESstate *s, uchar key[], int keybytes, uchar *ivec);
|
||||||
void aesCBCencrypt(uchar *p, int len, AESstate *s);
|
void aesCBCencrypt(uchar *p, int len, AESstate *s);
|
||||||
void aesCBCdecrypt(uchar *p, int len, AESstate *s);
|
void aesCBCdecrypt(uchar *p, int len, AESstate *s);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// Blowfish Definitions
|
/* Blowfish Definitions */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ enum
|
||||||
BFrounds = 16
|
BFrounds = 16
|
||||||
};
|
};
|
||||||
|
|
||||||
// 16-round Blowfish
|
/* 16-round Blowfish */
|
||||||
typedef struct BFstate BFstate;
|
typedef struct BFstate BFstate;
|
||||||
struct BFstate
|
struct BFstate
|
||||||
{
|
{
|
||||||
|
@ -70,16 +70,16 @@ void bfCBCdecrypt(uchar*, int, BFstate*);
|
||||||
void bfECBencrypt(uchar*, int, BFstate*);
|
void bfECBencrypt(uchar*, int, BFstate*);
|
||||||
void bfECBdecrypt(uchar*, int, BFstate*);
|
void bfECBdecrypt(uchar*, int, BFstate*);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// DES definitions
|
/* DES definitions */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
DESbsize= 8
|
DESbsize= 8
|
||||||
};
|
};
|
||||||
|
|
||||||
// single des
|
/* single des */
|
||||||
typedef struct DESstate DESstate;
|
typedef struct DESstate DESstate;
|
||||||
struct DESstate
|
struct DESstate
|
||||||
{
|
{
|
||||||
|
@ -97,12 +97,12 @@ void desCBCdecrypt(uchar*, int, DESstate*);
|
||||||
void desECBencrypt(uchar*, int, DESstate*);
|
void desECBencrypt(uchar*, int, DESstate*);
|
||||||
void desECBdecrypt(uchar*, int, DESstate*);
|
void desECBdecrypt(uchar*, int, DESstate*);
|
||||||
|
|
||||||
// for backward compatibility with 7 byte DES key format
|
/* for backward compatibility with 7 byte DES key format */
|
||||||
void des56to64(uchar *k56, uchar *k64);
|
void des56to64(uchar *k56, uchar *k64);
|
||||||
void des64to56(uchar *k64, uchar *k56);
|
void des64to56(uchar *k64, uchar *k56);
|
||||||
void key_setup(uchar[7], ulong[32]);
|
void key_setup(uchar[7], ulong[32]);
|
||||||
|
|
||||||
// triple des encrypt/decrypt orderings
|
/* triple des encrypt/decrypt orderings */
|
||||||
enum {
|
enum {
|
||||||
DES3E= 0,
|
DES3E= 0,
|
||||||
DES3D= 1,
|
DES3D= 1,
|
||||||
|
@ -128,9 +128,9 @@ void des3CBCdecrypt(uchar*, int, DES3state*);
|
||||||
void des3ECBencrypt(uchar*, int, DES3state*);
|
void des3ECBencrypt(uchar*, int, DES3state*);
|
||||||
void des3ECBdecrypt(uchar*, int, DES3state*);
|
void des3ECBdecrypt(uchar*, int, DES3state*);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// digests
|
/* digests */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -162,27 +162,27 @@ DigestState* hmac_sha1(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
|
||||||
char* sha1pickle(SHA1state*);
|
char* sha1pickle(SHA1state*);
|
||||||
SHA1state* sha1unpickle(char*);
|
SHA1state* sha1unpickle(char*);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// random number generation
|
/* random number generation */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
void genrandom(uchar *buf, int nbytes);
|
void genrandom(uchar *buf, int nbytes);
|
||||||
void prng(uchar *buf, int nbytes);
|
void prng(uchar *buf, int nbytes);
|
||||||
ulong fastrand(void);
|
ulong fastrand(void);
|
||||||
ulong nfastrand(ulong);
|
ulong nfastrand(ulong);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// primes
|
/* primes */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
void genprime(mpint *p, int n, int accuracy); // generate an n bit probable prime
|
void genprime(mpint *p, int n, int accuracy); /* generate an n bit probable prime */
|
||||||
void gensafeprime(mpint *p, mpint *alpha, int n, int accuracy); // prime and generator
|
void gensafeprime(mpint *p, mpint *alpha, int n, int accuracy); /* prime and generator */
|
||||||
void genstrongprime(mpint *p, int n, int accuracy); // generate an n bit strong prime
|
void genstrongprime(mpint *p, int n, int accuracy); /* generate an n bit strong prime */
|
||||||
void DSAprimes(mpint *q, mpint *p, uchar seed[SHA1dlen]);
|
void DSAprimes(mpint *q, mpint *p, uchar seed[SHA1dlen]);
|
||||||
int probably_prime(mpint *n, int nrep); // miller-rabin test
|
int probably_prime(mpint *n, int nrep); /* miller-rabin test */
|
||||||
int smallprimetest(mpint *p); // returns -1 if not prime, 0 otherwise
|
int smallprimetest(mpint *p); /* returns -1 if not prime, 0 otherwise */
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// rc4
|
/* rc4 */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
typedef struct RC4state RC4state;
|
typedef struct RC4state RC4state;
|
||||||
struct RC4state
|
struct RC4state
|
||||||
{
|
{
|
||||||
|
@ -196,33 +196,33 @@ void rc4(RC4state*, uchar*, int);
|
||||||
void rc4skip(RC4state*, int);
|
void rc4skip(RC4state*, int);
|
||||||
void rc4back(RC4state*, int);
|
void rc4back(RC4state*, int);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// rsa
|
/* rsa */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
typedef struct RSApub RSApub;
|
typedef struct RSApub RSApub;
|
||||||
typedef struct RSApriv RSApriv;
|
typedef struct RSApriv RSApriv;
|
||||||
typedef struct PEMChain PEMChain;
|
typedef struct PEMChain PEMChain;
|
||||||
|
|
||||||
// public/encryption key
|
/* public/encryption key */
|
||||||
struct RSApub
|
struct RSApub
|
||||||
{
|
{
|
||||||
mpint *n; // modulus
|
mpint *n; /* modulus */
|
||||||
mpint *ek; // exp (encryption key)
|
mpint *ek; /* exp (encryption key) */
|
||||||
};
|
};
|
||||||
|
|
||||||
// private/decryption key
|
/* private/decryption key */
|
||||||
struct RSApriv
|
struct RSApriv
|
||||||
{
|
{
|
||||||
RSApub pub;
|
RSApub pub;
|
||||||
|
|
||||||
mpint *dk; // exp (decryption key)
|
mpint *dk; /* exp (decryption key) */
|
||||||
|
|
||||||
// precomputed values to help with chinese remainder theorem calc
|
/* precomputed values to help with chinese remainder theorem calc */
|
||||||
mpint *p;
|
mpint *p;
|
||||||
mpint *q;
|
mpint *q;
|
||||||
mpint *kp; // dk mod p-1
|
mpint *kp; /* dk mod p-1 */
|
||||||
mpint *kq; // dk mod q-1
|
mpint *kq; /* dk mod q-1 */
|
||||||
mpint *c2; // (inv p) mod q
|
mpint *c2; /* (inv p) mod q */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PEMChain
|
struct PEMChain
|
||||||
|
@ -248,29 +248,29 @@ uchar* X509gen(RSApriv *priv, char *subj, ulong valid[2], int *certlen);
|
||||||
RSApriv* rsafill(mpint *n, mpint *ek, mpint *dk, mpint *p, mpint *q);
|
RSApriv* rsafill(mpint *n, mpint *ek, mpint *dk, mpint *p, mpint *q);
|
||||||
uchar* X509req(RSApriv *priv, char *subj, int *certlen);
|
uchar* X509req(RSApriv *priv, char *subj, int *certlen);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// elgamal
|
/* elgamal */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
typedef struct EGpub EGpub;
|
typedef struct EGpub EGpub;
|
||||||
typedef struct EGpriv EGpriv;
|
typedef struct EGpriv EGpriv;
|
||||||
typedef struct EGsig EGsig;
|
typedef struct EGsig EGsig;
|
||||||
|
|
||||||
// public/encryption key
|
/* public/encryption key */
|
||||||
struct EGpub
|
struct EGpub
|
||||||
{
|
{
|
||||||
mpint *p; // modulus
|
mpint *p; /* modulus */
|
||||||
mpint *alpha; // generator
|
mpint *alpha; /* generator */
|
||||||
mpint *key; // (encryption key) alpha**secret mod p
|
mpint *key; /* (encryption key) alpha**secret mod p */
|
||||||
};
|
};
|
||||||
|
|
||||||
// private/decryption key
|
/* private/decryption key */
|
||||||
struct EGpriv
|
struct EGpriv
|
||||||
{
|
{
|
||||||
EGpub pub;
|
EGpub pub;
|
||||||
mpint *secret; // (decryption key)
|
mpint *secret; /* (decryption key) */
|
||||||
};
|
};
|
||||||
|
|
||||||
// signature
|
/* signature */
|
||||||
struct EGsig
|
struct EGsig
|
||||||
{
|
{
|
||||||
mpint *r, *s;
|
mpint *r, *s;
|
||||||
|
@ -289,30 +289,30 @@ EGsig* egsigalloc(void);
|
||||||
void egsigfree(EGsig*);
|
void egsigfree(EGsig*);
|
||||||
EGpub* egprivtopub(EGpriv*);
|
EGpub* egprivtopub(EGpriv*);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// dsa
|
/* dsa */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
typedef struct DSApub DSApub;
|
typedef struct DSApub DSApub;
|
||||||
typedef struct DSApriv DSApriv;
|
typedef struct DSApriv DSApriv;
|
||||||
typedef struct DSAsig DSAsig;
|
typedef struct DSAsig DSAsig;
|
||||||
|
|
||||||
// public/encryption key
|
/* public/encryption key */
|
||||||
struct DSApub
|
struct DSApub
|
||||||
{
|
{
|
||||||
mpint *p; // modulus
|
mpint *p; /* modulus */
|
||||||
mpint *q; // group order, q divides p-1
|
mpint *q; /* group order, q divides p-1 */
|
||||||
mpint *alpha; // group generator
|
mpint *alpha; /* group generator */
|
||||||
mpint *key; // (encryption key) alpha**secret mod p
|
mpint *key; /* (encryption key) alpha**secret mod p */
|
||||||
};
|
};
|
||||||
|
|
||||||
// private/decryption key
|
/* private/decryption key */
|
||||||
struct DSApriv
|
struct DSApriv
|
||||||
{
|
{
|
||||||
DSApub pub;
|
DSApub pub;
|
||||||
mpint *secret; // (decryption key)
|
mpint *secret; /* (decryption key) */
|
||||||
};
|
};
|
||||||
|
|
||||||
// signature
|
/* signature */
|
||||||
struct DSAsig
|
struct DSAsig
|
||||||
{
|
{
|
||||||
mpint *r, *s;
|
mpint *r, *s;
|
||||||
|
@ -330,33 +330,33 @@ void dsasigfree(DSAsig*);
|
||||||
DSApub* dsaprivtopub(DSApriv*);
|
DSApub* dsaprivtopub(DSApriv*);
|
||||||
DSApriv* asn1toDSApriv(uchar*, int);
|
DSApriv* asn1toDSApriv(uchar*, int);
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
// TLS
|
/* TLS */
|
||||||
/////////////////////////////////////////////////////////
|
/*******************************************************/
|
||||||
typedef struct Thumbprint{
|
typedef struct Thumbprint{
|
||||||
struct Thumbprint *next;
|
struct Thumbprint *next;
|
||||||
uchar sha1[SHA1dlen];
|
uchar sha1[SHA1dlen];
|
||||||
} Thumbprint;
|
} Thumbprint;
|
||||||
|
|
||||||
typedef struct TLSconn{
|
typedef struct TLSconn{
|
||||||
char dir[40]; // connection directory
|
char dir[40]; /* connection directory */
|
||||||
uchar *cert; // certificate (local on input, remote on output)
|
uchar *cert; /* certificate (local on input, remote on output) */
|
||||||
uchar *sessionID;
|
uchar *sessionID;
|
||||||
int certlen, sessionIDlen;
|
int certlen, sessionIDlen;
|
||||||
int (*trace)(char*fmt, ...);
|
int (*trace)(char*fmt, ...);
|
||||||
PEMChain *chain;
|
PEMChain *chain;
|
||||||
} TLSconn;
|
} TLSconn;
|
||||||
|
|
||||||
// tlshand.c
|
/* tlshand.c */
|
||||||
extern int tlsClient(int fd, TLSconn *c);
|
extern int tlsClient(int fd, TLSconn *c);
|
||||||
extern int tlsServer(int fd, TLSconn *c);
|
extern int tlsServer(int fd, TLSconn *c);
|
||||||
|
|
||||||
// thumb.c
|
/* thumb.c */
|
||||||
extern Thumbprint* initThumbprints(char *ok, char *crl);
|
extern Thumbprint* initThumbprints(char *ok, char *crl);
|
||||||
extern void freeThumbprints(Thumbprint *ok);
|
extern void freeThumbprints(Thumbprint *ok);
|
||||||
extern int okThumbprint(uchar *sha1, Thumbprint *ok);
|
extern int okThumbprint(uchar *sha1, Thumbprint *ok);
|
||||||
|
|
||||||
// readcert.c
|
/* readcert.c */
|
||||||
extern uchar *readcert(char *filename, int *pcertlen);
|
extern uchar *readcert(char *filename, int *pcertlen);
|
||||||
PEMChain *readcertchain(char *filename);
|
PEMChain *readcertchain(char *filename);
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ enum
|
||||||
LREG, /* register */
|
LREG, /* register */
|
||||||
LADDR, /* absolute address */
|
LADDR, /* absolute address */
|
||||||
LCONST, /* constant (an anonymous readonly location) */
|
LCONST, /* constant (an anonymous readonly location) */
|
||||||
LOFFSET, /* dereference offset + register ptr */
|
LOFFSET /* dereference offset + register ptr */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Loc
|
struct Loc
|
||||||
|
@ -357,7 +357,7 @@ enum
|
||||||
|
|
||||||
RINT = 0<<0,
|
RINT = 0<<0,
|
||||||
RFLT = 1<<0,
|
RFLT = 1<<0,
|
||||||
RRDONLY = 1<<1,
|
RRDONLY = 1<<1
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Regdesc
|
struct Regdesc
|
||||||
|
@ -456,7 +456,7 @@ enum
|
||||||
CPARAM, /* function parameter */
|
CPARAM, /* function parameter */
|
||||||
CTEXT, /* text segment */
|
CTEXT, /* text segment */
|
||||||
CDATA, /* data segment */
|
CDATA, /* data segment */
|
||||||
CANY,
|
CANY
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Symbol
|
struct Symbol
|
||||||
|
|
|
@ -33,7 +33,7 @@ enum {
|
||||||
Fgrey = 1<<2, /* is grey */
|
Fgrey = 1<<2, /* is grey */
|
||||||
Falpha = 1<<3, /* has explicit alpha */
|
Falpha = 1<<3, /* has explicit alpha */
|
||||||
Fcmap = 1<<4, /* has cmap channel */
|
Fcmap = 1<<4, /* has cmap channel */
|
||||||
Fbytes = 1<<5, /* has only 8-bit channels */
|
Fbytes = 1<<5 /* has only 8-bit channels */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Memimage
|
struct Memimage
|
||||||
|
@ -94,8 +94,8 @@ enum {
|
||||||
Simplemask=1<<1,
|
Simplemask=1<<1,
|
||||||
Replsrc=1<<2,
|
Replsrc=1<<2,
|
||||||
Replmask=1<<3,
|
Replmask=1<<3,
|
||||||
Fullsrc = 1<<4,
|
Fullsrc=1<<4,
|
||||||
Fullmask=1<<5,
|
Fullmask=1<<5
|
||||||
};
|
};
|
||||||
struct Memdrawparam
|
struct Memdrawparam
|
||||||
{
|
{
|
||||||
|
|
130
include/mp.h
130
include/mp.h
|
@ -15,17 +15,17 @@ AUTOLIB(mp)
|
||||||
|
|
||||||
typedef ulong mpdigit;
|
typedef ulong mpdigit;
|
||||||
|
|
||||||
// the code assumes mpdigit to be at least an int
|
/* the code assumes mpdigit to be at least an int */
|
||||||
// mpdigit must be an atomic type. mpdigit is defined
|
/* mpdigit must be an atomic type. mpdigit is defined */
|
||||||
// in the architecture specific u.h
|
/* in the architecture specific u.h */
|
||||||
|
|
||||||
typedef struct mpint mpint;
|
typedef struct mpint mpint;
|
||||||
|
|
||||||
struct mpint
|
struct mpint
|
||||||
{
|
{
|
||||||
int sign; // +1 or -1
|
int sign; /* +1 or -1 */
|
||||||
int size; // allocated digits
|
int size; /* allocated digits */
|
||||||
int top; // significant digits
|
int top; /* significant digits */
|
||||||
mpdigit *p;
|
mpdigit *p;
|
||||||
char flags;
|
char flags;
|
||||||
};
|
};
|
||||||
|
@ -33,117 +33,117 @@ struct mpint
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MPstatic= 0x01,
|
MPstatic= 0x01,
|
||||||
Dbytes= sizeof(mpdigit), // bytes per digit
|
Dbytes= sizeof(mpdigit), /* bytes per digit */
|
||||||
Dbits= Dbytes*8 // bits per digit
|
Dbits= Dbytes*8 /* bits per digit */
|
||||||
};
|
};
|
||||||
|
|
||||||
// allocation
|
/* allocation */
|
||||||
void mpsetminbits(int n); // newly created mpint's get at least n bits
|
void mpsetminbits(int n); /* newly created mpint's get at least n bits */
|
||||||
mpint* mpnew(int n); // create a new mpint with at least n bits
|
mpint* mpnew(int n); /* create a new mpint with at least n bits */
|
||||||
void mpfree(mpint *b);
|
void mpfree(mpint *b);
|
||||||
void mpbits(mpint *b, int n); // ensure that b has at least n bits
|
void mpbits(mpint *b, int n); /* ensure that b has at least n bits */
|
||||||
void mpnorm(mpint *b); // dump leading zeros
|
void mpnorm(mpint *b); /* dump leading zeros */
|
||||||
mpint* mpcopy(mpint *b);
|
mpint* mpcopy(mpint *b);
|
||||||
void mpassign(mpint *old, mpint *new);
|
void mpassign(mpint *old, mpint *new);
|
||||||
|
|
||||||
// random bits
|
/* random bits */
|
||||||
mpint* mprand(int bits, void (*gen)(uchar*, int), mpint *b);
|
mpint* mprand(int bits, void (*gen)(uchar*, int), mpint *b);
|
||||||
|
|
||||||
// conversion
|
/* conversion */
|
||||||
mpint* strtomp(char*, char**, int, mpint*); // ascii
|
mpint* strtomp(char*, char**, int, mpint*); /* ascii */
|
||||||
int mpfmt(Fmt*);
|
int mpfmt(Fmt*);
|
||||||
char* mptoa(mpint*, int, char*, int);
|
char* mptoa(mpint*, int, char*, int);
|
||||||
mpint* letomp(uchar*, uint, mpint*); // byte array, little-endian
|
mpint* letomp(uchar*, uint, mpint*); /* byte array, little-endian */
|
||||||
int mptole(mpint*, uchar*, uint, uchar**);
|
int mptole(mpint*, uchar*, uint, uchar**);
|
||||||
mpint* betomp(uchar*, uint, mpint*); // byte array, little-endian
|
mpint* betomp(uchar*, uint, mpint*); /* byte array, little-endian */
|
||||||
int mptobe(mpint*, uchar*, uint, uchar**);
|
int mptobe(mpint*, uchar*, uint, uchar**);
|
||||||
uint mptoui(mpint*); // unsigned int
|
uint mptoui(mpint*); /* unsigned int */
|
||||||
mpint* uitomp(uint, mpint*);
|
mpint* uitomp(uint, mpint*);
|
||||||
int mptoi(mpint*); // int
|
int mptoi(mpint*); /* int */
|
||||||
mpint* itomp(int, mpint*);
|
mpint* itomp(int, mpint*);
|
||||||
uvlong mptouv(mpint*); // unsigned vlong
|
uvlong mptouv(mpint*); /* unsigned vlong */
|
||||||
mpint* uvtomp(uvlong, mpint*);
|
mpint* uvtomp(uvlong, mpint*);
|
||||||
vlong mptov(mpint*); // vlong
|
vlong mptov(mpint*); /* vlong */
|
||||||
mpint* vtomp(vlong, mpint*);
|
mpint* vtomp(vlong, mpint*);
|
||||||
|
|
||||||
// divide 2 digits by one
|
/* divide 2 digits by one */
|
||||||
void mpdigdiv(mpdigit *dividend, mpdigit divisor, mpdigit *quotient);
|
void mpdigdiv(mpdigit *dividend, mpdigit divisor, mpdigit *quotient);
|
||||||
|
|
||||||
// in the following, the result mpint may be
|
/* in the following, the result mpint may be */
|
||||||
// the same as one of the inputs.
|
/* the same as one of the inputs. */
|
||||||
void mpadd(mpint *b1, mpint *b2, mpint *sum); // sum = b1+b2
|
void mpadd(mpint *b1, mpint *b2, mpint *sum); /* sum = b1+b2 */
|
||||||
void mpsub(mpint *b1, mpint *b2, mpint *diff); // diff = b1-b2
|
void mpsub(mpint *b1, mpint *b2, mpint *diff); /* diff = b1-b2 */
|
||||||
void mpleft(mpint *b, int shift, mpint *res); // res = b<<shift
|
void mpleft(mpint *b, int shift, mpint *res); /* res = b<<shift */
|
||||||
void mpright(mpint *b, int shift, mpint *res); // res = b>>shift
|
void mpright(mpint *b, int shift, mpint *res); /* res = b>>shift */
|
||||||
void mpmul(mpint *b1, mpint *b2, mpint *prod); // prod = b1*b2
|
void mpmul(mpint *b1, mpint *b2, mpint *prod); /* prod = b1*b2 */
|
||||||
void mpexp(mpint *b, mpint *e, mpint *m, mpint *res); // res = b**e mod m
|
void mpexp(mpint *b, mpint *e, mpint *m, mpint *res); /* res = b**e mod m */
|
||||||
void mpmod(mpint *b, mpint *m, mpint *remainder); // remainder = b mod m
|
void mpmod(mpint *b, mpint *m, mpint *remainder); /* remainder = b mod m */
|
||||||
|
|
||||||
// quotient = dividend/divisor, remainder = dividend % divisor
|
/* quotient = dividend/divisor, remainder = dividend % divisor */
|
||||||
void mpdiv(mpint *dividend, mpint *divisor, mpint *quotient, mpint *remainder);
|
void mpdiv(mpint *dividend, mpint *divisor, mpint *quotient, mpint *remainder);
|
||||||
|
|
||||||
// return neg, 0, pos as b1-b2 is neg, 0, pos
|
/* return neg, 0, pos as b1-b2 is neg, 0, pos */
|
||||||
int mpcmp(mpint *b1, mpint *b2);
|
int mpcmp(mpint *b1, mpint *b2);
|
||||||
|
|
||||||
// extended gcd return d, x, and y, s.t. d = gcd(a,b) and ax+by = d
|
/* extended gcd return d, x, and y, s.t. d = gcd(a,b) and ax+by = d */
|
||||||
void mpextendedgcd(mpint *a, mpint *b, mpint *d, mpint *x, mpint *y);
|
void mpextendedgcd(mpint *a, mpint *b, mpint *d, mpint *x, mpint *y);
|
||||||
|
|
||||||
// res = b**-1 mod m
|
/* res = b**-1 mod m */
|
||||||
void mpinvert(mpint *b, mpint *m, mpint *res);
|
void mpinvert(mpint *b, mpint *m, mpint *res);
|
||||||
|
|
||||||
// bit counting
|
/* bit counting */
|
||||||
int mpsignif(mpint*); // number of sigificant bits in mantissa
|
int mpsignif(mpint*); /* number of sigificant bits in mantissa */
|
||||||
int mplowbits0(mpint*); // k, where n = 2**k * q for odd q
|
int mplowbits0(mpint*); /* k, where n = 2**k * q for odd q */
|
||||||
|
|
||||||
// well known constants
|
/* well known constants */
|
||||||
extern mpint *mpzero, *mpone, *mptwo;
|
extern mpint *mpzero, *mpone, *mptwo;
|
||||||
|
|
||||||
// sum[0:alen] = a[0:alen-1] + b[0:blen-1]
|
/* sum[0:alen] = a[0:alen-1] + b[0:blen-1] */
|
||||||
// prereq: alen >= blen, sum has room for alen+1 digits
|
/* prereq: alen >= blen, sum has room for alen+1 digits */
|
||||||
void mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *sum);
|
void mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *sum);
|
||||||
|
|
||||||
// diff[0:alen-1] = a[0:alen-1] - b[0:blen-1]
|
/* diff[0:alen-1] = a[0:alen-1] - b[0:blen-1] */
|
||||||
// prereq: alen >= blen, diff has room for alen digits
|
/* prereq: alen >= blen, diff has room for alen digits */
|
||||||
void mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff);
|
void mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff);
|
||||||
|
|
||||||
// p[0:n] += m * b[0:n-1]
|
/* p[0:n] += m * b[0:n-1] */
|
||||||
// prereq: p has room for n+1 digits
|
/* prereq: p has room for n+1 digits */
|
||||||
void mpvecdigmuladd(mpdigit *b, int n, mpdigit m, mpdigit *p);
|
void mpvecdigmuladd(mpdigit *b, int n, mpdigit m, mpdigit *p);
|
||||||
|
|
||||||
// p[0:n] -= m * b[0:n-1]
|
/* p[0:n] -= m * b[0:n-1] */
|
||||||
// prereq: p has room for n+1 digits
|
/* prereq: p has room for n+1 digits */
|
||||||
int mpvecdigmulsub(mpdigit *b, int n, mpdigit m, mpdigit *p);
|
int mpvecdigmulsub(mpdigit *b, int n, mpdigit m, mpdigit *p);
|
||||||
|
|
||||||
// p[0:alen*blen-1] = a[0:alen-1] * b[0:blen-1]
|
/* p[0:alen*blen-1] = a[0:alen-1] * b[0:blen-1] */
|
||||||
// prereq: alen >= blen, p has room for m*n digits
|
/* prereq: alen >= blen, p has room for m*n digits */
|
||||||
void mpvecmul(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *p);
|
void mpvecmul(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *p);
|
||||||
|
|
||||||
// sign of a - b or zero if the same
|
/* sign of a - b or zero if the same */
|
||||||
int mpveccmp(mpdigit *a, int alen, mpdigit *b, int blen);
|
int mpveccmp(mpdigit *a, int alen, mpdigit *b, int blen);
|
||||||
|
|
||||||
// divide the 2 digit dividend by the one digit divisor and stick in quotient
|
/* divide the 2 digit dividend by the one digit divisor and stick in quotient */
|
||||||
// we assume that the result is one digit - overflow is all 1's
|
/* we assume that the result is one digit - overflow is all 1's */
|
||||||
void mpdigdiv(mpdigit *dividend, mpdigit divisor, mpdigit *quotient);
|
void mpdigdiv(mpdigit *dividend, mpdigit divisor, mpdigit *quotient);
|
||||||
|
|
||||||
// playing with magnitudes
|
/* playing with magnitudes */
|
||||||
int mpmagcmp(mpint *b1, mpint *b2);
|
int mpmagcmp(mpint *b1, mpint *b2);
|
||||||
void mpmagadd(mpint *b1, mpint *b2, mpint *sum); // sum = b1+b2
|
void mpmagadd(mpint *b1, mpint *b2, mpint *sum); /* sum = b1+b2 */
|
||||||
void mpmagsub(mpint *b1, mpint *b2, mpint *sum); // sum = b1+b2
|
void mpmagsub(mpint *b1, mpint *b2, mpint *sum); /* sum = b1+b2 */
|
||||||
|
|
||||||
// chinese remainder theorem
|
/* chinese remainder theorem */
|
||||||
typedef struct CRTpre CRTpre; // precomputed values for converting
|
typedef struct CRTpre CRTpre; /* precomputed values for converting */
|
||||||
// twixt residues and mpint
|
/* twixt residues and mpint */
|
||||||
typedef struct CRTres CRTres; // residue form of an mpint
|
typedef struct CRTres CRTres; /* residue form of an mpint */
|
||||||
|
|
||||||
struct CRTres
|
struct CRTres
|
||||||
{
|
{
|
||||||
int n; // number of residues
|
int n; /* number of residues */
|
||||||
mpint *r[1]; // residues
|
mpint *r[1]; /* residues */
|
||||||
};
|
};
|
||||||
|
|
||||||
CRTpre* crtpre(int, mpint**); // precompute conversion values
|
CRTpre* crtpre(int, mpint**); /* precompute conversion values */
|
||||||
CRTres* crtin(CRTpre*, mpint*); // convert mpint to residues
|
CRTres* crtin(CRTpre*, mpint*); /* convert mpint to residues */
|
||||||
void crtout(CRTpre*, CRTres*, mpint*); // convert residues to mpint
|
void crtout(CRTpre*, CRTres*, mpint*); /* convert residues to mpint */
|
||||||
void crtprefree(CRTpre*);
|
void crtprefree(CRTpre*);
|
||||||
void crtresfree(CRTres*);
|
void crtresfree(CRTres*);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ typedef struct Ndbcache Ndbcache;
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Ndbalen= 32, /* max attribute length */
|
Ndbalen= 32, /* max attribute length */
|
||||||
Ndbvlen= 64, /* max value length */
|
Ndbvlen= 64 /* max value length */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -148,7 +148,7 @@ enum {
|
||||||
Nfs3FsCanSetTime = 16,
|
Nfs3FsCanSetTime = 16,
|
||||||
|
|
||||||
Nfs3Version = 3,
|
Nfs3Version = 3,
|
||||||
Nfs3Program = 100003,
|
Nfs3Program = 100003
|
||||||
};
|
};
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ typedef enum
|
||||||
Nfs3ErrBadType = 10007,
|
Nfs3ErrBadType = 10007,
|
||||||
Nfs3ErrJukebox = 10008,
|
Nfs3ErrJukebox = 10008,
|
||||||
Nfs3ErrFprintNotFound = 10009,
|
Nfs3ErrFprintNotFound = 10009,
|
||||||
Nfs3ErrAborted = 10010,
|
Nfs3ErrAborted = 10010
|
||||||
} Nfs3Status;
|
} Nfs3Status;
|
||||||
|
|
||||||
void nfs3errstr(Nfs3Status);
|
void nfs3errstr(Nfs3Status);
|
||||||
|
@ -196,14 +196,14 @@ typedef enum
|
||||||
Nfs3FileChar = 4,
|
Nfs3FileChar = 4,
|
||||||
Nfs3FileSymlink = 5,
|
Nfs3FileSymlink = 5,
|
||||||
Nfs3FileSocket = 6,
|
Nfs3FileSocket = 6,
|
||||||
Nfs3FileFifo = 7,
|
Nfs3FileFifo = 7
|
||||||
} Nfs3FileType;
|
} Nfs3FileType;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Nfs3ModeSetUid = 0x800,
|
Nfs3ModeSetUid = 0x800,
|
||||||
Nfs3ModeSetGid = 0x400,
|
Nfs3ModeSetGid = 0x400,
|
||||||
Nfs3ModeSticky = 0x200,
|
Nfs3ModeSticky = 0x200
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -251,7 +251,7 @@ typedef enum
|
||||||
Nfs3CallTPathconf,
|
Nfs3CallTPathconf,
|
||||||
Nfs3CallRPathconf,
|
Nfs3CallRPathconf,
|
||||||
Nfs3CallTCommit,
|
Nfs3CallTCommit,
|
||||||
Nfs3CallRCommit,
|
Nfs3CallRCommit
|
||||||
} Nfs3CallType;
|
} Nfs3CallType;
|
||||||
|
|
||||||
typedef struct Nfs3Handle Nfs3Handle;
|
typedef struct Nfs3Handle Nfs3Handle;
|
||||||
|
@ -263,7 +263,7 @@ typedef enum
|
||||||
{
|
{
|
||||||
Nfs3SetTimeDont = 0,
|
Nfs3SetTimeDont = 0,
|
||||||
Nfs3SetTimeServer = 1,
|
Nfs3SetTimeServer = 1,
|
||||||
Nfs3SetTimeClient = 2,
|
Nfs3SetTimeClient = 2
|
||||||
} Nfs3SetTime;
|
} Nfs3SetTime;
|
||||||
|
|
||||||
typedef struct Nfs3SetAttr Nfs3SetAttr;
|
typedef struct Nfs3SetAttr Nfs3SetAttr;
|
||||||
|
@ -285,7 +285,7 @@ typedef enum
|
||||||
{
|
{
|
||||||
Nfs3SyncNone = 0,
|
Nfs3SyncNone = 0,
|
||||||
Nfs3SyncData = 1,
|
Nfs3SyncData = 1,
|
||||||
Nfs3SyncFile = 2,
|
Nfs3SyncFile = 2
|
||||||
} Nfs3Sync;
|
} Nfs3Sync;
|
||||||
|
|
||||||
typedef struct Nfs3TWrite Nfs3TWrite;
|
typedef struct Nfs3TWrite Nfs3TWrite;
|
||||||
|
@ -294,7 +294,7 @@ typedef enum
|
||||||
{
|
{
|
||||||
Nfs3CreateUnchecked = 0,
|
Nfs3CreateUnchecked = 0,
|
||||||
Nfs3CreateGuarded = 1,
|
Nfs3CreateGuarded = 1,
|
||||||
Nfs3CreateExclusive = 2,
|
Nfs3CreateExclusive = 2
|
||||||
} Nfs3Create;
|
} Nfs3Create;
|
||||||
|
|
||||||
typedef struct Nfs3TCreate Nfs3TCreate;
|
typedef struct Nfs3TCreate Nfs3TCreate;
|
||||||
|
|
|
@ -21,7 +21,7 @@ enum
|
||||||
SunAuthNone = 0,
|
SunAuthNone = 0,
|
||||||
SunAuthSys,
|
SunAuthSys,
|
||||||
SunAuthShort,
|
SunAuthShort,
|
||||||
SunAuthDes,
|
SunAuthDes
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -46,7 +46,7 @@ typedef enum {
|
||||||
SunAuthRejectedVerf,
|
SunAuthRejectedVerf,
|
||||||
SunAuthTooWeak,
|
SunAuthTooWeak,
|
||||||
SunAuthInvalidResp,
|
SunAuthInvalidResp,
|
||||||
SunAuthFailed,
|
SunAuthFailed
|
||||||
} SunStatus;
|
} SunStatus;
|
||||||
|
|
||||||
struct SunAuthInfo
|
struct SunAuthInfo
|
||||||
|
@ -78,7 +78,7 @@ struct SunRpc
|
||||||
u32int proc;
|
u32int proc;
|
||||||
|
|
||||||
/* call */
|
/* call */
|
||||||
// uint proc;
|
/* uint proc; */
|
||||||
u32int prog, vers;
|
u32int prog, vers;
|
||||||
SunAuthInfo cred;
|
SunAuthInfo cred;
|
||||||
SunAuthInfo verf;
|
SunAuthInfo verf;
|
||||||
|
@ -87,16 +87,16 @@ struct SunRpc
|
||||||
|
|
||||||
/* reply */
|
/* reply */
|
||||||
u32int status;
|
u32int status;
|
||||||
// SunAuthInfo verf;
|
/* SunAuthInfo verf; */
|
||||||
u32int low, high;
|
u32int low, high;
|
||||||
// uchar *data;
|
/* uchar *data; */
|
||||||
// uint ndata;
|
/* uint ndata; */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SunCallTypeTNull,
|
SunCallTypeTNull,
|
||||||
SunCallTypeRNull,
|
SunCallTypeRNull
|
||||||
} SunCallType;
|
} SunCallType;
|
||||||
|
|
||||||
struct SunCall
|
struct SunCall
|
||||||
|
@ -191,7 +191,7 @@ typedef struct SunSrv SunSrv;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
SunStackSize = 32768,
|
SunStackSize = 32768
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SunMsg
|
struct SunMsg
|
||||||
|
@ -316,7 +316,7 @@ typedef enum
|
||||||
PortCallTDump,
|
PortCallTDump,
|
||||||
PortCallRDump,
|
PortCallRDump,
|
||||||
PortCallTCallit,
|
PortCallTCallit,
|
||||||
PortCallRCallit,
|
PortCallRCallit
|
||||||
} PortCallType;
|
} PortCallType;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -71,7 +71,7 @@ enum
|
||||||
CHANSND,
|
CHANSND,
|
||||||
CHANRCV,
|
CHANRCV,
|
||||||
CHANNOP,
|
CHANNOP,
|
||||||
CHANNOBLK,
|
CHANNOBLK
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Alt
|
struct Alt
|
||||||
|
|
|
@ -11,7 +11,7 @@ enum
|
||||||
UTFmax = 3, /* maximum bytes per rune */
|
UTFmax = 3, /* maximum bytes per rune */
|
||||||
Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
|
Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
|
||||||
Runeself = 0x80, /* rune and UTF sequences are the same (<) */
|
Runeself = 0x80, /* rune and UTF sequences are the same (<) */
|
||||||
Runeerror = 0xFFFD, /* decoding error in UTF */
|
Runeerror = 0xFFFD /* decoding error in UTF */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/utf/?*.c | grep -v static |grep -v __ */
|
/* Edit .+1,/^$/ | cfn $PLAN9/src/lib9/utf/?*.c | grep -v static |grep -v __ */
|
||||||
|
|
|
@ -17,7 +17,7 @@ AUTOLIB(venti)
|
||||||
*/
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MaxFragSize = 9*1024,
|
MaxFragSize = 9*1024
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Packet Packet;
|
typedef struct Packet Packet;
|
||||||
|
@ -91,7 +91,7 @@ enum
|
||||||
VtScoreSize = 20,
|
VtScoreSize = 20,
|
||||||
VtMaxStringSize = 1024,
|
VtMaxStringSize = 1024,
|
||||||
VtMaxLumpSize = 56*1024,
|
VtMaxLumpSize = 56*1024,
|
||||||
VtPointerDepth = 7,
|
VtPointerDepth = 7
|
||||||
};
|
};
|
||||||
#define VtMaxFileSize ((1ULL<<48)-1)
|
#define VtMaxFileSize ((1ULL<<48)-1)
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ enum
|
||||||
VtCorruptType = 0xFF,
|
VtCorruptType = 0xFF,
|
||||||
|
|
||||||
VtTypeDepthMask = 7,
|
VtTypeDepthMask = 7,
|
||||||
VtTypeBaseMask = ~VtTypeDepthMask,
|
VtTypeBaseMask = ~VtTypeDepthMask
|
||||||
};
|
};
|
||||||
|
|
||||||
/* convert to/from on-disk type numbers */
|
/* convert to/from on-disk type numbers */
|
||||||
|
@ -141,11 +141,11 @@ enum
|
||||||
_VtEntryDir = 1<<1, /* a directory */
|
_VtEntryDir = 1<<1, /* a directory */
|
||||||
_VtEntryDepthShift = 2, /* shift for pointer depth */
|
_VtEntryDepthShift = 2, /* shift for pointer depth */
|
||||||
_VtEntryDepthMask = 7<<2, /* mask for pointer depth */
|
_VtEntryDepthMask = 7<<2, /* mask for pointer depth */
|
||||||
VtEntryLocal = 1<<5, /* for local storage only */
|
VtEntryLocal = 1<<5 /* for local storage only */
|
||||||
};
|
};
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
VtEntrySize = 40,
|
VtEntrySize = 40
|
||||||
};
|
};
|
||||||
struct VtEntry
|
struct VtEntry
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ struct VtRoot
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
VtRootSize = 300,
|
VtRootSize = 300,
|
||||||
VtRootVersion = 2,
|
VtRootVersion = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
void vtrootpack(VtRoot*, uchar*);
|
void vtrootpack(VtRoot*, uchar*);
|
||||||
|
@ -231,7 +231,7 @@ enum
|
||||||
VtCryptoStrengthNone,
|
VtCryptoStrengthNone,
|
||||||
VtCryptoStrengthAuth,
|
VtCryptoStrengthAuth,
|
||||||
VtCryptoStrengthWeak,
|
VtCryptoStrengthWeak,
|
||||||
VtCryptoStrengthStrong,
|
VtCryptoStrengthStrong
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -242,7 +242,7 @@ enum
|
||||||
VtCryptoNone,
|
VtCryptoNone,
|
||||||
VtCryptoSSL3,
|
VtCryptoSSL3,
|
||||||
VtCryptoTLS1,
|
VtCryptoTLS1,
|
||||||
VtCryptoMax,
|
VtCryptoMax
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -313,7 +313,7 @@ enum
|
||||||
{
|
{
|
||||||
VtStateAlloc,
|
VtStateAlloc,
|
||||||
VtStateConnected,
|
VtStateConnected,
|
||||||
VtStateClosed,
|
VtStateClosed
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VtConn
|
struct VtConn
|
||||||
|
@ -387,7 +387,7 @@ int vtping(VtConn*);
|
||||||
*/
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
NilBlock = ~0,
|
NilBlock = ~0
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct VtBlock VtBlock;
|
typedef struct VtBlock VtBlock;
|
||||||
|
@ -459,7 +459,7 @@ enum
|
||||||
{
|
{
|
||||||
VtOREAD,
|
VtOREAD,
|
||||||
VtOWRITE,
|
VtOWRITE,
|
||||||
VtORDWR,
|
VtORDWR
|
||||||
};
|
};
|
||||||
|
|
||||||
VtFile *vtfileopenroot(VtCache*, VtEntry*);
|
VtFile *vtfileopenroot(VtCache*, VtEntry*);
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
[^!@.]+ translate "$PLAN9/bin/upas/aliasmail '&'"
|
[^!@.]+ translate "$PLAN9/bin/upas/aliasmail '&'"
|
||||||
|
|
||||||
# append the local domain to addresses without a domain
|
# append the local domain to addresses without a domain
|
||||||
local!(.*) alias \1@YOURDOMAIN.DOM
|
local!(.*) alias \1@swtch.com
|
||||||
|
|
||||||
# convert source domain address to a chain a@b@c@d...
|
# convert source domain address to a chain a@b@c@d...
|
||||||
@([^@!,]*):([^!@]*)@([^!]*) alias \2@\3@\1
|
@([^@!,]*):([^!@]*)@([^!]*) alias \2@\3@\1
|
||||||
|
@ -24,5 +24,8 @@ local!(.*) alias \1@YOURDOMAIN.DOM
|
||||||
([^@]+)@([^@]+)@(.+) alias \2!\1@\3
|
([^@]+)@([^@]+)@(.+) alias \2!\1@\3
|
||||||
([^@]+)@([^@]+) alias \2!\1
|
([^@]+)@([^@]+) alias \2!\1
|
||||||
|
|
||||||
|
# send swtch.com mail separately to appease mail avenger
|
||||||
|
(swtch.com)!(.*) | "$PLAN9/mail/lib/qmail '\s' 'swtch.com'" "'\2@\1'"
|
||||||
|
|
||||||
# send all mail to the gateway or mail server, $smtp, for delivery
|
# send all mail to the gateway or mail server, $smtp, for delivery
|
||||||
([^!]*)!(.*) | "$PLAN9/mail/lib/qmail '\s' 'YOURGATEWAY.DOM'" "'\2@\1'"
|
([^!]*)!(.*) | "$PLAN9/mail/lib/qmail '\s' 'holo.morphisms.net'" "'\2@\1'"
|
||||||
|
|
|
@ -251,7 +251,7 @@ parsedir(Cdimg *cd, Direc *d, uchar *buf, int len, char *(*cvtname)(uchar*, int)
|
||||||
d->mode = little(p, 4);
|
d->mode = little(p, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BUG: rock ridge extensions
|
/* BUG: rock ridge extensions */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ Cgetc(Cdimg *cd)
|
||||||
if((c = Bgetc(&cd->brd)) == Beof) {
|
if((c = Bgetc(&cd->brd)) == Beof) {
|
||||||
fprint(2, "getc at %lud\n", Croffset(cd));
|
fprint(2, "getc at %lud\n", Croffset(cd));
|
||||||
assert(0);
|
assert(0);
|
||||||
//sysfatal("Bgetc: %r");
|
/*sysfatal("Bgetc: %r"); */
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -203,16 +203,16 @@ main(int argc, char **argv)
|
||||||
} else
|
} else
|
||||||
convertnames(&iroot, (char* (*)(char*, char*))strcpy);
|
convertnames(&iroot, (char* (*)(char*, char*))strcpy);
|
||||||
|
|
||||||
// isoabstract = findconform(&iroot, abstract);
|
/* isoabstract = findconform(&iroot, abstract); */
|
||||||
// isobiblio = findconform(&iroot, biblio);
|
/* isobiblio = findconform(&iroot, biblio); */
|
||||||
// isonotice = findconform(&iroot, notice);
|
/* isonotice = findconform(&iroot, notice); */
|
||||||
|
|
||||||
dsort(&iroot, isocmp);
|
dsort(&iroot, isocmp);
|
||||||
|
|
||||||
if(cd->flags & CDjoliet) {
|
if(cd->flags & CDjoliet) {
|
||||||
// jabstract = findconform(&jroot, abstract);
|
/* jabstract = findconform(&jroot, abstract); */
|
||||||
// jbiblio = findconform(&jroot, biblio);
|
/* jbiblio = findconform(&jroot, biblio); */
|
||||||
// jnotice = findconform(&jroot, notice);
|
/* jnotice = findconform(&jroot, notice); */
|
||||||
|
|
||||||
checknames(&jroot, isbadjoliet);
|
checknames(&jroot, isbadjoliet);
|
||||||
convertnames(&jroot, (char* (*)(char*, char*))strcpy);
|
convertnames(&jroot, (char* (*)(char*, char*))strcpy);
|
||||||
|
@ -393,7 +393,7 @@ addprotofile(char *new, char *old, Dir *d, void *a)
|
||||||
if((direc = adddirec((Direc*)a, new, &xd))) {
|
if((direc = adddirec((Direc*)a, new, &xd))) {
|
||||||
direc->srcfile = atom(old);
|
direc->srcfile = atom(old);
|
||||||
|
|
||||||
// BUG: abstract, biblio, notice
|
/* BUG: abstract, biblio, notice */
|
||||||
}
|
}
|
||||||
if(name)
|
if(name)
|
||||||
free(name);
|
free(name);
|
||||||
|
|
|
@ -65,7 +65,7 @@ struct Direc {
|
||||||
int nchild;
|
int nchild;
|
||||||
};
|
};
|
||||||
enum { /* Direc flags */
|
enum { /* Direc flags */
|
||||||
Dbadname = 1<<0, /* Non-conformant name */
|
Dbadname = 1<<0 /* Non-conformant name */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -132,7 +132,7 @@ enum { /* Cdimg->flags, Cdinfo->flags */
|
||||||
CDrockridge = 1<<3,
|
CDrockridge = 1<<3,
|
||||||
CDnew = 1<<4,
|
CDnew = 1<<4,
|
||||||
CDdump = 1<<5,
|
CDdump = 1<<5,
|
||||||
CDbootable = 1<<6,
|
CDbootable = 1<<6
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Tx Tx;
|
typedef struct Tx Tx;
|
||||||
|
@ -159,7 +159,7 @@ struct Cdinfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
Blocklen = 2048,
|
Blocklen = 2048
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -265,7 +265,7 @@ enum { /* Rockridge flags */
|
||||||
RR_CL = 1<<4,
|
RR_CL = 1<<4,
|
||||||
RR_PL = 1<<5,
|
RR_PL = 1<<5,
|
||||||
RR_RE = 1<<6,
|
RR_RE = 1<<6,
|
||||||
RR_TF = 1<<7,
|
RR_TF = 1<<7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { /* CputrripTF type argument */
|
enum { /* CputrripTF type argument */
|
||||||
|
@ -276,7 +276,7 @@ enum { /* CputrripTF type argument */
|
||||||
TFbackup = 1<<4,
|
TFbackup = 1<<4,
|
||||||
TFexpiration = 1<<5,
|
TFexpiration = 1<<5,
|
||||||
TFeffective = 1<<6,
|
TFeffective = 1<<6,
|
||||||
TFlongform = 1<<7,
|
TFlongform = 1<<7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { /* CputrripNM flag types */
|
enum { /* CputrripNM flag types */
|
||||||
|
@ -285,7 +285,7 @@ enum { /* CputrripNM flag types */
|
||||||
NMparent = 1<<2,
|
NMparent = 1<<2,
|
||||||
NMroot = 1<<3,
|
NMroot = 1<<3,
|
||||||
NMvolroot = 1<<4,
|
NMvolroot = 1<<4,
|
||||||
NMhost = 1<<5,
|
NMhost = 1<<5
|
||||||
};
|
};
|
||||||
|
|
||||||
/* boot.c */
|
/* boot.c */
|
||||||
|
@ -414,7 +414,7 @@ enum {
|
||||||
DTdotdot,
|
DTdotdot,
|
||||||
DTiden,
|
DTiden,
|
||||||
DTroot,
|
DTroot,
|
||||||
DTrootdot,
|
DTrootdot
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ulong now;
|
extern ulong now;
|
||||||
|
|
|
@ -19,7 +19,7 @@ static ulong CputsuspCE(Cdimg *cd, ulong offset);
|
||||||
static int CputsuspER(Cdimg*, int);
|
static int CputsuspER(Cdimg*, int);
|
||||||
static int CputsuspRR(Cdimg*, int, int);
|
static int CputsuspRR(Cdimg*, int, int);
|
||||||
static int CputsuspSP(Cdimg*, int);
|
static int CputsuspSP(Cdimg*, int);
|
||||||
//static int CputsuspST(Cdimg*, int);
|
/*static int CputsuspST(Cdimg*, int); */
|
||||||
static int Cputrripname(Cdimg*, char*, int, char*, int);
|
static int Cputrripname(Cdimg*, char*, int, char*, int);
|
||||||
static int CputrripSL(Cdimg*, int, int, char*, int);
|
static int CputrripSL(Cdimg*, int, int, char*, int);
|
||||||
static int CputrripPX(Cdimg*, Direc*, int, int);
|
static int CputrripPX(Cdimg*, Direc*, int, int);
|
||||||
|
@ -524,12 +524,12 @@ CputrripTF(Cdimg *cd, Direc *d, int type, int dowrite)
|
||||||
if (type & TFattributes)
|
if (type & TFattributes)
|
||||||
Cputdate(cd, d?d->ctime:0);
|
Cputdate(cd, d?d->ctime:0);
|
||||||
|
|
||||||
// if (type & TFbackup)
|
/* if (type & TFbackup) */
|
||||||
// Cputdate(cd, 0);
|
/* Cputdate(cd, 0); */
|
||||||
// if (type & TFexpiration)
|
/* if (type & TFexpiration) */
|
||||||
// Cputdate(cd, 0);
|
/* Cputdate(cd, 0); */
|
||||||
// if (type & TFeffective)
|
/* if (type & TFeffective) */
|
||||||
// Cputdate(cd, 0);
|
/* Cputdate(cd, 0); */
|
||||||
}
|
}
|
||||||
return 5+7*length;
|
return 5+7*length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ static long numericgid(char *gp);
|
||||||
void
|
void
|
||||||
dirtoxdir(XDir *xd, Dir *d)
|
dirtoxdir(XDir *xd, Dir *d)
|
||||||
{
|
{
|
||||||
// char buf[NAMELEN+1];
|
/* char buf[NAMELEN+1]; */
|
||||||
memset(xd, 0, sizeof *xd);
|
memset(xd, 0, sizeof *xd);
|
||||||
|
|
||||||
xd->name = atom(d->name);
|
xd->name = atom(d->name);
|
||||||
|
@ -38,8 +38,8 @@ dirtoxdir(XDir *xd, Dir *d)
|
||||||
xd->length = d->length;
|
xd->length = d->length;
|
||||||
if(xd->mode & CHLINK) {
|
if(xd->mode & CHLINK) {
|
||||||
xd->mode |= 0777;
|
xd->mode |= 0777;
|
||||||
//xd->symlink = atom(d->symlink);
|
/*xd->symlink = atom(d->symlink); */
|
||||||
xd->symlink = atom("symlink"); // XXX: rsc
|
xd->symlink = atom("symlink"); /* XXX: rsc */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ enum
|
||||||
{
|
{
|
||||||
STACK = 32768,
|
STACK = 32768,
|
||||||
NHASH = 31,
|
NHASH = 31,
|
||||||
MAXMSG = 64, /* per connection */
|
MAXMSG = 64 /* per connection */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Hash Hash;
|
typedef struct Hash Hash;
|
||||||
|
@ -240,8 +240,8 @@ mainproc(void *v)
|
||||||
threadcreate(inputthread, nil, STACK);
|
threadcreate(inputthread, nil, STACK);
|
||||||
threadcreate(outputthread, nil, STACK);
|
threadcreate(outputthread, nil, STACK);
|
||||||
|
|
||||||
// if(rootfid)
|
/* if(rootfid) */
|
||||||
// dorootstat();
|
/* dorootstat(); */
|
||||||
|
|
||||||
threadcreate(listenthread, nil, STACK);
|
threadcreate(listenthread, nil, STACK);
|
||||||
threadexits(0);
|
threadexits(0);
|
||||||
|
@ -618,14 +618,14 @@ openfdthread(void *v)
|
||||||
sendomsg(m);
|
sendomsg(m);
|
||||||
recvp(c->internal);
|
recvp(c->internal);
|
||||||
if(m->rx.type == Rerror){
|
if(m->rx.type == Rerror){
|
||||||
// fprint(2, "%T read error: %s\n", m->rx.ename);
|
/* fprint(2, "%T read error: %s\n", m->rx.ename); */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(m->rx.count == 0)
|
if(m->rx.count == 0)
|
||||||
break;
|
break;
|
||||||
tot += m->rx.count;
|
tot += m->rx.count;
|
||||||
if(iowrite(io, c->fd, m->rx.data, m->rx.count) != m->rx.count){
|
if(iowrite(io, c->fd, m->rx.data, m->rx.count) != m->rx.count){
|
||||||
// fprint(2, "%T pipe write error: %r\n");
|
/* fprint(2, "%T pipe write error: %r\n"); */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
msgput(m);
|
msgput(m);
|
||||||
|
@ -658,7 +658,7 @@ openfdthread(void *v)
|
||||||
sendomsg(m);
|
sendomsg(m);
|
||||||
recvp(c->internal);
|
recvp(c->internal);
|
||||||
if(m->rx.type == Rerror){
|
if(m->rx.type == Rerror){
|
||||||
// fprint(2, "%T write error: %s\n", m->rx.ename);
|
/* fprint(2, "%T write error: %s\n", m->rx.ename); */
|
||||||
}
|
}
|
||||||
tot += n;
|
tot += n;
|
||||||
msgput(m);
|
msgput(m);
|
||||||
|
@ -907,7 +907,7 @@ inputthread(void *arg)
|
||||||
msgput(m);
|
msgput(m);
|
||||||
}
|
}
|
||||||
closeioproc(io);
|
closeioproc(io);
|
||||||
//fprint(2, "%T input eof\n");
|
/*fprint(2, "%T input eof\n"); */
|
||||||
threadexitsall(0);
|
threadexitsall(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ new(Image *i, int hideit, int scrollit, int pid, char *dir, char *cmd, char **ar
|
||||||
error("new: channel alloc failed");
|
error("new: channel alloc failed");
|
||||||
mc = emalloc(sizeof(Mousectl));
|
mc = emalloc(sizeof(Mousectl));
|
||||||
*mc = *mousectl;
|
*mc = *mousectl;
|
||||||
// mc->image = i;
|
/* mc->image = i; */
|
||||||
mc->c = cm;
|
mc->c = cm;
|
||||||
w = wmk(i, mc, ck, cctl, scrollit);
|
w = wmk(i, mc, ck, cctl, scrollit);
|
||||||
free(mc); /* wmk copies *mc */
|
free(mc); /* wmk copies *mc */
|
||||||
|
@ -282,7 +282,7 @@ enum
|
||||||
Plumb,
|
Plumb,
|
||||||
Send,
|
Send,
|
||||||
Scroll,
|
Scroll,
|
||||||
Cook,
|
Cook
|
||||||
};
|
};
|
||||||
|
|
||||||
char *menu2str[] = {
|
char *menu2str[] = {
|
||||||
|
|
|
@ -24,13 +24,13 @@ enum
|
||||||
Scrollgap = 4, /* gap right of scroll bar */
|
Scrollgap = 4, /* gap right of scroll bar */
|
||||||
BIG = 3, /* factor by which window dimension can exceed screen */
|
BIG = 3, /* factor by which window dimension can exceed screen */
|
||||||
TRUE = 1,
|
TRUE = 1,
|
||||||
FALSE = 0,
|
FALSE = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Kscrolloneup = KF|0x20,
|
Kscrolloneup = KF|0x20,
|
||||||
Kscrollonedown = KF|0x21,
|
Kscrollonedown = KF|0x21
|
||||||
};
|
};
|
||||||
|
|
||||||
enum /* control messages */
|
enum /* control messages */
|
||||||
|
@ -45,7 +45,7 @@ enum /* control messages */
|
||||||
Holdon,
|
Holdon,
|
||||||
Holdoff,
|
Holdoff,
|
||||||
Deleted,
|
Deleted,
|
||||||
Exited,
|
Exited
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Wctlmesg
|
struct Wctlmesg
|
||||||
|
|
|
@ -169,7 +169,7 @@ Cursor l = {
|
||||||
Cursor *corners[9] = {
|
Cursor *corners[9] = {
|
||||||
&tl, &t, &tr,
|
&tl, &t, &tr,
|
||||||
&l, nil, &r,
|
&l, nil, &r,
|
||||||
&bl, &b, &br,
|
&bl, &b, &br
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -31,7 +31,7 @@ Event blank = {
|
||||||
'X',
|
'X',
|
||||||
0, 0, 0, 1, 1,
|
0, 0, 0, 1, 1,
|
||||||
{ ' ', 0 },
|
{ ' ', 0 },
|
||||||
{ ' ', 0 },
|
{ ' ', 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Q
|
struct Q
|
||||||
|
@ -47,7 +47,7 @@ CFid *eventfd;
|
||||||
CFid *addrfd;
|
CFid *addrfd;
|
||||||
CFid *datafd;
|
CFid *datafd;
|
||||||
CFid *ctlfd;
|
CFid *ctlfd;
|
||||||
// int bodyfd;
|
/* int bodyfd; */
|
||||||
|
|
||||||
char *typing;
|
char *typing;
|
||||||
int ntypeb;
|
int ntypeb;
|
||||||
|
|
|
@ -19,7 +19,7 @@ enum
|
||||||
{
|
{
|
||||||
HiWater = 640000, /* max size of history */
|
HiWater = 640000, /* max size of history */
|
||||||
LoWater = 400000, /* min size of history after max'ed */
|
LoWater = 400000, /* min size of history after max'ed */
|
||||||
MinWater = 20000, /* room to leave available when reallocating */
|
MinWater = 20000 /* room to leave available when reallocating */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int topped;
|
static int topped;
|
||||||
|
@ -121,8 +121,8 @@ fprint(2, "res %p %p\n", w->i, i);
|
||||||
freeimage(w->i);
|
freeimage(w->i);
|
||||||
w->i = i;
|
w->i = i;
|
||||||
}
|
}
|
||||||
// wsetname(w);
|
/* wsetname(w); */
|
||||||
//XXX w->mc.image = i;
|
/*XXX w->mc.image = i; */
|
||||||
r = insetrect(i->r, Selborder+1);
|
r = insetrect(i->r, Selborder+1);
|
||||||
w->scrollr = r;
|
w->scrollr = r;
|
||||||
w->scrollr.max.x = r.min.x+Scrollwid;
|
w->scrollr.max.x = r.min.x+Scrollwid;
|
||||||
|
@ -276,9 +276,9 @@ winctl(void *arg)
|
||||||
case WKey:
|
case WKey:
|
||||||
for(i=0; kbdr[i]!=L'\0'; i++)
|
for(i=0; kbdr[i]!=L'\0'; i++)
|
||||||
wkeyctl(w, kbdr[i]);
|
wkeyctl(w, kbdr[i]);
|
||||||
// wkeyctl(w, r);
|
/* wkeyctl(w, r); */
|
||||||
// while(nbrecv(w->ck, &r))
|
/* while(nbrecv(w->ck, &r)) */
|
||||||
// wkeyctl(w, r);
|
/* wkeyctl(w, r); */
|
||||||
break;
|
break;
|
||||||
case WMouse:
|
case WMouse:
|
||||||
if(w->mouseopen) {
|
if(w->mouseopen) {
|
||||||
|
@ -307,9 +307,10 @@ winctl(void *arg)
|
||||||
m = w->mouse.queue[w->mouse.ri];
|
m = w->mouse.queue[w->mouse.ri];
|
||||||
if(++w->mouse.ri == nelem(w->mouse.queue))
|
if(++w->mouse.ri == nelem(w->mouse.queue))
|
||||||
w->mouse.ri = 0;
|
w->mouse.ri = 0;
|
||||||
} else
|
} else {
|
||||||
m = (Mousestate){w->mc.m, w->mouse.counter};
|
m.m = w->mc.m;
|
||||||
|
m.counter = w->mouse.counter;
|
||||||
|
}
|
||||||
w->mouse.lastcounter = m.counter;
|
w->mouse.lastcounter = m.counter;
|
||||||
send(mrm.cm, &m.m);
|
send(mrm.cm, &m.m);
|
||||||
continue;
|
continue;
|
||||||
|
@ -393,13 +394,13 @@ winctl(void *arg)
|
||||||
c = t[i]; /* knows break characters fit in a byte */
|
c = t[i]; /* knows break characters fit in a byte */
|
||||||
i += wid;
|
i += wid;
|
||||||
if(!w->rawing && (c == '\n' || c=='\004')){
|
if(!w->rawing && (c == '\n' || c=='\004')){
|
||||||
// if(c == '\004')
|
/* if(c == '\004') */
|
||||||
// i--;
|
/* i--; */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if(i==nb && w->qh<w->nr && w->r[w->qh]=='\004')
|
/* if(i==nb && w->qh<w->nr && w->r[w->qh]=='\004') */
|
||||||
// w->qh++;
|
/* w->qh++; */
|
||||||
if(i > nb){
|
if(i > nb){
|
||||||
npart = i-nb;
|
npart = i-nb;
|
||||||
memmove(part, t+nb, npart);
|
memmove(part, t+nb, npart);
|
||||||
|
|
|
@ -10,7 +10,7 @@ enum
|
||||||
NFD = 100,
|
NFD = 100,
|
||||||
Maxproc = 50,
|
Maxproc = 50,
|
||||||
Maxval = 10,
|
Maxval = 10,
|
||||||
Mempergc = 1024*1024,
|
Mempergc = 1024*1024
|
||||||
};
|
};
|
||||||
|
|
||||||
/* #pragma varargck type "L" void */
|
/* #pragma varargck type "L" void */
|
||||||
|
@ -81,7 +81,7 @@ enum
|
||||||
TCODE,
|
TCODE,
|
||||||
TREG,
|
TREG,
|
||||||
TCON,
|
TCON,
|
||||||
NUMT,
|
NUMT
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Type
|
struct Type
|
||||||
|
@ -327,5 +327,5 @@ enum
|
||||||
OEVAL,
|
OEVAL,
|
||||||
OWHAT,
|
OWHAT,
|
||||||
OUPLUS,
|
OUPLUS,
|
||||||
NUMO,
|
NUMO
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,7 +38,7 @@ char *typenames[] = {
|
||||||
"float",
|
"float",
|
||||||
"string",
|
"string",
|
||||||
"list",
|
"list",
|
||||||
"code",
|
"code"
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -202,7 +202,7 @@ deinstall(int pid)
|
||||||
for(i = 0; i < Maxproc; i++) {
|
for(i = 0; i < Maxproc; i++) {
|
||||||
if(ptab[i].pid == pid) {
|
if(ptab[i].pid == pid) {
|
||||||
detachproc(pid);
|
detachproc(pid);
|
||||||
// close(ptab[i].ctl);
|
/* close(ptab[i].ctl); */
|
||||||
ptab[i].pid = 0;
|
ptab[i].pid = 0;
|
||||||
s = look("proclist");
|
s = look("proclist");
|
||||||
d = &s->v->store.u.l;
|
d = &s->v->store.u.l;
|
||||||
|
|
|
@ -14,7 +14,7 @@ enum
|
||||||
Array,
|
Array,
|
||||||
Range,
|
Range,
|
||||||
Defer,
|
Defer,
|
||||||
Typedef,
|
Typedef
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Type
|
struct Type
|
||||||
|
|
|
@ -67,7 +67,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if(!have){
|
if(!have){
|
||||||
Bprint(&b, "// no debugging symbols in %s\n\n", argv[i]);
|
Bprint(&b, "// no debugging symbols in %s\n\n", argv[i]);
|
||||||
// fprint(2, "no debugging symbols in %s\n", argv[i]);
|
/* fprint(2, "no debugging symbols in %s\n", argv[i]); */
|
||||||
}
|
}
|
||||||
uncrackhdr(fp);
|
uncrackhdr(fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ struct {
|
||||||
"XER", "$XER",
|
"XER", "$XER",
|
||||||
"CTR", "$CTR",
|
"CTR", "$CTR",
|
||||||
"VRSAVE", "$VRSAVE",
|
"VRSAVE", "$VRSAVE",
|
||||||
"FPSCR", "$FPSCR",
|
"FPSCR", "$FPSCR"
|
||||||
};
|
};
|
||||||
|
|
||||||
char*
|
char*
|
||||||
|
@ -469,7 +469,7 @@ nameof(Type *t, int doanon)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char
|
static char
|
||||||
basecharof(Type *t) //XXX
|
basecharof(Type *t) /*XXX */
|
||||||
{
|
{
|
||||||
switch(t->xsizeof){
|
switch(t->xsizeof){
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -37,7 +37,7 @@ Rune snarfrune[NSnarf+1];
|
||||||
char *fontnames[2] =
|
char *fontnames[2] =
|
||||||
{
|
{
|
||||||
"/lib/font/bit/lucsans/euro.8.font",
|
"/lib/font/bit/lucsans/euro.8.font",
|
||||||
"/lib/font/bit/lucm/unicode.9.font",
|
"/lib/font/bit/lucm/unicode.9.font"
|
||||||
};
|
};
|
||||||
|
|
||||||
Command *command;
|
Command *command;
|
||||||
|
@ -160,7 +160,7 @@ threadmain(int argc, char *argv[])
|
||||||
|
|
||||||
d = display;
|
d = display;
|
||||||
font = d->defaultfont;
|
font = d->defaultfont;
|
||||||
//assert(font);
|
/*assert(font); */
|
||||||
|
|
||||||
reffont.f = font;
|
reffont.f = font;
|
||||||
reffonts[0] = &reffont;
|
reffonts[0] = &reffont;
|
||||||
|
@ -355,8 +355,8 @@ killprocs(void)
|
||||||
Command *c;
|
Command *c;
|
||||||
|
|
||||||
fsysclose();
|
fsysclose();
|
||||||
// if(display)
|
/* if(display) */
|
||||||
// flushimage(display, 1);
|
/* flushimage(display, 1); */
|
||||||
|
|
||||||
for(c=command; c; c=c->next)
|
for(c=command; c; c=c->next)
|
||||||
postnote(PNGROUP, c->pid, "hangup");
|
postnote(PNGROUP, c->pid, "hangup");
|
||||||
|
|
|
@ -15,13 +15,13 @@ enum
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Fore = '+',
|
Fore = '+',
|
||||||
Back = '-',
|
Back = '-'
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Char,
|
Char,
|
||||||
Line,
|
Line
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Slop = 100, /* room to grow with reallocation */
|
Slop = 100 /* room to grow with reallocation */
|
||||||
};
|
};
|
||||||
|
|
||||||
static
|
static
|
||||||
|
|
|
@ -21,7 +21,7 @@ enum
|
||||||
QWwrsel,
|
QWwrsel,
|
||||||
QWtag,
|
QWtag,
|
||||||
QWxdata,
|
QWxdata,
|
||||||
QMAX,
|
QMAX
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -29,7 +29,7 @@ enum
|
||||||
Blockincr = 256,
|
Blockincr = 256,
|
||||||
Maxblock = 8*1024,
|
Maxblock = 8*1024,
|
||||||
NRange = 10,
|
NRange = 10,
|
||||||
Infinity = 0x7FFFFFFF, /* huge value for regexp address */
|
Infinity = 0x7FFFFFFF /* huge value for regexp address */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Buffer AcmeBuffer
|
#define Buffer AcmeBuffer
|
||||||
|
@ -166,7 +166,7 @@ enum /* Text.what */
|
||||||
Columntag,
|
Columntag,
|
||||||
Rowtag,
|
Rowtag,
|
||||||
Tag,
|
Tag,
|
||||||
Body,
|
Body
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Text
|
struct Text
|
||||||
|
@ -463,7 +463,7 @@ enum
|
||||||
Scrollwid = 12, /* width of scroll bar */
|
Scrollwid = 12, /* width of scroll bar */
|
||||||
Scrollgap = 4, /* gap right of scroll bar */
|
Scrollgap = 4, /* gap right of scroll bar */
|
||||||
Margin = 4, /* margin around text */
|
Margin = 4, /* margin around text */
|
||||||
Border = 2, /* line between rows, cols, windows */
|
Border = 2 /* line between rows, cols, windows */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define QID(w,q) ((w<<8)|(q))
|
#define QID(w,q) ((w<<8)|(q))
|
||||||
|
@ -477,7 +477,7 @@ enum
|
||||||
{
|
{
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
XXX,
|
XXX
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
@ -487,14 +487,14 @@ enum
|
||||||
Delete = 'd',
|
Delete = 'd',
|
||||||
Insert = 'i',
|
Insert = 'i',
|
||||||
Replace = 'r',
|
Replace = 'r',
|
||||||
Filename = 'f',
|
Filename = 'f'
|
||||||
};
|
};
|
||||||
|
|
||||||
enum /* editing */
|
enum /* editing */
|
||||||
{
|
{
|
||||||
Inactive = 0,
|
Inactive = 0,
|
||||||
Inserting,
|
Inserting,
|
||||||
Collecting,
|
Collecting
|
||||||
};
|
};
|
||||||
|
|
||||||
uint globalincref;
|
uint globalincref;
|
||||||
|
@ -545,7 +545,7 @@ int dodollarsigns;
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Kscrolloneup = KF|0x20,
|
Kscrolloneup = KF|0x20,
|
||||||
Kscrollonedown = KF|0x21,
|
Kscrollonedown = KF|0x21
|
||||||
};
|
};
|
||||||
|
|
||||||
Channel *cplumb; /* chan(Plumbmsg*) */
|
Channel *cplumb; /* chan(Plumbmsg*) */
|
||||||
|
|
|
@ -898,14 +898,14 @@ alllooper(Window *w, void *v)
|
||||||
|
|
||||||
lp = v;
|
lp = v;
|
||||||
cp = lp->cp;
|
cp = lp->cp;
|
||||||
// if(w->isscratch || w->isdir)
|
/* if(w->isscratch || w->isdir) */
|
||||||
// return;
|
/* return; */
|
||||||
t = &w->body;
|
t = &w->body;
|
||||||
/* only use this window if it's the current window for the file */
|
/* only use this window if it's the current window for the file */
|
||||||
if(t->file->curtext != t)
|
if(t->file->curtext != t)
|
||||||
return;
|
return;
|
||||||
// if(w->nopen[QWevent] > 0)
|
/* if(w->nopen[QWevent] > 0) */
|
||||||
// return;
|
/* return; */
|
||||||
/* no auto-execute on files without names */
|
/* no auto-execute on files without names */
|
||||||
if(cp->re==nil && t->file->nname==0)
|
if(cp->re==nil && t->file->nname==0)
|
||||||
return;
|
return;
|
||||||
|
@ -1012,7 +1012,7 @@ cmdaddress(Addr *ap, Address a, int sign)
|
||||||
|
|
||||||
case '\'':
|
case '\'':
|
||||||
editerror("can't handle '");
|
editerror("can't handle '");
|
||||||
// a.r = f->mark;
|
/* a.r = f->mark; */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
|
@ -1093,8 +1093,8 @@ alltofile(Window *w, void *v)
|
||||||
/* only use this window if it's the current window for the file */
|
/* only use this window if it's the current window for the file */
|
||||||
if(t->file->curtext != t)
|
if(t->file->curtext != t)
|
||||||
return;
|
return;
|
||||||
// if(w->nopen[QWevent] > 0)
|
/* if(w->nopen[QWevent] > 0) */
|
||||||
// return;
|
/* return; */
|
||||||
if(runeeq(tp->r->r, tp->r->n, t->file->name, t->file->nname))
|
if(runeeq(tp->r->r, tp->r->n, t->file->name, t->file->nname))
|
||||||
tp->f = t->file;
|
tp->f = t->file;
|
||||||
}
|
}
|
||||||
|
@ -1127,8 +1127,8 @@ allmatchfile(Window *w, void *v)
|
||||||
/* only use this window if it's the current window for the file */
|
/* only use this window if it's the current window for the file */
|
||||||
if(t->file->curtext != t)
|
if(t->file->curtext != t)
|
||||||
return;
|
return;
|
||||||
// if(w->nopen[QWevent] > 0)
|
/* if(w->nopen[QWevent] > 0) */
|
||||||
// return;
|
/* return; */
|
||||||
if(filematch(w->body.file, tp->r)){
|
if(filematch(w->body.file, tp->r)){
|
||||||
if(tp->f != nil)
|
if(tp->f != nil)
|
||||||
editerror("too many files match \"%S\"", tp->r->r);
|
editerror("too many files match \"%S\"", tp->r->r);
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct cmdtab cmdtab[]={
|
||||||
'q', 0, 0, 0, 0, aNo, 0, 0, q_cmd,
|
'q', 0, 0, 0, 0, aNo, 0, 0, q_cmd,
|
||||||
'!', 0, 0, 0, 0, aNo, 0, linex, plan9_cmd,
|
'!', 0, 0, 0, 0, aNo, 0, linex, plan9_cmd,
|
||||||
*/
|
*/
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
Cmd *parsecmd(int);
|
Cmd *parsecmd(int);
|
||||||
|
@ -82,8 +82,8 @@ editthread(void *v)
|
||||||
USED(v);
|
USED(v);
|
||||||
threadsetname("editthread");
|
threadsetname("editthread");
|
||||||
while((cmdp=parsecmd(0)) != 0){
|
while((cmdp=parsecmd(0)) != 0){
|
||||||
// ocurfile = curfile;
|
/* ocurfile = curfile; */
|
||||||
// loaded = curfile && !curfile->unread;
|
/* loaded = curfile && !curfile->unread; */
|
||||||
if(cmdexec(curtext, cmdp) == 0)
|
if(cmdexec(curtext, cmdp) == 0)
|
||||||
break;
|
break;
|
||||||
freecmd();
|
freecmd();
|
||||||
|
|
|
@ -76,7 +76,7 @@ struct List /* code depends on a long being able to hold a pointer */
|
||||||
enum Defaddr{ /* default addresses */
|
enum Defaddr{ /* default addresses */
|
||||||
aNo,
|
aNo,
|
||||||
aDot,
|
aDot,
|
||||||
aAll,
|
aAll
|
||||||
};
|
};
|
||||||
|
|
||||||
int nl_cmd(Text*, Cmd*), a_cmd(Text*, Cmd*), b_cmd(Text*, Cmd*);
|
int nl_cmd(Text*, Cmd*), a_cmd(Text*, Cmd*), b_cmd(Text*, Cmd*);
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct Buflog
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Buflogsize = sizeof(Buflog)/sizeof(Rune),
|
Buflogsize = sizeof(Buflog)/sizeof(Rune)
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -46,7 +46,7 @@ enum
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Minstring = 16, /* distance beneath which we merge changes */
|
Minstring = 16, /* distance beneath which we merge changes */
|
||||||
Maxstring = RBUFSIZE, /* maximum length of change we will merge into one */
|
Maxstring = RBUFSIZE /* maximum length of change we will merge into one */
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -108,7 +108,7 @@ Exectab exectab[] = {
|
||||||
{ LTab, tab, FALSE, XXX, XXX },
|
{ LTab, tab, FALSE, XXX, XXX },
|
||||||
{ LUndo, undo, FALSE, TRUE, XXX },
|
{ LUndo, undo, FALSE, TRUE, XXX },
|
||||||
{ LZerox, zeroxx, FALSE, XXX, XXX },
|
{ LZerox, zeroxx, FALSE, XXX, XXX },
|
||||||
{ nil, 0, 0, 0, 0 },
|
{ nil, 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
Exectab*
|
Exectab*
|
||||||
|
@ -1198,7 +1198,7 @@ enum {
|
||||||
IGlobal = -2,
|
IGlobal = -2,
|
||||||
IError = -1,
|
IError = -1,
|
||||||
Ion = 0,
|
Ion = 0,
|
||||||
Ioff = 1,
|
Ioff = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1318,7 +1318,7 @@ runproc(void *argvp)
|
||||||
char buf[512];
|
char buf[512];
|
||||||
int olddir;
|
int olddir;
|
||||||
int ret;
|
int ret;
|
||||||
//static void *parg[2];
|
/*static void *parg[2]; */
|
||||||
char *rcarg[4];
|
char *rcarg[4];
|
||||||
void **argv;
|
void **argv;
|
||||||
CFsys *fs;
|
CFsys *fs;
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct Undo
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Undosize = sizeof(Undo)/sizeof(Rune),
|
Undosize = sizeof(Undo)/sizeof(Rune)
|
||||||
};
|
};
|
||||||
|
|
||||||
File*
|
File*
|
||||||
|
|
|
@ -467,8 +467,10 @@ fsyswalk(Xfid *x, Fid *f)
|
||||||
goto Accept;
|
goto Accept;
|
||||||
|
|
||||||
Regular:
|
Regular:
|
||||||
// if(FILE(f->qid) == Qacme) /* empty directory */
|
/*
|
||||||
// break;
|
if(FILE(f->qid) == Qacme) // empty directory
|
||||||
|
break;
|
||||||
|
*/
|
||||||
if(strcmp(x->fcall.wname[i], "new") == 0){
|
if(strcmp(x->fcall.wname[i], "new") == 0){
|
||||||
if(w)
|
if(w)
|
||||||
error("w set in walk to new");
|
error("w set in walk to new");
|
||||||
|
|
|
@ -7,7 +7,7 @@ enum
|
||||||
{
|
{
|
||||||
STACK = 8192,
|
STACK = 8192,
|
||||||
EVENTSIZE = 256,
|
EVENTSIZE = 256,
|
||||||
NEVENT = 5,
|
NEVENT = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Event
|
struct Event
|
||||||
|
|
|
@ -42,7 +42,7 @@ char *goodtypes[] = {
|
||||||
"text/richtext",
|
"text/richtext",
|
||||||
"text/tab-separated-values",
|
"text/tab-separated-values",
|
||||||
"application/octet-stream",
|
"application/octet-stream",
|
||||||
nil,
|
nil
|
||||||
};
|
};
|
||||||
|
|
||||||
char *okheaders[] =
|
char *okheaders[] =
|
||||||
|
@ -60,7 +60,7 @@ char *extraheaders[] =
|
||||||
"Resent-From:",
|
"Resent-From:",
|
||||||
"Resent-To:",
|
"Resent-To:",
|
||||||
"Sort:",
|
"Sort:",
|
||||||
nil,
|
nil
|
||||||
};
|
};
|
||||||
|
|
||||||
char*
|
char*
|
||||||
|
@ -100,10 +100,10 @@ mkaddrs(char *t)
|
||||||
for(i=0; i+1<nf; i+=2){
|
for(i=0; i+1<nf; i+=2){
|
||||||
if(i > 0)
|
if(i > 0)
|
||||||
fmtprint(&fmt, ", ");
|
fmtprint(&fmt, ", ");
|
||||||
// if(f[i][0] == 0 || strcmp(f[i], f[i+1]) == 0)
|
/* if(f[i][0] == 0 || strcmp(f[i], f[i+1]) == 0) */
|
||||||
fmtprint(&fmt, "%s", f[i+1]);
|
fmtprint(&fmt, "%s", f[i+1]);
|
||||||
// else
|
/* else */
|
||||||
// fmtprint(&fmt, "%s <%s>", f[i], f[i+1]);
|
/* fmtprint(&fmt, "%s <%s>", f[i], f[i+1]); */
|
||||||
}
|
}
|
||||||
free(f);
|
free(f);
|
||||||
return fmtstrflush(&fmt);
|
return fmtstrflush(&fmt);
|
||||||
|
@ -752,10 +752,10 @@ mesgcommand(Message *m, char *cmd)
|
||||||
mesgmenumarkundel(wbox, &mbox, m);
|
mesgmenumarkundel(wbox, &mbox, m);
|
||||||
goto Return;
|
goto Return;
|
||||||
}
|
}
|
||||||
// if(strcmp(args[0], "Headers") == 0){
|
/* if(strcmp(args[0], "Headers") == 0){ */
|
||||||
// m->showheaders();
|
/* m->showheaders(); */
|
||||||
// return True;
|
/* return True; */
|
||||||
// }
|
/* } */
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
|
@ -1149,8 +1149,8 @@ tokenizec(char *str, char **args, int max, char *splitc)
|
||||||
if(max <= 0)
|
if(max <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '('))
|
/* if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '(')) */
|
||||||
// splitc = ",";
|
/* splitc = ","; */
|
||||||
for(na=0; *str != '\0';str++){
|
for(na=0; *str != '\0';str++){
|
||||||
if(strchr(splitc, *str) == nil){
|
if(strchr(splitc, *str) == nil){
|
||||||
if(intok)
|
if(intok)
|
||||||
|
@ -1331,7 +1331,7 @@ mesgopen(Message *mbox, char *dir, char *s, Message *mesg, int plumbed, char *di
|
||||||
winopenbody(m->w, OWRITE);
|
winopenbody(m->w, OWRITE);
|
||||||
mesgload(m, dir, m->name, m->w);
|
mesgload(m, dir, m->name, m->w);
|
||||||
winclosebody(m->w);
|
winclosebody(m->w);
|
||||||
// sleep(100);
|
/* sleep(100); */
|
||||||
winclean(m->w);
|
winclean(m->w);
|
||||||
m->opened = 1;
|
m->opened = 1;
|
||||||
if(ndirelem == 1){
|
if(ndirelem == 1){
|
||||||
|
@ -1405,7 +1405,7 @@ mesglookupfile(Message *mbox, char *name, char *digest)
|
||||||
k = strlen(name);
|
k = strlen(name);
|
||||||
n = strlen(mbox->name);
|
n = strlen(mbox->name);
|
||||||
if(k==0 || strncmp(name, mbox->name, n) != 0){
|
if(k==0 || strncmp(name, mbox->name, n) != 0){
|
||||||
// fprint(2, "Mail: message %s not in this mailbox\n", name);
|
/* fprint(2, "Mail: message %s not in this mailbox\n", name); */
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
return mesglookup(mbox, name+n, digest);
|
return mesglookup(mbox, name+n, digest);
|
||||||
|
|
|
@ -240,7 +240,7 @@ enum{
|
||||||
CC,
|
CC,
|
||||||
FROM,
|
FROM,
|
||||||
INCLUDE,
|
INCLUDE,
|
||||||
TO,
|
TO
|
||||||
};
|
};
|
||||||
|
|
||||||
char *headers[] = {
|
char *headers[] = {
|
||||||
|
@ -250,7 +250,7 @@ char *headers[] = {
|
||||||
"from:",
|
"from:",
|
||||||
"include:",
|
"include:",
|
||||||
"to:",
|
"to:",
|
||||||
nil,
|
nil
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -516,7 +516,7 @@ mesgsend(Message *m)
|
||||||
e->sync = sync;
|
e->sync = sync;
|
||||||
proccreate(execproc, e, EXECSTACK);
|
proccreate(execproc, e, EXECSTACK);
|
||||||
recvul(sync);
|
recvul(sync);
|
||||||
// close(p[0]);
|
/* close(p[0]); */
|
||||||
|
|
||||||
/* using marshal -8, so generate rfc822 headers */
|
/* using marshal -8, so generate rfc822 headers */
|
||||||
if(nto > 0){
|
if(nto > 0){
|
||||||
|
|
|
@ -74,7 +74,7 @@ textscrdraw(Text *t)
|
||||||
r2.min.x = r2.max.x-1;
|
r2.min.x = r2.max.x-1;
|
||||||
draw(b, r2, t->fr.cols[BORD], nil, ZP);
|
draw(b, r2, t->fr.cols[BORD], nil, ZP);
|
||||||
draw(t->fr.b, r, b, nil, Pt(0, r1.min.y));
|
draw(t->fr.b, r, b, nil, Pt(0, r1.min.y));
|
||||||
/*flushimage(display, 1);*//*BUG?*/
|
/*flushimage(display, 1); // BUG? */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1174,7 +1174,7 @@ textsetselect(Text *t, uint q0, uint q1)
|
||||||
*/
|
*/
|
||||||
enum {
|
enum {
|
||||||
DELAY = 2,
|
DELAY = 2,
|
||||||
MINMOVE = 4,
|
MINMOVE = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
uint
|
uint
|
||||||
|
|
|
@ -53,7 +53,7 @@ wininit(Window *w, Window *clone, Rectangle r)
|
||||||
filereset(w->tag.file);
|
filereset(w->tag.file);
|
||||||
textsetselect(&w->tag, nc, nc);
|
textsetselect(&w->tag, nc, nc);
|
||||||
}
|
}
|
||||||
//assert(w->body.w == w);
|
/*assert(w->body.w == w); */
|
||||||
r1 = r;
|
r1 = r;
|
||||||
r1.min.y += w->taglines*font->height + 1;
|
r1.min.y += w->taglines*font->height + 1;
|
||||||
if(r1.max.y < r1.min.y)
|
if(r1.max.y < r1.min.y)
|
||||||
|
@ -66,7 +66,7 @@ wininit(Window *w, Window *clone, Rectangle r)
|
||||||
rf = rfget(FALSE, FALSE, FALSE, clone->body.reffont->f->name);
|
rf = rfget(FALSE, FALSE, FALSE, clone->body.reffont->f->name);
|
||||||
}else
|
}else
|
||||||
rf = rfget(FALSE, FALSE, FALSE, nil);
|
rf = rfget(FALSE, FALSE, FALSE, nil);
|
||||||
//assert(w->body.w == w);
|
/*assert(w->body.w == w); */
|
||||||
f = fileaddtext(f, &w->body);
|
f = fileaddtext(f, &w->body);
|
||||||
w->body.what = Body;
|
w->body.what = Body;
|
||||||
textinit(&w->body, f, r1, rf, textcols);
|
textinit(&w->body, f, r1, rf, textcols);
|
||||||
|
@ -82,7 +82,7 @@ wininit(Window *w, Window *clone, Rectangle r)
|
||||||
w->filemenu = TRUE;
|
w->filemenu = TRUE;
|
||||||
w->maxlines = w->body.fr.maxlines;
|
w->maxlines = w->body.fr.maxlines;
|
||||||
w->autoindent = globalautoindent;
|
w->autoindent = globalautoindent;
|
||||||
//assert(w->body.w == w);
|
/*assert(w->body.w == w); */
|
||||||
if(clone){
|
if(clone){
|
||||||
w->dirty = clone->dirty;
|
w->dirty = clone->dirty;
|
||||||
w->autoindent = clone->autoindent;
|
w->autoindent = clone->autoindent;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
|
||||||
//#pragma varargck type "R" double
|
#ifdef VARARGCK
|
||||||
//#pragma varargck type "D" double
|
#pragma varargck type "R" double
|
||||||
|
#pragma varargck type "D" double
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct Obj1 Obj1;
|
typedef struct Obj1 Obj1;
|
||||||
typedef struct Obj2 Obj2;
|
typedef struct Obj2 Obj2;
|
||||||
|
@ -20,7 +22,7 @@ enum
|
||||||
DARK = 1<<0,
|
DARK = 1<<0,
|
||||||
SIGNIF = 1<<1,
|
SIGNIF = 1<<1,
|
||||||
PTIME = 1<<2,
|
PTIME = 1<<2,
|
||||||
LIGHT = 1<<3,
|
LIGHT = 1<<3
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Obj1
|
struct Obj1
|
||||||
|
@ -150,7 +152,7 @@ extern double cosx(double, int, int, int, int, double);
|
||||||
extern double dist(Obj1*, Obj1*);
|
extern double dist(Obj1*, Obj1*);
|
||||||
extern double dsrc(double, Tim*, int);
|
extern double dsrc(double, Tim*, int);
|
||||||
extern void dtsetup(double, Tim*);
|
extern void dtsetup(double, Tim*);
|
||||||
//extern int evcomp(void*, void*);
|
/*extern int evcomp(void*, void*);*/
|
||||||
extern void event(char*, char*, char*, double, int);
|
extern void event(char*, char*, char*, double, int);
|
||||||
extern void evflush(void);
|
extern void evflush(void);
|
||||||
extern double fmod(double, double);
|
extern double fmod(double, double);
|
||||||
|
|
|
@ -14,7 +14,7 @@ Obj2* objlst[] =
|
||||||
&onept,
|
&onept,
|
||||||
&oplut,
|
&oplut,
|
||||||
&ocomet,
|
&ocomet,
|
||||||
0,
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct idata
|
struct idata
|
||||||
|
@ -35,7 +35,7 @@ struct idata
|
||||||
"Uranus", "uranus", uran,
|
"Uranus", "uranus", uran,
|
||||||
"Neptune", "neptune", nept,
|
"Neptune", "neptune", nept,
|
||||||
"Pluto", "pluto", plut,
|
"Pluto", "pluto", plut,
|
||||||
"Comet", "comet", comet,
|
"Comet", "comet", comet
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -52,12 +52,12 @@ loop:
|
||||||
d = dist(&eobj1->point[i], &eobj2->point[i]);
|
d = dist(&eobj1->point[i], &eobj2->point[i]);
|
||||||
print("dist %s to %s = %.4f\n", eobj1->name, eobj2->name, d);
|
print("dist %s to %s = %.4f\n", eobj1->name, eobj2->name, d);
|
||||||
}
|
}
|
||||||
// if(flags['p']) {
|
/* if(flags['p']) { */
|
||||||
// pdate(d);
|
/* pdate(d); */
|
||||||
// print(" ");
|
/* print(" "); */
|
||||||
// ptime(d);
|
/* ptime(d); */
|
||||||
// print("\n");
|
/* print("\n"); */
|
||||||
// }
|
/* } */
|
||||||
if(flags['p'] || flags['e'])
|
if(flags['p'] || flags['e'])
|
||||||
break;
|
break;
|
||||||
d += deld;
|
d += deld;
|
||||||
|
@ -151,8 +151,8 @@ args(int argc, char *argv[])
|
||||||
if(flags['j'])
|
if(flags['j'])
|
||||||
print("jday = %.4f\n", day);
|
print("jday = %.4f\n", day);
|
||||||
deltat = day * .001704;
|
deltat = day * .001704;
|
||||||
if(deltat > 32.184) // assume date is utc1
|
if(deltat > 32.184) /* assume date is utc1 */
|
||||||
deltat = 32.184; // correct by leap sec
|
deltat = 32.184; /* correct by leap sec */
|
||||||
if(flags['t'])
|
if(flags['t'])
|
||||||
deltat = readdt();
|
deltat = readdt();
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,7 @@ double mercfp[] =
|
||||||
0.160e-6, 2.1241,
|
0.160e-6, 2.1241,
|
||||||
0.134e-6, 5.1260,
|
0.134e-6, 5.1260,
|
||||||
0.347e-6, 5.1620,
|
0.347e-6, 5.1620,
|
||||||
0,
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
char merccp[] =
|
char merccp[] =
|
||||||
|
@ -332,5 +332,5 @@ char merccp[] =
|
||||||
0, 2,
|
0, 2,
|
||||||
-1, 2,
|
-1, 2,
|
||||||
2, 3,
|
2, 3,
|
||||||
1, 3,
|
1, 3
|
||||||
};
|
};
|
||||||
|
|
|
@ -286,5 +286,5 @@ Moontab moontab[] =
|
||||||
-.0130, 4,0,0,-2,
|
-.0130, 4,0,0,-2,
|
||||||
0.0115, 3,-1,0,0,
|
0.0115, 3,-1,0,0,
|
||||||
-.0141, 2,0,-2,-2,
|
-.0141, 2,0,-2,-2,
|
||||||
0, 0,0,0,0,
|
0, 0,0,0,0
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
|
|
||||||
static double elem[] =
|
static double elem[] =
|
||||||
{
|
{
|
||||||
36525.0, // [0] eday of epoc
|
36525.0, /* [0] eday of epoc */
|
||||||
|
|
||||||
30.06896348, // [1] semi major axis (au)
|
30.06896348, /* [1] semi major axis (au) */
|
||||||
0.00858587, // [2] eccentricity
|
0.00858587, /* [2] eccentricity */
|
||||||
1.76917, // [3] inclination (deg)
|
1.76917, /* [3] inclination (deg) */
|
||||||
131.72169, // [4] longitude of the ascending node (deg)
|
131.72169, /* [4] longitude of the ascending node (deg) */
|
||||||
44.97135, // [5] longitude of perihelion (deg)
|
44.97135, /* [5] longitude of perihelion (deg) */
|
||||||
304.88003, // [6] mean longitude (deg)
|
304.88003, /* [6] mean longitude (deg) */
|
||||||
|
|
||||||
-0.00125196, // [1+6] (au/julian century)
|
-0.00125196, /* [1+6] (au/julian century) */
|
||||||
0.0000251, // [2+6] (e/julian century)
|
0.0000251, /* [2+6] (e/julian century) */
|
||||||
-3.64, // [3+6] (arcsec/julian century)
|
-3.64, /* [3+6] (arcsec/julian century) */
|
||||||
-151.25, // [4+6] (arcsec/julian century)
|
-151.25, /* [4+6] (arcsec/julian century) */
|
||||||
-844.43, // [5+6] (arcsec/julian century)
|
-844.43, /* [5+6] (arcsec/julian century) */
|
||||||
786449.21, // [6+6] (arcsec/julian century)
|
786449.21, /* [6+6] (arcsec/julian century) */
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -32,12 +32,12 @@ nept(void)
|
||||||
|
|
||||||
double cy;
|
double cy;
|
||||||
|
|
||||||
cy = (eday - elem[0]) / 36525.; // per julian century
|
cy = (eday - elem[0]) / 36525.; /* per julian century */
|
||||||
|
|
||||||
mrad = elem[1] + elem[1+6]*cy;
|
mrad = elem[1] + elem[1+6]*cy;
|
||||||
ecc = elem[2] + elem[2+6]*cy;
|
ecc = elem[2] + elem[2+6]*cy;
|
||||||
|
|
||||||
cy = cy / 3600; // arcsec/deg per julian century
|
cy = cy / 3600; /* arcsec/deg per julian century */
|
||||||
incl = elem[3] + elem[3+6]*cy;
|
incl = elem[3] + elem[3+6]*cy;
|
||||||
node = elem[4] + elem[4+6]*cy;
|
node = elem[4] + elem[4+6]*cy;
|
||||||
argp = elem[5] + elem[5+6]*cy;
|
argp = elem[5] + elem[5+6]*cy;
|
||||||
|
|
|
@ -34,7 +34,7 @@ double nutfp[] =
|
||||||
.0183, 0,
|
.0183, 0,
|
||||||
.0113, 0,
|
.0113, 0,
|
||||||
-.0050, 0,
|
-.0050, 0,
|
||||||
0,
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
char nutcp[] =
|
char nutcp[] =
|
||||||
|
@ -67,5 +67,5 @@ char nutcp[] =
|
||||||
2,2,0,
|
2,2,0,
|
||||||
1,2,0,
|
1,2,0,
|
||||||
2,2,1,
|
2,2,1,
|
||||||
2,2,-1,
|
2,2,-1
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ char* month[] =
|
||||||
"September",
|
"September",
|
||||||
"October",
|
"October",
|
||||||
"November",
|
"November",
|
||||||
"December",
|
"December"
|
||||||
};
|
};
|
||||||
|
|
||||||
double
|
double
|
||||||
|
@ -163,13 +163,13 @@ pstime(double d)
|
||||||
lambda = 0;
|
lambda = 0;
|
||||||
beta = 0;
|
beta = 0;
|
||||||
|
|
||||||
// uses lambda, beta, rad, motion
|
/* uses lambda, beta, rad, motion */
|
||||||
// sets alpha, delta, rp
|
/* sets alpha, delta, rp */
|
||||||
|
|
||||||
helio();
|
helio();
|
||||||
|
|
||||||
// uses alpha, delta, rp
|
/* uses alpha, delta, rp */
|
||||||
// sets ra, decl, lha, decl2, az, el
|
/* sets ra, decl, lha, decl2, az, el */
|
||||||
|
|
||||||
geo();
|
geo();
|
||||||
|
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
|
|
||||||
static double elem[] =
|
static double elem[] =
|
||||||
{
|
{
|
||||||
36525.0, // [0] eday of epoc
|
36525.0, /* [0] eday of epoc */
|
||||||
|
|
||||||
39.48168677, // [1] semi major axis (au)
|
39.48168677, /* [1] semi major axis (au) */
|
||||||
0.24880766, // [2] eccentricity
|
0.24880766, /* [2] eccentricity */
|
||||||
17.14175, // [3] inclination (deg)
|
17.14175, /* [3] inclination (deg) */
|
||||||
110.30347, // [4] longitude of the ascending node (deg)
|
110.30347, /* [4] longitude of the ascending node (deg) */
|
||||||
224.06676, // [5] longitude of perihelion (deg)
|
224.06676, /* [5] longitude of perihelion (deg) */
|
||||||
238.92881, // [6] mean longitude (deg)
|
238.92881, /* [6] mean longitude (deg) */
|
||||||
|
|
||||||
-0.00076912, // [1+6] (au/julian century)
|
-0.00076912, /* [1+6] (au/julian century) */
|
||||||
0.00006465, // [2+6] (e/julian century)
|
0.00006465, /* [2+6] (e/julian century) */
|
||||||
11.07, // [3+6] (arcsec/julian century)
|
11.07, /* [3+6] (arcsec/julian century) */
|
||||||
-37.33, // [4+6] (arcsec/julian century)
|
-37.33, /* [4+6] (arcsec/julian century) */
|
||||||
-132.25, // [5+6] (arcsec/julian century)
|
-132.25, /* [5+6] (arcsec/julian century) */
|
||||||
522747.90, // [6+6] (arcsec/julian century)
|
522747.90, /* [6+6] (arcsec/julian century) */
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -32,12 +32,12 @@ plut(void)
|
||||||
|
|
||||||
double cy;
|
double cy;
|
||||||
|
|
||||||
cy = (eday - elem[0]) / 36525.; // per julian century
|
cy = (eday - elem[0]) / 36525.; /* per julian century */
|
||||||
|
|
||||||
mrad = elem[1] + elem[1+6]*cy;
|
mrad = elem[1] + elem[1+6]*cy;
|
||||||
ecc = elem[2] + elem[2+6]*cy;
|
ecc = elem[2] + elem[2+6]*cy;
|
||||||
|
|
||||||
cy = cy / 3600; // arcsec/deg per julian century
|
cy = cy / 3600; /* arcsec/deg per julian century */
|
||||||
incl = elem[3] + elem[3+6]*cy;
|
incl = elem[3] + elem[3+6]*cy;
|
||||||
node = elem[4] + elem[4+6]*cy;
|
node = elem[4] + elem[4+6]*cy;
|
||||||
argp = elem[5] + elem[5+6]*cy;
|
argp = elem[5] + elem[5+6]*cy;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
char* satlst[] =
|
char* satlst[] =
|
||||||
{
|
{
|
||||||
0,
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
|
|
@ -5,7 +5,7 @@ char* solstr[] =
|
||||||
"Fall equinox",
|
"Fall equinox",
|
||||||
"Winter solstice",
|
"Winter solstice",
|
||||||
"Spring equinox",
|
"Spring equinox",
|
||||||
"Summer solstice",
|
"Summer solstice"
|
||||||
};
|
};
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
|
|
@ -122,7 +122,7 @@ double sunfp[] =
|
||||||
-1.33e-6, 0,
|
-1.33e-6, 0,
|
||||||
0.37e-6, 0,
|
0.37e-6, 0,
|
||||||
0.36e-6, 0,
|
0.36e-6, 0,
|
||||||
0,
|
0
|
||||||
};
|
};
|
||||||
char suncp[] =
|
char suncp[] =
|
||||||
{
|
{
|
||||||
|
@ -238,5 +238,5 @@ char suncp[] =
|
||||||
1,0,0,
|
1,0,0,
|
||||||
1,-1,0,
|
1,-1,0,
|
||||||
1,1,0,
|
1,1,0,
|
||||||
1,0,-1,
|
1,0,-1
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
|
|
||||||
static double elem[] =
|
static double elem[] =
|
||||||
{
|
{
|
||||||
36525.0, // [0] eday of epoc
|
36525.0, /* [0] eday of epoc */
|
||||||
|
|
||||||
19.19126393, // [1] semi major axis (au)
|
19.19126393, /* [1] semi major axis (au) */
|
||||||
0.04716771, // [2] eccentricity
|
0.04716771, /* [2] eccentricity */
|
||||||
0.76986, // [3] inclination (deg)
|
0.76986, /* [3] inclination (deg) */
|
||||||
74.22988, // [4] longitude of the ascending node (deg)
|
74.22988, /* [4] longitude of the ascending node (deg) */
|
||||||
170.96424, // [5] longitude of perihelion (deg)
|
170.96424, /* [5] longitude of perihelion (deg) */
|
||||||
313.23218, // [6] mean longitude (deg)
|
313.23218, /* [6] mean longitude (deg) */
|
||||||
|
|
||||||
0.00152025, // [1+6] (au/julian century)
|
0.00152025, /* [1+6] (au/julian century) */
|
||||||
-0.00019150, // [2+6] (e/julian century)
|
-0.00019150, /* [2+6] (e/julian century) */
|
||||||
-2.09, // [3+6] (arcsec/julian century)
|
-2.09, /* [3+6] (arcsec/julian century) */
|
||||||
-1681.40, // [4+6] (arcsec/julian century)
|
-1681.40, /* [4+6] (arcsec/julian century) */
|
||||||
1312.56, // [5+6] (arcsec/julian century)
|
1312.56, /* [5+6] (arcsec/julian century) */
|
||||||
1542547.79, // [6+6] (arcsec/julian century)
|
1542547.79, /* [6+6] (arcsec/julian century) */
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -32,12 +32,12 @@ uran(void)
|
||||||
|
|
||||||
double cy;
|
double cy;
|
||||||
|
|
||||||
cy = (eday - elem[0]) / 36525.; // per julian century
|
cy = (eday - elem[0]) / 36525.; /* per julian century */
|
||||||
|
|
||||||
mrad = elem[1] + elem[1+6]*cy;
|
mrad = elem[1] + elem[1+6]*cy;
|
||||||
ecc = elem[2] + elem[2+6]*cy;
|
ecc = elem[2] + elem[2+6]*cy;
|
||||||
|
|
||||||
cy = cy / 3600; // arcsec/deg per julian century
|
cy = cy / 3600; /* arcsec/deg per julian century */
|
||||||
incl = elem[3] + elem[3+6]*cy;
|
incl = elem[3] + elem[3+6]*cy;
|
||||||
node = elem[4] + elem[4+6]*cy;
|
node = elem[4] + elem[4+6]*cy;
|
||||||
argp = elem[5] + elem[5+6]*cy;
|
argp = elem[5] + elem[5+6]*cy;
|
||||||
|
|
|
@ -27,7 +27,7 @@ double venfp[] =
|
||||||
0.717e-6, 2.2969,
|
0.717e-6, 2.2969,
|
||||||
2.991e-6, 2.0611,
|
2.991e-6, 2.0611,
|
||||||
1.335e-6, 0.9628,
|
1.335e-6, 0.9628,
|
||||||
0.,
|
0.
|
||||||
};
|
};
|
||||||
|
|
||||||
char vencp[] =
|
char vencp[] =
|
||||||
|
@ -56,5 +56,5 @@ char vencp[] =
|
||||||
4,-5,0,0,
|
4,-5,0,0,
|
||||||
2,0,-3,0,
|
2,0,-3,0,
|
||||||
1,0,0,-1,
|
1,0,0,-1,
|
||||||
2,0,0,-2,
|
2,0,0,-2
|
||||||
};
|
};
|
||||||
|
|
|
@ -148,7 +148,7 @@ struct ServerState
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
APOPCHALLEN = 128,
|
APOPCHALLEN = 128
|
||||||
};
|
};
|
||||||
|
|
||||||
static int apopchal(ServerState*, int, char[APOPCHALLEN]);
|
static int apopchal(ServerState*, int, char[APOPCHALLEN]);
|
||||||
|
|
|
@ -143,7 +143,7 @@ hasqueries(Attr *a)
|
||||||
|
|
||||||
char *ignored[] = {
|
char *ignored[] = {
|
||||||
"role",
|
"role",
|
||||||
"disabled",
|
"disabled"
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -33,7 +33,7 @@ enum {
|
||||||
|
|
||||||
MShashlen = 16,
|
MShashlen = 16,
|
||||||
MSchallen = 8,
|
MSchallen = 8,
|
||||||
MSresplen = 24,
|
MSresplen = 24
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -315,7 +315,7 @@ out:
|
||||||
keyclose(s.k);
|
keyclose(s.k);
|
||||||
free(user);
|
free(user);
|
||||||
free(resp);
|
free(resp);
|
||||||
// xioclose(s.asfd);
|
/* xioclose(s.asfd); */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,16 +411,17 @@ chaproles[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
Proto chap = {
|
Proto chap = {
|
||||||
.name= "chap",
|
"chap",
|
||||||
.roles= chaproles,
|
chaproles,
|
||||||
.checkkey= chapcheck,
|
"user? !password?",
|
||||||
.keyprompt= "user? !password?",
|
chapcheck
|
||||||
};
|
};
|
||||||
|
|
||||||
Proto mschap = {
|
Proto mschap = {
|
||||||
.name= "mschap",
|
"mschap",
|
||||||
.roles= chaproles,
|
chaproles,
|
||||||
.checkkey= chapcheck,
|
"user? !password?",
|
||||||
.keyprompt= "user? !password?",
|
chapcheck
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ struct AuthMethod {
|
||||||
{
|
{
|
||||||
{ "p9", p9auth, srvp9auth,},
|
{ "p9", p9auth, srvp9auth,},
|
||||||
{ "netkey", netkeyauth, netkeysrvauth,},
|
{ "netkey", netkeyauth, netkeysrvauth,},
|
||||||
// { "none", noauth, srvnoauth,},
|
/* { "none", noauth, srvnoauth,}, */
|
||||||
{ nil, nil}
|
{ nil, nil}
|
||||||
};
|
};
|
||||||
AuthMethod *am = authmethod; /* default is p9 */
|
AuthMethod *am = authmethod; /* default is p9 */
|
||||||
|
@ -687,7 +687,7 @@ enum
|
||||||
Qdir,
|
Qdir,
|
||||||
Qcpunote,
|
Qcpunote,
|
||||||
|
|
||||||
Nfid = 32,
|
Nfid = 32
|
||||||
};
|
};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -697,7 +697,7 @@ struct {
|
||||||
} fstab[] =
|
} fstab[] =
|
||||||
{
|
{
|
||||||
[Qdir] { ".", {Qdir, 0, QTDIR}, DMDIR|0555 },
|
[Qdir] { ".", {Qdir, 0, QTDIR}, DMDIR|0555 },
|
||||||
[Qcpunote] { "cpunote", {Qcpunote, 0}, 0444 },
|
[Qcpunote] { "cpunote", {Qcpunote, 0}, 0444 }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Note Note;
|
typedef struct Note Note;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
static char *msg[] = {
|
static char *msg[] = {
|
||||||
"key",
|
"key",
|
||||||
"delkey",
|
"delkey",
|
||||||
"debug",
|
"debug"
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -13,7 +13,7 @@ enum
|
||||||
RpcWriteHex,
|
RpcWriteHex,
|
||||||
|
|
||||||
/* thread stack size - big buffers for printing */
|
/* thread stack size - big buffers for printing */
|
||||||
STACK = 65536,
|
STACK = 65536
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Conv Conv;
|
typedef struct Conv Conv;
|
||||||
|
|
|
@ -12,7 +12,7 @@ enum
|
||||||
Qlog,
|
Qlog,
|
||||||
Qctl,
|
Qctl,
|
||||||
Qneedkey,
|
Qneedkey,
|
||||||
Qconv,
|
Qconv
|
||||||
};
|
};
|
||||||
|
|
||||||
static int qtop;
|
static int qtop;
|
||||||
|
@ -41,7 +41,7 @@ static struct
|
||||||
"rpc", Qrpc, 0666,
|
"rpc", Qrpc, 0666,
|
||||||
"proto", Qprotolist, 0444,
|
"proto", Qprotolist, 0444,
|
||||||
"log", Qlog, 0600|DMEXCL,
|
"log", Qlog, 0600|DMEXCL,
|
||||||
"conv", Qconv, 0400,
|
"conv", Qconv, 0400
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -26,7 +26,7 @@ threadmain(int argc, char *argv[])
|
||||||
char *mtpt;
|
char *mtpt;
|
||||||
char err[ERRMAX];
|
char err[ERRMAX];
|
||||||
|
|
||||||
// mtpt = "/mnt";
|
/* mtpt = "/mnt"; */
|
||||||
mtpt = nil;
|
mtpt = nil;
|
||||||
owner = getuser();
|
owner = getuser();
|
||||||
quotefmtinstall();
|
quotefmtinstall();
|
||||||
|
|
|
@ -15,7 +15,7 @@ extern Proto p9sk1, p9sk2, p9cr;
|
||||||
static Proto* okproto[] =
|
static Proto* okproto[] =
|
||||||
{
|
{
|
||||||
&p9sk1,
|
&p9sk1,
|
||||||
nil,
|
nil
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -267,6 +267,6 @@ p9anyroles[] =
|
||||||
|
|
||||||
Proto p9any = {
|
Proto p9any = {
|
||||||
"p9any",
|
"p9any",
|
||||||
p9anyroles,
|
p9anyroles
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ out:
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MAXCHAL = 64,
|
MAXCHAL = 64
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct State State;
|
typedef struct State State;
|
||||||
|
@ -222,7 +222,7 @@ enum
|
||||||
SHaveChal,
|
SHaveChal,
|
||||||
SNeedResp,
|
SNeedResp,
|
||||||
|
|
||||||
Maxphase,
|
Maxphase
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *phasenames[Maxphase] =
|
static char *phasenames[Maxphase] =
|
||||||
|
@ -231,7 +231,7 @@ static char *phasenames[Maxphase] =
|
||||||
[CHaveResp] "CHaveResp",
|
[CHaveResp] "CHaveResp",
|
||||||
|
|
||||||
[SHaveChal] "SHaveChal",
|
[SHaveChal] "SHaveChal",
|
||||||
[SNeedResp] "SNeedResp",
|
[SNeedResp] "SNeedResp"
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -525,7 +525,7 @@ Proto p9cr =
|
||||||
.write= p9crwrite,
|
.write= p9crwrite,
|
||||||
.read= p9crread,
|
.read= p9crread,
|
||||||
.close= p9crclose,
|
.close= p9crclose,
|
||||||
.keyprompt= "user? !password?",
|
.keyprompt= "user? !password?"
|
||||||
};
|
};
|
||||||
|
|
||||||
Proto vnc =
|
Proto vnc =
|
||||||
|
@ -536,5 +536,5 @@ Proto vnc =
|
||||||
.read= p9crread,
|
.read= p9crread,
|
||||||
.close= p9crclose,
|
.close= p9crclose,
|
||||||
.keyprompt= "!password?",
|
.keyprompt= "!password?",
|
||||||
.addkey= vncaddkey,
|
.addkey= vncaddkey
|
||||||
};
|
};
|
||||||
|
|
|
@ -343,11 +343,11 @@ Proto p9sk1 = {
|
||||||
p9sk1roles,
|
p9sk1roles,
|
||||||
"user? dom? !password?",
|
"user? dom? !password?",
|
||||||
p9sk1check,
|
p9sk1check,
|
||||||
p9sk1close,
|
p9sk1close
|
||||||
};
|
};
|
||||||
|
|
||||||
Proto p9sk2 = {
|
Proto p9sk2 = {
|
||||||
"p9sk2",
|
"p9sk2",
|
||||||
p9sk2roles,
|
p9sk2roles
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ Proto *prototab[] = {
|
||||||
&p9sk2,
|
&p9sk2,
|
||||||
&pass,
|
&pass,
|
||||||
&rsa,
|
&rsa,
|
||||||
nil,
|
nil
|
||||||
};
|
};
|
||||||
|
|
||||||
Proto*
|
Proto*
|
||||||
|
|
|
@ -41,7 +41,7 @@ char *rpcname[] =
|
||||||
"start",
|
"start",
|
||||||
"write",
|
"write",
|
||||||
"readhex",
|
"readhex",
|
||||||
"writehex",
|
"writehex"
|
||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
enum{ CHK = 16};
|
enum{ CHK = 16};
|
||||||
enum{ MAXFILESIZE = 10*1024*1024 };
|
enum{ MAXFILESIZE = 10*1024*1024 };
|
||||||
|
|
||||||
enum{// PW status bits
|
enum{/* PW status bits */
|
||||||
Enabled = (1<<0),
|
Enabled = (1<<0),
|
||||||
STA = (1<<1), // extra SecurID step
|
STA = (1<<1) /* extra SecurID step */
|
||||||
};
|
};
|
||||||
|
|
||||||
static char testmess[] = "__secstore\tPAK\nC=%s\nm=0\n";
|
static char testmess[] = "__secstore\tPAK\nC=%s\nm=0\n";
|
||||||
|
@ -75,28 +75,28 @@ havesecstore(void)
|
||||||
return strcmp((char*)buf, "!account exists") == 0;
|
return strcmp((char*)buf, "!account exists") == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delimited, authenticated, encrypted connection
|
/* delimited, authenticated, encrypted connection */
|
||||||
enum{ Maxmsg=4096 }; // messages > Maxmsg bytes are truncated
|
enum{ Maxmsg=4096 }; /* messages > Maxmsg bytes are truncated */
|
||||||
typedef struct SConn SConn;
|
typedef struct SConn SConn;
|
||||||
|
|
||||||
extern SConn* newSConn(int); // arg is open file descriptor
|
extern SConn* newSConn(int); /* arg is open file descriptor */
|
||||||
struct SConn{
|
struct SConn{
|
||||||
void *chan;
|
void *chan;
|
||||||
int secretlen;
|
int secretlen;
|
||||||
int (*secret)(SConn*, uchar*, int);//
|
int (*secret)(SConn*, uchar*, int);/* */
|
||||||
int (*read)(SConn*, uchar*, int); // <0 if error; errmess in buffer
|
int (*read)(SConn*, uchar*, int); /* <0 if error; errmess in buffer */
|
||||||
int (*write)(SConn*, uchar*, int);
|
int (*write)(SConn*, uchar*, int);
|
||||||
void (*free)(SConn*); // also closes file descriptor
|
void (*free)(SConn*); /* also closes file descriptor */
|
||||||
};
|
};
|
||||||
// secret(s,b,dir) sets secret for digest, encrypt, using the secretlen
|
/* secret(s,b,dir) sets secret for digest, encrypt, using the secretlen */
|
||||||
// bytes in b to form keys for the two directions;
|
/* bytes in b to form keys for the two directions; */
|
||||||
// set dir=0 in client, dir=1 in server
|
/* set dir=0 in client, dir=1 in server */
|
||||||
|
|
||||||
// error convention: write !message in-band
|
/* error convention: write !message in-band */
|
||||||
#define readstr secstore_readstr
|
#define readstr secstore_readstr
|
||||||
static void writerr(SConn*, char*);
|
static void writerr(SConn*, char*);
|
||||||
static int readstr(SConn*, char*); // call with buf of size Maxmsg+1
|
static int readstr(SConn*, char*); /* call with buf of size Maxmsg+1 */
|
||||||
// returns -1 upon error, with error message in buf
|
/* returns -1 upon error, with error message in buf */
|
||||||
|
|
||||||
typedef struct ConnState {
|
typedef struct ConnState {
|
||||||
uchar secret[SHA1dlen];
|
uchar secret[SHA1dlen];
|
||||||
|
@ -105,8 +105,8 @@ typedef struct ConnState {
|
||||||
} ConnState;
|
} ConnState;
|
||||||
|
|
||||||
typedef struct SS{
|
typedef struct SS{
|
||||||
int fd; // file descriptor for read/write of encrypted data
|
int fd; /* file descriptor for read/write of encrypted data */
|
||||||
int alg; // if nonzero, "alg sha rc4_128"
|
int alg; /* if nonzero, "alg sha rc4_128" */
|
||||||
ConnState in, out;
|
ConnState in, out;
|
||||||
} SS;
|
} SS;
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ SC_secret(SConn *conn, uchar *sigma, int direction)
|
||||||
hmac_sha1(sigma, nsigma, (uchar*)"two", 3, ss->out.secret, nil);
|
hmac_sha1(sigma, nsigma, (uchar*)"two", 3, ss->out.secret, nil);
|
||||||
hmac_sha1(sigma, nsigma, (uchar*)"one", 3, ss->in.secret, nil);
|
hmac_sha1(sigma, nsigma, (uchar*)"one", 3, ss->in.secret, nil);
|
||||||
}
|
}
|
||||||
setupRC4state(&ss->in.rc4, ss->in.secret, 16); // restrict to 128 bits
|
setupRC4state(&ss->in.rc4, ss->in.secret, 16); /* restrict to 128 bits */
|
||||||
setupRC4state(&ss->out.rc4, ss->out.secret, 16);
|
setupRC4state(&ss->out.rc4, ss->out.secret, 16);
|
||||||
ss->alg = 1;
|
ss->alg = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -174,7 +174,7 @@ SC_read(SConn *conn, uchar *buf, int n)
|
||||||
werrstr("!SC_read invalid count");
|
werrstr("!SC_read invalid count");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len = (count[0]&0x7f)<<8 | count[1]; // SSL-style count; no pad
|
len = (count[0]&0x7f)<<8 | count[1]; /* SSL-style count; no pad */
|
||||||
if(ss->alg){
|
if(ss->alg){
|
||||||
len -= SHA1dlen;
|
len -= SHA1dlen;
|
||||||
if(len <= 0 || readn(ss->fd, digest, SHA1dlen) != SHA1dlen){
|
if(len <= 0 || readn(ss->fd, digest, SHA1dlen) != SHA1dlen){
|
||||||
|
@ -328,7 +328,7 @@ getfile(SConn *conn, uchar *key, int nkey)
|
||||||
if((len = atoi(s)) < 0){
|
if((len = atoi(s)) < 0){
|
||||||
werrstr("secstore: remote file %s does not exist", gf);
|
werrstr("secstore: remote file %s does not exist", gf);
|
||||||
return -1;
|
return -1;
|
||||||
}else if(len > MAXFILESIZE){//assert
|
}else if(len > MAXFILESIZE){/*assert */
|
||||||
werrstr("secstore: implausible file size %d for %s", len, gf);
|
werrstr("secstore: implausible file size %d for %s", len, gf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ typedef struct PAKparams{
|
||||||
|
|
||||||
static PAKparams *pak;
|
static PAKparams *pak;
|
||||||
|
|
||||||
// This group was generated by the seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E.
|
/* This group was generated by the seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E. */
|
||||||
static void
|
static void
|
||||||
initPAKparams(void)
|
initPAKparams(void)
|
||||||
{
|
{
|
||||||
|
@ -422,8 +422,8 @@ initPAKparams(void)
|
||||||
"2A6E0BAE08B14258F8C03CC1B30E0DDADFCF7CEDF0727684D3D255F1", nil, 16, nil);
|
"2A6E0BAE08B14258F8C03CC1B30E0DDADFCF7CEDF0727684D3D255F1", nil, 16, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
// H = (sha(ver,C,sha(passphrase)))^r mod p,
|
/* H = (sha(ver,C,sha(passphrase)))^r mod p, */
|
||||||
// a hash function expensive to attack by brute force.
|
/* a hash function expensive to attack by brute force. */
|
||||||
static void
|
static void
|
||||||
longhash(char *ver, char *C, uchar *passwd, mpint *H)
|
longhash(char *ver, char *C, uchar *passwd, mpint *H)
|
||||||
{
|
{
|
||||||
|
@ -449,7 +449,7 @@ longhash(char *ver, char *C, uchar *passwd, mpint *H)
|
||||||
mpexp(H, pak->r, pak->p, H);
|
mpexp(H, pak->r, pak->p, H);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hi = H^-1 mod p
|
/* Hi = H^-1 mod p */
|
||||||
static char *
|
static char *
|
||||||
PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi)
|
PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi)
|
||||||
{
|
{
|
||||||
|
@ -462,8 +462,8 @@ PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi)
|
||||||
return mptoa(Hi, 64, nil, 0);
|
return mptoa(Hi, 64, nil, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// another, faster, hash function for each party to
|
/* another, faster, hash function for each party to */
|
||||||
// confirm that the other has the right secrets.
|
/* confirm that the other has the right secrets. */
|
||||||
static void
|
static void
|
||||||
shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi, uchar *digest)
|
shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi, uchar *digest)
|
||||||
{
|
{
|
||||||
|
@ -485,12 +485,12 @@ shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi
|
||||||
sha1((uchar*)Hi, strlen(Hi), digest, state);
|
sha1((uchar*)Hi, strlen(Hi), digest, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// On input, conn provides an open channel to the server;
|
/* On input, conn provides an open channel to the server; */
|
||||||
// C is the name this client calls itself;
|
/* C is the name this client calls itself; */
|
||||||
// pass is the user's passphrase
|
/* pass is the user's passphrase */
|
||||||
// On output, session secret has been set in conn
|
/* On output, session secret has been set in conn */
|
||||||
// (unless return code is negative, which means failure).
|
/* (unless return code is negative, which means failure). */
|
||||||
// If pS is not nil, it is set to the (alloc'd) name the server calls itself.
|
/* If pS is not nil, it is set to the (alloc'd) name the server calls itself. */
|
||||||
static int
|
static int
|
||||||
PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
||||||
{
|
{
|
||||||
|
@ -503,7 +503,7 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
||||||
|
|
||||||
hexHi = PAK_Hi(C, pass, H, Hi);
|
hexHi = PAK_Hi(C, pass, H, Hi);
|
||||||
|
|
||||||
// random 1<=x<=q-1; send C, m=g**x H
|
/* random 1<=x<=q-1; send C, m=g**x H */
|
||||||
x = mprand(164, genrandom, nil);
|
x = mprand(164, genrandom, nil);
|
||||||
mpmod(x, pak->q, x);
|
mpmod(x, pak->q, x);
|
||||||
if(mpcmp(x, mpzero) == 0)
|
if(mpcmp(x, mpzero) == 0)
|
||||||
|
@ -517,7 +517,7 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
||||||
snprint(mess, Maxmsg, "%s\tPAK\nC=%s\nm=%s\n", VERSION, C, hexm);
|
snprint(mess, Maxmsg, "%s\tPAK\nC=%s\nm=%s\n", VERSION, C, hexm);
|
||||||
conn->write(conn, (uchar*)mess, strlen(mess));
|
conn->write(conn, (uchar*)mess, strlen(mess));
|
||||||
|
|
||||||
// recv g**y, S, check hash1(g**xy)
|
/* recv g**y, S, check hash1(g**xy) */
|
||||||
if(readstr(conn, mess) < 0){
|
if(readstr(conn, mess) < 0){
|
||||||
fprint(2, "error: %s\n", mess);
|
fprint(2, "error: %s\n", mess);
|
||||||
writerr(conn, "couldn't read g**y");
|
writerr(conn, "couldn't read g**y");
|
||||||
|
@ -556,18 +556,18 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send hash2(g**xy)
|
/* send hash2(g**xy) */
|
||||||
shorthash("client", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
shorthash("client", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
||||||
enc64(kc, sizeof kc, digest, SHA1dlen);
|
enc64(kc, sizeof kc, digest, SHA1dlen);
|
||||||
snprint(mess2, Maxmsg, "k'=%s\n", kc);
|
snprint(mess2, Maxmsg, "k'=%s\n", kc);
|
||||||
conn->write(conn, (uchar*)mess2, strlen(mess2));
|
conn->write(conn, (uchar*)mess2, strlen(mess2));
|
||||||
|
|
||||||
// set session key
|
/* set session key */
|
||||||
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
||||||
memset(hexsigma, 0, strlen(hexsigma));
|
memset(hexsigma, 0, strlen(hexsigma));
|
||||||
n = conn->secret(conn, digest, 0);
|
n = conn->secret(conn, digest, 0);
|
||||||
memset(digest, 0, SHA1dlen);
|
memset(digest, 0, SHA1dlen);
|
||||||
if(n < 0){//assert
|
if(n < 0){/*assert */
|
||||||
writerr(conn, "can't set secret");
|
writerr(conn, "can't set secret");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ Test test[] =
|
||||||
"cram", proxyserver, proxyclient,
|
"cram", proxyserver, proxyclient,
|
||||||
"p9sk1", proxyserver, proxyclient,
|
"p9sk1", proxyserver, proxyclient,
|
||||||
"p9sk2", proxyserver, proxyclient,
|
"p9sk2", proxyserver, proxyclient,
|
||||||
"p9any", proxyserver, proxyclient,
|
"p9any", proxyserver, proxyclient
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -13,8 +13,8 @@ typedef struct ConnState {
|
||||||
} ConnState;
|
} ConnState;
|
||||||
|
|
||||||
typedef struct SS{
|
typedef struct SS{
|
||||||
int fd; // file descriptor for read/write of encrypted data
|
int fd; /* file descriptor for read/write of encrypted data */
|
||||||
int alg; // if nonzero, "alg sha rc4_128"
|
int alg; /* if nonzero, "alg sha rc4_128" */
|
||||||
ConnState in, out;
|
ConnState in, out;
|
||||||
} SS;
|
} SS;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ SC_secret(SConn *conn, uchar *sigma, int direction)
|
||||||
hmac_sha1(sigma, nsigma, (uchar*)"two", 3, ss->out.secret, nil);
|
hmac_sha1(sigma, nsigma, (uchar*)"two", 3, ss->out.secret, nil);
|
||||||
hmac_sha1(sigma, nsigma, (uchar*)"one", 3, ss->in.secret, nil);
|
hmac_sha1(sigma, nsigma, (uchar*)"one", 3, ss->in.secret, nil);
|
||||||
}
|
}
|
||||||
setupRC4state(&ss->in.rc4, ss->in.secret, 16); // restrict to 128 bits
|
setupRC4state(&ss->in.rc4, ss->in.secret, 16); /* restrict to 128 bits */
|
||||||
setupRC4state(&ss->out.rc4, ss->out.secret, 16);
|
setupRC4state(&ss->out.rc4, ss->out.secret, 16);
|
||||||
ss->alg = 1;
|
ss->alg = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -82,7 +82,7 @@ SC_read(SConn *conn, uchar *buf, int n)
|
||||||
snprint((char*)buf,n,"!SC_read invalid count");
|
snprint((char*)buf,n,"!SC_read invalid count");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
len = (count[0]&0x7f)<<8 | count[1]; // SSL-style count; no pad
|
len = (count[0]&0x7f)<<8 | count[1]; /* SSL-style count; no pad */
|
||||||
if(ss->alg){
|
if(ss->alg){
|
||||||
len -= SHA1dlen;
|
len -= SHA1dlen;
|
||||||
if(len <= 0 || readn(ss->fd, digest, SHA1dlen) != SHA1dlen){
|
if(len <= 0 || readn(ss->fd, digest, SHA1dlen) != SHA1dlen){
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
// delimited, authenticated, encrypted connection
|
/* delimited, authenticated, encrypted connection */
|
||||||
enum{ Maxmsg=4096 }; // messages > Maxmsg bytes are truncated
|
enum{ Maxmsg=4096 }; /* messages > Maxmsg bytes are truncated */
|
||||||
typedef struct SConn SConn;
|
typedef struct SConn SConn;
|
||||||
|
|
||||||
extern SConn* newSConn(int); // arg is open file descriptor
|
extern SConn* newSConn(int); /* arg is open file descriptor */
|
||||||
struct SConn{
|
struct SConn{
|
||||||
void *chan;
|
void *chan;
|
||||||
int secretlen;
|
int secretlen;
|
||||||
int (*secret)(SConn*, uchar*, int);//
|
int (*secret)(SConn*, uchar*, int);/* */
|
||||||
int (*read)(SConn*, uchar*, int); // <0 if error; errmess in buffer
|
int (*read)(SConn*, uchar*, int); /* <0 if error; errmess in buffer */
|
||||||
int (*write)(SConn*, uchar*, int);
|
int (*write)(SConn*, uchar*, int);
|
||||||
void (*free)(SConn*); // also closes file descriptor
|
void (*free)(SConn*); /* also closes file descriptor */
|
||||||
};
|
};
|
||||||
// secret(s,b,dir) sets secret for digest, encrypt, using the secretlen
|
/* secret(s,b,dir) sets secret for digest, encrypt, using the secretlen */
|
||||||
// bytes in b to form keys for the two directions;
|
/* bytes in b to form keys for the two directions; */
|
||||||
// set dir=0 in client, dir=1 in server
|
/* set dir=0 in client, dir=1 in server */
|
||||||
|
|
||||||
// error convention: write !message in-band
|
/* error convention: write !message in-band */
|
||||||
extern void writerr(SConn*, char*);
|
extern void writerr(SConn*, char*);
|
||||||
extern int readstr(SConn*, char*); // call with buf of size Maxmsg+1
|
extern int readstr(SConn*, char*); /* call with buf of size Maxmsg+1 */
|
||||||
// returns -1 upon error, with error message in buf
|
/* returns -1 upon error, with error message in buf */
|
||||||
|
|
||||||
extern void *emalloc(ulong); /* dies on failure; clears memory */
|
extern void *emalloc(ulong); /* dies on failure; clears memory */
|
||||||
extern void *erealloc(void *, ulong);
|
extern void *erealloc(void *, ulong);
|
||||||
|
|
|
@ -100,7 +100,7 @@ main(int argc, char **argv)
|
||||||
aesCBCencrypt(buf+AESbsize, AESbsize, &aes); /* use second AESbsize bytes as initial plaintext */
|
aesCBCencrypt(buf+AESbsize, AESbsize, &aes); /* use second AESbsize bytes as initial plaintext */
|
||||||
safewrite(buf, 2*AESbsize);
|
safewrite(buf, 2*AESbsize);
|
||||||
dstate = hmac_sha1(buf+AESbsize, AESbsize, key2, MD5dlen, 0, 0);
|
dstate = hmac_sha1(buf+AESbsize, AESbsize, key2, MD5dlen, 0, 0);
|
||||||
while(1){
|
for(;;){
|
||||||
n = Bread(&bin, buf, BUF);
|
n = Bread(&bin, buf, BUF);
|
||||||
if(n < 0){
|
if(n < 0){
|
||||||
fprint(2,"read error\n");
|
fprint(2,"read error\n");
|
||||||
|
@ -134,9 +134,9 @@ main(int argc, char **argv)
|
||||||
exits("decrypted file failed to authenticate");
|
exits("decrypted file failed to authenticate");
|
||||||
}
|
}
|
||||||
}else{ /* compatibility with past mistake */
|
}else{ /* compatibility with past mistake */
|
||||||
// if file was encrypted with bad aescbc use this:
|
/* if file was encrypted with bad aescbc use this: */
|
||||||
// memset(key, 0, AESmaxkey);
|
/* memset(key, 0, AESmaxkey); */
|
||||||
// else assume we're decrypting secstore files
|
/* else assume we're decrypting secstore files */
|
||||||
setupAESstate(&aes, key, AESbsize, buf);
|
setupAESstate(&aes, key, AESbsize, buf);
|
||||||
saferead(buf, CHK);
|
saferead(buf, CHK);
|
||||||
aesCBCdecrypt(buf, CHK, &aes);
|
aesCBCdecrypt(buf, CHK, &aes);
|
||||||
|
|
|
@ -74,7 +74,7 @@ dirls(char *path)
|
||||||
}
|
}
|
||||||
for(list=nil, len=0, i=0; i<ndir; i++){
|
for(list=nil, len=0, i=0; i<ndir; i++){
|
||||||
date = ctime(dirbuf[i].mtime);
|
date = ctime(dirbuf[i].mtime);
|
||||||
date[28] = 0; // trim newline
|
date[28] = 0; /* trim newline */
|
||||||
n = snprint(buf, sizeof buf, "%*ulld %s", lenwid, dirbuf[i].length, date+4);
|
n = snprint(buf, sizeof buf, "%*ulld %s", lenwid, dirbuf[i].length, date+4);
|
||||||
n += enc64(dig, sizeof dig, sha1file(path, dirbuf[i].name), SHA1dlen);
|
n += enc64(dig, sizeof dig, sha1file(path, dirbuf[i].name), SHA1dlen);
|
||||||
n += nmwid+3+strlen(dirbuf[i].name);
|
n += nmwid+3+strlen(dirbuf[i].name);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// PAK is an encrypted key exchange protocol designed by Philip MacKenzie et al.
|
/* PAK is an encrypted key exchange protocol designed by Philip MacKenzie et al. */
|
||||||
// It is patented and use outside Plan 9 requires you get a license.
|
/* It is patented and use outside Plan 9 requires you get a license. */
|
||||||
// (All other EKE protocols are patented as well, by Lucent or others.)
|
/* (All other EKE protocols are patented as well, by Lucent or others.) */
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
#include <mp.h>
|
#include <mp.h>
|
||||||
|
@ -19,7 +19,7 @@ typedef struct PAKparams{
|
||||||
|
|
||||||
static PAKparams *pak;
|
static PAKparams *pak;
|
||||||
|
|
||||||
// from seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E
|
/* from seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E */
|
||||||
static void
|
static void
|
||||||
initPAKparams(void)
|
initPAKparams(void)
|
||||||
{
|
{
|
||||||
|
@ -43,8 +43,8 @@ initPAKparams(void)
|
||||||
nil, 16, nil);
|
nil, 16, nil);
|
||||||
}
|
}
|
||||||
|
|
||||||
// H = (sha(ver,C,sha(passphrase)))^r mod p,
|
/* H = (sha(ver,C,sha(passphrase)))^r mod p, */
|
||||||
// a hash function expensive to attack by brute force.
|
/* a hash function expensive to attack by brute force. */
|
||||||
static void
|
static void
|
||||||
longhash(char *ver, char *C, uchar *passwd, mpint *H)
|
longhash(char *ver, char *C, uchar *passwd, mpint *H)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ longhash(char *ver, char *C, uchar *passwd, mpint *H)
|
||||||
mpexp(H, pak->r, pak->p, H);
|
mpexp(H, pak->r, pak->p, H);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hi = H^-1 mod p
|
/* Hi = H^-1 mod p */
|
||||||
char *
|
char *
|
||||||
PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi)
|
PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi)
|
||||||
{
|
{
|
||||||
|
@ -83,8 +83,8 @@ PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi)
|
||||||
return mptoa(Hi, 64, nil, 0);
|
return mptoa(Hi, 64, nil, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// another, faster, hash function for each party to
|
/* another, faster, hash function for each party to */
|
||||||
// confirm that the other has the right secrets.
|
/* confirm that the other has the right secrets. */
|
||||||
static void
|
static void
|
||||||
shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi, uchar *digest)
|
shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi, uchar *digest)
|
||||||
{
|
{
|
||||||
|
@ -106,12 +106,12 @@ shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi
|
||||||
sha1((uchar*)Hi, strlen(Hi), digest, state);
|
sha1((uchar*)Hi, strlen(Hi), digest, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// On input, conn provides an open channel to the server;
|
/* On input, conn provides an open channel to the server; */
|
||||||
// C is the name this client calls itself;
|
/* C is the name this client calls itself; */
|
||||||
// pass is the user's passphrase
|
/* pass is the user's passphrase */
|
||||||
// On output, session secret has been set in conn
|
/* On output, session secret has been set in conn */
|
||||||
// (unless return code is negative, which means failure).
|
/* (unless return code is negative, which means failure). */
|
||||||
// If pS is not nil, it is set to the (alloc'd) name the server calls itself.
|
/* If pS is not nil, it is set to the (alloc'd) name the server calls itself. */
|
||||||
int
|
int
|
||||||
PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
||||||
{
|
{
|
||||||
|
@ -124,9 +124,9 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
||||||
|
|
||||||
hexHi = PAK_Hi(C, pass, H, Hi);
|
hexHi = PAK_Hi(C, pass, H, Hi);
|
||||||
if(verbose)
|
if(verbose)
|
||||||
fprint(2,"%s\n", feedback[H->p[0]&0x7]); // provide a clue to catch typos
|
fprint(2,"%s\n", feedback[H->p[0]&0x7]); /* provide a clue to catch typos */
|
||||||
|
|
||||||
// random 1<=x<=q-1; send C, m=g**x H
|
/* random 1<=x<=q-1; send C, m=g**x H */
|
||||||
x = mprand(240, genrandom, nil);
|
x = mprand(240, genrandom, nil);
|
||||||
mpmod(x, pak->q, x);
|
mpmod(x, pak->q, x);
|
||||||
if(mpcmp(x, mpzero) == 0)
|
if(mpcmp(x, mpzero) == 0)
|
||||||
|
@ -140,7 +140,7 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
||||||
snprint(mess, Maxmsg, "%s\tPAK\nC=%s\nm=%s\n", VERSION, C, hexm);
|
snprint(mess, Maxmsg, "%s\tPAK\nC=%s\nm=%s\n", VERSION, C, hexm);
|
||||||
conn->write(conn, (uchar*)mess, strlen(mess));
|
conn->write(conn, (uchar*)mess, strlen(mess));
|
||||||
|
|
||||||
// recv g**y, S, check hash1(g**xy)
|
/* recv g**y, S, check hash1(g**xy) */
|
||||||
if(readstr(conn, mess) < 0){
|
if(readstr(conn, mess) < 0){
|
||||||
fprint(2, "error: %s\n", mess);
|
fprint(2, "error: %s\n", mess);
|
||||||
writerr(conn, "couldn't read g**y");
|
writerr(conn, "couldn't read g**y");
|
||||||
|
@ -179,13 +179,13 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send hash2(g**xy)
|
/* send hash2(g**xy) */
|
||||||
shorthash("client", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
shorthash("client", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
||||||
enc64(kc, sizeof kc, digest, SHA1dlen);
|
enc64(kc, sizeof kc, digest, SHA1dlen);
|
||||||
snprint(mess2, Maxmsg, "k'=%s\n", kc);
|
snprint(mess2, Maxmsg, "k'=%s\n", kc);
|
||||||
conn->write(conn, (uchar*)mess2, strlen(mess2));
|
conn->write(conn, (uchar*)mess2, strlen(mess2));
|
||||||
|
|
||||||
// set session key
|
/* set session key */
|
||||||
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
||||||
memset(hexsigma, 0, strlen(hexsigma));
|
memset(hexsigma, 0, strlen(hexsigma));
|
||||||
n = conn->secret(conn, digest, 0);
|
n = conn->secret(conn, digest, 0);
|
||||||
|
@ -210,12 +210,12 @@ done:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// On input,
|
/* On input, */
|
||||||
// mess contains first message;
|
/* mess contains first message; */
|
||||||
// name is name this server should call itself.
|
/* name is name this server should call itself. */
|
||||||
// On output, session secret has been set in conn;
|
/* On output, session secret has been set in conn; */
|
||||||
// if pw!=nil, then *pw points to PW struct for authenticated user.
|
/* if pw!=nil, then *pw points to PW struct for authenticated user. */
|
||||||
// returns -1 if error
|
/* returns -1 if error */
|
||||||
int
|
int
|
||||||
PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
||||||
{
|
{
|
||||||
|
@ -227,7 +227,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
||||||
mpint *y = nil, *m = mpnew(0), *mu = mpnew(0), *sigma = mpnew(0);
|
mpint *y = nil, *m = mpnew(0), *mu = mpnew(0), *sigma = mpnew(0);
|
||||||
PW *pw = nil;
|
PW *pw = nil;
|
||||||
|
|
||||||
// secstore version and algorithm
|
/* secstore version and algorithm */
|
||||||
snprint(mess2,Maxmsg,"%s\tPAK\n", VERSION);
|
snprint(mess2,Maxmsg,"%s\tPAK\n", VERSION);
|
||||||
n = strlen(mess2);
|
n = strlen(mess2);
|
||||||
if(strncmp(mess,mess2,n) != 0){
|
if(strncmp(mess,mess2,n) != 0){
|
||||||
|
@ -237,7 +237,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
||||||
mess += n;
|
mess += n;
|
||||||
initPAKparams();
|
initPAKparams();
|
||||||
|
|
||||||
// parse first message into C, m
|
/* parse first message into C, m */
|
||||||
eol = strchr(mess, '\n');
|
eol = strchr(mess, '\n');
|
||||||
if(strncmp("C=", mess, 2) != 0 || !eol){
|
if(strncmp("C=", mess, 2) != 0 || !eol){
|
||||||
fprint(2,"mess[1]=%s\n", mess);
|
fprint(2,"mess[1]=%s\n", mess);
|
||||||
|
@ -256,7 +256,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
||||||
strtomp(hexm, nil, 64, m);
|
strtomp(hexm, nil, 64, m);
|
||||||
mpmod(m, pak->p, m);
|
mpmod(m, pak->p, m);
|
||||||
|
|
||||||
// lookup client
|
/* lookup client */
|
||||||
if((pw = getPW(C,0)) == nil) {
|
if((pw = getPW(C,0)) == nil) {
|
||||||
snprint(mess2, sizeof mess2, "%r");
|
snprint(mess2, sizeof mess2, "%r");
|
||||||
writerr(conn, mess2);
|
writerr(conn, mess2);
|
||||||
|
@ -270,7 +270,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
||||||
}
|
}
|
||||||
hexHi = mptoa(pw->Hi, 64, nil, 0);
|
hexHi = mptoa(pw->Hi, 64, nil, 0);
|
||||||
|
|
||||||
// random y, mu=g**y, sigma=g**xy
|
/* random y, mu=g**y, sigma=g**xy */
|
||||||
y = mprand(240, genrandom, nil);
|
y = mprand(240, genrandom, nil);
|
||||||
mpmod(y, pak->q, y);
|
mpmod(y, pak->q, y);
|
||||||
if(mpcmp(y, mpzero) == 0){
|
if(mpcmp(y, mpzero) == 0){
|
||||||
|
@ -281,7 +281,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
||||||
mpmod(m, pak->p, m);
|
mpmod(m, pak->p, m);
|
||||||
mpexp(m, y, pak->p, sigma);
|
mpexp(m, y, pak->p, sigma);
|
||||||
|
|
||||||
// send g**y, hash1(g**xy)
|
/* send g**y, hash1(g**xy) */
|
||||||
hexmu = mptoa(mu, 64, nil, 0);
|
hexmu = mptoa(mu, 64, nil, 0);
|
||||||
hexsigma = mptoa(sigma, 64, nil, 0);
|
hexsigma = mptoa(sigma, 64, nil, 0);
|
||||||
shorthash("server", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
shorthash("server", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
||||||
|
@ -289,7 +289,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
||||||
snprint(mess2, sizeof mess2, "mu=%s\nk=%s\nS=%s\n", hexmu, ks, S);
|
snprint(mess2, sizeof mess2, "mu=%s\nk=%s\nS=%s\n", hexmu, ks, S);
|
||||||
conn->write(conn, (uchar*)mess2, strlen(mess2));
|
conn->write(conn, (uchar*)mess2, strlen(mess2));
|
||||||
|
|
||||||
// recv hash2(g**xy)
|
/* recv hash2(g**xy) */
|
||||||
if(readstr(conn, mess2) < 0){
|
if(readstr(conn, mess2) < 0){
|
||||||
writerr(conn, "couldn't read verifier");
|
writerr(conn, "couldn't read verifier");
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -308,7 +308,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set session key
|
/* set session key */
|
||||||
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
|
||||||
n = conn->secret(conn, digest, 1);
|
n = conn->secret(conn, digest, 1);
|
||||||
if(n < 0){
|
if(n < 0){
|
||||||
|
|
|
@ -42,7 +42,7 @@ getPW(char *id, int dead_or_alive)
|
||||||
uint now = time(0);
|
uint now = time(0);
|
||||||
Biobuf *bin;
|
Biobuf *bin;
|
||||||
PW *pw;
|
PW *pw;
|
||||||
char *f1, *f2; // fields 1, 2 = attribute, value
|
char *f1, *f2; /* fields 1, 2 = attribute, value */
|
||||||
|
|
||||||
if((bin = openPW(id, OREAD)) == 0){
|
if((bin = openPW(id, OREAD)) == 0){
|
||||||
id = "FICTITIOUS";
|
id = "FICTITIOUS";
|
||||||
|
@ -75,7 +75,7 @@ getPW(char *id, int dead_or_alive)
|
||||||
}
|
}
|
||||||
Bterm(bin);
|
Bterm(bin);
|
||||||
if(dead_or_alive)
|
if(dead_or_alive)
|
||||||
return pw; // return PW entry for editing, whether currently valid or not
|
return pw; /* return PW entry for editing, whether currently valid or not */
|
||||||
if(pw->expire <= now){
|
if(pw->expire <= now){
|
||||||
werrstr("account expired");
|
werrstr("account expired");
|
||||||
freePW(pw);
|
freePW(pw);
|
||||||
|
@ -87,14 +87,14 @@ getPW(char *id, int dead_or_alive)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
if(pw->failed < 10)
|
if(pw->failed < 10)
|
||||||
return pw; // success
|
return pw; /* success */
|
||||||
if(now < mtimePW(id)+300){
|
if(now < mtimePW(id)+300){
|
||||||
werrstr("too many failures; try again in five minutes");
|
werrstr("too many failures; try again in five minutes");
|
||||||
freePW(pw);
|
freePW(pw);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
pw->failed = 0;
|
pw->failed = 0;
|
||||||
putPW(pw); // reset failed-login-counter after five minutes
|
putPW(pw); /* reset failed-login-counter after five minutes */
|
||||||
return pw;
|
return pw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,8 +142,8 @@ getfile(SConn *conn, char *gf, uchar **buf, ulong *buflen, uchar *key, int nkey)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This sends a file to the secstore disk that can, in an emergency, be
|
/* This sends a file to the secstore disk that can, in an emergency, be */
|
||||||
// decrypted by the program aescbc.c.
|
/* decrypted by the program aescbc.c. */
|
||||||
static int
|
static int
|
||||||
putfile(SConn *conn, char *pf, uchar *buf, ulong len, uchar *key, int nkey)
|
putfile(SConn *conn, char *pf, uchar *buf, ulong len, uchar *key, int nkey)
|
||||||
{
|
{
|
||||||
|
@ -206,7 +206,7 @@ putfile(SConn *conn, char *pf, uchar *buf, ulong len, uchar *key, int nkey)
|
||||||
ivo = 0;
|
ivo = 0;
|
||||||
if(n < Maxmsg){ /* EOF on input; append XX... */
|
if(n < Maxmsg){ /* EOF on input; append XX... */
|
||||||
memset(b+n, 'X', CHK);
|
memset(b+n, 'X', CHK);
|
||||||
n += CHK; // might push n>Maxmsg
|
n += CHK; /* might push n>Maxmsg */
|
||||||
done = 1;
|
done = 1;
|
||||||
}
|
}
|
||||||
aesCBCencrypt(b, n, &aes);
|
aesCBCencrypt(b, n, &aes);
|
||||||
|
@ -255,7 +255,7 @@ cmd(AuthConn *c, char **gf, int *Gflag, char **pf, char **rf)
|
||||||
if(getfile(c->conn, *gf, *Gflag ? &memfile : nil, &len, (uchar*)c->pass, c->passlen) < 0)
|
if(getfile(c->conn, *gf, *Gflag ? &memfile : nil, &len, (uchar*)c->pass, c->passlen) < 0)
|
||||||
goto Out;
|
goto Out;
|
||||||
if(*Gflag){
|
if(*Gflag){
|
||||||
// write one line at a time, as required by /mnt/factotum/ctl
|
/* write one line at a time, as required by /mnt/factotum/ctl */
|
||||||
memcur = memfile;
|
memcur = memfile;
|
||||||
while(len>0){
|
while(len>0){
|
||||||
memnext = (uchar*)strchr((char*)memcur, '\n');
|
memnext = (uchar*)strchr((char*)memcur, '\n');
|
||||||
|
@ -309,7 +309,7 @@ chpasswd(AuthConn *c, char *id)
|
||||||
|
|
||||||
H = mpnew(0);
|
H = mpnew(0);
|
||||||
Hi = mpnew(0);
|
Hi = mpnew(0);
|
||||||
// changing our password is vulnerable to connection failure
|
/* changing our password is vulnerable to connection failure */
|
||||||
for(;;){
|
for(;;){
|
||||||
snprint(prompt, sizeof(prompt), "new password for %s: ", id);
|
snprint(prompt, sizeof(prompt), "new password for %s: ", id);
|
||||||
newpass = readcons(prompt, nil, 1);
|
newpass = readcons(prompt, nil, 1);
|
||||||
|
@ -392,7 +392,7 @@ login(char *id, char *dest, int pass_stdin, int pass_nvram)
|
||||||
strecpy(c->pass, c->pass+sizeof c->pass, nvr.config);
|
strecpy(c->pass, c->pass+sizeof c->pass, nvr.config);
|
||||||
}
|
}
|
||||||
if(pass_stdin){
|
if(pass_stdin){
|
||||||
n = readn(0, s, Maxmsg-2); // so len(PINSTA)<Maxmsg-3
|
n = readn(0, s, Maxmsg-2); /* so len(PINSTA)<Maxmsg-3 */
|
||||||
if(n < 1)
|
if(n < 1)
|
||||||
exits("no password on standard input");
|
exits("no password on standard input");
|
||||||
s[n] = 0;
|
s[n] = 0;
|
||||||
|
@ -442,7 +442,7 @@ login(char *id, char *dest, int pass_stdin, int pass_nvram)
|
||||||
exits("invalid password on standard input");
|
exits("invalid password on standard input");
|
||||||
if(pass_nvram)
|
if(pass_nvram)
|
||||||
exits("invalid password in nvram");
|
exits("invalid password in nvram");
|
||||||
// and let user try retyping the password
|
/* and let user try retyping the password */
|
||||||
if(ntry==3)
|
if(ntry==3)
|
||||||
fprint(2, "Enter an empty password to quit.\n");
|
fprint(2, "Enter an empty password to quit.\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
enum{ MAXFILESIZE = 10*1024*1024 };
|
enum{ MAXFILESIZE = 10*1024*1024 };
|
||||||
|
|
||||||
enum{// PW status bits
|
enum{/* PW status bits */
|
||||||
Enabled = (1<<0),
|
Enabled = (1<<0),
|
||||||
STA = (1<<1), // extra SecurID step
|
STA = (1<<1) /* extra SecurID step */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct PW {
|
typedef struct PW {
|
||||||
char *id; // user id
|
char *id; /* user id */
|
||||||
ulong expire; // expiration time (epoch seconds)
|
ulong expire; /* expiration time (epoch seconds) */
|
||||||
ushort status; // Enabled, STA, ...
|
ushort status; /* Enabled, STA, ... */
|
||||||
ushort failed; // number of failed login attempts
|
ushort failed; /* number of failed login attempts */
|
||||||
char *other; // other information, e.g. sponsor
|
char *other; /* other information, e.g. sponsor */
|
||||||
mpint *Hi; // H(passphrase)^-1 mod p
|
mpint *Hi; /* H(passphrase)^-1 mod p */
|
||||||
} PW;
|
} PW;
|
||||||
|
|
||||||
PW *getPW(char *, int);
|
PW *getPW(char *, int);
|
||||||
int putPW(PW *);
|
int putPW(PW *);
|
||||||
void freePW(PW *);
|
void freePW(PW *);
|
||||||
|
|
||||||
// *client: SConn, client name, passphrase
|
/* *client: SConn, client name, passphrase */
|
||||||
// *server: SConn, (partial) 1st msg, PW entry
|
/* *server: SConn, (partial) 1st msg, PW entry */
|
||||||
// *setpass: Username, hashed passphrase, PW entry
|
/* *setpass: Username, hashed passphrase, PW entry */
|
||||||
int PAKclient(SConn *, char *, char *, char **);
|
int PAKclient(SConn *, char *, char *, char **);
|
||||||
int PAKserver(SConn *, char *, char *, PW **);
|
int PAKserver(SConn *, char *, char *, PW **);
|
||||||
char *PAK_Hi(char *, char *, mpint *, mpint *);
|
char *PAK_Hi(char *, char *, mpint *, mpint *);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "secstore.h"
|
#include "secstore.h"
|
||||||
|
|
||||||
char *SECSTORE_DIR;
|
char *SECSTORE_DIR;
|
||||||
char* secureidcheck(char *, char *); // from /sys/src/cmd/auth/
|
char* secureidcheck(char *, char *); /* from /sys/src/cmd/auth/ */
|
||||||
extern char* dirls(char *path);
|
extern char* dirls(char *path);
|
||||||
|
|
||||||
int verbose;
|
int verbose;
|
||||||
|
@ -247,7 +247,7 @@ dologin(int fd, char *S, int forceSTA)
|
||||||
pw = nil;
|
pw = nil;
|
||||||
rv = -1;
|
rv = -1;
|
||||||
|
|
||||||
// collect the first message
|
/* collect the first message */
|
||||||
if((conn = newSConn(fd)) == nil)
|
if((conn = newSConn(fd)) == nil)
|
||||||
return -1;
|
return -1;
|
||||||
if(readstr(conn, msg) < 0){
|
if(readstr(conn, msg) < 0){
|
||||||
|
@ -256,7 +256,7 @@ dologin(int fd, char *S, int forceSTA)
|
||||||
goto Out;
|
goto Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// authenticate
|
/* authenticate */
|
||||||
if(PAKserver(conn, S, msg, &pw) < 0){
|
if(PAKserver(conn, S, msg, &pw) < 0){
|
||||||
if(pw != nil)
|
if(pw != nil)
|
||||||
syslog(0, LOG, "secstore denied for %s", pw->id);
|
syslog(0, LOG, "secstore denied for %s", pw->id);
|
||||||
|
@ -277,7 +277,7 @@ dologin(int fd, char *S, int forceSTA)
|
||||||
conn->write(conn, (uchar*)"OK", 2);
|
conn->write(conn, (uchar*)"OK", 2);
|
||||||
syslog(0, LOG, "AUTH %s", pw->id);
|
syslog(0, LOG, "AUTH %s", pw->id);
|
||||||
|
|
||||||
// perform operations as asked
|
/* perform operations as asked */
|
||||||
while((n = readstr(conn, msg)) > 0){
|
while((n = readstr(conn, msg)) > 0){
|
||||||
syslog(0, LOG, "[%s] %s", pw->id, msg);
|
syslog(0, LOG, "[%s] %s", pw->id, msg);
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
S = sysname();
|
S = sysname();
|
||||||
SECSTORE_DIR = unsharp("#9/secstore");
|
SECSTORE_DIR = unsharp("#9/secstore");
|
||||||
// setnetmtpt(net, sizeof(net), nil);
|
/* setnetmtpt(net, sizeof(net), nil); */
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
case 'R':
|
case 'R':
|
||||||
forceSTA = 1;
|
forceSTA = 1;
|
||||||
|
@ -362,7 +362,7 @@ main(int argc, char **argv)
|
||||||
if(p == nil)
|
if(p == nil)
|
||||||
usage();
|
usage();
|
||||||
USED(p);
|
USED(p);
|
||||||
// setnetmtpt(net, sizeof(net), p);
|
/* setnetmtpt(net, sizeof(net), p); */
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
|
@ -395,7 +395,7 @@ main(int argc, char **argv)
|
||||||
close(lcfd);
|
close(lcfd);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
// "/lib/ndb/common.radius does not exist" if db set before fork
|
/* "/lib/ndb/common.radius does not exist" if db set before fork */
|
||||||
db = ndbopen(dbpath=unsharp("#9/ndb/auth"));
|
db = ndbopen(dbpath=unsharp("#9/ndb/auth"));
|
||||||
if(db == 0)
|
if(db == 0)
|
||||||
syslog(0, LOG, "no ndb/auth");
|
syslog(0, LOG, "no ndb/auth");
|
||||||
|
@ -405,7 +405,7 @@ main(int argc, char **argv)
|
||||||
db = ndbcat(db, db2);
|
db = ndbcat(db, db2);
|
||||||
if((dfd = accept(lcfd, ldir)) < 0)
|
if((dfd = accept(lcfd, ldir)) < 0)
|
||||||
exits("can't accept");
|
exits("can't accept");
|
||||||
alarm(30*60*1000); // 30 min
|
alarm(30*60*1000); /* 30 min */
|
||||||
remote = remoteIP(ldir);
|
remote = remoteIP(ldir);
|
||||||
syslog(0, LOG, "secstore from %s", remote);
|
syslog(0, LOG, "secstore from %s", remote);
|
||||||
free(remote);
|
free(remote);
|
||||||
|
|
|
@ -29,7 +29,7 @@ typedef struct Secret{
|
||||||
typedef struct Attribute{
|
typedef struct Attribute{
|
||||||
struct Attribute *next;
|
struct Attribute *next;
|
||||||
uchar type;
|
uchar type;
|
||||||
uchar len; // number of bytes in value
|
uchar len; /* number of bytes in value */
|
||||||
uchar val[256];
|
uchar val[256];
|
||||||
} Attribute;
|
} Attribute;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ typedef struct Packet{
|
||||||
Attribute first;
|
Attribute first;
|
||||||
} Packet;
|
} Packet;
|
||||||
|
|
||||||
// assumes pass is at most 16 chars
|
/* assumes pass is at most 16 chars */
|
||||||
void
|
void
|
||||||
hide(Secret *shared, uchar *auth, Secret *pass, uchar *x)
|
hide(Secret *shared, uchar *auth, Secret *pass, uchar *x)
|
||||||
{
|
{
|
||||||
|
@ -60,9 +60,9 @@ authcmp(Secret *shared, uchar *buf, int m, uchar *auth)
|
||||||
DigestState *M;
|
DigestState *M;
|
||||||
uchar x[16];
|
uchar x[16];
|
||||||
|
|
||||||
M = md5(buf, 4, nil, nil); // Code+ID+Length
|
M = md5(buf, 4, nil, nil); /* Code+ID+Length */
|
||||||
M = md5(auth, 16, nil, M); // RequestAuth
|
M = md5(auth, 16, nil, M); /* RequestAuth */
|
||||||
M = md5(buf+20, m-20, nil, M); // Attributes
|
M = md5(buf+20, m-20, nil, M); /* Attributes */
|
||||||
md5(shared->s, shared->len, x, M);
|
md5(shared->s, shared->len, x, M);
|
||||||
return memcmp(x, buf+4, 16);
|
return memcmp(x, buf+4, 16);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ rpc(char *dest, Secret *shared, Packet *req)
|
||||||
Attribute *a;
|
Attribute *a;
|
||||||
int m, n, fd, try;
|
int m, n, fd, try;
|
||||||
|
|
||||||
// marshal request
|
/* marshal request */
|
||||||
e = buf + sizeof buf;
|
e = buf + sizeof buf;
|
||||||
buf[0] = req->code;
|
buf[0] = req->code;
|
||||||
buf[1] = req->ID;
|
buf[1] = req->ID;
|
||||||
|
@ -136,7 +136,7 @@ rpc(char *dest, Secret *shared, Packet *req)
|
||||||
buf[2] = n>>8;
|
buf[2] = n>>8;
|
||||||
buf[3] = n;
|
buf[3] = n;
|
||||||
|
|
||||||
// send request, wait for reply
|
/* send request, wait for reply */
|
||||||
fd = dial(dest, 0, 0, 0);
|
fd = dial(dest, 0, 0, 0);
|
||||||
if(fd < 0){
|
if(fd < 0){
|
||||||
syslog(0, AUTHLOG, "%s: rpc can't get udp channel", dest);
|
syslog(0, AUTHLOG, "%s: rpc can't get udp channel", dest);
|
||||||
|
@ -156,9 +156,9 @@ rpc(char *dest, Secret *shared, Packet *req)
|
||||||
alarm(0);
|
alarm(0);
|
||||||
if(m < 0){
|
if(m < 0){
|
||||||
syslog(0, AUTHLOG, "%s rpc read err %d: %r", dest, m);
|
syslog(0, AUTHLOG, "%s rpc read err %d: %r", dest, m);
|
||||||
break; // failure
|
break; /* failure */
|
||||||
}
|
}
|
||||||
if(m == 0 || buf2[1] != buf[1]){ // need matching ID
|
if(m == 0 || buf2[1] != buf[1]){ /* need matching ID */
|
||||||
syslog(0, AUTHLOG, "%s unmatched reply %d", dest, m);
|
syslog(0, AUTHLOG, "%s unmatched reply %d", dest, m);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ rpc(char *dest, Secret *shared, Packet *req)
|
||||||
if(m <= 0)
|
if(m <= 0)
|
||||||
return nil;
|
return nil;
|
||||||
|
|
||||||
// unmarshal reply
|
/* unmarshal reply */
|
||||||
b = buf2;
|
b = buf2;
|
||||||
e = buf2+m;
|
e = buf2+m;
|
||||||
resp = (Packet*)malloc(sizeof(*resp));
|
resp = (Packet*)malloc(sizeof(*resp));
|
||||||
|
@ -192,18 +192,18 @@ rpc(char *dest, Secret *shared, Packet *req)
|
||||||
while(1){
|
while(1){
|
||||||
if(b >= e){
|
if(b >= e){
|
||||||
a->next = nil;
|
a->next = nil;
|
||||||
break; // exit loop
|
break; /* exit loop */
|
||||||
}
|
}
|
||||||
a->type = *b++;
|
a->type = *b++;
|
||||||
a->len = (*b++) - 2;
|
a->len = (*b++) - 2;
|
||||||
if(b + a->len > e){ // corrupt packet
|
if(b + a->len > e){ /* corrupt packet */
|
||||||
a->next = nil;
|
a->next = nil;
|
||||||
freePacket(resp);
|
freePacket(resp);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
memmove(a->val, b, a->len);
|
memmove(a->val, b, a->len);
|
||||||
b += a->len;
|
b += a->len;
|
||||||
if(b < e){ // any more attributes?
|
if(b < e){ /* any more attributes? */
|
||||||
a->next = (Attribute*)malloc(sizeof(*a));
|
a->next = (Attribute*)malloc(sizeof(*a));
|
||||||
if(a->next == nil){
|
if(a->next == nil){
|
||||||
free(req);
|
free(req);
|
||||||
|
@ -230,7 +230,7 @@ setAttribute(Packet *p, uchar type, uchar *s, int n)
|
||||||
}
|
}
|
||||||
a->type = type;
|
a->type = type;
|
||||||
a->len = n;
|
a->len = n;
|
||||||
if(a->len > 253 ) // RFC2138, section 5
|
if(a->len > 253 ) /* RFC2138, section 5 */
|
||||||
a->len = 253;
|
a->len = 253;
|
||||||
memmove(a->val, s, a->len);
|
memmove(a->val, s, a->len);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -435,7 +435,7 @@ secureidcheck(char *user, char *response)
|
||||||
syslog(0, AUTHLOG, "%s code=%d ruser=%s %s", dest, resp->code, ruser, replymsg(resp));
|
syslog(0, AUTHLOG, "%s code=%d ruser=%s %s", dest, resp->code, ruser, replymsg(resp));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break; // we have a proper reply, no need to ask again
|
break; /* we have a proper reply, no need to ask again */
|
||||||
}
|
}
|
||||||
ndbfree(t);
|
ndbfree(t);
|
||||||
free(radiussecret);
|
free(radiussecret);
|
||||||
|
|
|
@ -49,7 +49,7 @@ enum /* agent protocol packet types */
|
||||||
SSH2_AGENT_FAILURE = 30,
|
SSH2_AGENT_FAILURE = 30,
|
||||||
|
|
||||||
SSH_COM_AGENT2_FAILURE = 102,
|
SSH_COM_AGENT2_FAILURE = 102,
|
||||||
SSH_AGENT_OLD_SIGNATURE = 0x01,
|
SSH_AGENT_OLD_SIGNATURE = 0x01
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct Aconn Aconn;
|
typedef struct Aconn Aconn;
|
||||||
|
|
|
@ -56,7 +56,7 @@ main(int argc, char **argv)
|
||||||
fd = openlog(argv[2]);
|
fd = openlog(argv[2]);
|
||||||
fprint(fd, "%s: %s\n", t, p);
|
fprint(fd, "%s: %s\n", t, p);
|
||||||
}
|
}
|
||||||
} else if(Blinelen(&in) == 0) // true eof
|
} else if(Blinelen(&in) == 0) /* true eof */
|
||||||
break;
|
break;
|
||||||
else {
|
else {
|
||||||
Bread(&in, buf, sizeof buf);
|
Bread(&in, buf, sizeof buf);
|
||||||
|
|
|
@ -88,7 +88,7 @@ sampleinit(void)
|
||||||
if(host_page_size(stat_port, &sample.pgsize) != KERN_SUCCESS)
|
if(host_page_size(stat_port, &sample.pgsize) != KERN_SUCCESS)
|
||||||
sample.pgsize = 4096;
|
sample.pgsize = 4096;
|
||||||
|
|
||||||
// populate clock tick info for timestamps
|
/* populate clock tick info for timestamps */
|
||||||
mach_timebase_info(&info);
|
mach_timebase_info(&info);
|
||||||
sample.divisor = 1000.0 * (double)info.denom/info.numer;
|
sample.divisor = 1000.0 * (double)info.denom/info.numer;
|
||||||
sample.time = mach_absolute_time();
|
sample.time = mach_absolute_time();
|
||||||
|
@ -361,10 +361,10 @@ xvm(int first)
|
||||||
isys("vm.stats.vm.v_rforks")
|
isys("vm.stats.vm.v_rforks")
|
||||||
+isys("vm.stats.vm.v_vforks"));
|
+isys("vm.stats.vm.v_vforks"));
|
||||||
|
|
||||||
// Bprint(&bout, "hits %lud of %lud lookups (%d%% hit rate)\n",
|
/* Bprint(&bout, "hits %lud of %lud lookups (%d%% hit rate)\n", */
|
||||||
// (asamp.vm_stat.hits),
|
/* (asamp.vm_stat.hits), */
|
||||||
// (asamp.vm_stat.lookups),
|
/* (asamp.vm_stat.lookups), */
|
||||||
// (natural_t)(((double)asamp.vm_stat.hits*100)/ (double)asamp.vm_stat.lookups));
|
/* (natural_t)(((double)asamp.vm_stat.hits*100)/ (double)asamp.vm_stat.lookups)); */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue