home *** CD-ROM | disk | FTP | other *** search
- Subject: v19i037: A software configuration management system, Part24/33
- Newsgroups: comp.sources.unix
- Sender: sources
- Approved: rsalz@uunet.UU.NET
-
- Submitted-by: Axel Mahler <unido!coma!axel>
- Posting-number: Volume 19, Issue 37
- Archive-name: shape/part24
-
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 24 (of 33)."
- # Contents: src/shape/files.c
- # Wrapped by rsalz@papaya.bbn.com on Thu Jun 1 19:27:15 1989
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'src/shape/files.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/shape/files.c'\"
- else
- echo shar: Extracting \"'src/shape/files.c'\" \(27004 characters\)
- sed "s/^X//" >'src/shape/files.c' <<'END_OF_FILE'
- X/*
- X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
- X * and U. Pralle
- X *
- X * This software is published on an as-is basis. There is ABSOLUTELY NO
- X * WARRANTY for any part of this software to work correctly or as described
- X * in the manuals. We do not accept any liability for any kind of damage
- X * caused by use of this software, such as loss of data, time, money, or
- X * effort.
- X *
- X * Permission is granted to use, copy, modify, or distribute any part of
- X * this software as long as this is done without asking for charge, and
- X * provided that this copyright notice is retained as part of the source
- X * files. You may charge a distribution fee for the physical act of
- X * transferring a copy, and you may at your option offer warranty
- X * protection in exchange for a fee.
- X *
- X * Direct questions to: Tech. Univ. Berlin
- X * Wilfried Koch
- X * Sekr. FR 5-6
- X * Franklinstr. 28/29
- X * D-1000 Berlin 10, West Germany
- X *
- X * Tel: +49-30-314-22972
- X * E-mail: shape@coma.uucp or shape@db0tui62.bitnet
- X */
- X#ifndef lint
- Xstatic char *RCSid = "$Header: files.c,v 3.3 89/02/20 16:23:45 wolfgang Exp $";
- X#endif
- X#ifndef lint
- Xstatic char *ConfFlg = CFFLGS; /* should be defined from within Makefile */
- X#endif
- X/*
- X * $Log: files.c,v $
- X * Revision 3.3 89/02/20 16:23:45 wolfgang
- X * NET-RELEASE
- X *
- X * Revision 3.2 89/02/13 19:35:15 wolfgang
- X * performance improved
- X *
- X * Revision 3.1 89/02/08 12:45:42 wolfgang
- X * performance improved.
- X *
- X * Revision 3.0 89/01/24 11:35:24 wolfgang
- X * New System Generation
- X *
- X * Revision 2.30 89/01/03 13:09:44 wolfgang
- X * changes done for lint
- X *
- X * Revision 2.29 88/12/21 15:02:45 wolfgang
- X * changes done for lint
- X *
- X * Revision 2.28 88/12/12 13:15:58 wolfgang
- X * bug fixed (something for sun).
- X *
- X * Revision 2.27 88/11/24 14:30:36 wolfgang
- X * derived object no longer inherit uda's .
- X *
- X * Revision 2.26 88/11/23 15:19:39 wolfgang
- X * hidden attrs are no longer part of confid.
- X *
- X * Revision 2.25 88/11/23 15:02:57 wolfgang
- X * bug fixed.
- X *
- X * Revision 2.24 88/11/22 17:27:33 wolfgang
- X * bug fixed (strncmp).
- X *
- X * Revision 2.22 88/11/21 15:51:11 wolfgang
- X * return code of all malloc's checked
- X *
- X * Revision 2.21 88/11/08 18:06:04 wolfgang
- X * bug fixed: retcode wasn't correct initialized (in exists_file()).
- X *
- X * Revision 2.20 88/11/08 11:01:23 wolfgang
- X * bug fixed in evtl_set_busy: selction rules are now not applied to
- X * derived objects.
- X *
- X * Revision 2.19 88/11/05 14:35:51 wolfgang
- X * bug fixed. full filenames (including path) were destroyed sometimes.
- X *
- X * Revision 2.18 88/11/03 17:28:59 wolfgang
- X * bug fixed in exists_file
- X *
- X * Revision 2.17 88/10/24 16:19:30 wolfgang
- X * bug fixed in exists_file.
- X *
- X * Revision 2.16 88/10/18 20:33:48 wolfgang
- X * bugs fixed. pathlist wasn't correct. set busy of name including
- X * full path didn't work.
- X *
- X * Revision 2.15 88/10/10 17:02:34 wolfgang
- X * This version is part of a release
- X *
- X * Revision 2.14 88/09/22 16:14:06 wolfgang
- X * changes done to set busy the same file more than once.
- X *
- X * Revision 2.13 88/09/15 18:42:14 wolfgang
- X * call of reset_vclass added.
- X *
- X * Revision 2.12 88/08/30 12:20:44 wolfgang
- X * minor bug fixed.,
- X *
- X * Revision 2.11 88/08/25 16:10:55 wolfgang
- X * This version is part of a release
- X *
- X * Revision 2.10 88/08/25 10:29:31 wolfgang
- X * Now a warning is produced, if a confid contains non-frozen versions
- X * of a component.
- X *
- X * Revision 2.9 88/08/23 16:35:40 wolfgang
- X * The handling of author@host is now correct.
- X *
- X * Revision 2.8 88/08/23 15:35:45 wolfgang
- X * Genarating of confid's has been changed. The name of the selection
- X * rule starts now with '@'.
- X *
- X * Revision 2.7 88/08/23 14:06:47 wolfgang
- X * Minor bug fixed. The dummy predicate SMILEY was followed by ":"
- X * instead of ",".
- X *
- X * Revision 2.6 88/08/23 11:22:37 wolfgang
- X * vardump(fd) added to finish_confid.
- X *
- X * Revision 2.5 88/08/23 10:27:01 wolfgang
- X * ruledump() added to finish_confid; little bug fix in write_confid.
- X *
- X * Revision 2.4 88/08/22 17:13:31 wolfgang
- X * Two procedures added:
- X * init_confid: to initialize the confid
- X * finish_confid: dumps the macrodefinitions.
- X * write_confid changed; only the relevant predicates are written to the
- X * confid now.
- X * Furthermore handling of syspath & host added to evtl_set_busy().
- X *
- X * Revision 2.3 88/08/22 11:13:41 wolfgang
- X * Minor bug fixed. attr(author,<name>) wasn't evaluated correctly.
- X *
- X * Revision 2.2 88/08/19 12:25:02 wolfgang
- X * Minor bug fixed. Pathlist contained '/' in filename.
- X *
- X * Revision 2.1 88/08/19 10:17:18 wolfgang
- X * This version is part of a release
- X *
- X */
- X
- X#include "shape.h"
- X#include "files.h"
- X
- X#include <pwd.h>
- X#include <stdio.h>
- X#include <sys/stat.h>
- X#include <sys/time.h>
- X#include <errno.h>
- X
- Xextern int errno;
- X
- Xextern register_link();
- X
- Xextern FILE *af_open();
- X
- Xextern struct passwd *getpwnam();
- Xextern char *mktemp();
- X
- Xextern int af_setgkey();
- Xextern int af_gattrs();
- Xextern int WriteXPand();
- Xextern int logerr();
- Xextern int append_attrs();
- Xextern int append_mtime();
- Xextern Bool stopit();
- Xextern Bool tunix();
- Xextern struct rules *get_target();
- Xextern int dump();
- Xextern int ruledump();
- Xextern int vardump();
- Xextern int reset_vclass();
- X
- XAf_attrs buft;
- Xextern char *macrostr;
- Xextern char cursr[];
- Xchar actpath[MAXNAMLEN];
- Xextern char *states[];
- Xextern struct selection_rules *currule;
- X
- Xextern Bool busy_done;
- Xextern int depth;
- Xextern int pathi;
- Xchar *pathlist[MAXPATHLIST][2];
- Xint lastpath = 0;
- Xchar dollarplus[MAXNAMLEN];
- X
- Xget_date_of(anything,set,path)
- X char *anything;
- X Af_set *set;
- X char *path;
- X {
- X /* attrs of busy version */
- XAf_attrs buf;
- X
- Xchar bname[MAXNAMLEN];
- Xchar *p;
- Xchar *d;
- Xchar sysp[MAXNAMLEN];
- X
- Xsysp[0] = '\0';
- X
- X(void) strcpy(bname,anything);
- Xif ((p = rindex(bname,'.')) == NIL)
- X ;
- Xelse
- X {
- X p[0] = '\0';
- X *p++;
- X }
- X
- Xif ((d = rindex(bname,'/')) != 0)
- X {
- X (void) strcpy(sysp, bname);
- X d = rindex(sysp, '/');
- X d[0] = '\0';
- X *d++;
- X (void) strcpy(bname,d);
- X }
- Xaf_initattrs(&buf);
- X
- Xbuf.af_gen = AF_BUSYVERS;
- Xbuf.af_rev = AF_BUSYVERS;
- X
- X(void) strcpy(buf.af_name,bname);
- Xif (p != NIL)
- X (void) strcpy(buf.af_type,p);
- Xelse
- X (void) strcpy(buf.af_type,"");
- X
- Xif(path != NIL)
- X (void) strcpy(buf.af_syspath, path);
- X
- X/* if ((retcode = af_bpfind(&buf,&bset)) == -1)
- X errexit(10,"af_bpfind"); */
- X
- Xif (af_find(&buf,set) == -1) /* &aset */
- X errexit(10,"af_find");
- X
- X/* if ((retcode = af_union(&aset,&bset,set)) == -1 )
- X errexit(10,"af_union"); */
- X}
- X
- X
- XBool exists_file(name,mode)
- X char *name;
- X int mode;
- X{
- X
- Xchar bname[MAXNAMLEN];
- Xchar type[64];
- Xchar *p;
- Xchar *d;
- X
- Xint retcode = -1;
- Xint retcodex;
- Xint retcodey;
- Xint i;
- Xint ii = 1;
- Xchar sysp[MAXNAMLEN];
- Xchar lname[MAXNAMLEN];
- Xchar *px;
- XAf_attrs buf;
- X
- Xsysp[0] = '\0';
- Xif (name == NIL)
- X return (FALSE);
- X
- X(void) strcpy(lname,name);
- Xif((px = rindex(lname,'/')) != NIL)
- X {
- X *px = '\0';
- X px++;
- X }
- Xelse
- X px = &lname[0];
- X
- Xif (mode != BINARY)
- X {
- X for(i = lastpath - 1; i >= 0; i--)
- X /* looking in pathlist if file already exists */
- X {
- X if(!strcmp(px,pathlist[i][0]))
- X {
- X if (!strcmp(pathlist[i][1],"&$"))
- X (void) strcpy(actpath,curvpath[0]);
- X else
- X {
- X if(pathlist[i][1][0] != '/')
- X {
- X (void) strcpy(actpath,curvpath[0]);
- X (void) strcat(actpath,"/");
- X (void) strcat(actpath,pathlist[i][1]);
- X }
- X else
- X {
- X (void) strcpy(actpath,pathlist[i][1]);
- X }
- X if ((px = rindex(actpath,'/')) != NIL)
- X *px = '\0';
- X }
- X return(TRUE);
- X }
- X }
- X }
- X
- X(void) strcpy(bname,name);
- Xif ((p = rindex(bname,'.')) == 0)
- X {
- X type[0] = '\0';
- X }
- Xelse
- X {
- X p[0] = '\0';
- X *p++;
- X (void) strcpy(type,p);
- X }
- Xif ((d = rindex(bname,'/')) != 0)
- X {
- X (void) strcpy(sysp, bname);
- X d = rindex(sysp, '/');
- X d[0] = '\0';
- X *d++;
- X (void) strcpy(bname,d);
- X }
- Xaf_initattrs(&buf);
- X
- Xbuf.af_gen = AF_NOVNUM;
- Xbuf.af_rev = AF_NOVNUM;
- X
- X(void) strcpy(buf.af_name,bname);
- X
- X(void) strcpy(buf.af_type,type);
- X
- Xwhile(curvpath[ii] != NIL)
- X ii++;
- X
- Xi = ii - 1;
- X
- Xwhile ( i >= 1 )
- X {
- X (void) strcpy(buf.af_syspath, curvpath[i]);
- X
- X if (mode == ALL)
- X {
- X retcodex = af_access(buf.af_syspath, buf.af_name, buf.af_type, AF_SOURCE);
- X retcodey = af_access(buf.af_syspath, buf.af_name, buf.af_type, AF_DERIVED);
- X if((retcodex == 0) || (retcodey == 0))
- X retcode = 0;
- X else
- X retcode = -1;
- X }
- X
- X if (mode == SOURCE)
- X retcode = af_access(buf.af_syspath, buf.af_name, buf.af_type, AF_SOURCE);
- X
- X if (mode == BINARY)
- X retcode = af_access(buf.af_syspath, buf.af_name, buf.af_type, AF_DERIVED);
- X
- X if ((retcode == 0)) /* && (strcmp(buf.af_syspath,curvpath[0]))) */
- X {
- X (void) strcpy(actpath,curvpath[i]);
- X if ((pathlist[lastpath][0] = malloc(MAXNAMLEN)) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(pathlist[lastpath][0],buf.af_name);
- X if (buf.af_type[0] != '\0')
- X {
- X (void) strcat(pathlist[lastpath][0],".");
- X (void) strcat(pathlist[lastpath][0],buf.af_type);
- X }
- X if (!strcmp(buf.af_syspath,curvpath[0]))
- X {
- X if((pathlist[lastpath][1] = malloc(3)) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(pathlist[lastpath][1],"&$");
- X#ifdef DEBUG_FILES
- Xprintf("%d:%s:%s\n", lastpath,pathlist[lastpath][0], pathlist[lastpath][1]);
- X#endif DEBUG_FILES
- X lastpath++;
- X }
- X else
- X {
- X if((pathlist[lastpath][1] = malloc(MAXNAMLEN)) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(pathlist[lastpath][1],buf.af_syspath);
- X (void) strcat(pathlist[lastpath][1],"/");
- X (void) strcat(pathlist[lastpath][1],pathlist[lastpath][0]);
- X#ifdef DEBUG_FILES
- Xprintf("%d:%s:%s\n", lastpath,pathlist[lastpath][0], pathlist[lastpath][1]);
- X#endif DEBUG_FILES
- X lastpath++;
- X break;
- X }
- X }
- X i--;
- X }
- Xif (retcode == 0)
- X {
- X (void) strcpy(actpath,curvpath[i]);
- X return(TRUE);
- X }
- X
- Xif (sysp[0] != '\0')
- X (void) strcpy(buf.af_syspath, sysp);
- Xelse
- X (void) strcpy(buf.af_syspath, curvpath[0]);
- X
- X
- Xif (mode == ALL)
- X {
- X retcodex = af_access(buf.af_syspath, buf.af_name, buf.af_type, AF_SOURCE);
- X retcodey = af_access(buf.af_syspath, buf.af_name, buf.af_type, AF_DERIVED);
- X if((retcodex == 0) || (retcodey == 0))
- X retcode = 0;
- X else
- X retcode = -1;
- X }
- X
- Xif (mode == SOURCE)
- X retcode = af_access(buf.af_syspath, buf.af_name, buf.af_type, AF_SOURCE);
- X
- Xif (mode == BINARY)
- X retcode = af_access(buf.af_syspath, buf.af_name, buf.af_type, AF_DERIVED);
- X
- Xif (retcode == 0) /* && (strcmp(buf.af_syspath,curvpath[0]))) */
- X {
- X (void) strcpy(actpath,buf.af_syspath);
- X if ((pathlist[lastpath][0] = malloc(MAXNAMLEN)) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(pathlist[lastpath][0],buf.af_name);
- X if (buf.af_type[0] != '\0')
- X {
- X (void) strcat(pathlist[lastpath][0],".");
- X (void) strcat(pathlist[lastpath][0],buf.af_type);
- X }
- X if (!strcmp(buf.af_syspath,curvpath[0]))
- X {
- X if((pathlist[lastpath][1] = malloc(3)) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(pathlist[lastpath][1],"&$");
- X#ifdef DEBUG_FILES
- Xprintf("%d:%s:%s\n", lastpath,pathlist[lastpath][0], pathlist[lastpath][1]);
- X#endif DEBUG_FILES
- X lastpath++;
- X }
- X else
- X {
- X if ((pathlist[lastpath][1] = malloc(MAXNAMLEN)) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(pathlist[lastpath][1],buf.af_syspath);
- X (void) strcat(pathlist[lastpath][1],"/");
- X (void) strcat(pathlist[lastpath][1],pathlist[lastpath][0]);
- X#ifdef DEBUG_FILES
- Xprintf("%d:%s:%s\n", lastpath,pathlist[lastpath][0], pathlist[lastpath][1]);
- X#endif DEBUG_FILES
- X lastpath++;
- X return(TRUE);
- X }
- X }
- X
- Xif(retcode == 0)
- X {
- X (void) strcpy(actpath,buf.af_syspath);
- X return(TRUE);
- X }
- X
- Xif (retcode == -1)
- X return (FALSE);
- Xelse
- X return (TRUE);
- X}
- X
- X
- XFILE *vmfopen( filename, mode, gen,rev)
- X char *filename;
- X char *mode;
- X int gen;
- X int rev;
- X{
- X char syspath[MAXNAMLEN];
- X char *name = NIL;
- X char *type = NIL;
- X
- X Af_key key;
- X
- X char *ind;
- X char *ind2;
- X char *basename;
- X FILE *fp;
- X char fname[MAXNAMLEN];
- X (void) strcpy(fname, filename);
- X
- X if ((ind = rindex(fname,'/')) == NIL)
- X {
- X (void) strcpy(syspath,curvpath[0]);
- X basename = fname;
- X }
- X else
- X {
- X ind[0] = '\0';
- X ind++;
- X basename = ind;
- X (void) strcpy(syspath,fname);
- X }
- X
- X if ((ind2 = rindex(basename,'.')) == NIL)
- X {
- X name = basename;
- X }
- X else
- X {
- X ind2[0] = '\0';
- X ind2++;
- X type = ind2;
- X name = basename;
- X }
- X if(af_getkey(syspath, name, type, gen, rev,NIL, &key) == -1)
- X return ((FILE *) NIL);
- X else
- X {
- X fp = af_open(&key, mode);
- X return (fp);
- X }
- X}
- X
- X
- Xget_set(anything,set)
- X char *anything;
- X Af_set *set;
- X {
- X
- XAf_attrs buf;
- X
- Xchar bname[MAXNAMLEN];
- Xchar *p;
- Xchar *d;
- Xchar sysp[MAXNAMLEN];
- X
- Xsysp[0] = '\0';
- X
- X(void) strcpy(bname,anything);
- Xif ((p = rindex(bname,'.')) == NIL)
- X ;
- Xelse
- X {
- X p[0] = '\0';
- X *p++;
- X }
- X
- Xif ((d = rindex(bname,'/')) != 0)
- X {
- X (void) strcpy(sysp, bname);
- X d = rindex(sysp, '/');
- X d[0] = '\0';
- X *d++;
- X (void) strcpy(bname,d);
- X }
- Xaf_initattrs(&buf);
- X
- X(void) strcpy(buf.af_name,bname);
- Xif (p != NIL)
- X (void) strcpy(buf.af_type,p);
- Xif(sysp[0] != '\0')
- X (void) strcpy(buf.af_syspath, sysp);
- Xelse
- X (void) strcpy(buf.af_syspath, curvpath[0]);
- Xif (af_find(&buf,set) == -1)
- X errexit(10,"af_find");
- X}
- X
- X
- X
- XBool evtl_set_busy(dep, test)
- X char *dep;
- X Bool test;
- X{
- X struct list *sellist;
- X FILE *tmp_fp;
- X FILE *afs_fp;
- X Af_attrs buf1;
- X Af_attrs buf2;
- X
- X Af_key key2;
- X Af_key keyt;
- X
- X Af_set set2;
- X Af_set sett;
- X
- X Bool t1;
- X Bool match = FALSE;
- X Bool full;
- X Bool has_attr = FALSE;
- X Bool busy_exist;
- X int ii = 0;
- X int tt = 0;
- X int uda = 0;
- X int pathind = 0;
- X char *pp;
- X char *ppp;
- X char *zzz;
- X char *pauth;
- X char dep2[MAXNAMLEN];
- X char *testdep;
- X char testpath[MAXNAMLEN];
- X char *testtype = NIL;
- X Af_attrs testbuf;
- X char *xxx;
- X int testi = 0;
- X int pathj;
- X Af_key testkey;
- X char *buf;
- X char tmpname[MAXNAMLEN];
- X char afsname[MAXNAMLEN];
- X char afslinkname[MAXNAMLEN];
- X
- X (void) strcpy(afsname,dep);
- X stopflg = FALSE;
- X
- X af_initattrs(&buf1);
- X af_initattrs(&buf2);
- X (void) strcpy(dep2,dep);
- X
- X if (exists_file(dep2, 2))
- X return(FALSE);
- X
- X t1 = exists_file(dep2,1);
- X if(t1)
- X {
- X if ((testdep = malloc(MAXNAMLEN)) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(testdep,dep2);
- X if ((xxx = rindex(testdep,'/')) != NIL)
- X {
- X *xxx = '\0';
- X (void) strcpy(testpath,testdep);
- X xxx++;
- X testdep = xxx;
- X }
- X else
- X (void) strcpy(testpath,actpath);
- X
- X if ((xxx = rindex(testdep,'.')) != NIL)
- X {
- X *xxx = '\0';
- X xxx++;
- X testtype = xxx;
- X }
- X else
- X testtype = NIL;
- X
- X if(af_getkey(testpath, testdep, testtype, AF_BUSYVERS, AF_BUSYVERS, NIL, &testkey) == -1)
- X {
- X if(af_getkey(testpath, testdep, testtype, AF_LASTVERS, AF_LASTVERS, NIL, &testkey) == -1)
- X errexit(10,"af_getkey");
- X }
- X if(af_gattrs(&testkey,&testbuf) == -1)
- X errexit(10,"af_gattrs");
- X while(testbuf.af_udattrs[testi] != NIL)
- X {
- X if(!strncmp(testbuf.af_udattrs[testi],ATTRNAME,10))
- X {
- X has_attr = TRUE;
- X break;
- X }
- X testi++;
- X }
- X
- X if((!has_attr) && (get_target(dep) == (struct rules *) NIL))
- X {
- X append_mtime(&testbuf,depth);
- X if((af_dropkey(&testkey)) == -1)
- X errexit(10,"af_dropkey");
- X free(testdep);
- X }
- X (void) strcpy(actpath, testpath);
- X if(has_attr)
- X {
- X if((af_dropkey(&testkey)) == -1)
- X errexit(10,"af_dropkey");
- X free(testdep);
- X return(FALSE);
- X }
- X }
- X
- X if (t1)
- X {
- X /* dep name matches? */
- X ii = 0;
- X while ((currule->predlist[ii] != (struct list *) NIL) && (match == FALSE))
- X {
- X if((currule->predlist[ii]->selfunc(dep,currule->predlist[ii]->parv)) == TRUE)
- X {
- X match = TRUE;
- X if (match == FALSE)
- X ii++;
- X }
- X if (match == TRUE)
- X {
- X if(currule->predlist[ii]->i == SMILEY)
- X {
- X (void) tunix(NIL,NIL,(Af_set *) NIL);
- X }
- X if(currule->predlist[ii]->i == GRIMMY)
- X {
- X (void) stopit(NIL,NIL,(Af_set *) NIL);
- X }
- X
- X (void) strcpy(dollarplus, dep);
- X
- X if (index(dep,'/') == NIL)
- X {
- X if(strcmp(actpath,""))
- X (void) strcpy(testpath,actpath);
- X else
- X (void) strcpy(testpath,curvpath[0]);
- X (void) strcat(testpath,"/");
- X (void) strcat(testpath,dep);
- X get_set(testpath,&set2);
- X }
- X else
- X get_set(dep,&set2);
- X
- X if (set2.af_setlen == 0)
- X return(TRUE);
- X
- X /* generate buffer */
- X af_initattrs(&buft);
- X /* insert unique attrs */
- X
- X if (af_setgkey(&set2,0, &key2) == -1)
- X errexit(10,"af_setgkey");
- X
- X if (af_dropset(&set2) == -1)
- X errexit(10,"af_dropset");
- X
- X if (af_gattrs(&key2,&buf2) == -1)
- X errexit(10,"af_gattrs");
- X
- X (void) strcpy(buft.af_name,buf2.af_name);
- X (void) strcpy(buft.af_type,buf2.af_type);
- X (void) strcpy(buft.af_syspath,buf2.af_syspath);
- X sellist = currule->predlist[ii];
- X while (sellist != (struct list *) NIL)
- X {
- X if((sellist->i == 0) && (test))
- X sellist->selfunc(sellist->parn,sellist->parv, (Af_set *) NIL);
- X sellist = sellist->cont;
- X }
- X sellist = currule->predlist[ii];
- X while (sellist != (struct list *) NIL)
- X {
- X tt = get_attr_type(sellist->parn);
- X if (sellist->i == 1)
- X {
- X switch (tt)
- X {
- X case 0:
- X buft.af_gen = atoi(sellist->parv);
- X break;
- X case 1:
- X buft.af_rev = atoi(sellist->parv);
- X break;
- X case 2:
- X buft.af_state = (short) get_state_no(sellist->parv);
- X if (buft.af_state == 99)
- X errexit(16, sellist->parv);
- X break;
- X case 3:
- X (void) strcpy(buft.af_author.af_username,sellist->parv);
- X if ((pauth = index(buft.af_author.af_username,'@')) != NIL)
- X {
- X *pauth = '\0';
- X pauth++;
- X (void) strcpy(buft.af_author.af_userhost, pauth);
- X }
- X break;
- X case 4:
- X errexit(10,"group id");
- X break;
- X case 5:
- X if ((ppp = malloc((unsigned) (strlen(sellist->parv) + 1))) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(ppp,sellist->parv);
- X if (( pp = index(ppp,'.')) == 0)
- X errexit(9,sellist->parv);
- X else
- X {
- X pp[0] = '\0';
- X buft.af_gen = atoi(ppp);
- X pp++;
- X buft.af_rev = atoi(pp);
- X }
- X break;
- X case 6:
- X /* variant */
- X break; /* evtl. set path & flags ???? */
- X case 7:
- X (void) strcpy(buft.af_syspath,sellist->parv);
- X break;
- X case 8:
- X (void) strcpy(buft.af_host,sellist->parv);
- X break;
- X default:
- X if ((buft.af_udattrs[uda] =
- X malloc((unsigned) (strlen(sellist->parv) + 1 + strlen(sellist->parn) + 1 + 1))) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(buft.af_udattrs[uda],sellist->parn);
- X (void) strcat(buft.af_udattrs[uda],"=");
- X (void) strcat(buft.af_udattrs[uda],sellist->parv);
- X uda++;
- X break;
- X }
- X }
- X/* else part by Sibylle */
- X else
- X {
- X if ((sellist->i == 2) && (tt > 5))
- X /* if sellist->selfunc is attrnot, attrlt, attrgt, */
- X /* attrle, attrge, attrmax or attrmin and parameter */
- X /* type is uda then it's more efficient to perform */
- X /* af_find on said uda. Hence parn is copied to buft. */
- X {
- X if ((buft.af_udattrs[uda] =
- X malloc((unsigned) (strlen(sellist->parn) + 1))) == NIL)
- X errexit(10,"malloc");
- X (void) strcpy(buft.af_udattrs[uda],sellist->parn);
- X uda++;
- X break;
- X }
- X }
- X
- X sellist = sellist->cont;
- X }
- X /* af_find with this buffer */
- X
- X pathj = pathi;
- X while(curvpath[pathj] == NIL)
- X pathj--;
- X
- X for(pathind = pathj; pathind >= 0; pathind--)
- X {
- X if ((zzz = rindex(dep,'/')) == NIL)
- X {
- X (void) strcpy(buft.af_syspath,curvpath[pathind]);
- X }
- X else
- X {
- X (void) strcpy(buft.af_syspath,dep);
- X zzz = rindex(buft.af_syspath,'/');
- X *zzz = '\0';
- X }
- X if (af_find(&buft,&sett) == -1)
- X errexit(10,"af_find");
- X if (sett.af_nkeys != 0)
- X {
- X sellist = currule->predlist[ii];
- X full = TRUE;
- X while((sellist != (struct list *) NIL) && (full))
- X {
- X if (sellist->i == 2)
- X {
- X full = sellist->selfunc(sellist->parn, sellist->parv, &sett);
- X }
- X sellist = sellist->cont;
- X }
- X }
- X if (sett.af_nkeys == 1)
- X {
- X /* ==> successful */
- X if (test == FALSE)
- X return(TRUE);
- X if (af_setgkey(&sett,0,&keyt) == -1)
- X errexit(10,"af_setgkey");
- X if(af_gattrs(&keyt,&buft) == -1)
- X errexit(10,"af_gattrs");
- X if(confid == TRUE)
- X write_confid(&buft);
- X
- X append_attrs(&buft,depth);
- X
- X if ((buft.af_state != AF_BUSY ) || (expflg))
- X {
- X /* link, unlink, set busy */
- X if ((afs_fp = af_open(&keyt,"r")) == NULL)
- X errexit(10,"af_open");
- X
- X /* creation of a temporary file for the old revision */
- X (void) strcpy(tmpname,mktemp("shapeXXXXXX"));
- X if ((tmp_fp = fopen(tmpname, "w")) == NULL)
- X errexit(10,"could not create tmpfile");
- X
- X /* copy old revision into temp. file */
- X if ((buf = malloc((unsigned) buft.af_size)) == NIL)
- X errexit(10,"malloc");
- X (void) fread(buf,sizeof(char),(int) buft.af_size,afs_fp);
- X
- X if(noexpflg)
- X (void) fwrite(buf,sizeof(char),(int) buft.af_size,tmp_fp);
- X else
- X WriteXPand(buf,buft.af_size,tmp_fp,&keyt);
- X free(buf);
- X af_close(afs_fp);
- X (void) fclose(tmp_fp);
- X if (buft.af_syspath == NIL)
- X {
- X (void) strcpy(afsname,curvpath[0]);
- X (void) strcat(afsname,"/");
- X }
- X else
- X {
- X (void) strcpy(afsname,buft.af_syspath);
- X (void) strcat(afsname,"/");
- X }
- X (void) strcat(afsname,buft.af_name);
- X (void) strcat(afsname,".");
- X (void) strcat(afsname,buft.af_type);
- X if(buft.af_syspath == NIL)
- X {
- X (void) strcpy(afslinkname,curvpath[0]);
- X (void) strcat(afslinkname,"/AFS/");
- X }
- X else
- X {
- X (void) strcpy(afslinkname,buft.af_syspath);
- X (void) strcat(afslinkname,"/AFS/");
- X }
- X (void) strcat(afslinkname,buft.af_name);
- X (void) strcat(afslinkname,".");
- X (void) strcat(afslinkname,buft.af_type);
- X (void) strcat(afslinkname,"XXXXXX");
- X (void) strcpy(afslinkname, mktemp(afslinkname));
- X
- X /* save busy version into AFS directory */
- X (void) link(afsname,afsname);
- X if (errno == EEXIST)
- X {
- X busy_exist = TRUE;
- X if (link(afsname,afslinkname) != 0)
- X errexit(20, dep);
- X if (unlink(afsname) != 0)
- X errexit(21, afsname);
- X }
- X else
- X busy_exist = FALSE;
- X if (link(tmpname,afsname) != 0)
- X errexit(22, afsname);
- X if (unlink(tmpname) != 0)
- X errexit(21, tmpname);
- X register_link(afsname,afslinkname,busy_exist);
- X if (buft.af_state != AF_BUSY)
- X busy_done = TRUE;
- X return (TRUE);
- X }
- X else
- X return(TRUE);
- X }
- X }
- X if ((sett.af_nkeys == 0) && (currule->predlist[ii+1] == (struct list *) NIL) && (!tunixflg))
- X {
- X if ((get_target(dep2)) != (struct rules *) NIL)
- X return(TRUE);
- X else
- X errexit(17,dep2);
- X }
- X else
- X /* next predicate */
- X {
- X if (stopflg)
- X errexit(28,dep);
- X if(tunixflg)
- X {
- X tunixflg = FALSE;
- X return(FALSE);
- X }
- X if (af_dropset(&sett) == -1)
- X errexit(10,"af_dropset");
- X
- X }
- X }
- X ii++;
- X stopflg = FALSE;
- X match = FALSE;
- X reset_vclass();
- X } /* end while */
- X
- X/* if (buft.af_syspath != NIL)
- X {
- X (void) strcpy(afsname,buft.af_syspath);
- X (void) strcat(afsname,"/");
- X (void) strcat(afsname,dep);
- X }
- X (void) link(afsname,afsname);
- X if ((buft.af_state == AF_BUSY) && (errno == EEXIST))
- X return(TRUE);
- X*/
- X if ((match == FALSE) && (currule->predlist[ii] == (struct list *) NIL))
- X {
- X if ((get_target(dep)) != (struct rules *) NIL)
- X return(TRUE);
- X else
- X errexit(17,dep);
- X }
- X }
- X /*NOTREACHED*/
- X return(FALSE);
- X}
- X
- X
- X
- Xint init_confid(name)
- X char *name;
- X{
- X fprintf(cid,"###### CONFID for %s ######\n", name);
- X fprintf(cid,"\n");
- X fprintf(cid,"#%% RULE-SECTION\n");
- X fprintf(cid,"@%s:\n", name);
- X}
- X
- X
- X
- Xint write_confid(buf)
- X Af_attrs *buf;
- X{
- X fprintf(cid,"\t%s.%s,\n", buf->af_name, buf->af_type);
- X
- X fprintf(cid,"\tattr(host,%s),\n", buf->af_host);
- X
- X fprintf(cid,"\tattr(syspath,%s),\n", buf->af_syspath);
- X
- X/* fprintf(cid,"\tattr(type,%s),\n", buf->af_type); */
- X
- X if(buf->af_gen != AF_BUSYVERS)
- X {
- X fprintf(cid,"\tattr(generation,%d),\n", buf->af_gen);
- X
- X fprintf(cid,"\tattr(revision,%d),\n", buf->af_rev);
- X }
- X
- X if (strcmp(buf->af_variant,""))
- X fprintf(cid,"\tattr(variant,%s),\n", buf->af_variant);
- X
- X if (buf->af_state != AF_FROZEN)
- X {
- X fprintf(cid,"\tmsg(warning: confid contains %s version for %s.%s),\n",
- X states[buf->af_state], buf->af_name, buf->af_type);
- X fprintf(stderr,"shape - warning: confid contains %s version for %s.%s\n",
- X states[buf->af_state], buf->af_name, buf->af_type);
- X }
- X
- X fprintf(cid,"\tattr(state,%s),\n", states[buf->af_state]);
- X/* fprintf(cid,"\tattr(owner,%s@%s),\n",
- X buf->af_owner.af_username, buf->af_owner.af_userhost); */
- X
- X fprintf(cid,"\tattr(author,%s@%s)",
- X buf->af_author.af_username, buf->af_author.af_userhost);
- X
- X/* fprintf(cid,"\tattr(size,%d),\n", buf->af_size); */
- X
- X/* fprintf(cid,"\tattr(mode,%d),\n", buf->af_mode); */
- X
- X/* if(strcmp(buf->af_locker.af_username,""))
- X fprintf(cid,"\tattr(locker,%s@%s),\n",
- X buf->af_locker.af_username, buf->af_locker.af_userhost); */
- X
- X/* fprintf(cid,"\tattr(mtime,%d),\n", buf->af_mtime); */
- X
- X/* fprintf(cid,"\tattr(atime,%d),\n", buf->af_atime); */
- X
- X/* fprintf(cid,"\tattr(ctime,%d),\n", buf->af_ctime); */
- X
- X/* fprintf(cid,"\tattr(stime,%d),\n", buf->af_stime); */
- X
- X/* fprintf(cid,"\tattr(ltime,%d)", buf->af_ltime); */
- X
- X fprintf(cid,";\n");
- X
- X fprintf(cid,"\n");
- X (void) fflush(cid);
- X}
- X
- Xint finish_confid()
- X
- X{
- X fprintf(cid,"\t:-\) SMILEY,\n\tmsg\(\"Just to get a . to the end of the rule\"\).\n\n");
- X fprintf(cid,"#%% END-RULE-SECTION\n");
- X fprintf(cid,"\n");
- X dump(cid);
- X ruledump(cid);
- X vardump(cid);
- X}
- X
- X
- XFILE *cmfopen( filename, mode, gen,rev)
- X char *filename;
- X char *mode;
- X /*ARGSUSED*/
- X int gen;
- X int rev;
- X{
- X char syspath[MAXNAMLEN];
- X char *name = NIL;
- X char *type = NIL;
- X
- X Af_key key;
- X
- X char *ind;
- X char *ind2;
- X char *basename;
- X FILE *fp;
- X char fname[MAXNAMLEN];
- X (void) strcpy(fname, filename);
- X
- X if ((ind = rindex(fname,'/')) == NIL)
- X {
- X (void) strcpy(syspath,curvpath[0]);
- X basename = fname;
- X }
- X else
- X {
- X ind[0] = '\0';
- X ind++;
- X basename = ind;
- X (void) strcpy(syspath,fname);
- X }
- X
- X if ((ind2 = rindex(basename,'.')) == NIL)
- X {
- X name = basename;
- X }
- X else
- X {
- X ind2[0] = '\0';
- X ind2++;
- X type = ind2;
- X name = basename;
- X }
- X if(af_crkey(syspath, name, type,&key) == -1)
- X errexit(10,"af_crkey");
- X else
- X {
- X fp = af_open(&key, mode);
- X return (fp);
- X }
- X return((FILE *) NIL);
- X}
- END_OF_FILE
- if test 27004 -ne `wc -c <'src/shape/files.c'`; then
- echo shar: \"'src/shape/files.c'\" unpacked with wrong size!
- fi
- # end of 'src/shape/files.c'
- fi
- echo shar: End of archive 24 \(of 33\).
- cp /dev/null ark24isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 33 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-