enum { CHUNK = 32, /* # Ents to malloc at a time */ ATOMIC = 120, /* ChnageLog events are atomic if this close (in sec) */ DAY = 60*60*24, /* grainularity of checkin dirs (in sec) */ EXPIRY = 10, /* Files flushed from cache if idle for this long (in min) */ SNAPTIME = 60*60*4, /* Offset from midnight when psudo-snaps take place (in sec) */ }; enum { /* states for rlog parser */ Slost, /* where we are initially */ Sfile, /* file level info */ Stags, /* tags list */ Sjunk, /* junk stuff between keyword subs and revisions */ Srevision, /* revision details */ Sbranches, /* maybe branches: info, maybe not (ugh!) */ Sdesc, /* description of changes */ }; typedef struct Tag Tag; struct Tag { Tag *next; /* next in list */ char *tag; /* name of tag */ char *rev; /* revision name */ }; typedef struct Rev Rev; struct Rev { Rev *next; long mtime; /* time checked in */ char *locker; /* who locked the file or nil */ char *author; /* who checked in this revision */ char *rev; /* revision */ char *desc; /* description of this change */ int added; /* lines added since previous revision */ int removed; /* lines removed since previous revision */ int mode; /* file mode - only really known after checkout */ Lock lock; /* mutex between file service and cache flush */ int epoch; /* session epoch when this file was last read */ int ref; /* open ref count */ long atime; /* last access time */ uvlong length; /* file size */ char *data; /* file contents */ }; typedef struct View View; struct View { char *path; /* directory path to tag/revision */ long mtime; /* mod time of revision if non-zero */ char *tag; /* tag of revision if non-nil */ }; typedef struct Ent Ent; struct Ent { char *path; /* full remote file path */ char *keysub; /* keyword susbstution flags */ char *head; /* head revision name */ Tag *tags; /* list of tag names */ Rev *revs; /* revision info */ long deleted; /* !=0 -> when deleted, IE now in Attic */ }; typedef struct Sess Sess; struct Sess { int fdin; int fdout; Biobuf *bin; /* from network */ Biobuf *bout; /* to network */ char *port; /* port to dial */ char *prog; /* prog used to connect or nil if direct */ char *root; /* path (on remote host) to root of repository */ char *logroot; /* root remote host things the repository has in its logs */ char *user; /* username for direct TCP connection */ char *keyp; /* key params for ssh/rx connection */ char *host; /* host to connect to */ char *method; /* connection method name */ Ent *ents; /* one per file in repository */ int nents; /* number of above */ View *views; /* one per top level directory pair */ int nviews; /* number of above */ int epoch; /* session epoch, bumped on reconnect */ }; extern int Debug; extern int Verbose; /* mangle.c */ extern char *mangle(char *); /* changelog.c */ extern char *changelog(Sess *); /* cvs.c */ extern char *cvsopen(Sess *); extern void cvsclose(Sess *); extern int cvsrlog(Sess *, char *); extern int cvscheckout(Sess *, char **, uvlong *, int *, char *, char *); /* main.c */ extern char *path2D(char *); extern void main(int, char *[]); /* mangle.c */ /* str.c */ extern char *strheap(char *); extern char *strgrow(char *, char *); extern char *strpfx(char *, char *); extern long str2date(char *); extern int str2mode(char *p); /* util.c */ extern int Bprnt(Biobufhdr *bp, char *fmt, ...); extern char *Bgetline(Biobuf *);