Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.

This commit is contained in:
rsc 2006-04-01 19:24:03 +00:00
parent 226d80b821
commit cbeb0b26e4
492 changed files with 3218 additions and 3167 deletions

4
bin/9c
View file

@ -8,6 +8,8 @@ usegcc()
-O2 \
-c \
-Wall \
-ansi \
-pedantic \
-Wno-parentheses \
-Wno-missing-braces \
-Wno-switch \
@ -67,7 +69,7 @@ xtmp=/tmp/9c.$$.$USER.out
$cc -DPLAN9PORT -I$PLAN9/include $cflags "$@" 2>$xtmp
status=$?
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' |
uniq 1>&2
rm -f $xtmp $xtmp.status

View file

@ -40,7 +40,7 @@ enum
ARrpcfailure,
ARphase,
AuthRpcMax = 4096,
AuthRpcMax = 4096
};
struct AuthRpc
@ -108,7 +108,7 @@ typedef struct Attr Attr;
enum {
AttrNameval, /* name=val -- when matching, must have name=val */
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
{

View file

@ -34,7 +34,7 @@ enum
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 */
KEYDBLEN= OKEYDBLEN+SECRETLEN, /* length of an entry in key file */
OMD5LEN= 16,
OMD5LEN= 16
};
/* encryption numberings (anti-replay) */
@ -60,7 +60,7 @@ enum
AuthAs, /* server generated authenticator */
AuthAc, /* client generated authenticator */
AuthTp, /* ticket encrypted with client's key for password change */
AuthHr, /* http reply */
AuthHr /* http reply */
};
struct Ticketreq
@ -140,7 +140,7 @@ extern int passtokey(char*, char*);
*/
enum {
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

View file

@ -64,7 +64,7 @@ enum {
Gpart = 0, /* partition info source */
Gdisk,
Gguess,
Gguess
};
/* proto file parsing */

View file

@ -60,7 +60,7 @@ enum
{
Displaybufsize = 8000,
ICOSSCALE = 1024,
Borderwidth = 4,
Borderwidth = 4
};
enum
@ -103,7 +103,7 @@ typedef enum
DatopS = DinS|SoutD,
DxorS = DoutS|SoutD, /* == SxorD */
Ncomp = 12,
Ncomp = 12
} Drawop;
/*
@ -117,7 +117,7 @@ enum {
CAlpha,
CMap,
CIgnore,
NChan,
NChan
};
#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 */
ABGR32 = CHAN4(CAlpha, 8, CBlue, 8, CGreen, 8, CRed, 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);
@ -526,7 +526,7 @@ extern void drawsetdebug(int);
*/
enum
{
SnarfSize = 64*1024,
SnarfSize = 64*1024
};
char *getsnarf(void);
void putsnarf(char*);

View file

@ -10,13 +10,13 @@ typedef struct Menu Menu;
enum
{
Emouse = 1,
Ekeyboard = 2,
Ekeyboard = 2
};
enum
{
MAXSLAVE = 32,
EMAXMSG = 128+8192, /* size of 9p header+data */
EMAXMSG = 128+8192 /* size of 9p header+data */
};
struct Mouse

View file

@ -108,7 +108,7 @@ enum
Tmax,
Topenfd = 98,
Ropenfd,
Ropenfd
};
uint convM2S(uchar*, uint, Fcall*);

View file

@ -22,7 +22,7 @@ enum
FlateInputFail = -2,
FlateOutputFail = -3,
FlateCorrupted = -4,
FlateInternal = -5,
FlateInternal = -5
};
int deflateinit(void);

View file

@ -10,13 +10,13 @@ AUTOLIB(html)
#pragma src "/sys/src/libhtml"
*/
// UTILS
/* UTILS */
extern uchar* fromStr(Rune* 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
{
ApplMsword,
@ -58,14 +58,14 @@ enum
NMEDIATYPES
};
// HTTP methods
/* HTTP methods */
enum
{
HGet,
HPost
};
// Charsets
/* Charsets */
enum
{
UnknownCharset,
@ -76,7 +76,7 @@ enum
NCHARSETS
};
// Frame Target IDs
/* Frame Target IDs */
enum {
FTtop,
FTself,
@ -84,11 +84,11 @@ enum {
FTblank
};
// LEX
/* LEX */
typedef struct Token Token;
typedef struct Attr Attr;
// BUILD
/* BUILD */
typedef struct Item Item;
typedef struct Itext Itext;
@ -119,9 +119,9 @@ typedef struct Docinfo Docinfo;
typedef struct Stack Stack;
typedef struct Pstate Pstate;
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 {
ALnone = 0, ALleft, ALcenter, ALright, ALjustify,
ALchar, ALtop, ALmiddle, ALbottom, ALbaseline
@ -129,16 +129,16 @@ enum {
struct Align
{
uchar halign; // one of ALnone, ALleft, etc.
uchar valign; // one of ALnone, ALtop, etc.
uchar halign; /* one of ALnone, ALleft, etc. */
uchar valign; /* one of ALnone, ALtop, etc. */
};
// A Dimen holds a dimension specification, especially for those
// cases when a number can be followed by a % or a * to indicate
// percentage of total or relative weight.
// Dnone means no dimension was specified
/* A Dimen holds a dimension specification, especially for those */
/* cases when a number can be followed by a % or a * to indicate */
/* percentage of total or relative weight. */
/* 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 {
Dnone = 0,
Dpixels = (1<<29),
@ -150,36 +150,36 @@ enum {
struct Dimen
{
int kindspec; // kind | spec
int kindspec; /* kind | spec */
};
// Background is either an image or a color.
// If both are set, the image has precedence.
/* Background is either an image or a color. */
/* If both are set, the image has precedence. */
struct Background
{
Rune* image; // url
Rune* image; /* url */
int color;
};
// There are about a half dozen Item variants.
// The all look like this at the start (using Plan 9 C's
// anonymous structure member mechanism),
// and then the tag field dictates what extra fields there are.
/* There are about a half dozen Item variants. */
/* The all look like this at the start (using Plan 9 C's */
/* anonymous structure member mechanism), */
/* and then the tag field dictates what extra fields there are. */
struct Item
{
Item* next; // successor in list of items
int width; // width in pixels (0 for floating items)
int height; // height in pixels
Item* next; /* successor in list of items */
int width; /* width in pixels (0 for floating items) */
int height; /* height in pixels */
Rectangle r;
int ascent; // ascent (from top to baseline) in pixels
int anchorid; // if nonzero, which anchor we're in
int state; // flags and values (see below)
Genattr* genattr; // generic attributes and events
int tag; // variant discriminator: Itexttag, etc.
int ascent; /* ascent (from top to baseline) in pixels */
int anchorid; /* if nonzero, which anchor we're in */
int state; /* flags and values (see below) */
Genattr* genattr; /* generic attributes and events */
int tag; /* variant discriminator: Itexttag, etc. */
};
// Item variant tags
/* Item variant tags */
enum {
Itexttag,
Iruletag,
@ -192,45 +192,45 @@ enum {
struct Itext
{
Item item; // (with tag ==Itexttag)
Rune* s; // the characters
int fnt; // style*NumSize+size (see font stuff, below)
int fg; // Pixel (color) for text
uchar voff; // Voffbias+vertical offset from baseline, in pixels (+ve == down)
uchar ul; // ULnone, ULunder, or ULmid
Item item; /* (with tag ==Itexttag) */
Rune* s; /* the characters */
int fnt; /* style*NumSize+size (see font stuff, below) */
int fg; /* Pixel (color) for text */
uchar voff; /* Voffbias+vertical offset from baseline, in pixels (+ve == down) */
uchar ul; /* ULnone, ULunder, or ULmid */
};
struct Irule
{
Item item; // (with tag ==Iruletag)
uchar align; // alignment spec
uchar noshade; // if true, don't shade
int size; // size attr (rule height)
Dimen wspec; // width spec
Item item; /* (with tag ==Iruletag) */
uchar align; /* alignment spec */
uchar noshade; /* if true, don't shade */
int size; /* size attr (rule height) */
Dimen wspec; /* width spec */
};
struct Iimage
{
Item item; // (with tag ==Iimagetag)
Rune* imsrc; // image src url
int imwidth; // spec width (actual, if no spec)
int imheight; // spec height (actual, if no spec)
Rune* altrep; // alternate representation, in absence of image
Map* map; // if non-nil, client side map
int ctlid; // if animated
uchar align; // vertical alignment
uchar hspace; // in pixels; buffer space on each side
uchar vspace; // in pixels; buffer space on top and bottom
uchar border; // in pixels: border width to draw around image
Iimage* nextimage; // next in list of document's images
Item item; /* (with tag ==Iimagetag) */
Rune* imsrc; /* image src url */
int imwidth; /* spec width (actual, if no spec) */
int imheight; /* spec height (actual, if no spec) */
Rune* altrep; /* alternate representation, in absence of image */
Map* map; /* if non-nil, client side map */
int ctlid; /* if animated */
uchar align; /* vertical alignment */
uchar hspace; /* in pixels; buffer space on each side */
uchar vspace; /* in pixels; buffer space on top and bottom */
uchar border; /* in pixels: border width to draw around image */
Iimage* nextimage; /* next in list of document's images */
void *aux;
};
struct Iformfield
{
Item item; // (with tag ==Iformfieldtag)
Item item; /* (with tag ==Iformfieldtag) */
Formfield* formfield;
void *aux;
};
@ -238,59 +238,59 @@ struct Iformfield
struct Itable
{
Item item; // (with tag ==Itabletag)
Item item; /* (with tag ==Itabletag) */
Table* table;
};
struct Ifloat
{
Item _item; // (with tag ==Ifloattag)
Item* item; // table or image item that floats
int x; // x coord of top (from right, if ALright)
int y; // y coord of top
uchar side; // margin it floats to: ALleft or ALright
uchar infloats; // true if this has been added to a lay.floats
Ifloat* nextfloat; // in list of floats
Item _item; /* (with tag ==Ifloattag) */
Item* item; /* table or image item that floats */
int x; /* x coord of top (from right, if ALright) */
int y; /* y coord of top */
uchar side; /* margin it floats to: ALleft or ALright */
uchar infloats; /* true if this has been added to a lay.floats */
Ifloat* nextfloat; /* in list of floats */
};
struct Ispacer
{
Item item; // (with tag ==Ispacertag)
int spkind; // ISPnull, etc.
Item item; /* (with tag ==Ispacertag) */
int spkind; /* ISPnull, etc. */
};
// Item state flags and value fields
/* Item state flags and value fields */
enum {
// IFbrk = 0x80000000, // forced break before this item
/* IFbrk = 0x80000000, // forced break before this item */
#define IFbrk 0x80000000 /* too big for sun */
IFbrksp = 0x40000000, // add 1 line space to break (IFbrk set too)
IFnobrk = 0x20000000, // break not allowed before this item
IFcleft = 0x10000000, // clear left floats (IFbrk set too)
IFcright = 0x08000000, // clear right floats (IFbrk set too)
IFwrap = 0x04000000, // in a wrapping (non-pre) line
IFhang = 0x02000000, // in a hanging (into left indent) item
IFrjust = 0x01000000, // right justify current line
IFcjust = 0x00800000, // center justify current line
IFsmap = 0x00400000, // image is server-side map
IFbrksp = 0x40000000, /* add 1 line space to break (IFbrk set too) */
IFnobrk = 0x20000000, /* break not allowed before this item */
IFcleft = 0x10000000, /* clear left floats (IFbrk set too) */
IFcright = 0x08000000, /* clear right floats (IFbrk set too) */
IFwrap = 0x04000000, /* in a wrapping (non-pre) line */
IFhang = 0x02000000, /* in a hanging (into left indent) item */
IFrjust = 0x01000000, /* right justify current line */
IFcjust = 0x00800000, /* center justify current line */
IFsmap = 0x00400000, /* image is server-side map */
IFindentshift = 8,
IFindentmask = (255<<IFindentshift), // current indent, in tab stops
IFhangmask = 255 // current hang into left indent, in 1/10th tabstops
IFindentmask = (255<<IFindentshift), /* current indent, in tab stops */
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 };
// Spacer kinds
/* Spacer kinds */
enum {
ISPnull, // 0 height and width
ISPvline, // height and ascent of current font
ISPhspace, // width of space in current font
ISPgeneral // other purposes (e.g., between markers and list)
ISPnull, /* 0 height and width */
ISPvline, /* height and ascent of current font */
ISPhspace, /* width of space in current font */
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
{
Rune* id;
@ -302,8 +302,8 @@ struct Genattr
struct SEvent
{
SEvent* next; // in list of events
int type; // SEonblur, etc.
SEvent* next; /* in list of events */
int type; /* SEonblur, etc. */
Rune* script;
};
@ -316,7 +316,7 @@ enum {
Numscriptev
};
// Form field types
/* Form field types */
enum {
Ftext,
Fpassword,
@ -332,24 +332,24 @@ enum {
Ftextarea
};
// Information about a field in a form
/* Information about a field in a form */
struct Formfield
{
Formfield* next; // in list of fields for a form
int ftype; // Ftext, Fpassword, etc.
int fieldid; // serial no. of field within its form
Form* form; // containing form
Rune* name; // name attr
Rune* value; // value attr
int size; // size attr
int maxlength; // maxlength attr
int rows; // rows attr
int cols; // cols attr
uchar flags; // FFchecked, etc.
Option* options; // for Fselect fields
Item* image; // image item, for Fimage fields
int ctlid; // identifies control for this field in layout
SEvent* events; // same as genattr->events of containing item
Formfield* next; /* in list of fields for a form */
int ftype; /* Ftext, Fpassword, etc. */
int fieldid; /* serial no. of field within its form */
Form* form; /* containing form */
Rune* name; /* name attr */
Rune* value; /* value attr */
int size; /* size attr */
int maxlength; /* maxlength attr */
int rows; /* rows attr */
int cols; /* cols attr */
uchar flags; /* FFchecked, etc. */
Option* options; /* for Fselect fields */
Item* image; /* image item, for Fimage fields */
int ctlid; /* identifies control for this field in layout */
SEvent* events; /* same as genattr->events of containing item */
};
enum {
@ -357,29 +357,29 @@ enum {
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
{
Option* next; // next in list of options for a field
int selected; // true if selected initially
Rune* value; // value attr
Rune* display; // display string
Option* next; /* next in list of options for a field */
int selected; /* true if selected initially */
Rune* value; /* value attr */
Rune* display; /* display string */
};
// Form holds info about a form
/* Form holds info about a form */
struct Form
{
Form* next; // in list of forms for document
int formid; // serial no. of form within its doc
Rune* name; // name or id attr (netscape uses name, HTML 4.0 uses id)
Rune* action; // action attr
int target; // target attr as targetid
int method; // HGet or HPost
int nfields; // number of fields
Formfield* fields; // field's forms, in input order
Form* next; /* in list of forms for document */
int formid; /* serial no. of form within its doc */
Rune* name; /* name or id attr (netscape uses name, HTML 4.0 uses id) */
Rune* action; /* action attr */
int target; /* target attr as targetid */
int method; /* HGet or HPost */
int nfields; /* number of fields */
Formfield* fields; /* field's forms, in input order */
};
// Flags used in various table structures
/* Flags used in various table structures */
enum {
TFparsing = (1<<7),
TFnowrap = (1<<6),
@ -387,33 +387,33 @@ enum {
};
// Information about a table
/* Information about a table */
struct Table
{
Table* next; // next in list of document's tables
int tableid; // serial no. of table within its doc
Tablerow* rows; // array of row specs (list during parsing)
int nrow; // total number of rows
Tablecol* cols; // array of column specs
int ncol; // total number of columns
Tablecell* cells; // list of unique cells
int ncell; // total number of cells
Tablecell*** grid; // 2-D array of cells
Align align; // alignment spec for whole table
Dimen width; // width spec for whole table
int border; // border attr
int cellspacing; // cellspacing attr
int cellpadding; // cellpadding attr
Background background; // table background
Item* caption; // linked list of Items, giving caption
uchar caption_place; // ALtop or ALbottom
Lay* caption_lay; // layout of caption
int totw; // total width
int toth; // total height
int caph; // caption height
int availw; // used for previous 3 sizes
Token* tabletok; // token that started the table
uchar flags; // Lchanged, perhaps
Table* next; /* next in list of document's tables */
int tableid; /* serial no. of table within its doc */
Tablerow* rows; /* array of row specs (list during parsing) */
int nrow; /* total number of rows */
Tablecol* cols; /* array of column specs */
int ncol; /* total number of columns */
Tablecell* cells; /* list of unique cells */
int ncell; /* total number of cells */
Tablecell*** grid; /* 2-D array of cells */
Align align; /* alignment spec for whole table */
Dimen width; /* width spec for whole table */
int border; /* border attr */
int cellspacing; /* cellspacing attr */
int cellpadding; /* cellpadding attr */
Background background; /* table background */
Item* caption; /* linked list of Items, giving caption */
uchar caption_place; /* ALtop or ALbottom */
Lay* caption_lay; /* layout of caption */
int totw; /* total width */
int toth; /* total height */
int caph; /* caption height */
int availw; /* used for previous 3 sizes */
Token* tabletok; /* token that started the table */
uchar flags; /* Lchanged, perhaps */
};
@ -427,101 +427,101 @@ struct Tablecol
struct Tablerow
{
Tablerow* next; // Next in list of rows, during parsing
Tablecell* cells; // Cells in row, linked through nextinrow
Tablerow* next; /* Next in list of rows, during parsing */
Tablecell* cells; /* Cells in row, linked through nextinrow */
int height;
int ascent;
Align align;
Background background;
Point pos;
uchar flags; // 0 or TFparsing
uchar flags; /* 0 or TFparsing */
};
// A Tablecell is one cell of a table.
// It may span multiple rows and multiple columns.
// Cells are linked on two lists: the list for all the cells of
// a document (the next pointers), and the list of all the
// cells that start in a given row (the nextinrow pointers)
/* A Tablecell is one cell of a table. */
/* It may span multiple rows and multiple columns. */
/* Cells are linked on two lists: the list for all the cells of */
/* a document (the next pointers), and the list of all the */
/* cells that start in a given row (the nextinrow pointers) */
struct Tablecell
{
Tablecell* next; // next in list of table's cells
Tablecell* nextinrow; // next in list of row's cells
int cellid; // serial no. of cell within table
Item* content; // contents before layout
Lay* lay; // layout of cell
int rowspan; // number of rows spanned by this cell
int colspan; // number of cols spanned by this cell
Align align; // alignment spec
uchar flags; // TFparsing, TFnowrap, TFisth
Dimen wspec; // suggested width
int hspec; // suggested height
Background background; // cell background
int minw; // minimum possible width
int maxw; // maximum width
int ascent; // cell's ascent
int row; // row of upper left corner
int col; // col of upper left corner
Point pos; // nw corner of cell contents, in cell
Tablecell* next; /* next in list of table's cells */
Tablecell* nextinrow; /* next in list of row's cells */
int cellid; /* serial no. of cell within table */
Item* content; /* contents before layout */
Lay* lay; /* layout of cell */
int rowspan; /* number of rows spanned by this cell */
int colspan; /* number of cols spanned by this cell */
Align align; /* alignment spec */
uchar flags; /* TFparsing, TFnowrap, TFisth */
Dimen wspec; /* suggested width */
int hspec; /* suggested height */
Background background; /* cell background */
int minw; /* minimum possible width */
int maxw; /* maximum width */
int ascent; /* cell's ascent */
int row; /* row of upper left corner */
int col; /* col of upper left corner */
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
{
Anchor* next; // next in list of document's anchors
int index; // serial no. of anchor within its doc
Rune* name; // name attr
Rune* href; // href attr
int target; // target attr as targetid
Anchor* next; /* next in list of document's anchors */
int index; /* serial no. of anchor within its doc */
Rune* name; /* name attr */
Rune* href; /* href attr */
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
{
DestAnchor* next; // next in list of document's destanchors
int index; // serial no. of anchor within its doc
Rune* name; // name attr
Item* item; // the destination
DestAnchor* next; /* next in list of document's destanchors */
int index; /* serial no. of anchor within its doc */
Rune* name; /* name attr */
Item* item; /* the destination */
};
// Maps (client side)
/* Maps (client side) */
struct Map
{
Map* next; // next in list of document's maps
Rune* name; // map name
Area* areas; // list of map areas
Map* next; /* next in list of document's maps */
Rune* name; /* map name */
Area* areas; /* list of map areas */
};
struct Area
{
Area* next; // next in list of a map's areas
int shape; // SHrect, etc.
Rune* href; // associated hypertext link
int target; // associated target frame
Dimen* coords; // array of coords for shape
int ncoords; // size of coords array
Area* next; /* next in list of a map's areas */
int shape; /* SHrect, etc. */
Rune* href; /* associated hypertext link */
int target; /* associated target frame */
Dimen* coords; /* array of coords for shape */
int ncoords; /* size of coords array */
};
// Area shapes
/* Area shapes */
enum {
SHrect, SHcircle, SHpoly
};
// Fonts are represented by integers: style*NumSize + size
/* Fonts are represented by integers: style*NumSize + size */
// Font styles
/* Font styles */
enum {
FntR, // roman
FntI, // italic
FntB, // bold
FntT, // typewriter
FntR, /* roman */
FntI, /* italic */
FntB, /* bold */
FntT, /* typewriter */
NumStyle
};
// Font sizes
/* Font sizes */
enum {
Tiny,
Small,
@ -536,12 +536,12 @@ enum {
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 {
ULnone, ULunder, ULmid
};
// Kidinfo flags
/* Kidinfo flags */
enum {
FRnoresize = (1<<0),
FRnoscroll = (1<<1),
@ -551,59 +551,59 @@ enum {
FRvscrollauto = (1<<5)
};
// Information about child frame or frameset
/* Information about child frame or frameset */
struct Kidinfo
{
Kidinfo* next; // in list of kidinfos for a frameset
Kidinfo* next; /* in list of kidinfos for a frameset */
int isframeset;
// fields for "frame"
Rune* src; // only nil if a "dummy" frame or this is frameset
Rune* name; // always non-empty if this isn't frameset
/* fields for "frame" */
Rune* src; /* only nil if a "dummy" frame or this is frameset */
Rune* name; /* always non-empty if this isn't frameset */
int marginw;
int marginh;
int framebd;
int flags;
// fields for "frameset"
Dimen* rows; // array of row dimensions
int nrows; // length of rows
Dimen* cols; // array of col dimensions
int ncols; // length of cols
/* fields for "frameset" */
Dimen* rows; /* array of row dimensions */
int nrows; /* length of rows */
Dimen* cols; /* array of col dimensions */
int ncols; /* length of cols */
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
{
// stuff from HTTP headers, doc head, and body tag
Rune* src; // original source of doc
Rune* base; // base URL of doc
Rune* doctitle; // from <title> element
Background background; // background specification
Iimage* backgrounditem; // Image Item for doc background image, or nil
int text; // doc foreground (text) color
int link; // unvisited hyperlink color
int vlink; // visited hyperlink color
int alink; // highlighting hyperlink color
int target; // target frame default
int chset; // ISO_8859, etc.
int mediatype; // TextHtml, etc.
int scripttype; // TextJavascript, etc.
int hasscripts; // true if scripts used
Rune* refresh; // content of <http-equiv=Refresh ...>
Kidinfo* kidinfo; // if a frameset
int frameid; // id of document frame
/* stuff from HTTP headers, doc head, and body tag */
Rune* src; /* original source of doc */
Rune* base; /* base URL of doc */
Rune* doctitle; /* from <title> element */
Background background; /* background specification */
Iimage* backgrounditem; /* Image Item for doc background image, or nil */
int text; /* doc foreground (text) color */
int link; /* unvisited hyperlink color */
int vlink; /* visited hyperlink color */
int alink; /* highlighting hyperlink color */
int target; /* target frame default */
int chset; /* ISO_8859, etc. */
int mediatype; /* TextHtml, etc. */
int scripttype; /* TextJavascript, etc. */
int hasscripts; /* true if scripts used */
Rune* refresh; /* content of <http-equiv=Refresh ...> */
Kidinfo* kidinfo; /* if a frameset */
int frameid; /* id of document frame */
// info needed to respond to user actions
Anchor* anchors; // list of href anchors
DestAnchor* dests; // list of destination anchors
Form* forms; // list of forms
Table* tables; // list of tables
Map* maps; // list of maps
Iimage* images; // list of image items (through nextimage links)
/* info needed to respond to user actions */
Anchor* anchors; /* list of href anchors */
DestAnchor* dests; /* list of destination anchors */
Form* forms; /* list of forms */
Table* tables; /* list of tables */
Map* maps; /* list of maps */
Iimage* images; /* list of image items (through nextimage links) */
};
extern int dimenkind(Dimen d);
@ -618,14 +618,14 @@ extern int validitems(Item* i);
/* #pragma varargck type "I" Item* */
// Control print output
/* Control print output */
extern int warn;
extern int dbglex;
extern int dbgbuild;
// To be provided by caller
// emalloc and erealloc should not return if can't get memory.
// emalloc should zero its memory.
/* To be provided by caller */
/* emalloc and erealloc should not return if can't get memory. */
/* emalloc should zero its memory. */
extern void* emalloc(ulong);
extern void* erealloc(void* p, ulong size);
#ifdef __cpluspplus

View file

@ -48,7 +48,7 @@ enum
HExpectFail,
HUnkVers,
HBadCont,
HOK,
HOK
};
/*

View file

@ -18,7 +18,7 @@ enum
IPaddrlen= 16,
IPv4addrlen= 4,
IPv4off= 12,
IPllen= 4,
IPllen= 4
};
/*
@ -80,7 +80,7 @@ struct Ipifc
*/
enum
{
Udphdrsize= 52, /* size of a Udphdr */
Udphdrsize= 52 /* size of a Udphdr */
};
typedef struct Udphdr Udphdr;

View file

@ -37,7 +37,7 @@ enum {
Kalt= KF|0x15,
Kshift= KF|0x16,
Kctl= KF|0x17,
Kctl= KF|0x17
};
#if defined(__cplusplus)

View file

@ -349,7 +349,7 @@ extern vlong p9nsec(void);
enum
{
PNPROC = 1,
PNGROUP = 2,
PNGROUP = 2
};
/* extern int abs(int); <stdlib.h> */
@ -671,7 +671,7 @@ enum
RFNOWAIT = (1<<6),
RFCNAMEG = (1<<10),
RFCENVG = (1<<11),
RFCFDG = (1<<12),
RFCFDG = (1<<12)
/* RFREND = (1<<13), */
/* RFNOMNT = (1<<14) */
};

View file

@ -14,9 +14,9 @@ AUTOLIB(sec)
typedef struct mpint mpint;
#endif
/////////////////////////////////////////////////////////
// AES definitions
/////////////////////////////////////////////////////////
/*******************************************************/
/* AES definitions */
/*******************************************************/
enum
{
@ -41,9 +41,9 @@ void setupAESstate(AESstate *s, uchar key[], int keybytes, uchar *ivec);
void aesCBCencrypt(uchar *p, int len, AESstate *s);
void aesCBCdecrypt(uchar *p, int len, AESstate *s);
/////////////////////////////////////////////////////////
// Blowfish Definitions
/////////////////////////////////////////////////////////
/*******************************************************/
/* Blowfish Definitions */
/*******************************************************/
enum
{
@ -51,7 +51,7 @@ enum
BFrounds = 16
};
// 16-round Blowfish
/* 16-round Blowfish */
typedef struct BFstate BFstate;
struct BFstate
{
@ -70,16 +70,16 @@ void bfCBCdecrypt(uchar*, int, BFstate*);
void bfECBencrypt(uchar*, int, BFstate*);
void bfECBdecrypt(uchar*, int, BFstate*);
/////////////////////////////////////////////////////////
// DES definitions
/////////////////////////////////////////////////////////
/*******************************************************/
/* DES definitions */
/*******************************************************/
enum
{
DESbsize= 8
};
// single des
/* single des */
typedef struct DESstate DESstate;
struct DESstate
{
@ -97,12 +97,12 @@ void desCBCdecrypt(uchar*, int, DESstate*);
void desECBencrypt(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 des64to56(uchar *k64, uchar *k56);
void key_setup(uchar[7], ulong[32]);
// triple des encrypt/decrypt orderings
/* triple des encrypt/decrypt orderings */
enum {
DES3E= 0,
DES3D= 1,
@ -128,9 +128,9 @@ void des3CBCdecrypt(uchar*, int, DES3state*);
void des3ECBencrypt(uchar*, int, DES3state*);
void des3ECBdecrypt(uchar*, int, DES3state*);
/////////////////////////////////////////////////////////
// digests
/////////////////////////////////////////////////////////
/*******************************************************/
/* digests */
/*******************************************************/
enum
{
@ -162,27 +162,27 @@ DigestState* hmac_sha1(uchar*, ulong, uchar*, ulong, uchar*, DigestState*);
char* sha1pickle(SHA1state*);
SHA1state* sha1unpickle(char*);
/////////////////////////////////////////////////////////
// random number generation
/////////////////////////////////////////////////////////
/*******************************************************/
/* random number generation */
/*******************************************************/
void genrandom(uchar *buf, int nbytes);
void prng(uchar *buf, int nbytes);
ulong fastrand(void);
ulong nfastrand(ulong);
/////////////////////////////////////////////////////////
// primes
/////////////////////////////////////////////////////////
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 genstrongprime(mpint *p, int n, int accuracy); // generate an n bit strong prime
/*******************************************************/
/* primes */
/*******************************************************/
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 genstrongprime(mpint *p, int n, int accuracy); /* generate an n bit strong prime */
void DSAprimes(mpint *q, mpint *p, uchar seed[SHA1dlen]);
int probably_prime(mpint *n, int nrep); // miller-rabin test
int smallprimetest(mpint *p); // returns -1 if not prime, 0 otherwise
int probably_prime(mpint *n, int nrep); /* miller-rabin test */
int smallprimetest(mpint *p); /* returns -1 if not prime, 0 otherwise */
/////////////////////////////////////////////////////////
// rc4
/////////////////////////////////////////////////////////
/*******************************************************/
/* rc4 */
/*******************************************************/
typedef struct RC4state RC4state;
struct RC4state
{
@ -196,33 +196,33 @@ void rc4(RC4state*, uchar*, int);
void rc4skip(RC4state*, int);
void rc4back(RC4state*, int);
/////////////////////////////////////////////////////////
// rsa
/////////////////////////////////////////////////////////
/*******************************************************/
/* rsa */
/*******************************************************/
typedef struct RSApub RSApub;
typedef struct RSApriv RSApriv;
typedef struct PEMChain PEMChain;
// public/encryption key
/* public/encryption key */
struct RSApub
{
mpint *n; // modulus
mpint *ek; // exp (encryption key)
mpint *n; /* modulus */
mpint *ek; /* exp (encryption key) */
};
// private/decryption key
/* private/decryption key */
struct RSApriv
{
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 *q;
mpint *kp; // dk mod p-1
mpint *kq; // dk mod q-1
mpint *c2; // (inv p) mod q
mpint *kp; /* dk mod p-1 */
mpint *kq; /* dk mod q-1 */
mpint *c2; /* (inv p) mod q */
};
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);
uchar* X509req(RSApriv *priv, char *subj, int *certlen);
/////////////////////////////////////////////////////////
// elgamal
/////////////////////////////////////////////////////////
/*******************************************************/
/* elgamal */
/*******************************************************/
typedef struct EGpub EGpub;
typedef struct EGpriv EGpriv;
typedef struct EGsig EGsig;
// public/encryption key
/* public/encryption key */
struct EGpub
{
mpint *p; // modulus
mpint *alpha; // generator
mpint *key; // (encryption key) alpha**secret mod p
mpint *p; /* modulus */
mpint *alpha; /* generator */
mpint *key; /* (encryption key) alpha**secret mod p */
};
// private/decryption key
/* private/decryption key */
struct EGpriv
{
EGpub pub;
mpint *secret; // (decryption key)
mpint *secret; /* (decryption key) */
};
// signature
/* signature */
struct EGsig
{
mpint *r, *s;
@ -289,30 +289,30 @@ EGsig* egsigalloc(void);
void egsigfree(EGsig*);
EGpub* egprivtopub(EGpriv*);
/////////////////////////////////////////////////////////
// dsa
/////////////////////////////////////////////////////////
/*******************************************************/
/* dsa */
/*******************************************************/
typedef struct DSApub DSApub;
typedef struct DSApriv DSApriv;
typedef struct DSAsig DSAsig;
// public/encryption key
/* public/encryption key */
struct DSApub
{
mpint *p; // modulus
mpint *q; // group order, q divides p-1
mpint *alpha; // group generator
mpint *key; // (encryption key) alpha**secret mod p
mpint *p; /* modulus */
mpint *q; /* group order, q divides p-1 */
mpint *alpha; /* group generator */
mpint *key; /* (encryption key) alpha**secret mod p */
};
// private/decryption key
/* private/decryption key */
struct DSApriv
{
DSApub pub;
mpint *secret; // (decryption key)
mpint *secret; /* (decryption key) */
};
// signature
/* signature */
struct DSAsig
{
mpint *r, *s;
@ -330,33 +330,33 @@ void dsasigfree(DSAsig*);
DSApub* dsaprivtopub(DSApriv*);
DSApriv* asn1toDSApriv(uchar*, int);
/////////////////////////////////////////////////////////
// TLS
/////////////////////////////////////////////////////////
/*******************************************************/
/* TLS */
/*******************************************************/
typedef struct Thumbprint{
struct Thumbprint *next;
uchar sha1[SHA1dlen];
} Thumbprint;
typedef struct TLSconn{
char dir[40]; // connection directory
uchar *cert; // certificate (local on input, remote on output)
char dir[40]; /* connection directory */
uchar *cert; /* certificate (local on input, remote on output) */
uchar *sessionID;
int certlen, sessionIDlen;
int (*trace)(char*fmt, ...);
PEMChain *chain;
} TLSconn;
// tlshand.c
/* tlshand.c */
extern int tlsClient(int fd, TLSconn *c);
extern int tlsServer(int fd, TLSconn *c);
// thumb.c
/* thumb.c */
extern Thumbprint* initThumbprints(char *ok, char *crl);
extern void freeThumbprints(Thumbprint *ok);
extern int okThumbprint(uchar *sha1, Thumbprint *ok);
// readcert.c
/* readcert.c */
extern uchar *readcert(char *filename, int *pcertlen);
PEMChain *readcertchain(char *filename);

View file

@ -154,7 +154,7 @@ enum
LREG, /* register */
LADDR, /* absolute address */
LCONST, /* constant (an anonymous readonly location) */
LOFFSET, /* dereference offset + register ptr */
LOFFSET /* dereference offset + register ptr */
};
struct Loc
@ -357,7 +357,7 @@ enum
RINT = 0<<0,
RFLT = 1<<0,
RRDONLY = 1<<1,
RRDONLY = 1<<1
};
struct Regdesc
@ -456,7 +456,7 @@ enum
CPARAM, /* function parameter */
CTEXT, /* text segment */
CDATA, /* data segment */
CANY,
CANY
};
struct Symbol

View file

@ -33,7 +33,7 @@ enum {
Fgrey = 1<<2, /* is grey */
Falpha = 1<<3, /* has explicit alpha */
Fcmap = 1<<4, /* has cmap channel */
Fbytes = 1<<5, /* has only 8-bit channels */
Fbytes = 1<<5 /* has only 8-bit channels */
};
struct Memimage
@ -94,8 +94,8 @@ enum {
Simplemask=1<<1,
Replsrc=1<<2,
Replmask=1<<3,
Fullsrc = 1<<4,
Fullmask=1<<5,
Fullsrc=1<<4,
Fullmask=1<<5
};
struct Memdrawparam
{

View file

@ -15,17 +15,17 @@ AUTOLIB(mp)
typedef ulong mpdigit;
// the code assumes mpdigit to be at least an int
// mpdigit must be an atomic type. mpdigit is defined
// in the architecture specific u.h
/* the code assumes mpdigit to be at least an int */
/* mpdigit must be an atomic type. mpdigit is defined */
/* in the architecture specific u.h */
typedef struct mpint mpint;
struct mpint
{
int sign; // +1 or -1
int size; // allocated digits
int top; // significant digits
int sign; /* +1 or -1 */
int size; /* allocated digits */
int top; /* significant digits */
mpdigit *p;
char flags;
};
@ -33,117 +33,117 @@ struct mpint
enum
{
MPstatic= 0x01,
Dbytes= sizeof(mpdigit), // bytes per digit
Dbits= Dbytes*8 // bits per digit
Dbytes= sizeof(mpdigit), /* bytes per digit */
Dbits= Dbytes*8 /* bits per digit */
};
// allocation
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
/* allocation */
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 */
void mpfree(mpint *b);
void mpbits(mpint *b, int n); // ensure that b has at least n bits
void mpnorm(mpint *b); // dump leading zeros
void mpbits(mpint *b, int n); /* ensure that b has at least n bits */
void mpnorm(mpint *b); /* dump leading zeros */
mpint* mpcopy(mpint *b);
void mpassign(mpint *old, mpint *new);
// random bits
/* random bits */
mpint* mprand(int bits, void (*gen)(uchar*, int), mpint *b);
// conversion
mpint* strtomp(char*, char**, int, mpint*); // ascii
/* conversion */
mpint* strtomp(char*, char**, int, mpint*); /* ascii */
int mpfmt(Fmt*);
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**);
mpint* betomp(uchar*, uint, mpint*); // byte array, little-endian
mpint* betomp(uchar*, uint, mpint*); /* byte array, little-endian */
int mptobe(mpint*, uchar*, uint, uchar**);
uint mptoui(mpint*); // unsigned int
uint mptoui(mpint*); /* unsigned int */
mpint* uitomp(uint, mpint*);
int mptoi(mpint*); // int
int mptoi(mpint*); /* int */
mpint* itomp(int, mpint*);
uvlong mptouv(mpint*); // unsigned vlong
uvlong mptouv(mpint*); /* unsigned vlong */
mpint* uvtomp(uvlong, mpint*);
vlong mptov(mpint*); // vlong
vlong mptov(mpint*); /* vlong */
mpint* vtomp(vlong, mpint*);
// divide 2 digits by one
/* divide 2 digits by one */
void mpdigdiv(mpdigit *dividend, mpdigit divisor, mpdigit *quotient);
// in the following, the result mpint may be
// the same as one of the inputs.
void mpadd(mpint *b1, mpint *b2, mpint *sum); // sum = 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 mpright(mpint *b, int shift, mpint *res); // res = b>>shift
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 mpmod(mpint *b, mpint *m, mpint *remainder); // remainder = b mod m
/* in the following, the result mpint may be */
/* the same as one of the inputs. */
void mpadd(mpint *b1, mpint *b2, mpint *sum); /* sum = 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 mpright(mpint *b, int shift, mpint *res); /* res = b>>shift */
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 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);
// 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);
// 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);
// res = b**-1 mod m
/* res = b**-1 mod m */
void mpinvert(mpint *b, mpint *m, mpint *res);
// bit counting
int mpsignif(mpint*); // number of sigificant bits in mantissa
int mplowbits0(mpint*); // k, where n = 2**k * q for odd q
/* bit counting */
int mpsignif(mpint*); /* number of sigificant bits in mantissa */
int mplowbits0(mpint*); /* k, where n = 2**k * q for odd q */
// well known constants
/* well known constants */
extern mpint *mpzero, *mpone, *mptwo;
// sum[0:alen] = a[0:alen-1] + b[0:blen-1]
// prereq: alen >= blen, sum has room for alen+1 digits
/* sum[0:alen] = a[0:alen-1] + b[0:blen-1] */
/* prereq: alen >= blen, sum has room for alen+1 digits */
void mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *sum);
// diff[0:alen-1] = a[0:alen-1] - b[0:blen-1]
// prereq: alen >= blen, diff has room for alen digits
/* diff[0:alen-1] = a[0:alen-1] - b[0:blen-1] */
/* prereq: alen >= blen, diff has room for alen digits */
void mpvecsub(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *diff);
// p[0:n] += m * b[0:n-1]
// prereq: p has room for n+1 digits
/* p[0:n] += m * b[0:n-1] */
/* prereq: p has room for n+1 digits */
void mpvecdigmuladd(mpdigit *b, int n, mpdigit m, mpdigit *p);
// p[0:n] -= m * b[0:n-1]
// prereq: p has room for n+1 digits
/* p[0:n] -= m * b[0:n-1] */
/* prereq: p has room for n+1 digits */
int mpvecdigmulsub(mpdigit *b, int n, mpdigit m, mpdigit *p);
// p[0:alen*blen-1] = a[0:alen-1] * b[0:blen-1]
// prereq: alen >= blen, p has room for m*n digits
/* p[0:alen*blen-1] = a[0:alen-1] * b[0:blen-1] */
/* prereq: alen >= blen, p has room for m*n digits */
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);
// 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
/* 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 */
void mpdigdiv(mpdigit *dividend, mpdigit divisor, mpdigit *quotient);
// playing with magnitudes
/* playing with magnitudes */
int mpmagcmp(mpint *b1, mpint *b2);
void mpmagadd(mpint *b1, mpint *b2, mpint *sum); // sum = b1+b2
void mpmagsub(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 */
// chinese remainder theorem
typedef struct CRTpre CRTpre; // precomputed values for converting
// twixt residues and mpint
typedef struct CRTres CRTres; // residue form of an mpint
/* chinese remainder theorem */
typedef struct CRTpre CRTpre; /* precomputed values for converting */
/* twixt residues and mpint */
typedef struct CRTres CRTres; /* residue form of an mpint */
struct CRTres
{
int n; // number of residues
mpint *r[1]; // residues
int n; /* number of residues */
mpint *r[1]; /* residues */
};
CRTpre* crtpre(int, mpint**); // precompute conversion values
CRTres* crtin(CRTpre*, mpint*); // convert mpint to residues
void crtout(CRTpre*, CRTres*, mpint*); // convert residues to mpint
CRTpre* crtpre(int, mpint**); /* precompute conversion values */
CRTres* crtin(CRTpre*, mpint*); /* convert mpint to residues */
void crtout(CRTpre*, CRTres*, mpint*); /* convert residues to mpint */
void crtprefree(CRTpre*);
void crtresfree(CRTres*);

View file

@ -21,7 +21,7 @@ typedef struct Ndbcache Ndbcache;
enum
{
Ndbalen= 32, /* max attribute length */
Ndbvlen= 64, /* max value length */
Ndbvlen= 64 /* max value length */
};
/*

View file

@ -148,7 +148,7 @@ enum {
Nfs3FsCanSetTime = 16,
Nfs3Version = 3,
Nfs3Program = 100003,
Nfs3Program = 100003
};
typedef enum
{
@ -183,7 +183,7 @@ typedef enum
Nfs3ErrBadType = 10007,
Nfs3ErrJukebox = 10008,
Nfs3ErrFprintNotFound = 10009,
Nfs3ErrAborted = 10010,
Nfs3ErrAborted = 10010
} Nfs3Status;
void nfs3errstr(Nfs3Status);
@ -196,14 +196,14 @@ typedef enum
Nfs3FileChar = 4,
Nfs3FileSymlink = 5,
Nfs3FileSocket = 6,
Nfs3FileFifo = 7,
Nfs3FileFifo = 7
} Nfs3FileType;
enum
{
Nfs3ModeSetUid = 0x800,
Nfs3ModeSetGid = 0x400,
Nfs3ModeSticky = 0x200,
Nfs3ModeSticky = 0x200
};
typedef enum
@ -251,7 +251,7 @@ typedef enum
Nfs3CallTPathconf,
Nfs3CallRPathconf,
Nfs3CallTCommit,
Nfs3CallRCommit,
Nfs3CallRCommit
} Nfs3CallType;
typedef struct Nfs3Handle Nfs3Handle;
@ -263,7 +263,7 @@ typedef enum
{
Nfs3SetTimeDont = 0,
Nfs3SetTimeServer = 1,
Nfs3SetTimeClient = 2,
Nfs3SetTimeClient = 2
} Nfs3SetTime;
typedef struct Nfs3SetAttr Nfs3SetAttr;
@ -285,7 +285,7 @@ typedef enum
{
Nfs3SyncNone = 0,
Nfs3SyncData = 1,
Nfs3SyncFile = 2,
Nfs3SyncFile = 2
} Nfs3Sync;
typedef struct Nfs3TWrite Nfs3TWrite;
@ -294,7 +294,7 @@ typedef enum
{
Nfs3CreateUnchecked = 0,
Nfs3CreateGuarded = 1,
Nfs3CreateExclusive = 2,
Nfs3CreateExclusive = 2
} Nfs3Create;
typedef struct Nfs3TCreate Nfs3TCreate;

View file

@ -21,7 +21,7 @@ enum
SunAuthNone = 0,
SunAuthSys,
SunAuthShort,
SunAuthDes,
SunAuthDes
};
typedef enum {
@ -46,7 +46,7 @@ typedef enum {
SunAuthRejectedVerf,
SunAuthTooWeak,
SunAuthInvalidResp,
SunAuthFailed,
SunAuthFailed
} SunStatus;
struct SunAuthInfo
@ -78,7 +78,7 @@ struct SunRpc
u32int proc;
/* call */
// uint proc;
/* uint proc; */
u32int prog, vers;
SunAuthInfo cred;
SunAuthInfo verf;
@ -87,16 +87,16 @@ struct SunRpc
/* reply */
u32int status;
// SunAuthInfo verf;
/* SunAuthInfo verf; */
u32int low, high;
// uchar *data;
// uint ndata;
/* uchar *data; */
/* uint ndata; */
};
typedef enum
{
SunCallTypeTNull,
SunCallTypeRNull,
SunCallTypeRNull
} SunCallType;
struct SunCall
@ -191,7 +191,7 @@ typedef struct SunSrv SunSrv;
enum
{
SunStackSize = 32768,
SunStackSize = 32768
};
struct SunMsg
@ -316,7 +316,7 @@ typedef enum
PortCallTDump,
PortCallRDump,
PortCallTCallit,
PortCallRCallit,
PortCallRCallit
} PortCallType;
enum

View file

@ -71,7 +71,7 @@ enum
CHANSND,
CHANRCV,
CHANNOP,
CHANNOBLK,
CHANNOBLK
};
struct Alt

View file

@ -11,7 +11,7 @@ enum
UTFmax = 3, /* maximum bytes per rune */
Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
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 __ */

View file

@ -17,7 +17,7 @@ AUTOLIB(venti)
*/
enum
{
MaxFragSize = 9*1024,
MaxFragSize = 9*1024
};
typedef struct Packet Packet;
@ -91,7 +91,7 @@ enum
VtScoreSize = 20,
VtMaxStringSize = 1024,
VtMaxLumpSize = 56*1024,
VtPointerDepth = 7,
VtPointerDepth = 7
};
#define VtMaxFileSize ((1ULL<<48)-1)
@ -120,7 +120,7 @@ enum
VtCorruptType = 0xFF,
VtTypeDepthMask = 7,
VtTypeBaseMask = ~VtTypeDepthMask,
VtTypeBaseMask = ~VtTypeDepthMask
};
/* convert to/from on-disk type numbers */
@ -141,11 +141,11 @@ enum
_VtEntryDir = 1<<1, /* a directory */
_VtEntryDepthShift = 2, /* shift 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
{
VtEntrySize = 40,
VtEntrySize = 40
};
struct VtEntry
{
@ -173,7 +173,7 @@ struct VtRoot
enum
{
VtRootSize = 300,
VtRootVersion = 2,
VtRootVersion = 2
};
void vtrootpack(VtRoot*, uchar*);
@ -231,7 +231,7 @@ enum
VtCryptoStrengthNone,
VtCryptoStrengthAuth,
VtCryptoStrengthWeak,
VtCryptoStrengthStrong,
VtCryptoStrengthStrong
};
/*
@ -242,7 +242,7 @@ enum
VtCryptoNone,
VtCryptoSSL3,
VtCryptoTLS1,
VtCryptoMax,
VtCryptoMax
};
/*
@ -313,7 +313,7 @@ enum
{
VtStateAlloc,
VtStateConnected,
VtStateClosed,
VtStateClosed
};
struct VtConn
@ -387,7 +387,7 @@ int vtping(VtConn*);
*/
enum
{
NilBlock = ~0,
NilBlock = ~0
};
typedef struct VtBlock VtBlock;
@ -459,7 +459,7 @@ enum
{
VtOREAD,
VtOWRITE,
VtORDWR,
VtORDWR
};
VtFile *vtfileopenroot(VtCache*, VtEntry*);

View file

@ -14,7 +14,7 @@
[^!@.]+ translate "$PLAN9/bin/upas/aliasmail '&'"
# 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...
@([^@!,]*):([^!@]*)@([^!]*) alias \2@\3@\1
@ -24,5 +24,8 @@ local!(.*) alias \1@YOURDOMAIN.DOM
([^@]+)@([^@]+)@(.+) alias \2!\1@\3
([^@]+)@([^@]+) 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
([^!]*)!(.*) | "$PLAN9/mail/lib/qmail '\s' 'YOURGATEWAY.DOM'" "'\2@\1'"
([^!]*)!(.*) | "$PLAN9/mail/lib/qmail '\s' 'holo.morphisms.net'" "'\2@\1'"

View file

@ -251,7 +251,7 @@ parsedir(Cdimg *cd, Direc *d, uchar *buf, int len, char *(*cvtname)(uchar*, int)
d->mode = little(p, 4);
}
// BUG: rock ridge extensions
/* BUG: rock ridge extensions */
return 0;
}
@ -604,7 +604,7 @@ Cgetc(Cdimg *cd)
if((c = Bgetc(&cd->brd)) == Beof) {
fprint(2, "getc at %lud\n", Croffset(cd));
assert(0);
//sysfatal("Bgetc: %r");
/*sysfatal("Bgetc: %r"); */
}
return c;
}

View file

@ -203,16 +203,16 @@ main(int argc, char **argv)
} else
convertnames(&iroot, (char* (*)(char*, char*))strcpy);
// isoabstract = findconform(&iroot, abstract);
// isobiblio = findconform(&iroot, biblio);
// isonotice = findconform(&iroot, notice);
/* isoabstract = findconform(&iroot, abstract); */
/* isobiblio = findconform(&iroot, biblio); */
/* isonotice = findconform(&iroot, notice); */
dsort(&iroot, isocmp);
if(cd->flags & CDjoliet) {
// jabstract = findconform(&jroot, abstract);
// jbiblio = findconform(&jroot, biblio);
// jnotice = findconform(&jroot, notice);
/* jabstract = findconform(&jroot, abstract); */
/* jbiblio = findconform(&jroot, biblio); */
/* jnotice = findconform(&jroot, notice); */
checknames(&jroot, isbadjoliet);
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))) {
direc->srcfile = atom(old);
// BUG: abstract, biblio, notice
/* BUG: abstract, biblio, notice */
}
if(name)
free(name);

View file

@ -65,7 +65,7 @@ struct Direc {
int nchild;
};
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,
CDnew = 1<<4,
CDdump = 1<<5,
CDbootable = 1<<6,
CDbootable = 1<<6
};
typedef struct Tx Tx;
@ -159,7 +159,7 @@ struct Cdinfo {
};
enum {
Blocklen = 2048,
Blocklen = 2048
};
/*
@ -265,7 +265,7 @@ enum { /* Rockridge flags */
RR_CL = 1<<4,
RR_PL = 1<<5,
RR_RE = 1<<6,
RR_TF = 1<<7,
RR_TF = 1<<7
};
enum { /* CputrripTF type argument */
@ -276,7 +276,7 @@ enum { /* CputrripTF type argument */
TFbackup = 1<<4,
TFexpiration = 1<<5,
TFeffective = 1<<6,
TFlongform = 1<<7,
TFlongform = 1<<7
};
enum { /* CputrripNM flag types */
@ -285,7 +285,7 @@ enum { /* CputrripNM flag types */
NMparent = 1<<2,
NMroot = 1<<3,
NMvolroot = 1<<4,
NMhost = 1<<5,
NMhost = 1<<5
};
/* boot.c */
@ -414,7 +414,7 @@ enum {
DTdotdot,
DTiden,
DTroot,
DTrootdot,
DTrootdot
};
extern ulong now;

View file

@ -19,7 +19,7 @@ static ulong CputsuspCE(Cdimg *cd, ulong offset);
static int CputsuspER(Cdimg*, int);
static int CputsuspRR(Cdimg*, int, 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 CputrripSL(Cdimg*, int, int, char*, int);
static int CputrripPX(Cdimg*, Direc*, int, int);
@ -524,12 +524,12 @@ CputrripTF(Cdimg *cd, Direc *d, int type, int dowrite)
if (type & TFattributes)
Cputdate(cd, d?d->ctime:0);
// if (type & TFbackup)
// Cputdate(cd, 0);
// if (type & TFexpiration)
// Cputdate(cd, 0);
// if (type & TFeffective)
// Cputdate(cd, 0);
/* if (type & TFbackup) */
/* Cputdate(cd, 0); */
/* if (type & TFexpiration) */
/* Cputdate(cd, 0); */
/* if (type & TFeffective) */
/* Cputdate(cd, 0); */
}
return 5+7*length;
}

View file

@ -23,7 +23,7 @@ static long numericgid(char *gp);
void
dirtoxdir(XDir *xd, Dir *d)
{
// char buf[NAMELEN+1];
/* char buf[NAMELEN+1]; */
memset(xd, 0, sizeof *xd);
xd->name = atom(d->name);
@ -38,8 +38,8 @@ dirtoxdir(XDir *xd, Dir *d)
xd->length = d->length;
if(xd->mode & CHLINK) {
xd->mode |= 0777;
//xd->symlink = atom(d->symlink);
xd->symlink = atom("symlink"); // XXX: rsc
/*xd->symlink = atom(d->symlink); */
xd->symlink = atom("symlink"); /* XXX: rsc */
}
}

View file

@ -8,7 +8,7 @@ enum
{
STACK = 32768,
NHASH = 31,
MAXMSG = 64, /* per connection */
MAXMSG = 64 /* per connection */
};
typedef struct Hash Hash;
@ -240,8 +240,8 @@ mainproc(void *v)
threadcreate(inputthread, nil, STACK);
threadcreate(outputthread, nil, STACK);
// if(rootfid)
// dorootstat();
/* if(rootfid) */
/* dorootstat(); */
threadcreate(listenthread, nil, STACK);
threadexits(0);
@ -618,14 +618,14 @@ openfdthread(void *v)
sendomsg(m);
recvp(c->internal);
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;
}
if(m->rx.count == 0)
break;
tot += 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;
}
msgput(m);
@ -658,7 +658,7 @@ openfdthread(void *v)
sendomsg(m);
recvp(c->internal);
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;
msgput(m);
@ -907,7 +907,7 @@ inputthread(void *arg)
msgput(m);
}
closeioproc(io);
//fprint(2, "%T input eof\n");
/*fprint(2, "%T input eof\n"); */
threadexitsall(0);
}

View file

@ -248,7 +248,7 @@ new(Image *i, int hideit, int scrollit, int pid, char *dir, char *cmd, char **ar
error("new: channel alloc failed");
mc = emalloc(sizeof(Mousectl));
*mc = *mousectl;
// mc->image = i;
/* mc->image = i; */
mc->c = cm;
w = wmk(i, mc, ck, cctl, scrollit);
free(mc); /* wmk copies *mc */
@ -282,7 +282,7 @@ enum
Plumb,
Send,
Scroll,
Cook,
Cook
};
char *menu2str[] = {

View file

@ -24,13 +24,13 @@ enum
Scrollgap = 4, /* gap right of scroll bar */
BIG = 3, /* factor by which window dimension can exceed screen */
TRUE = 1,
FALSE = 0,
FALSE = 0
};
enum
{
Kscrolloneup = KF|0x20,
Kscrollonedown = KF|0x21,
Kscrollonedown = KF|0x21
};
enum /* control messages */
@ -45,7 +45,7 @@ enum /* control messages */
Holdon,
Holdoff,
Deleted,
Exited,
Exited
};
struct Wctlmesg

View file

@ -169,7 +169,7 @@ Cursor l = {
Cursor *corners[9] = {
&tl, &t, &tr,
&l, nil, &r,
&bl, &b, &br,
&bl, &b, &br
};
void

View file

@ -31,7 +31,7 @@ Event blank = {
'X',
0, 0, 0, 1, 1,
{ ' ', 0 },
{ ' ', 0 },
{ ' ', 0 }
};
struct Q
@ -47,7 +47,7 @@ CFid *eventfd;
CFid *addrfd;
CFid *datafd;
CFid *ctlfd;
// int bodyfd;
/* int bodyfd; */
char *typing;
int ntypeb;

View file

@ -19,7 +19,7 @@ enum
{
HiWater = 640000, /* max size of history */
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;
@ -121,8 +121,8 @@ fprint(2, "res %p %p\n", w->i, i);
freeimage(w->i);
w->i = i;
}
// wsetname(w);
//XXX w->mc.image = i;
/* wsetname(w); */
/*XXX w->mc.image = i; */
r = insetrect(i->r, Selborder+1);
w->scrollr = r;
w->scrollr.max.x = r.min.x+Scrollwid;
@ -276,9 +276,9 @@ winctl(void *arg)
case WKey:
for(i=0; kbdr[i]!=L'\0'; i++)
wkeyctl(w, kbdr[i]);
// wkeyctl(w, r);
// while(nbrecv(w->ck, &r))
// wkeyctl(w, r);
/* wkeyctl(w, r); */
/* while(nbrecv(w->ck, &r)) */
/* wkeyctl(w, r); */
break;
case WMouse:
if(w->mouseopen) {
@ -307,9 +307,10 @@ winctl(void *arg)
m = w->mouse.queue[w->mouse.ri];
if(++w->mouse.ri == nelem(w->mouse.queue))
w->mouse.ri = 0;
} else
m = (Mousestate){w->mc.m, w->mouse.counter};
} else {
m.m = w->mc.m;
m.counter = w->mouse.counter;
}
w->mouse.lastcounter = m.counter;
send(mrm.cm, &m.m);
continue;
@ -393,13 +394,13 @@ winctl(void *arg)
c = t[i]; /* knows break characters fit in a byte */
i += wid;
if(!w->rawing && (c == '\n' || c=='\004')){
// if(c == '\004')
// i--;
/* if(c == '\004') */
/* i--; */
break;
}
}
// if(i==nb && w->qh<w->nr && w->r[w->qh]=='\004')
// w->qh++;
/* if(i==nb && w->qh<w->nr && w->r[w->qh]=='\004') */
/* w->qh++; */
if(i > nb){
npart = i-nb;
memmove(part, t+nb, npart);

View file

@ -10,7 +10,7 @@ enum
NFD = 100,
Maxproc = 50,
Maxval = 10,
Mempergc = 1024*1024,
Mempergc = 1024*1024
};
/* #pragma varargck type "L" void */
@ -81,7 +81,7 @@ enum
TCODE,
TREG,
TCON,
NUMT,
NUMT
};
struct Type
@ -327,5 +327,5 @@ enum
OEVAL,
OWHAT,
OUPLUS,
NUMO,
NUMO
};

View file

@ -38,7 +38,7 @@ char *typenames[] = {
"float",
"string",
"list",
"code",
"code"
};
void

View file

@ -202,7 +202,7 @@ deinstall(int pid)
for(i = 0; i < Maxproc; i++) {
if(ptab[i].pid == pid) {
detachproc(pid);
// close(ptab[i].ctl);
/* close(ptab[i].ctl); */
ptab[i].pid = 0;
s = look("proclist");
d = &s->v->store.u.l;

View file

@ -14,7 +14,7 @@ enum
Array,
Range,
Defer,
Typedef,
Typedef
};
struct Type

View file

@ -67,7 +67,7 @@ main(int argc, char **argv)
if(!have){
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);
}

View file

@ -235,7 +235,7 @@ struct {
"XER", "$XER",
"CTR", "$CTR",
"VRSAVE", "$VRSAVE",
"FPSCR", "$FPSCR",
"FPSCR", "$FPSCR"
};
char*
@ -469,7 +469,7 @@ nameof(Type *t, int doanon)
}
static char
basecharof(Type *t) //XXX
basecharof(Type *t) /*XXX */
{
switch(t->xsizeof){
default:

View file

@ -37,7 +37,7 @@ Rune snarfrune[NSnarf+1];
char *fontnames[2] =
{
"/lib/font/bit/lucsans/euro.8.font",
"/lib/font/bit/lucm/unicode.9.font",
"/lib/font/bit/lucm/unicode.9.font"
};
Command *command;
@ -160,7 +160,7 @@ threadmain(int argc, char *argv[])
d = display;
font = d->defaultfont;
//assert(font);
/*assert(font); */
reffont.f = font;
reffonts[0] = &reffont;
@ -355,8 +355,8 @@ killprocs(void)
Command *c;
fsysclose();
// if(display)
// flushimage(display, 1);
/* if(display) */
/* flushimage(display, 1); */
for(c=command; c; c=c->next)
postnote(PNGROUP, c->pid, "hangup");

View file

@ -15,13 +15,13 @@ enum
{
None = 0,
Fore = '+',
Back = '-',
Back = '-'
};
enum
{
Char,
Line,
Line
};
int

View file

@ -13,7 +13,7 @@
enum
{
Slop = 100, /* room to grow with reallocation */
Slop = 100 /* room to grow with reallocation */
};
static

View file

@ -21,7 +21,7 @@ enum
QWwrsel,
QWtag,
QWxdata,
QMAX,
QMAX
};
enum
@ -29,7 +29,7 @@ enum
Blockincr = 256,
Maxblock = 8*1024,
NRange = 10,
Infinity = 0x7FFFFFFF, /* huge value for regexp address */
Infinity = 0x7FFFFFFF /* huge value for regexp address */
};
#define Buffer AcmeBuffer
@ -166,7 +166,7 @@ enum /* Text.what */
Columntag,
Rowtag,
Tag,
Body,
Body
};
struct Text
@ -463,7 +463,7 @@ enum
Scrollwid = 12, /* width of scroll bar */
Scrollgap = 4, /* gap right of scroll bar */
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))
@ -477,7 +477,7 @@ enum
{
FALSE,
TRUE,
XXX,
XXX
};
enum
@ -487,14 +487,14 @@ enum
Delete = 'd',
Insert = 'i',
Replace = 'r',
Filename = 'f',
Filename = 'f'
};
enum /* editing */
{
Inactive = 0,
Inserting,
Collecting,
Collecting
};
uint globalincref;
@ -545,7 +545,7 @@ int dodollarsigns;
enum
{
Kscrolloneup = KF|0x20,
Kscrollonedown = KF|0x21,
Kscrollonedown = KF|0x21
};
Channel *cplumb; /* chan(Plumbmsg*) */

View file

@ -898,14 +898,14 @@ alllooper(Window *w, void *v)
lp = v;
cp = lp->cp;
// if(w->isscratch || w->isdir)
// return;
/* if(w->isscratch || w->isdir) */
/* return; */
t = &w->body;
/* only use this window if it's the current window for the file */
if(t->file->curtext != t)
return;
// if(w->nopen[QWevent] > 0)
// return;
/* if(w->nopen[QWevent] > 0) */
/* return; */
/* no auto-execute on files without names */
if(cp->re==nil && t->file->nname==0)
return;
@ -1012,7 +1012,7 @@ cmdaddress(Addr *ap, Address a, int sign)
case '\'':
editerror("can't handle '");
// a.r = f->mark;
/* a.r = f->mark; */
break;
case '?':
@ -1093,8 +1093,8 @@ alltofile(Window *w, void *v)
/* only use this window if it's the current window for the file */
if(t->file->curtext != t)
return;
// if(w->nopen[QWevent] > 0)
// return;
/* if(w->nopen[QWevent] > 0) */
/* return; */
if(runeeq(tp->r->r, tp->r->n, t->file->name, t->file->nname))
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 */
if(t->file->curtext != t)
return;
// if(w->nopen[QWevent] > 0)
// return;
/* if(w->nopen[QWevent] > 0) */
/* return; */
if(filematch(w->body.file, tp->r)){
if(tp->f != nil)
editerror("too many files match \"%S\"", tp->r->r);

View file

@ -49,7 +49,7 @@ struct cmdtab cmdtab[]={
'q', 0, 0, 0, 0, aNo, 0, 0, q_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);
@ -82,8 +82,8 @@ editthread(void *v)
USED(v);
threadsetname("editthread");
while((cmdp=parsecmd(0)) != 0){
// ocurfile = curfile;
// loaded = curfile && !curfile->unread;
/* ocurfile = curfile; */
/* loaded = curfile && !curfile->unread; */
if(cmdexec(curtext, cmdp) == 0)
break;
freecmd();

View file

@ -76,7 +76,7 @@ struct List /* code depends on a long being able to hold a pointer */
enum Defaddr{ /* default addresses */
aNo,
aDot,
aAll,
aAll
};
int nl_cmd(Text*, Cmd*), a_cmd(Text*, Cmd*), b_cmd(Text*, Cmd*);

View file

@ -36,7 +36,7 @@ struct Buflog
enum
{
Buflogsize = sizeof(Buflog)/sizeof(Rune),
Buflogsize = sizeof(Buflog)/sizeof(Rune)
};
/*
@ -46,7 +46,7 @@ enum
enum
{
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

View file

@ -108,7 +108,7 @@ Exectab exectab[] = {
{ LTab, tab, FALSE, XXX, XXX },
{ LUndo, undo, FALSE, TRUE, XXX },
{ LZerox, zeroxx, FALSE, XXX, XXX },
{ nil, 0, 0, 0, 0 },
{ nil, 0, 0, 0, 0 }
};
Exectab*
@ -1198,7 +1198,7 @@ enum {
IGlobal = -2,
IError = -1,
Ion = 0,
Ioff = 1,
Ioff = 1
};
static int
@ -1318,7 +1318,7 @@ runproc(void *argvp)
char buf[512];
int olddir;
int ret;
//static void *parg[2];
/*static void *parg[2]; */
char *rcarg[4];
void **argv;
CFsys *fs;

View file

@ -33,7 +33,7 @@ struct Undo
enum
{
Undosize = sizeof(Undo)/sizeof(Rune),
Undosize = sizeof(Undo)/sizeof(Rune)
};
File*

View file

@ -467,8 +467,10 @@ fsyswalk(Xfid *x, Fid *f)
goto Accept;
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(w)
error("w set in walk to new");

View file

@ -7,7 +7,7 @@ enum
{
STACK = 8192,
EVENTSIZE = 256,
NEVENT = 5,
NEVENT = 5
};
struct Event

View file

@ -42,7 +42,7 @@ char *goodtypes[] = {
"text/richtext",
"text/tab-separated-values",
"application/octet-stream",
nil,
nil
};
char *okheaders[] =
@ -60,7 +60,7 @@ char *extraheaders[] =
"Resent-From:",
"Resent-To:",
"Sort:",
nil,
nil
};
char*
@ -100,10 +100,10 @@ mkaddrs(char *t)
for(i=0; i+1<nf; i+=2){
if(i > 0)
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]);
// else
// fmtprint(&fmt, "%s <%s>", f[i], f[i+1]);
/* else */
/* fmtprint(&fmt, "%s <%s>", f[i], f[i+1]); */
}
free(f);
return fmtstrflush(&fmt);
@ -752,10 +752,10 @@ mesgcommand(Message *m, char *cmd)
mesgmenumarkundel(wbox, &mbox, m);
goto Return;
}
// if(strcmp(args[0], "Headers") == 0){
// m->showheaders();
// return True;
// }
/* if(strcmp(args[0], "Headers") == 0){ */
/* m->showheaders(); */
/* return True; */
/* } */
ret = 0;
@ -1149,8 +1149,8 @@ tokenizec(char *str, char **args, int max, char *splitc)
if(max <= 0)
return 0;
// if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '('))
// splitc = ",";
/* if(strchr(str, ',') || strchr(str, '"') || strchr(str, '<') || strchr(str, '(')) */
/* splitc = ","; */
for(na=0; *str != '\0';str++){
if(strchr(splitc, *str) == nil){
if(intok)
@ -1331,7 +1331,7 @@ mesgopen(Message *mbox, char *dir, char *s, Message *mesg, int plumbed, char *di
winopenbody(m->w, OWRITE);
mesgload(m, dir, m->name, m->w);
winclosebody(m->w);
// sleep(100);
/* sleep(100); */
winclean(m->w);
m->opened = 1;
if(ndirelem == 1){
@ -1405,7 +1405,7 @@ mesglookupfile(Message *mbox, char *name, char *digest)
k = strlen(name);
n = strlen(mbox->name);
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 mesglookup(mbox, name+n, digest);

View file

@ -240,7 +240,7 @@ enum{
CC,
FROM,
INCLUDE,
TO,
TO
};
char *headers[] = {
@ -250,7 +250,7 @@ char *headers[] = {
"from:",
"include:",
"to:",
nil,
nil
};
int
@ -516,7 +516,7 @@ mesgsend(Message *m)
e->sync = sync;
proccreate(execproc, e, EXECSTACK);
recvul(sync);
// close(p[0]);
/* close(p[0]); */
/* using marshal -8, so generate rfc822 headers */
if(nto > 0){

View file

@ -74,7 +74,7 @@ textscrdraw(Text *t)
r2.min.x = r2.max.x-1;
draw(b, r2, t->fr.cols[BORD], nil, ZP);
draw(t->fr.b, r, b, nil, Pt(0, r1.min.y));
/*flushimage(display, 1);*//*BUG?*/
/*flushimage(display, 1); // BUG? */
}
}

View file

@ -1174,7 +1174,7 @@ textsetselect(Text *t, uint q0, uint q1)
*/
enum {
DELAY = 2,
MINMOVE = 4,
MINMOVE = 4
};
uint

View file

@ -53,7 +53,7 @@ wininit(Window *w, Window *clone, Rectangle r)
filereset(w->tag.file);
textsetselect(&w->tag, nc, nc);
}
//assert(w->body.w == w);
/*assert(w->body.w == w); */
r1 = r;
r1.min.y += w->taglines*font->height + 1;
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);
}else
rf = rfget(FALSE, FALSE, FALSE, nil);
//assert(w->body.w == w);
/*assert(w->body.w == w); */
f = fileaddtext(f, &w->body);
w->body.what = Body;
textinit(&w->body, f, r1, rf, textcols);
@ -82,7 +82,7 @@ wininit(Window *w, Window *clone, Rectangle r)
w->filemenu = TRUE;
w->maxlines = w->body.fr.maxlines;
w->autoindent = globalautoindent;
//assert(w->body.w == w);
/*assert(w->body.w == w); */
if(clone){
w->dirty = clone->dirty;
w->autoindent = clone->autoindent;

View file

@ -1,8 +1,10 @@
#include <u.h>
#include <libc.h>
//#pragma varargck type "R" double
//#pragma varargck type "D" double
#ifdef VARARGCK
#pragma varargck type "R" double
#pragma varargck type "D" double
#endif
typedef struct Obj1 Obj1;
typedef struct Obj2 Obj2;
@ -20,7 +22,7 @@ enum
DARK = 1<<0,
SIGNIF = 1<<1,
PTIME = 1<<2,
LIGHT = 1<<3,
LIGHT = 1<<3
};
struct Obj1
@ -150,7 +152,7 @@ extern double cosx(double, int, int, int, int, double);
extern double dist(Obj1*, Obj1*);
extern double dsrc(double, Tim*, int);
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 evflush(void);
extern double fmod(double, double);

View file

@ -14,7 +14,7 @@ Obj2* objlst[] =
&onept,
&oplut,
&ocomet,
0,
0
};
struct idata
@ -35,7 +35,7 @@ struct idata
"Uranus", "uranus", uran,
"Neptune", "neptune", nept,
"Pluto", "pluto", plut,
"Comet", "comet", comet,
"Comet", "comet", comet
};
void

View file

@ -52,12 +52,12 @@ loop:
d = dist(&eobj1->point[i], &eobj2->point[i]);
print("dist %s to %s = %.4f\n", eobj1->name, eobj2->name, d);
}
// if(flags['p']) {
// pdate(d);
// print(" ");
// ptime(d);
// print("\n");
// }
/* if(flags['p']) { */
/* pdate(d); */
/* print(" "); */
/* ptime(d); */
/* print("\n"); */
/* } */
if(flags['p'] || flags['e'])
break;
d += deld;
@ -151,8 +151,8 @@ args(int argc, char *argv[])
if(flags['j'])
print("jday = %.4f\n", day);
deltat = day * .001704;
if(deltat > 32.184) // assume date is utc1
deltat = 32.184; // correct by leap sec
if(deltat > 32.184) /* assume date is utc1 */
deltat = 32.184; /* correct by leap sec */
if(flags['t'])
deltat = readdt();

View file

@ -168,7 +168,7 @@ double mercfp[] =
0.160e-6, 2.1241,
0.134e-6, 5.1260,
0.347e-6, 5.1620,
0,
0
};
char merccp[] =
@ -332,5 +332,5 @@ char merccp[] =
0, 2,
-1, 2,
2, 3,
1, 3,
1, 3
};

View file

@ -286,5 +286,5 @@ Moontab moontab[] =
-.0130, 4,0,0,-2,
0.0115, 3,-1,0,0,
-.0141, 2,0,-2,-2,
0, 0,0,0,0,
0, 0,0,0,0
};

View file

@ -2,21 +2,21 @@
static double elem[] =
{
36525.0, // [0] eday of epoc
36525.0, /* [0] eday of epoc */
30.06896348, // [1] semi major axis (au)
0.00858587, // [2] eccentricity
1.76917, // [3] inclination (deg)
131.72169, // [4] longitude of the ascending node (deg)
44.97135, // [5] longitude of perihelion (deg)
304.88003, // [6] mean longitude (deg)
30.06896348, /* [1] semi major axis (au) */
0.00858587, /* [2] eccentricity */
1.76917, /* [3] inclination (deg) */
131.72169, /* [4] longitude of the ascending node (deg) */
44.97135, /* [5] longitude of perihelion (deg) */
304.88003, /* [6] mean longitude (deg) */
-0.00125196, // [1+6] (au/julian century)
0.0000251, // [2+6] (e/julian century)
-3.64, // [3+6] (arcsec/julian century)
-151.25, // [4+6] (arcsec/julian century)
-844.43, // [5+6] (arcsec/julian century)
786449.21, // [6+6] (arcsec/julian century)
-0.00125196, /* [1+6] (au/julian century) */
0.0000251, /* [2+6] (e/julian century) */
-3.64, /* [3+6] (arcsec/julian century) */
-151.25, /* [4+6] (arcsec/julian century) */
-844.43, /* [5+6] (arcsec/julian century) */
786449.21, /* [6+6] (arcsec/julian century) */
};
void
@ -32,12 +32,12 @@ nept(void)
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;
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;
node = elem[4] + elem[4+6]*cy;
argp = elem[5] + elem[5+6]*cy;

View file

@ -34,7 +34,7 @@ double nutfp[] =
.0183, 0,
.0113, 0,
-.0050, 0,
0,
0
};
char nutcp[] =
@ -67,5 +67,5 @@ char nutcp[] =
2,2,0,
1,2,0,
2,2,1,
2,2,-1,
2,2,-1
};

View file

@ -14,7 +14,7 @@ char* month[] =
"September",
"October",
"November",
"December",
"December"
};
double
@ -163,13 +163,13 @@ pstime(double d)
lambda = 0;
beta = 0;
// uses lambda, beta, rad, motion
// sets alpha, delta, rp
/* uses lambda, beta, rad, motion */
/* sets alpha, delta, rp */
helio();
// uses alpha, delta, rp
// sets ra, decl, lha, decl2, az, el
/* uses alpha, delta, rp */
/* sets ra, decl, lha, decl2, az, el */
geo();

View file

@ -2,21 +2,21 @@
static double elem[] =
{
36525.0, // [0] eday of epoc
36525.0, /* [0] eday of epoc */
39.48168677, // [1] semi major axis (au)
0.24880766, // [2] eccentricity
17.14175, // [3] inclination (deg)
110.30347, // [4] longitude of the ascending node (deg)
224.06676, // [5] longitude of perihelion (deg)
238.92881, // [6] mean longitude (deg)
39.48168677, /* [1] semi major axis (au) */
0.24880766, /* [2] eccentricity */
17.14175, /* [3] inclination (deg) */
110.30347, /* [4] longitude of the ascending node (deg) */
224.06676, /* [5] longitude of perihelion (deg) */
238.92881, /* [6] mean longitude (deg) */
-0.00076912, // [1+6] (au/julian century)
0.00006465, // [2+6] (e/julian century)
11.07, // [3+6] (arcsec/julian century)
-37.33, // [4+6] (arcsec/julian century)
-132.25, // [5+6] (arcsec/julian century)
522747.90, // [6+6] (arcsec/julian century)
-0.00076912, /* [1+6] (au/julian century) */
0.00006465, /* [2+6] (e/julian century) */
11.07, /* [3+6] (arcsec/julian century) */
-37.33, /* [4+6] (arcsec/julian century) */
-132.25, /* [5+6] (arcsec/julian century) */
522747.90, /* [6+6] (arcsec/julian century) */
};
void
@ -32,12 +32,12 @@ plut(void)
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;
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;
node = elem[4] + elem[4+6]*cy;
argp = elem[5] + elem[5+6]*cy;

View file

@ -2,7 +2,7 @@
char* satlst[] =
{
0,
0
};
struct

View file

@ -5,7 +5,7 @@ char* solstr[] =
"Fall equinox",
"Winter solstice",
"Spring equinox",
"Summer solstice",
"Summer solstice"
};
struct

View file

@ -122,7 +122,7 @@ double sunfp[] =
-1.33e-6, 0,
0.37e-6, 0,
0.36e-6, 0,
0,
0
};
char suncp[] =
{
@ -238,5 +238,5 @@ char suncp[] =
1,0,0,
1,-1,0,
1,1,0,
1,0,-1,
1,0,-1
};

View file

@ -2,21 +2,21 @@
static double elem[] =
{
36525.0, // [0] eday of epoc
36525.0, /* [0] eday of epoc */
19.19126393, // [1] semi major axis (au)
0.04716771, // [2] eccentricity
0.76986, // [3] inclination (deg)
74.22988, // [4] longitude of the ascending node (deg)
170.96424, // [5] longitude of perihelion (deg)
313.23218, // [6] mean longitude (deg)
19.19126393, /* [1] semi major axis (au) */
0.04716771, /* [2] eccentricity */
0.76986, /* [3] inclination (deg) */
74.22988, /* [4] longitude of the ascending node (deg) */
170.96424, /* [5] longitude of perihelion (deg) */
313.23218, /* [6] mean longitude (deg) */
0.00152025, // [1+6] (au/julian century)
-0.00019150, // [2+6] (e/julian century)
-2.09, // [3+6] (arcsec/julian century)
-1681.40, // [4+6] (arcsec/julian century)
1312.56, // [5+6] (arcsec/julian century)
1542547.79, // [6+6] (arcsec/julian century)
0.00152025, /* [1+6] (au/julian century) */
-0.00019150, /* [2+6] (e/julian century) */
-2.09, /* [3+6] (arcsec/julian century) */
-1681.40, /* [4+6] (arcsec/julian century) */
1312.56, /* [5+6] (arcsec/julian century) */
1542547.79, /* [6+6] (arcsec/julian century) */
};
void
@ -32,12 +32,12 @@ uran(void)
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;
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;
node = elem[4] + elem[4+6]*cy;
argp = elem[5] + elem[5+6]*cy;

View file

@ -27,7 +27,7 @@ double venfp[] =
0.717e-6, 2.2969,
2.991e-6, 2.0611,
1.335e-6, 0.9628,
0.,
0.
};
char vencp[] =
@ -56,5 +56,5 @@ char vencp[] =
4,-5,0,0,
2,0,-3,0,
1,0,0,-1,
2,0,0,-2,
2,0,0,-2
};

View file

@ -148,7 +148,7 @@ struct ServerState
enum
{
APOPCHALLEN = 128,
APOPCHALLEN = 128
};
static int apopchal(ServerState*, int, char[APOPCHALLEN]);

View file

@ -143,7 +143,7 @@ hasqueries(Attr *a)
char *ignored[] = {
"role",
"disabled",
"disabled"
};
static int

View file

@ -33,7 +33,7 @@ enum {
MShashlen = 16,
MSchallen = 8,
MSresplen = 24,
MSresplen = 24
};
static int
@ -315,7 +315,7 @@ out:
keyclose(s.k);
free(user);
free(resp);
// xioclose(s.asfd);
/* xioclose(s.asfd); */
return ret;
}
@ -411,16 +411,17 @@ chaproles[] =
};
Proto chap = {
.name= "chap",
.roles= chaproles,
.checkkey= chapcheck,
.keyprompt= "user? !password?",
"chap",
chaproles,
"user? !password?",
chapcheck
};
Proto mschap = {
.name= "mschap",
.roles= chaproles,
.checkkey= chapcheck,
.keyprompt= "user? !password?",
"mschap",
chaproles,
"user? !password?",
chapcheck
};

View file

@ -56,7 +56,7 @@ struct AuthMethod {
{
{ "p9", p9auth, srvp9auth,},
{ "netkey", netkeyauth, netkeysrvauth,},
// { "none", noauth, srvnoauth,},
/* { "none", noauth, srvnoauth,}, */
{ nil, nil}
};
AuthMethod *am = authmethod; /* default is p9 */
@ -687,7 +687,7 @@ enum
Qdir,
Qcpunote,
Nfid = 32,
Nfid = 32
};
struct {
@ -697,7 +697,7 @@ struct {
} fstab[] =
{
[Qdir] { ".", {Qdir, 0, QTDIR}, DMDIR|0555 },
[Qcpunote] { "cpunote", {Qcpunote, 0}, 0444 },
[Qcpunote] { "cpunote", {Qcpunote, 0}, 0444 }
};
typedef struct Note Note;

View file

@ -17,7 +17,7 @@
static char *msg[] = {
"key",
"delkey",
"debug",
"debug"
};
static int

View file

@ -13,7 +13,7 @@ enum
RpcWriteHex,
/* thread stack size - big buffers for printing */
STACK = 65536,
STACK = 65536
};
typedef struct Conv Conv;

View file

@ -12,7 +12,7 @@ enum
Qlog,
Qctl,
Qneedkey,
Qconv,
Qconv
};
static int qtop;
@ -41,7 +41,7 @@ static struct
"rpc", Qrpc, 0666,
"proto", Qprotolist, 0444,
"log", Qlog, 0600|DMEXCL,
"conv", Qconv, 0400,
"conv", Qconv, 0400
};
static void

View file

@ -26,7 +26,7 @@ threadmain(int argc, char *argv[])
char *mtpt;
char err[ERRMAX];
// mtpt = "/mnt";
/* mtpt = "/mnt"; */
mtpt = nil;
owner = getuser();
quotefmtinstall();

View file

@ -15,7 +15,7 @@ extern Proto p9sk1, p9sk2, p9cr;
static Proto* okproto[] =
{
&p9sk1,
nil,
nil
};
static int
@ -267,6 +267,6 @@ p9anyroles[] =
Proto p9any = {
"p9any",
p9anyroles,
p9anyroles
};

View file

@ -197,7 +197,7 @@ out:
enum
{
MAXCHAL = 64,
MAXCHAL = 64
};
typedef struct State State;
@ -222,7 +222,7 @@ enum
SHaveChal,
SNeedResp,
Maxphase,
Maxphase
};
static char *phasenames[Maxphase] =
@ -231,7 +231,7 @@ static char *phasenames[Maxphase] =
[CHaveResp] "CHaveResp",
[SHaveChal] "SHaveChal",
[SNeedResp] "SNeedResp",
[SNeedResp] "SNeedResp"
};
static void
@ -525,7 +525,7 @@ Proto p9cr =
.write= p9crwrite,
.read= p9crread,
.close= p9crclose,
.keyprompt= "user? !password?",
.keyprompt= "user? !password?"
};
Proto vnc =
@ -536,5 +536,5 @@ Proto vnc =
.read= p9crread,
.close= p9crclose,
.keyprompt= "!password?",
.addkey= vncaddkey,
.addkey= vncaddkey
};

View file

@ -343,11 +343,11 @@ Proto p9sk1 = {
p9sk1roles,
"user? dom? !password?",
p9sk1check,
p9sk1close,
p9sk1close
};
Proto p9sk2 = {
"p9sk2",
p9sk2roles,
p9sk2roles
};

View file

@ -23,7 +23,7 @@ Proto *prototab[] = {
&p9sk2,
&pass,
&rsa,
nil,
nil
};
Proto*

View file

@ -41,7 +41,7 @@ char *rpcname[] =
"start",
"write",
"readhex",
"writehex",
"writehex"
};
static int

View file

@ -10,9 +10,9 @@
enum{ CHK = 16};
enum{ MAXFILESIZE = 10*1024*1024 };
enum{// PW status bits
enum{/* PW status bits */
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";
@ -75,28 +75,28 @@ havesecstore(void)
return strcmp((char*)buf, "!account exists") == 0;
}
// delimited, authenticated, encrypted connection
enum{ Maxmsg=4096 }; // messages > Maxmsg bytes are truncated
/* delimited, authenticated, encrypted connection */
enum{ Maxmsg=4096 }; /* messages > Maxmsg bytes are truncated */
typedef struct SConn SConn;
extern SConn* newSConn(int); // arg is open file descriptor
extern SConn* newSConn(int); /* arg is open file descriptor */
struct SConn{
void *chan;
int secretlen;
int (*secret)(SConn*, uchar*, int);//
int (*read)(SConn*, uchar*, int); // <0 if error; errmess in buffer
int (*secret)(SConn*, uchar*, int);/* */
int (*read)(SConn*, uchar*, int); /* <0 if error; errmess in buffer */
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
// bytes in b to form keys for the two directions;
// set dir=0 in client, dir=1 in server
/* secret(s,b,dir) sets secret for digest, encrypt, using the secretlen */
/* bytes in b to form keys for the two directions; */
/* 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
static void writerr(SConn*, char*);
static int readstr(SConn*, char*); // call with buf of size Maxmsg+1
// returns -1 upon error, with error message in buf
static int readstr(SConn*, char*); /* call with buf of size Maxmsg+1 */
/* returns -1 upon error, with error message in buf */
typedef struct ConnState {
uchar secret[SHA1dlen];
@ -105,8 +105,8 @@ typedef struct ConnState {
} ConnState;
typedef struct SS{
int fd; // file descriptor for read/write of encrypted data
int alg; // if nonzero, "alg sha rc4_128"
int fd; /* file descriptor for read/write of encrypted data */
int alg; /* if nonzero, "alg sha rc4_128" */
ConnState in, out;
} 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*)"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);
ss->alg = 1;
return 0;
@ -174,7 +174,7 @@ SC_read(SConn *conn, uchar *buf, int n)
werrstr("!SC_read invalid count");
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){
len -= 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){
werrstr("secstore: remote file %s does not exist", gf);
return -1;
}else if(len > MAXFILESIZE){//assert
}else if(len > MAXFILESIZE){/*assert */
werrstr("secstore: implausible file size %d for %s", len, gf);
return -1;
}
@ -400,7 +400,7 @@ typedef struct PAKparams{
static PAKparams *pak;
// This group was generated by the seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E.
/* This group was generated by the seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E. */
static void
initPAKparams(void)
{
@ -422,8 +422,8 @@ initPAKparams(void)
"2A6E0BAE08B14258F8C03CC1B30E0DDADFCF7CEDF0727684D3D255F1", nil, 16, nil);
}
// H = (sha(ver,C,sha(passphrase)))^r mod p,
// a hash function expensive to attack by brute force.
/* H = (sha(ver,C,sha(passphrase)))^r mod p, */
/* a hash function expensive to attack by brute force. */
static void
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);
}
// Hi = H^-1 mod p
/* Hi = H^-1 mod p */
static char *
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);
}
// another, faster, hash function for each party to
// confirm that the other has the right secrets.
/* another, faster, hash function for each party to */
/* confirm that the other has the right secrets. */
static void
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);
}
// On input, conn provides an open channel to the server;
// C is the name this client calls itself;
// pass is the user's passphrase
// On output, session secret has been set in conn
// (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.
/* On input, conn provides an open channel to the server; */
/* C is the name this client calls itself; */
/* pass is the user's passphrase */
/* On output, session secret has been set in conn */
/* (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. */
static int
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);
// 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);
mpmod(x, pak->q, x);
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);
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){
fprint(2, "error: %s\n", mess);
writerr(conn, "couldn't read g**y");
@ -556,18 +556,18 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
goto done;
}
// send hash2(g**xy)
/* send hash2(g**xy) */
shorthash("client", C, S, hexm, hexmu, hexsigma, hexHi, digest);
enc64(kc, sizeof kc, digest, SHA1dlen);
snprint(mess2, Maxmsg, "k'=%s\n", kc);
conn->write(conn, (uchar*)mess2, strlen(mess2));
// set session key
/* set session key */
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
memset(hexsigma, 0, strlen(hexsigma));
n = conn->secret(conn, digest, 0);
memset(digest, 0, SHA1dlen);
if(n < 0){//assert
if(n < 0){/*assert */
writerr(conn, "can't set secret");
goto done;
}

View file

@ -41,7 +41,7 @@ Test test[] =
"cram", proxyserver, proxyclient,
"p9sk1", proxyserver, proxyclient,
"p9sk2", proxyserver, proxyclient,
"p9any", proxyserver, proxyclient,
"p9any", proxyserver, proxyclient
};
void

View file

@ -13,8 +13,8 @@ typedef struct ConnState {
} ConnState;
typedef struct SS{
int fd; // file descriptor for read/write of encrypted data
int alg; // if nonzero, "alg sha rc4_128"
int fd; /* file descriptor for read/write of encrypted data */
int alg; /* if nonzero, "alg sha rc4_128" */
ConnState in, out;
} 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*)"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);
ss->alg = 1;
return 0;
@ -82,7 +82,7 @@ SC_read(SConn *conn, uchar *buf, int n)
snprint((char*)buf,n,"!SC_read invalid count");
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){
len -= SHA1dlen;
if(len <= 0 || readn(ss->fd, digest, SHA1dlen) != SHA1dlen){

View file

@ -1,24 +1,24 @@
// delimited, authenticated, encrypted connection
enum{ Maxmsg=4096 }; // messages > Maxmsg bytes are truncated
/* delimited, authenticated, encrypted connection */
enum{ Maxmsg=4096 }; /* messages > Maxmsg bytes are truncated */
typedef struct SConn SConn;
extern SConn* newSConn(int); // arg is open file descriptor
extern SConn* newSConn(int); /* arg is open file descriptor */
struct SConn{
void *chan;
int secretlen;
int (*secret)(SConn*, uchar*, int);//
int (*read)(SConn*, uchar*, int); // <0 if error; errmess in buffer
int (*secret)(SConn*, uchar*, int);/* */
int (*read)(SConn*, uchar*, int); /* <0 if error; errmess in buffer */
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
// bytes in b to form keys for the two directions;
// set dir=0 in client, dir=1 in server
/* secret(s,b,dir) sets secret for digest, encrypt, using the secretlen */
/* bytes in b to form keys for the two directions; */
/* 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 int readstr(SConn*, char*); // call with buf of size Maxmsg+1
// returns -1 upon error, with error message in buf
extern int readstr(SConn*, char*); /* call with buf of size Maxmsg+1 */
/* returns -1 upon error, with error message in buf */
extern void *emalloc(ulong); /* dies on failure; clears memory */
extern void *erealloc(void *, ulong);

View file

@ -100,7 +100,7 @@ main(int argc, char **argv)
aesCBCencrypt(buf+AESbsize, AESbsize, &aes); /* use second AESbsize bytes as initial plaintext */
safewrite(buf, 2*AESbsize);
dstate = hmac_sha1(buf+AESbsize, AESbsize, key2, MD5dlen, 0, 0);
while(1){
for(;;){
n = Bread(&bin, buf, BUF);
if(n < 0){
fprint(2,"read error\n");
@ -134,9 +134,9 @@ main(int argc, char **argv)
exits("decrypted file failed to authenticate");
}
}else{ /* compatibility with past mistake */
// if file was encrypted with bad aescbc use this:
// memset(key, 0, AESmaxkey);
// else assume we're decrypting secstore files
/* if file was encrypted with bad aescbc use this: */
/* memset(key, 0, AESmaxkey); */
/* else assume we're decrypting secstore files */
setupAESstate(&aes, key, AESbsize, buf);
saferead(buf, CHK);
aesCBCdecrypt(buf, CHK, &aes);

View file

@ -74,7 +74,7 @@ dirls(char *path)
}
for(list=nil, len=0, i=0; i<ndir; i++){
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 += enc64(dig, sizeof dig, sha1file(path, dirbuf[i].name), SHA1dlen);
n += nmwid+3+strlen(dirbuf[i].name);

View file

@ -1,6 +1,6 @@
// 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.
// (All other EKE protocols are patented as well, by Lucent or others.)
/* 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. */
/* (All other EKE protocols are patented as well, by Lucent or others.) */
#include <u.h>
#include <libc.h>
#include <mp.h>
@ -19,7 +19,7 @@ typedef struct PAKparams{
static PAKparams *pak;
// from seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E
/* from seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E */
static void
initPAKparams(void)
{
@ -43,8 +43,8 @@ initPAKparams(void)
nil, 16, nil);
}
// H = (sha(ver,C,sha(passphrase)))^r mod p,
// a hash function expensive to attack by brute force.
/* H = (sha(ver,C,sha(passphrase)))^r mod p, */
/* a hash function expensive to attack by brute force. */
static void
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);
}
// Hi = H^-1 mod p
/* Hi = H^-1 mod p */
char *
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);
}
// another, faster, hash function for each party to
// confirm that the other has the right secrets.
/* another, faster, hash function for each party to */
/* confirm that the other has the right secrets. */
static void
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);
}
// On input, conn provides an open channel to the server;
// C is the name this client calls itself;
// pass is the user's passphrase
// On output, session secret has been set in conn
// (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.
/* On input, conn provides an open channel to the server; */
/* C is the name this client calls itself; */
/* pass is the user's passphrase */
/* On output, session secret has been set in conn */
/* (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. */
int
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);
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);
mpmod(x, pak->q, x);
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);
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){
fprint(2, "error: %s\n", mess);
writerr(conn, "couldn't read g**y");
@ -179,13 +179,13 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
goto done;
}
// send hash2(g**xy)
/* send hash2(g**xy) */
shorthash("client", C, S, hexm, hexmu, hexsigma, hexHi, digest);
enc64(kc, sizeof kc, digest, SHA1dlen);
snprint(mess2, Maxmsg, "k'=%s\n", kc);
conn->write(conn, (uchar*)mess2, strlen(mess2));
// set session key
/* set session key */
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
memset(hexsigma, 0, strlen(hexsigma));
n = conn->secret(conn, digest, 0);
@ -210,12 +210,12 @@ done:
return rc;
}
// On input,
// mess contains first message;
// name is name this server should call itself.
// On output, session secret has been set in conn;
// if pw!=nil, then *pw points to PW struct for authenticated user.
// returns -1 if error
/* On input, */
/* mess contains first message; */
/* name is name this server should call itself. */
/* On output, session secret has been set in conn; */
/* if pw!=nil, then *pw points to PW struct for authenticated user. */
/* returns -1 if error */
int
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);
PW *pw = nil;
// secstore version and algorithm
/* secstore version and algorithm */
snprint(mess2,Maxmsg,"%s\tPAK\n", VERSION);
n = strlen(mess2);
if(strncmp(mess,mess2,n) != 0){
@ -237,7 +237,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
mess += n;
initPAKparams();
// parse first message into C, m
/* parse first message into C, m */
eol = strchr(mess, '\n');
if(strncmp("C=", mess, 2) != 0 || !eol){
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);
mpmod(m, pak->p, m);
// lookup client
/* lookup client */
if((pw = getPW(C,0)) == nil) {
snprint(mess2, sizeof mess2, "%r");
writerr(conn, mess2);
@ -270,7 +270,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
}
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);
mpmod(y, pak->q, y);
if(mpcmp(y, mpzero) == 0){
@ -281,7 +281,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
mpmod(m, pak->p, m);
mpexp(m, y, pak->p, sigma);
// send g**y, hash1(g**xy)
/* send g**y, hash1(g**xy) */
hexmu = mptoa(mu, 64, nil, 0);
hexsigma = mptoa(sigma, 64, nil, 0);
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);
conn->write(conn, (uchar*)mess2, strlen(mess2));
// recv hash2(g**xy)
/* recv hash2(g**xy) */
if(readstr(conn, mess2) < 0){
writerr(conn, "couldn't read verifier");
goto done;
@ -308,7 +308,7 @@ PAKserver(SConn *conn, char *S, char *mess, PW **pwp)
goto done;
}
// set session key
/* set session key */
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
n = conn->secret(conn, digest, 1);
if(n < 0){

View file

@ -42,7 +42,7 @@ getPW(char *id, int dead_or_alive)
uint now = time(0);
Biobuf *bin;
PW *pw;
char *f1, *f2; // fields 1, 2 = attribute, value
char *f1, *f2; /* fields 1, 2 = attribute, value */
if((bin = openPW(id, OREAD)) == 0){
id = "FICTITIOUS";
@ -75,7 +75,7 @@ getPW(char *id, int dead_or_alive)
}
Bterm(bin);
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){
werrstr("account expired");
freePW(pw);
@ -87,14 +87,14 @@ getPW(char *id, int dead_or_alive)
return nil;
}
if(pw->failed < 10)
return pw; // success
return pw; /* success */
if(now < mtimePW(id)+300){
werrstr("too many failures; try again in five minutes");
freePW(pw);
return nil;
}
pw->failed = 0;
putPW(pw); // reset failed-login-counter after five minutes
putPW(pw); /* reset failed-login-counter after five minutes */
return pw;
}

View file

@ -142,8 +142,8 @@ getfile(SConn *conn, char *gf, uchar **buf, ulong *buflen, uchar *key, int nkey)
return 0;
}
// This sends a file to the secstore disk that can, in an emergency, be
// decrypted by the program aescbc.c.
/* This sends a file to the secstore disk that can, in an emergency, be */
/* decrypted by the program aescbc.c. */
static int
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;
if(n < Maxmsg){ /* EOF on input; append XX... */
memset(b+n, 'X', CHK);
n += CHK; // might push n>Maxmsg
n += CHK; /* might push n>Maxmsg */
done = 1;
}
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)
goto Out;
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;
while(len>0){
memnext = (uchar*)strchr((char*)memcur, '\n');
@ -309,7 +309,7 @@ chpasswd(AuthConn *c, char *id)
H = mpnew(0);
Hi = mpnew(0);
// changing our password is vulnerable to connection failure
/* changing our password is vulnerable to connection failure */
for(;;){
snprint(prompt, sizeof(prompt), "new password for %s: ", id);
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);
}
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)
exits("no password on standard input");
s[n] = 0;
@ -442,7 +442,7 @@ login(char *id, char *dest, int pass_stdin, int pass_nvram)
exits("invalid password on standard input");
if(pass_nvram)
exits("invalid password in nvram");
// and let user try retyping the password
/* and let user try retyping the password */
if(ntry==3)
fprint(2, "Enter an empty password to quit.\n");
}

View file

@ -1,26 +1,26 @@
enum{ MAXFILESIZE = 10*1024*1024 };
enum{// PW status bits
enum{/* PW status bits */
Enabled = (1<<0),
STA = (1<<1), // extra SecurID step
STA = (1<<1) /* extra SecurID step */
};
typedef struct PW {
char *id; // user id
ulong expire; // expiration time (epoch seconds)
ushort status; // Enabled, STA, ...
ushort failed; // number of failed login attempts
char *other; // other information, e.g. sponsor
mpint *Hi; // H(passphrase)^-1 mod p
char *id; /* user id */
ulong expire; /* expiration time (epoch seconds) */
ushort status; /* Enabled, STA, ... */
ushort failed; /* number of failed login attempts */
char *other; /* other information, e.g. sponsor */
mpint *Hi; /* H(passphrase)^-1 mod p */
} PW;
PW *getPW(char *, int);
int putPW(PW *);
void freePW(PW *);
// *client: SConn, client name, passphrase
// *server: SConn, (partial) 1st msg, PW entry
// *setpass: Username, hashed passphrase, PW entry
/* *client: SConn, client name, passphrase */
/* *server: SConn, (partial) 1st msg, PW entry */
/* *setpass: Username, hashed passphrase, PW entry */
int PAKclient(SConn *, char *, char *, char **);
int PAKserver(SConn *, char *, char *, PW **);
char *PAK_Hi(char *, char *, mpint *, mpint *);

View file

@ -8,7 +8,7 @@
#include "secstore.h"
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);
int verbose;
@ -247,7 +247,7 @@ dologin(int fd, char *S, int forceSTA)
pw = nil;
rv = -1;
// collect the first message
/* collect the first message */
if((conn = newSConn(fd)) == nil)
return -1;
if(readstr(conn, msg) < 0){
@ -256,7 +256,7 @@ dologin(int fd, char *S, int forceSTA)
goto Out;
}
// authenticate
/* authenticate */
if(PAKserver(conn, S, msg, &pw) < 0){
if(pw != nil)
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);
syslog(0, LOG, "AUTH %s", pw->id);
// perform operations as asked
/* perform operations as asked */
while((n = readstr(conn, msg)) > 0){
syslog(0, LOG, "[%s] %s", pw->id, msg);
@ -346,7 +346,7 @@ main(int argc, char **argv)
S = sysname();
SECSTORE_DIR = unsharp("#9/secstore");
// setnetmtpt(net, sizeof(net), nil);
/* setnetmtpt(net, sizeof(net), nil); */
ARGBEGIN{
case 'R':
forceSTA = 1;
@ -362,7 +362,7 @@ main(int argc, char **argv)
if(p == nil)
usage();
USED(p);
// setnetmtpt(net, sizeof(net), p);
/* setnetmtpt(net, sizeof(net), p); */
break;
case 'v':
verbose++;
@ -395,7 +395,7 @@ main(int argc, char **argv)
close(lcfd);
break;
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"));
if(db == 0)
syslog(0, LOG, "no ndb/auth");
@ -405,7 +405,7 @@ main(int argc, char **argv)
db = ndbcat(db, db2);
if((dfd = accept(lcfd, ldir)) < 0)
exits("can't accept");
alarm(30*60*1000); // 30 min
alarm(30*60*1000); /* 30 min */
remote = remoteIP(ldir);
syslog(0, LOG, "secstore from %s", remote);
free(remote);

View file

@ -29,7 +29,7 @@ typedef struct Secret{
typedef struct Attribute{
struct Attribute *next;
uchar type;
uchar len; // number of bytes in value
uchar len; /* number of bytes in value */
uchar val[256];
} Attribute;
@ -39,7 +39,7 @@ typedef struct Packet{
Attribute first;
} Packet;
// assumes pass is at most 16 chars
/* assumes pass is at most 16 chars */
void
hide(Secret *shared, uchar *auth, Secret *pass, uchar *x)
{
@ -60,9 +60,9 @@ authcmp(Secret *shared, uchar *buf, int m, uchar *auth)
DigestState *M;
uchar x[16];
M = md5(buf, 4, nil, nil); // Code+ID+Length
M = md5(auth, 16, nil, M); // RequestAuth
M = md5(buf+20, m-20, nil, M); // Attributes
M = md5(buf, 4, nil, nil); /* Code+ID+Length */
M = md5(auth, 16, nil, M); /* RequestAuth */
M = md5(buf+20, m-20, nil, M); /* Attributes */
md5(shared->s, shared->len, x, M);
return memcmp(x, buf+4, 16);
}
@ -118,7 +118,7 @@ rpc(char *dest, Secret *shared, Packet *req)
Attribute *a;
int m, n, fd, try;
// marshal request
/* marshal request */
e = buf + sizeof buf;
buf[0] = req->code;
buf[1] = req->ID;
@ -136,7 +136,7 @@ rpc(char *dest, Secret *shared, Packet *req)
buf[2] = n>>8;
buf[3] = n;
// send request, wait for reply
/* send request, wait for reply */
fd = dial(dest, 0, 0, 0);
if(fd < 0){
syslog(0, AUTHLOG, "%s: rpc can't get udp channel", dest);
@ -156,9 +156,9 @@ rpc(char *dest, Secret *shared, Packet *req)
alarm(0);
if(m < 0){
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);
continue;
}
@ -170,7 +170,7 @@ rpc(char *dest, Secret *shared, Packet *req)
if(m <= 0)
return nil;
// unmarshal reply
/* unmarshal reply */
b = buf2;
e = buf2+m;
resp = (Packet*)malloc(sizeof(*resp));
@ -192,18 +192,18 @@ rpc(char *dest, Secret *shared, Packet *req)
while(1){
if(b >= e){
a->next = nil;
break; // exit loop
break; /* exit loop */
}
a->type = *b++;
a->len = (*b++) - 2;
if(b + a->len > e){ // corrupt packet
if(b + a->len > e){ /* corrupt packet */
a->next = nil;
freePacket(resp);
return nil;
}
memmove(a->val, b, a->len);
b += a->len;
if(b < e){ // any more attributes?
if(b < e){ /* any more attributes? */
a->next = (Attribute*)malloc(sizeof(*a));
if(a->next == nil){
free(req);
@ -230,7 +230,7 @@ setAttribute(Packet *p, uchar type, uchar *s, int n)
}
a->type = type;
a->len = n;
if(a->len > 253 ) // RFC2138, section 5
if(a->len > 253 ) /* RFC2138, section 5 */
a->len = 253;
memmove(a->val, s, a->len);
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));
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);
free(radiussecret);

View file

@ -49,7 +49,7 @@ enum /* agent protocol packet types */
SSH2_AGENT_FAILURE = 30,
SSH_COM_AGENT2_FAILURE = 102,
SSH_AGENT_OLD_SIGNATURE = 0x01,
SSH_AGENT_OLD_SIGNATURE = 0x01
};
typedef struct Aconn Aconn;

View file

@ -56,7 +56,7 @@ main(int argc, char **argv)
fd = openlog(argv[2]);
fprint(fd, "%s: %s\n", t, p);
}
} else if(Blinelen(&in) == 0) // true eof
} else if(Blinelen(&in) == 0) /* true eof */
break;
else {
Bread(&in, buf, sizeof buf);

View file

@ -88,7 +88,7 @@ sampleinit(void)
if(host_page_size(stat_port, &sample.pgsize) != KERN_SUCCESS)
sample.pgsize = 4096;
// populate clock tick info for timestamps
/* populate clock tick info for timestamps */
mach_timebase_info(&info);
sample.divisor = 1000.0 * (double)info.denom/info.numer;
sample.time = mach_absolute_time();
@ -361,10 +361,10 @@ xvm(int first)
isys("vm.stats.vm.v_rforks")
+isys("vm.stats.vm.v_vforks"));
// Bprint(&bout, "hits %lud of %lud lookups (%d%% hit rate)\n",
// (asamp.vm_stat.hits),
// (asamp.vm_stat.lookups),
// (natural_t)(((double)asamp.vm_stat.hits*100)/ (double)asamp.vm_stat.lookups));
/* Bprint(&bout, "hits %lud of %lud lookups (%d%% hit rate)\n", */
/* (asamp.vm_stat.hits), */
/* (asamp.vm_stat.lookups), */
/* (natural_t)(((double)asamp.vm_stat.hits*100)/ (double)asamp.vm_stat.lookups)); */
}
void

Some files were not shown because too many files have changed in this diff Show more