home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume19 / shape / part06 < prev    next >
Text File  |  1989-05-31  |  56KB  |  1,914 lines

  1. Subject:  v19i019:  A software configuration management system, Part06/33
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Axel Mahler <unido!coma!axel>
  7. Posting-number: Volume 19, Issue 19
  8. Archive-name: shape/part06
  9.  
  10.  
  11.  
  12. #! /bin/sh
  13. # This is a shell archive.  Remove anything before this line, then unpack
  14. # it by saving it into a file and typing "sh file".  To overwrite existing
  15. # files, type "sh file -c".  You can also feed this as standard input via
  16. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  17. # will see the following message at the end:
  18. #        "End of archive 6 (of 33)."
  19. # Contents:  man/man3/afretrieve.3 man/man5/afarchive.5
  20. #   src/afs/afarchive.h src/afs/aflock.c src/afs/afsysc.c
  21. #   src/afs/bsfd.c src/shape/hash.c src/shape/shape.h
  22. #   src/vc/vc_files.c src/vc/vc_lock.c
  23. # Wrapped by rsalz@papaya.bbn.com on Thu Jun  1 19:26:54 1989
  24. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  25. if test -f 'man/man3/afretrieve.3' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'man/man3/afretrieve.3'\"
  27. else
  28. echo shar: Extracting \"'man/man3/afretrieve.3'\" \(5193 characters\)
  29. sed "s/^X//" >'man/man3/afretrieve.3' <<'END_OF_FILE'
  30. X...
  31. X... Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  32. X...  and U. Pralle
  33. X... 
  34. X... This software is published on an as-is basis. There is ABSOLUTELY NO
  35. X... WARRANTY for any part of this software to work correctly or as described
  36. X... in the manuals. We do not accept any liability for any kind of damage
  37. X... caused by use of this software, such as loss of data, time, money, or 
  38. X... effort.
  39. X... 
  40. X... Permission is granted to use, copy, modify, or distribute any part of
  41. X... this software as long as this is done without asking for charge, and
  42. X... provided that this copyright notice is retained as part of the source
  43. X... files. You may charge a distribution fee for the physical act of
  44. X... transferring a copy, and you may at your option offer warranty
  45. X... protection in exchange for a fee.
  46. X... 
  47. X... Direct questions to: Tech. Univ. Berlin
  48. X...              Wilfried Koch
  49. X...              Sekr. FR 5-6 
  50. X...              Franklinstr. 28/29
  51. X...              D-1000 Berlin 10, West Germany
  52. X... 
  53. X...              Tel: +49-30-314-22972
  54. X...              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  55. X... 
  56. X.TH AF_RETRIEVE 3 "" \n(dy.\n(mo.\n(yr
  57. X.SH NAME
  58. Xaf_retrieve \(em retrieve interface of the Attribute Filesystem
  59. X.SH SYNOPSIS
  60. X\fB#include <sys/dir.h>
  61. X.br
  62. X#include <sys/param.h>
  63. X.br
  64. X#include <afs.h>
  65. X.sp
  66. Xaf_find (attrbuf, resultset)
  67. X.br
  68. XAf_attrs    *attrbuf;
  69. X.br
  70. XAf_set    *resultset;
  71. X.sp
  72. Xaf_bpfind (attrbuf, resultset)
  73. X.br
  74. XAf_attrs    *attrbuf;
  75. X.br
  76. XAf_set    *resultset;
  77. X.sp
  78. Xaf_initattrs (attrbuf)
  79. X.br
  80. XAf_attrs    *attrbuf;
  81. X.sp
  82. Xaf_getkey (syspath, name, type, gen, rev, var, key)
  83. X.br
  84. Xchar    *syspath, *name, *type;
  85. X.br
  86. Xint    gen, rev;
  87. X.br
  88. Xchar    *var;
  89. X.br
  90. XAf_key    *key;
  91. X.sp
  92. Xaf_dropkey (key)
  93. X.br
  94. XAf_key    *key;
  95. X.SH DESCRIPTION
  96. X\fIAf_find\fR and \fIaf_bpfind\fR retrieve ASOs by given attributes.
  97. X\fIAf_find\fR operates on source objects and \fIaf_bpfind\fR only on
  98. Xderived objects.
  99. XThe keys of all found ASOs are returned in \fIresultset\fR. 
  100. XThe set is not ordered in any way.
  101. XThe retrieve arguments are passed in \fIattrbuf\fR.
  102. X\fIAttrbuf\fR should be initialized by \fIaf_initattrs\fR before
  103. Xcalling \fIaf_find\fR.
  104. X.LP
  105. XThe structure of \fIattrbuf\fR is the following:
  106. X.nf
  107. X.ta 0.4i 1i 3.2i
  108. Xtypedef struct {
  109. X    char    af_host[MAXHOSTNAMELEN];    /* hostname */
  110. X    char    af_syspath[MAXNAMLEN];    /* system path */
  111. X    char    af_name[MAXNAMLEN];    /* name */
  112. X    char    af_type[MAXTYPLEN];    /* type */
  113. X    int    af_gen;    /* generation number */
  114. X    int    af_rev;    /* revision number */
  115. X    char    af_variant[MAXVARLEN];    /* variant attribute */
  116. X    int    af_state;    /* version state */
  117. X    Af_user    af_owner;    /* owner */
  118. X    Af_user    af_author;    /* author */
  119. X    off_t    af_size;    /* size of file */
  120. X    u_short    af_mode;    /* protection */
  121. X    Af_user    af_locker;    /* locker */
  122. X    time_t    af_mtime;    /* date of last modification */
  123. X    time_t    af_atime;    /* date of last access */
  124. X    time_t    af_ctime;    /* date of last status change*/
  125. X    time_t    af_stime;    /* save date */
  126. X    time_t    af_ltime;    /* date of last lock change */
  127. X    char    *af_udattrs[AF_MAXUDAS];    /* user defined attributes */
  128. X} Af_attrs;
  129. X.fi
  130. X.PP
  131. XA retrieve operation is always limited to one directory.
  132. XIf no syspath is given in the attribute buffer, the current directory
  133. Xis searched.
  134. X.PP
  135. XIt is possible to pass a list of \fIuser defined attributes\fR as
  136. Xretrieve arguments.
  137. XThe list of pointers \fIaf_udattrs\fR in \fIattrbuf\fR can be associated
  138. Xwith strings of the form name[=value].
  139. XThe list must be terminated by a nil pointer.
  140. X.PP
  141. XIt is interpreted in the following way:
  142. X.IP "\fIempty list\fR (first entry is a nil pointer)"
  143. Xmatches every ASO.
  144. X.IP "\fI""""\fR (first entry is an empty string)"
  145. Xmatches every ASO that has \fBno\fR user defined attributes.
  146. X.IP "\fIname\fR[\fI=\fR]"
  147. Xmatches, if a user defined attribute with the given name
  148. Xis present.
  149. X.IP "\fIname=value\fR"
  150. Xmatches all ASOs that have a corresponding user defined
  151. Xattribute, that has at least the given value.
  152. X.PP
  153. XA set generated by \fIaf_find\fR should be released by \fIaf_dropset\fR
  154. Xas soon as it will not be used any longer.
  155. X.PP
  156. X\fIAf_getkey\fR builds up an object key by unique attributes (pathname, name,
  157. Xtype, generation number, revision number and variant name).
  158. XUpon successful completion, the found object key is
  159. Xreturned in the buffer \fIkey\fR. \fIAf_getkey\fR works only on
  160. Xsource objects.
  161. X.PP
  162. XInstead of explicit version numbers, you can pass the pseudo-numbers
  163. X\fIAF_BUSYVERS\fR, \fIAF_FIRSTVERS\fR or \fIAF_LASTVERS\fR to \fIaf_getkey\fR.
  164. X.br
  165. XThe call \fCaf_getkey ("", "otto", "c", AF_BUSYVERS, AF_BUSYVERS)\fR leads
  166. Xto the key of the busy version of the ASO named otto (type c) in
  167. Xyour current context.
  168. X.br
  169. X\fCAf_getkey ("", "otto", "c", AF_LASTVERS, AF_LASTVERS)\fR delivers the
  170. Xlast saved Version (if present).
  171. X.PP
  172. XUse \fIaf_dropkey\fR to free the allocated memory associated with \fIkey\fR.
  173. X.SH SEE ALSO
  174. Xaf_dropset(3)
  175. X.SH DIAGNOSTICS
  176. X\fIAf_find\fR returns the number of found ASOs.
  177. XUpon error, -1 is returned and \fIaf_errno\fR is set to the corresponding
  178. Xerror number.
  179. X.SH BUGS
  180. XA given hostname will be ignored during \fIaf_find\fR.
  181. X.PP
  182. XIn \fIaf_getkey\fR, the \fIvariant\fR argument is ignored.
  183. X.PP
  184. XMixed version numbering in calls of af_getkey 
  185. X(eg. \fIgetkey ("", "otto", "c", AF_LASTVERS, 1)\fR or
  186. X\fIgetkey ("", "otto", "c", AF_FIRSTVERS, AF_LASTVERS)\fR are not supported.
  187. END_OF_FILE
  188. if test 5193 -ne `wc -c <'man/man3/afretrieve.3'`; then
  189.     echo shar: \"'man/man3/afretrieve.3'\" unpacked with wrong size!
  190. fi
  191. # end of 'man/man3/afretrieve.3'
  192. fi
  193. if test -f 'man/man5/afarchive.5' -a "${1}" != "-c" ; then 
  194.   echo shar: Will not clobber existing file \"'man/man5/afarchive.5'\"
  195. else
  196. echo shar: Extracting \"'man/man5/afarchive.5'\" \(4579 characters\)
  197. sed "s/^X//" >'man/man5/afarchive.5' <<'END_OF_FILE'
  198. X...
  199. X... Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  200. X...  and U. Pralle
  201. X... 
  202. X... This software is published on an as-is basis. There is ABSOLUTELY NO
  203. X... WARRANTY for any part of this software to work correctly or as described
  204. X... in the manuals. We do not accept any liability for any kind of damage
  205. X... caused by use of this software, such as loss of data, time, money, or 
  206. X... effort.
  207. X... 
  208. X... Permission is granted to use, copy, modify, or distribute any part of
  209. X... this software as long as this is done without asking for charge, and
  210. X... provided that this copyright notice is retained as part of the source
  211. X... files. You may charge a distribution fee for the physical act of
  212. X... transferring a copy, and you may at your option offer warranty
  213. X... protection in exchange for a fee.
  214. X... 
  215. X... Direct questions to: Tech. Univ. Berlin
  216. X...              Wilfried Koch
  217. X...              Sekr. FR 5-6 
  218. X...              Franklinstr. 28/29
  219. X...              D-1000 Berlin 10, West Germany
  220. X... 
  221. X...              Tel: +49-30-314-22972
  222. X...              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  223. X... 
  224. X.TH AF_ARCHIVE 5 "" \n(dy.\n(mo.\n(yr
  225. X.SH NAME
  226. Xaf_archive -- format of archive files in the \fIAttribute Filesystem\fR
  227. X.SH SYNOPSIS
  228. X\fB#include <afs.h>
  229. X.br
  230. X#include <afsys.h>
  231. X.SH DESCRIPTION
  232. XAFS archive files are used to store the data and attributes of
  233. Xnon-busy ASOs.
  234. XBeside these, some attributes (including all user defined attributes)
  235. Xof busy ASOs are stored in AFS archive files.
  236. X.PP
  237. XAFS maintains two archive files for each line of development \-
  238. Xone to hold the standard- and the user defined attributes and
  239. Xthe other to hold the data and change notes.
  240. XThese files are stored either in a subdirectory named \fCAFS\fR
  241. Xor in a explicitly named directory somewhere in your file system.
  242. XThe two archive files are named (\(lq\fC^B\fR\(rq stands for \(lqCtrl-B\(rq)
  243. X.br
  244. X    \fC^BA\fR<filename>\fCA\fR        (attributes) and
  245. X.br
  246. X    \fC^BA\fR<filename>\fCD\fR        (data).
  247. X.PP
  248. XThis manual contains a short, exemplary description of the archive structure.
  249. XApart from deltas, all data in AFS-archives are stored as ASCII-strings.
  250. XThe archives contain keywords that have the form \fC^B\fR<key>.
  251. XIn the following description, strings of the form \fI<field>\fR describe
  252. Xthe purpose of the appropriate field in the archive.
  253. X.PP
  254. XHere's the structure (the attributes file first):
  255. X.sp
  256. X.ce
  257. XThe Header, ...
  258. X.nf
  259. X.sp
  260. X\fC^BARHD\fR   <archive_format_version>   <no_of_revisions>   <size_of_data>
  261. X.sp
  262. X.ce
  263. X\&... the name ..
  264. X.sp
  265. X\fC^BI\fR   <hostname>   <path>   <name>   <type>   <variant>
  266. X.sp
  267. X.ce
  268. X\&... and the owner ..
  269. X.sp
  270. X\fC^BO\fR   <owner's_name>   <owner's_host>
  271. X.sp
  272. X.ce
  273. X\&... followed by some attributes for the busy version ...
  274. X.sp
  275. X\fC^BP\fR   <gen_>   <rev_of_physical_predecessor>
  276. X.br
  277. X\fC^BL\fR   <locker's_name>   <locker's_host>   <dat_of_last_lock_change>
  278. X.ce 2
  279. X\&... and the revision list, that contains all standard 
  280. Xattributes for non-busy versions. ... 
  281. X.sp
  282. X\fC^R\fR   <generation>   <revision>   <state>   <mode>   <variant>
  283. X.br
  284. X    \fC^BA\fR   <author's_name>   <_host>   <locker's_name>   <_host>
  285. X.br
  286. X    \fC^BT\fR   <date_of_last_modification>   <_last_access>   <_last_status_change>   ...
  287. X.in +3.3i
  288. X\&...   <_saving>   <_locking>
  289. X.in -3.3i
  290. X    \fC^BM\fR   <kind_of_representation>   <size_of_file>   <size_of_delta>   ...
  291. X.br
  292. X            ...   <gen_>   <rev_of_phys._successor>   <gen_>   <rev_of_phys._predecessor>
  293. X.br
  294. X\fC^BR ...\fR
  295. X.br
  296. X\fC^BR ...\fR
  297. X.sp
  298. X.ce 2
  299. X\&... Now follows a list of lists of user defined attributes
  300. X("-2 -2" indicates the busy version; "\fC@\fR" stands for a null byte). ...
  301. X.sp
  302. X\fC^BUSEG\fR
  303. X\fC^BU -2 -2\fR   <size_of_user_def_attributes>
  304. X\fCmachine=vax@data=fs@@\fR
  305. X\fC^BU\fR   <gen>   <rev>   <size_of_user_def_attributes>
  306. X\fCname=value@@\fR
  307. X\fC^BU ...\fR
  308. X.sp 0.5i
  309. XThe structure of the datafile:
  310. X.sp
  311. XData are represented either by deltas or by complete data-chunks...
  312. X.sp
  313. X\fC^BDATA\fR
  314. X.sp
  315. X\fC^BN\fR   <gen>   <rev>   <size_of_note>
  316. X\fC--- empty log message ---\fR
  317. X.sp
  318. X\fC^BD\fR   <gen>   <rev>   <kind_of_representation>   <size_of_data>
  319. X\fCA typical delta looks like:\fR
  320. X\fC"^A^?hg^some text^@^%^Gmore text^?^?$^D^E" and so on.\fR
  321. X\fCDeltas are indicated by a "1" at the "kind_of_representation" field.
  322. X.sp
  323. X\fC^BN\fR   <gen>   <rev>   <size_of_note>
  324. X\fCThis is a log message\fR
  325. X.sp
  326. X\fC^BD\fR   <gen>   <rev>   <kind_of_representation>   <size_of_data>
  327. X\fCA "0" at the "kind_of_representation" field indicates that this version\fR
  328. X\fCis stored completely.\fR
  329. X.sp
  330. X\fC^BN ...\fR
  331. X.sp
  332. X\fC^BD ...\fR
  333. X.fi
  334. X.SH AUTHOR
  335. XAndreas Lampen, TU Berlin
  336. X.br
  337. X.ta 0.7i
  338. XUUCP:    unido!coma!andy
  339. X.br
  340. XBITNET:    andy@db0tui62
  341. END_OF_FILE
  342. if test 4579 -ne `wc -c <'man/man5/afarchive.5'`; then
  343.     echo shar: \"'man/man5/afarchive.5'\" unpacked with wrong size!
  344. fi
  345. # end of 'man/man5/afarchive.5'
  346. fi
  347. if test -f 'src/afs/afarchive.h' -a "${1}" != "-c" ; then 
  348.   echo shar: Will not clobber existing file \"'src/afs/afarchive.h'\"
  349. else
  350. echo shar: Extracting \"'src/afs/afarchive.h'\" \(4674 characters\)
  351. sed "s/^X//" >'src/afs/afarchive.h' <<'END_OF_FILE'
  352. X/*
  353. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  354. X *  and U. Pralle
  355. X * 
  356. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  357. X * WARRANTY for any part of this software to work correctly or as described
  358. X * in the manuals. We do not accept any liability for any kind of damage
  359. X * caused by use of this software, such as loss of data, time, money, or 
  360. X * effort.
  361. X * 
  362. X * Permission is granted to use, copy, modify, or distribute any part of
  363. X * this software as long as this is done without asking for charge, and
  364. X * provided that this copyright notice is retained as part of the source
  365. X * files. You may charge a distribution fee for the physical act of
  366. X * transferring a copy, and you may at your option offer warranty
  367. X * protection in exchange for a fee.
  368. X * 
  369. X * Direct questions to: Tech. Univ. Berlin
  370. X *              Wilfried Koch
  371. X *              Sekr. FR 5-6 
  372. X *              Franklinstr. 28/29
  373. X *              D-1000 Berlin 10, West Germany
  374. X * 
  375. X *              Tel: +49-30-314-22972
  376. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  377. X */
  378. X/*
  379. X *    Shape/AFS
  380. X *
  381. X *    afarchive.h - Constant-Definitions for AFS-archives
  382. X *
  383. X *    Author:    Andreas Lampen (andy@coma.UUCP
  384. X *                andy@db0tui62.BITNET)
  385. X *
  386. X *    $Header: afarchive.h[1.2] Wed Feb 22 16:27:08 1989 andy@coma published $
  387. X *
  388. X */
  389. X
  390. X/*=========================================================================
  391. X * Internal Installation dependent constants
  392. X *=========================================================================*/
  393. X
  394. X#define AF_NEWREVS      8    /* add. space for new revisions in rev list */
  395. X#define AF_MAXLISTS   211       /* maximum number of read-in archives */
  396. X#define AF_LISTSEG      8       /* size of segments of revlists-list */
  397. X
  398. X#define AF_BPOOLSIZE   64       /* max number of files in binary pool */
  399. X                                /* should be determined dynamically */
  400. X#define MAXDBMLEN    1024       /* maximum size of dbm-datastring */
  401. X#define DBMLOSS         8       /* size of management data in dbm entry */
  402. X                                /* ( 2 * sizeof (int)) */
  403. X
  404. X/*=========================================================================
  405. X * Identification strings in archive and binary pool files
  406. X *=========================================================================*/
  407. X
  408. X#define AF_LINESIZ      1024            /* size of input line */
  409. X
  410. X#define AF_SEGSTRLEN    5
  411. X#define AF_ARHEADER     "\02ARHD"    /* Header of Archive-file */
  412. X#define AF_DATAHEADER     "\02DATA"    /* Header of Data-file */
  413. X#define AF_BPHEADER     "\02BPHD"    /* Header of Binary-pool-file */
  414. X#define AF_UDASEG     "\02USEG"    /* User defined attributes Segment */
  415. X
  416. X#define AF_IDSTRLEN     2
  417. X#define AF_NAMEID    "\02I"     /* Identification path, name, type */ 
  418. X#define AF_OWNID    "\02O"     /* Owner */
  419. X#define AF_PRDID    "\02P"     /* predecessor of busy version */
  420. X#define AF_LOCKID    "\02L"     /* Lock */
  421. X#define AF_REVID    "\02R"     /* revision specific attributes */
  422. X                /* gen, rev, state, mode */
  423. X#define AF_AUTHORID    "\02A"     /* Author */
  424. X#define AF_DATEID    "\02T"     /* date of last mod., last access, */
  425. X                /* creation, save */
  426. X#define AF_REPRID    "\02M"     /* kind of represetation, size of file, size */
  427. X                /* of delta and other delta stuff (tree) */
  428. X#define AF_NOTEID    "\02N"     /* gen, rev, size, text of note */
  429. X#define AF_UDAID    "\02U"     /* gen, rev, size, text of udattrs */
  430. X#define AF_DATAID    "\02D"     /* gen, rev, size, repr, text of data */
  431. X
  432. X#define AF_BPFILEID     "\02B"  /* filename prefix for BP files */
  433. X#define AF_AFSFILEID    "\02A"  /* filename prefix for AFS archives */
  434. X
  435. X/******* binary pool specific stuff *********/
  436. X#define AF_BPSTDENTRY   "\01##" /* dbm entry name for special information */
  437. X#define AF_BPOOLNAME    "\02Bpool"
  438. X
  439. X/*======================================================================
  440. X * other constants
  441. X *======================================================================*/
  442. X
  443. X#define AF_ARCHMODE     0444
  444. X#define AF_ARCURVERS    1
  445. X#define AF_BPCURVERS    1
  446. X
  447. X#define AF_NOSTRING     "\01$"
  448. X
  449. X/**** extent and type of revision list ****/
  450. X
  451. X#define AF_ATTRS    0001   /* Attributes are loaded */
  452. X#define AF_DATA        0002   /* Data are loaded */
  453. X#define AF_ALLSEGS    0003   /* Attributes and Data are loaded */
  454. X#define AF_COMPLETE     0004   /* List is complete (binary pools only) */
  455. X
  456. X#define AF_BPOOL        0010   /* Binary pool */
  457. X#define AF_ARCHIVE      0020   /* Line of development */
  458. X
  459. X#define AF_UXWRITE      0100   /* Unix write permission on AFS subdir */
  460. X
  461. X/*=========================================================================
  462. X * Useful macros
  463. X *=========================================================================*/
  464. X
  465. X/* test if string is empty */
  466. X#define NOTMT(str) ((str && str[0]) ? str : AF_NOSTRING)
  467. X
  468. END_OF_FILE
  469. if test 4674 -ne `wc -c <'src/afs/afarchive.h'`; then
  470.     echo shar: \"'src/afs/afarchive.h'\" unpacked with wrong size!
  471. fi
  472. # end of 'src/afs/afarchive.h'
  473. fi
  474. if test -f 'src/afs/aflock.c' -a "${1}" != "-c" ; then 
  475.   echo shar: Will not clobber existing file \"'src/afs/aflock.c'\"
  476. else
  477. echo shar: Extracting \"'src/afs/aflock.c'\" \(5339 characters\)
  478. sed "s/^X//" >'src/afs/aflock.c' <<'END_OF_FILE'
  479. X/*
  480. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  481. X *  and U. Pralle
  482. X * 
  483. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  484. X * WARRANTY for any part of this software to work correctly or as described
  485. X * in the manuals. We do not accept any liability for any kind of damage
  486. X * caused by use of this software, such as loss of data, time, money, or 
  487. X * effort.
  488. X * 
  489. X * Permission is granted to use, copy, modify, or distribute any part of
  490. X * this software as long as this is done without asking for charge, and
  491. X * provided that this copyright notice is retained as part of the source
  492. X * files. You may charge a distribution fee for the physical act of
  493. X * transferring a copy, and you may at your option offer warranty
  494. X * protection in exchange for a fee.
  495. X * 
  496. X * Direct questions to: Tech. Univ. Berlin
  497. X *              Wilfried Koch
  498. X *              Sekr. FR 5-6 
  499. X *              Franklinstr. 28/29
  500. X *              D-1000 Berlin 10, West Germany
  501. X * 
  502. X *              Tel: +49-30-314-22972
  503. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  504. X */
  505. X/*LINTLIBRARY*/
  506. X/*
  507. X *    Shape/AFS
  508. X *
  509. X *    aflock.c -- Version locking
  510. X *
  511. X *    Author: Andreas Lampen, TU-Berlin (andy@coma.UUCP)
  512. X *                      (andy@db0tui62.BITNET)
  513. X *
  514. X *    $Header: aflock.c[1.4] Wed Feb 22 16:27:44 1989 andy@coma published $
  515. X *
  516. X *    EXPORT:
  517. X *    af_lock -- lock busy version
  518. X *    af_unlock -- unlock version
  519. X *    af_testlock -- test if version is locked
  520. X */
  521. X
  522. X#include <stdio.h>
  523. X#include <string.h>
  524. X#ifdef SUNOS_4_0
  525. X#include <strings.h>
  526. X#endif
  527. X#include <sys/types.h>
  528. X#include <sys/stat.h>
  529. X
  530. X#include "typeconv.h"
  531. X#include "afsys.h"
  532. X#include "afs.h"
  533. X#include "afarchive.h"
  534. X
  535. X/*================================================================
  536. X *    af_lock
  537. X *
  538. X *================================================================*/
  539. X
  540. XEXPORT Af_user *af_lock (key, locker, mode)
  541. X     Af_key  *key;
  542. X     Af_user *locker;
  543. X     int     mode;
  544. X{
  545. X  int oldlockeruid, newlockeruid, calleruid;
  546. X  Af_key lkey, *lkp;
  547. X
  548. X  if (af_keytest (key))
  549. X    SFAIL ("lock", "", AF_EINVKEY, (Af_user *)0);
  550. X  
  551. X  if ((VATTR(key).af_mode & S_IFMT) != S_IFREG)
  552. X    SFAIL ("lock", "", AF_ENOTREGULAR, (Af_user *)0);
  553. X
  554. X  if (VATTR(key).af_class & AF_DERIVED)
  555. X    SFAIL ("lock", "", AF_EDERIVED, (Af_user *)0);
  556. X
  557. X  /* if caller == locker, everyone who has write access may set a lock, */
  558. X  /*                      if the object is not locked by someone else */
  559. X  /* else (caller != locker), only the owner may set a lock for someone else */
  560. X
  561. X  newlockeruid = af_getuid (locker->af_username, locker->af_userhost);
  562. X  calleruid = getuid ();
  563. X
  564. X  if (calleruid == newlockeruid)
  565. X    {
  566. X      if (af_checkperm (key, AF_WORLD) == ERROR)
  567. X    return ((Af_user *)0);
  568. X    }
  569. X  else
  570. X    {
  571. X      if (af_checkperm (key, AF_OWNER) == ERROR)
  572. X    return ((Af_user *)0);
  573. X    }
  574. X
  575. X  lkp = &lkey;
  576. X  lkp->af_ldes = key->af_ldes;
  577. X  if (mode == AF_VERSIONLOCK)
  578. X    lkp->af_lpos = key->af_lpos;
  579. X  else
  580. X    lkp->af_lpos = 0;
  581. X
  582. X  /* if version is not locked or already locked by caller */
  583. X  oldlockeruid = af_getuid (VATTR(lkp).af_lckname, VATTR(lkp).af_lckhost);
  584. X
  585. X  if ((oldlockeruid == (Uid_t) ERROR) || (oldlockeruid == calleruid))
  586. X    {
  587. X      VATTR(lkp).af_lckname = af_entersym (locker->af_username);
  588. X      VATTR(lkp).af_lckhost = af_enterhost (locker->af_userhost);
  589. X      VATTR(lkp).af_ltime = (time_t) af_acttime();
  590. X      if (af_updtvers (lkp, AF_CHANGE) == ERROR)
  591. X    return ((Af_user *)0);
  592. X      return (locker);
  593. X    }
  594. X  else
  595. X    SFAIL ("lock", "", AF_ENOTLOCKED, (Af_user *)0);
  596. X}
  597. X
  598. X/*================================================================
  599. X *    af_unlock
  600. X *
  601. X *================================================================*/
  602. X
  603. XEXPORT Af_user *af_unlock (key, mode)
  604. X     Af_key *key;
  605. X     int    mode;
  606. X{
  607. X  static Af_user locker;
  608. X  Af_key lkey, *lkp;
  609. X
  610. X  if (af_keytest (key))
  611. X    SFAIL ("unlock", "", AF_EINVKEY, (Af_user *)0);
  612. X
  613. X  if (af_checkperm (key, AF_OWNER | AF_LOCKHOLDER) == ERROR)
  614. X    return ((Af_user *)0);
  615. X
  616. X  lkp = &lkey;
  617. X  lkp->af_ldes = key->af_ldes;
  618. X  if (mode == AF_VERSIONLOCK)
  619. X    lkp->af_lpos = key->af_lpos;
  620. X  else
  621. X    lkp->af_lpos = 0;
  622. X
  623. X  if (VATTR(lkp).af_lckname != (char *)0)
  624. X    {
  625. X      (void) strcpy (locker.af_username, VATTR(lkp).af_lckname);
  626. X      (void) strcpy (locker.af_userhost, VATTR(lkp).af_lckhost);
  627. X      VATTR(lkp).af_lckname = (char *)0;
  628. X      VATTR(lkp).af_lckhost = (char *)0;
  629. X      VATTR(lkp).af_ltime = (time_t) af_acttime();
  630. X      if (af_updtvers (lkp, AF_CHANGE) == ERROR)
  631. X    return ((Af_user *)0);
  632. X    }
  633. X  else
  634. X    {
  635. X      locker.af_username[0] = '\0';
  636. X      locker.af_userhost[0] = '\0';
  637. X    }
  638. X  return (&locker);
  639. X}
  640. X
  641. X/*================================================================
  642. X *    af_testlock
  643. X *
  644. X *================================================================*/
  645. X
  646. XEXPORT Af_user *af_testlock (key, mode)
  647. X     Af_key *key;
  648. X     int    mode;
  649. X{
  650. X  static Af_user locker;
  651. X  Af_key lkey, *lkp;
  652. X
  653. X  if (af_keytest (key))
  654. X    SFAIL ("testlock", "", AF_EINVKEY, (Af_user *)0);
  655. X
  656. X  lkp = &lkey;
  657. X  lkp->af_ldes = key->af_ldes;
  658. X  if (mode == AF_VERSIONLOCK)
  659. X    lkp->af_lpos = key->af_lpos;
  660. X  else
  661. X    lkp->af_lpos = 0;
  662. X
  663. X  if (VATTR(lkp).af_lckname != (char *)0)
  664. X    {
  665. X      (void) strcpy (locker.af_username, VATTR(lkp).af_lckname);
  666. X      (void) strcpy (locker.af_userhost, VATTR(lkp).af_lckhost);
  667. X    }
  668. X  else
  669. X    {
  670. X      locker.af_username[0] = '\0';
  671. X      locker.af_userhost[0] = '\0';
  672. X    }
  673. X  return (&locker);
  674. X}
  675. X
  676. X
  677. END_OF_FILE
  678. if test 5339 -ne `wc -c <'src/afs/aflock.c'`; then
  679.     echo shar: \"'src/afs/aflock.c'\" unpacked with wrong size!
  680. fi
  681. # end of 'src/afs/aflock.c'
  682. fi
  683. if test -f 'src/afs/afsysc.c' -a "${1}" != "-c" ; then 
  684.   echo shar: Will not clobber existing file \"'src/afs/afsysc.c'\"
  685. else
  686. echo shar: Extracting \"'src/afs/afsysc.c'\" \(4951 characters\)
  687. sed "s/^X//" >'src/afs/afsysc.c' <<'END_OF_FILE'
  688. X/*
  689. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  690. X *  and U. Pralle
  691. X * 
  692. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  693. X * WARRANTY for any part of this software to work correctly or as described
  694. X * in the manuals. We do not accept any liability for any kind of damage
  695. X * caused by use of this software, such as loss of data, time, money, or 
  696. X * effort.
  697. X * 
  698. X * Permission is granted to use, copy, modify, or distribute any part of
  699. X * this software as long as this is done without asking for charge, and
  700. X * provided that this copyright notice is retained as part of the source
  701. X * files. You may charge a distribution fee for the physical act of
  702. X * transferring a copy, and you may at your option offer warranty
  703. X * protection in exchange for a fee.
  704. X * 
  705. X * Direct questions to: Tech. Univ. Berlin
  706. X *              Wilfried Koch
  707. X *              Sekr. FR 5-6 
  708. X *              Franklinstr. 28/29
  709. X *              D-1000 Berlin 10, West Germany
  710. X * 
  711. X *              Tel: +49-30-314-22972
  712. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  713. X */
  714. X/*
  715. X *    Shape/AFS
  716. X *
  717. X *    afsysc.c -- Isolate syscalls for portability 
  718. X *
  719. X *    Author: Andreas Lampen, TU-Berlin (andy@coma.UUCP)
  720. X *                      (andy@db0tui62.BITNET)
  721. X *
  722. X *    $Header: afsysc.c[1.3] Wed Feb 22 16:28:23 1989 andy@coma published $
  723. X *
  724. X *    EXPORT:
  725. X *    af_syslink -- create a link to a file
  726. X *      af_sysaccess -- determine accessibility of file
  727. X *    af_unlink -- remove file
  728. X *      af_retfsize -- return file size
  729. X *      af_uchown -- change owner
  730. X *      af_uchmod -- change mode
  731. X *      af_gethostname -- get host name
  732. X *      af_asctime -- get time as ascii string
  733. X *      af_acttime -- get actual time
  734. X *      af_cvttime -- convert time
  735. X */
  736. X
  737. X#include <stdio.h>
  738. X#include <sys/types.h>
  739. X#include <sys/stat.h>
  740. X#include <sys/file.h>
  741. X#include <sys/time.h>
  742. X
  743. X#include "typeconv.h"
  744. X#include "afsys.h"
  745. X#include "afs.h"
  746. X
  747. X/*================================================================
  748. X *    af_syslink
  749. X *
  750. X *================================================================*/
  751. X
  752. XEXPORT af_syslink (existfile, newfile)
  753. X     char *existfile, *newfile;
  754. X{
  755. X  if (link (existfile, newfile) == ERROR)
  756. X    return (ERROR);
  757. X  return (AF_OK);
  758. X} /* af_syslink */ 
  759. X
  760. X/*================================================================
  761. X *    af_sysaccess
  762. X *
  763. X *================================================================*/
  764. X
  765. XEXPORT af_sysaccess (path, mode)
  766. X     char *path;
  767. X     int  mode;
  768. X{
  769. X  return (access (path, mode));
  770. X} /* af_syslink */ 
  771. X
  772. X/*================================================================
  773. X *    af_unlink
  774. X *
  775. X *================================================================*/
  776. X
  777. XEXPORT af_unlink (file)
  778. X     char *file;
  779. X{
  780. X  return (unlink (file));
  781. X} /* af_unlink */ 
  782. X
  783. X/*================================================================
  784. X *    af_retfsize
  785. X *
  786. X *================================================================*/
  787. X
  788. XEXPORT off_t af_retfsize (file)
  789. X     char *file;
  790. X{
  791. X  struct stat ibuf;
  792. X  
  793. X  (void) lstat (file, &ibuf);
  794. X  return (ibuf.st_size);
  795. X} /* af_retfsize */ 
  796. X
  797. X/*================================================================
  798. X *    af_uchown
  799. X *
  800. X *================================================================*/
  801. X
  802. XEXPORT af_uchown (file, uid, gid)
  803. X     char *file;
  804. X     int uid, gid;
  805. X{
  806. X  if (chown (file, uid, gid) == ERROR)
  807. X    return (ERROR);
  808. X  return (AF_OK);
  809. X} /* af_uchown */
  810. X
  811. X
  812. X/*================================================================
  813. X *    af_uchmod
  814. X *
  815. X *================================================================*/
  816. X
  817. XEXPORT af_uchmod (file, mode)
  818. X     char *file;
  819. X     int  mode;
  820. X{
  821. X  if (chmod (file, mode) == ERROR)
  822. X    return (ERROR);
  823. X  return (AF_OK);
  824. X} /* af_uchmod */
  825. X
  826. X
  827. X/*================================================================
  828. X *    af_gethostname
  829. X *
  830. X *================================================================*/
  831. X
  832. Xstatic char *hostsym = (char *)0;
  833. X
  834. XEXPORT char *af_gethostname ()
  835. X{
  836. X  char hostname[MAXHOSTNAMELEN];
  837. X
  838. X  if (!hostsym)
  839. X    {
  840. X      (void) gethostname (hostname, MAXHOSTNAMELEN);
  841. X      hostsym =  af_entersym (hostname);
  842. X    }
  843. X  return (hostsym);
  844. X} /* af_uchmod */
  845. X
  846. X/*================================================================
  847. X *    af_asctime
  848. X *
  849. X *================================================================*/
  850. X
  851. XEXPORT char *af_asctime ()
  852. X{
  853. X  char *asctime();  
  854. X  long seconds, time();
  855. X
  856. X  seconds = time ((long *)0);
  857. X  return (asctime (localtime (&seconds)));
  858. X}
  859. X
  860. X/*================================================================
  861. X *    af_acttime -- return actual time (in seconds after ...)
  862. X *
  863. X *================================================================*/
  864. X
  865. XEXPORT af_acttime ()
  866. X{
  867. X  struct timeval tm;
  868. X  struct timezone tz;
  869. X
  870. X  (void) gettimeofday (&tm, &tz);
  871. X
  872. X  return (tm.tv_sec);
  873. X}
  874. X
  875. X/*================================================================
  876. X *    af_cvttime -- convert time from inode
  877. X *
  878. X *================================================================*/
  879. X
  880. XEXPORT af_cvttime (time)
  881. X     time_t time;
  882. X{
  883. X  return (time);
  884. X}
  885. END_OF_FILE
  886. if test 4951 -ne `wc -c <'src/afs/afsysc.c'`; then
  887.     echo shar: \"'src/afs/afsysc.c'\" unpacked with wrong size!
  888. fi
  889. # end of 'src/afs/afsysc.c'
  890. fi
  891. if test -f 'src/afs/bsfd.c' -a "${1}" != "-c" ; then 
  892.   echo shar: Will not clobber existing file \"'src/afs/bsfd.c'\"
  893. else
  894. echo shar: Extracting \"'src/afs/bsfd.c'\" \(4694 characters\)
  895. sed "s/^X//" >'src/afs/bsfd.c' <<'END_OF_FILE'
  896. X/*
  897. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  898. X *  and U. Pralle
  899. X * 
  900. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  901. X * WARRANTY for any part of this software to work correctly or as described
  902. X * in the manuals. We do not accept any liability for any kind of damage
  903. X * caused by use of this software, such as loss of data, time, money, or 
  904. X * effort.
  905. X * 
  906. X * Permission is granted to use, copy, modify, or distribute any part of
  907. X * this software as long as this is done without asking for charge, and
  908. X * provided that this copyright notice is retained as part of the source
  909. X * files. You may charge a distribution fee for the physical act of
  910. X * transferring a copy, and you may at your option offer warranty
  911. X * protection in exchange for a fee.
  912. X * 
  913. X * Direct questions to: Tech. Univ. Berlin
  914. X *              Wilfried Koch
  915. X *              Sekr. FR 5-6 
  916. X *              Franklinstr. 28/29
  917. X *              D-1000 Berlin 10, West Germany
  918. X * 
  919. X *              Tel: +49-30-314-22972
  920. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  921. X */
  922. X/* ================================================== */
  923. X/* ================================================== */
  924. X/*                                                    */
  925. X/* MODULE-NAME: bsfd        KEY : bs                  */
  926. X/*              = build string from delta             */
  927. X/*                                                    */
  928. X/* ORIGINAL                                           */
  929. X/* AUTHOR : sibylle         DATE: 15/06/87            */
  930. X/*                                                    */
  931. X/* LAST UPDATE                                        */
  932. X/* AUTHOR :                 DATE:                     */
  933. X/*                                                    */
  934. X/* VERSION: 1.6.1                                     */
  935. X/*                                                    */
  936. X/* ================================================== */
  937. X/*                                                    */
  938. X/* PURPOSE:                                           */
  939. X/*                building a string from a delta      */
  940. X/*                and writing it into a targetfile    */
  941. X/*                                                    */
  942. X/* SPECIALITIES:                                      */
  943. X/*                none                                */
  944. X/*                                                    */
  945. X/* EXCEPTIONS, ERRORS:                                */
  946. X/*                none                                */
  947. X/*                                                    */
  948. X/* ================================================== */
  949. X/*                                                    */
  950. X/*
  951. X * $Header: bsfd.c[1.0] Wed Feb 22 16:14:33 1989 shape@coma save $
  952. X */
  953. X
  954. X
  955. X# include "predef.h"
  956. X# include <stdio.h>
  957. X# include "edcmd.h"
  958. X# include "typeconv.h"
  959. X
  960. Xextern char *malloc();
  961. Xextern char *calloc();
  962. Xextern int free();
  963. Xextern int fwrite();
  964. Xextern int fclose();
  965. Xextern FILE *fopen();
  966. X
  967. X
  968. XLOCAL char *src_str = NIL;
  969. XLOCAL long src_size = (long) 0;
  970. XLOCAL char *dlt_str = NIL;
  971. XLOCAL char *dlt_pnt = NIL;
  972. XLOCAL long dlt_size = (long) 0;
  973. X
  974. X          
  975. X
  976. XLOCAL void move_to_target (cmd, indx, ftrg)
  977. X     struct ed_cmd *cmd;
  978. X     long indx;
  979. X     FILE *ftrg;
  980. X{
  981. X  char *str_addr = src_str;
  982. X
  983. X  (void) fwrite ((str_addr = (str_addr + indx)), sizeof(char), (Size_t)cmd->length, ftrg);
  984. X  return;
  985. X}
  986. X
  987. X
  988. XLOCAL void add_to_target (cmd, ftrg)
  989. X     struct ed_cmd *cmd;
  990. X     FILE *ftrg;
  991. X{
  992. X  (void) fwrite (dlt_pnt, sizeof(char), (Size_t)cmd->length, ftrg);
  993. X  dlt_pnt += cmd->length;
  994. X  return;
  995. X}
  996. X
  997. X
  998. XLOCAL Bool build_string (trg_fn)
  999. X     char *trg_fn;
  1000. X{
  1001. X  FILE *ftarg;
  1002. X  struct ed_cmd cmd;
  1003. X  long indx;
  1004. X
  1005. X  if ((ftarg = fopen(trg_fn, "w")) == (FILE *) NIL)
  1006. X    return (FALSE);
  1007. X
  1008. X  if (dlt_size == (long) 0)
  1009. X    {
  1010. X      cmd.cmd = MV;
  1011. X      cmd.length = src_size;
  1012. X      indx = (long) 0;
  1013. X      move_to_target (&cmd, indx, ftarg);
  1014. X      (void) fclose (ftarg);
  1015. X      
  1016. X      return (TRUE);
  1017. X     }
  1018. X
  1019. X  while (dlt_pnt < (dlt_str + dlt_size))
  1020. X    {
  1021. X      bcopy (dlt_pnt, (char *)&cmd, sizeof (cmd));
  1022. X      dlt_pnt += sizeof (cmd);
  1023. X      if (cmd.cmd == MV)
  1024. X    {
  1025. X      bcopy (dlt_pnt, (char*)&indx, sizeof (indx));
  1026. X      dlt_pnt += sizeof (indx);
  1027. X      move_to_target (&cmd, indx, ftarg);
  1028. X    }
  1029. X      else 
  1030. X    {
  1031. X      if (cmd.cmd == AD)
  1032. X        add_to_target (&cmd, ftarg);
  1033. X      else
  1034. X        return (FALSE);
  1035. X    }
  1036. X    }
  1037. X  
  1038. X  (void) fclose(ftarg);
  1039. X  return(TRUE);
  1040. X}
  1041. X      
  1042. X
  1043. XEXPORT bsfd (sourcestr, deltastr, sourcesize, deltasize, targetfn)
  1044. X     char *sourcestr, *deltastr;
  1045. X     long sourcesize, deltasize;
  1046. X     char *targetfn;
  1047. X{
  1048. X  src_str = sourcestr;
  1049. X  src_size = sourcesize;
  1050. X  dlt_str = deltastr;
  1051. X  dlt_size = deltasize;
  1052. X  dlt_pnt = dlt_str;
  1053. X
  1054. X  if (!(build_string(targetfn)))
  1055. X    return (-1);
  1056. X
  1057. X  return (0);
  1058. X}
  1059. END_OF_FILE
  1060. if test 4694 -ne `wc -c <'src/afs/bsfd.c'`; then
  1061.     echo shar: \"'src/afs/bsfd.c'\" unpacked with wrong size!
  1062. fi
  1063. # end of 'src/afs/bsfd.c'
  1064. fi
  1065. if test -f 'src/shape/hash.c' -a "${1}" != "-c" ; then 
  1066.   echo shar: Will not clobber existing file \"'src/shape/hash.c'\"
  1067. else
  1068. echo shar: Extracting \"'src/shape/hash.c'\" \(4626 characters\)
  1069. sed "s/^X//" >'src/shape/hash.c' <<'END_OF_FILE'
  1070. X/*
  1071. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  1072. X *  and U. Pralle
  1073. X * 
  1074. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  1075. X * WARRANTY for any part of this software to work correctly or as described
  1076. X * in the manuals. We do not accept any liability for any kind of damage
  1077. X * caused by use of this software, such as loss of data, time, money, or 
  1078. X * effort.
  1079. X * 
  1080. X * Permission is granted to use, copy, modify, or distribute any part of
  1081. X * this software as long as this is done without asking for charge, and
  1082. X * provided that this copyright notice is retained as part of the source
  1083. X * files. You may charge a distribution fee for the physical act of
  1084. X * transferring a copy, and you may at your option offer warranty
  1085. X * protection in exchange for a fee.
  1086. X * 
  1087. X * Direct questions to: Tech. Univ. Berlin
  1088. X *              Wilfried Koch
  1089. X *              Sekr. FR 5-6 
  1090. X *              Franklinstr. 28/29
  1091. X *              D-1000 Berlin 10, West Germany
  1092. X * 
  1093. X *              Tel: +49-30-314-22972
  1094. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  1095. X */
  1096. X#ifndef lint
  1097. Xstatic char *RCSid = "$Header: hash.c,v 3.0 89/01/24 11:35:41 wolfgang Stable $";
  1098. X#endif
  1099. X#ifndef lint
  1100. Xstatic char *ConfFlg = CFFLGS;    /* should be defined from within Makefile */
  1101. X#endif
  1102. X/*
  1103. X * $Log:    hash.c,v $
  1104. X * Revision 3.0  89/01/24  11:35:41  wolfgang
  1105. X * New System Generation
  1106. X * 
  1107. X * Revision 2.7  89/01/03  13:10:39  wolfgang
  1108. X * changes done for lint
  1109. X * 
  1110. X * Revision 2.6  88/12/21  15:03:22  wolfgang
  1111. X * changes done for lint
  1112. X * 
  1113. X * Revision 2.5  88/11/21  15:49:16  wolfgang
  1114. X * return code of all malloc's checked
  1115. X * 
  1116. X * Revision 2.4  88/08/23  16:40:12  wolfgang
  1117. X * This version is part of a release
  1118. X * 
  1119. X * Revision 2.3  88/08/23  14:39:29  wolfgang
  1120. X * In dump(fd) the printing of special macros is now suppressed.
  1121. X * 
  1122. X * Revision 2.2  88/08/22  17:00:57  wolfgang
  1123. X * Procedure dump() change to dump(fd) to be able to use it for the
  1124. X * construction of confid's.
  1125. X * 
  1126. X * Revision 2.1  88/08/19  10:17:28  wolfgang
  1127. X * This version is part of a release
  1128. X * 
  1129. X */
  1130. X
  1131. X#include "hash.h"
  1132. X#include "shape.h"
  1133. X
  1134. X#include <stdio.h>
  1135. X
  1136. Xhashval(name)
  1137. X     char *name;
  1138. X{
  1139. Xint hash = 0;
  1140. Xint i = 0;
  1141. X
  1142. Xfor(; name[i] != '\0'; i++)
  1143. X  hash = hash + name[i];
  1144. Xreturn(hash % HASHSIZE);
  1145. X} /* end hashval */
  1146. X
  1147. X
  1148. Xvoid addhash(hashv, name, value)
  1149. X     int hashv;
  1150. X     char *name;
  1151. X     char *value;
  1152. X{
  1153. X
  1154. Xstruct hash *current;
  1155. X  
  1156. Xif (hashtab[hashv] == (struct hash *) NIL)
  1157. X  {
  1158. X    if ((current = hashtab[hashv] = (struct hash *) malloc(sizeof(struct hash))) == (struct hash *) NIL)
  1159. X      errexit(10,"malloc");
  1160. X    current->name = NIL;
  1161. X    current->entry = NIL;
  1162. X    current->next = (struct hash *)NIL;
  1163. X  }
  1164. Xelse
  1165. X  current = hashtab[hashv];
  1166. X
  1167. Xif (current->name == NIL)
  1168. X  {
  1169. X    if ((current->entry = malloc ( (unsigned) strlen(value) + sizeof(char))) == NIL)
  1170. X      errexit(10,"malloc");
  1171. X    if((current->name = malloc ( (unsigned) strlen(name) + sizeof(char))) == NIL)
  1172. X      errexit(10,"malloc");
  1173. X    (void) strcpy(current->entry, value);
  1174. X    (void) strcpy(current->name, name);
  1175. X    return;
  1176. X  }
  1177. Xelse
  1178. X  {
  1179. X    while ((strcmp (current->name, name) != 0) &&
  1180. X       (current->next != (struct hash *)NIL))
  1181. X      current = current->next;
  1182. X
  1183. X    if(strcmp (current->name, name) == 0)
  1184. X      {
  1185. X    current->entry = realloc (current->entry,
  1186. X                  (unsigned) (strlen(value) + sizeof(char)));
  1187. X    (void) strcpy(current->entry, value);
  1188. X    return;
  1189. X      }
  1190. X
  1191. X    if(current->next == (struct hash *)NIL)
  1192. X      {
  1193. X    if ((current = current->next = (struct hash *) malloc(sizeof (struct hash))) == (struct hash *) NIL)
  1194. X      errexit(10,"malloc");
  1195. X    if((current->entry = malloc ( (unsigned) strlen (value) + sizeof(char))) == NIL)
  1196. X      errexit(10,"malloc");
  1197. X    if((current->name = malloc ((unsigned) strlen (name) + sizeof(char))) == NIL)
  1198. X      errexit(10,"malloc");
  1199. X    current->next = (struct hash *) NIL;
  1200. X    (void) strcpy(current->name, name);
  1201. X    (void) strcpy(current->entry, value);
  1202. X    return;
  1203. X      }
  1204. X  }
  1205. Xreturn;
  1206. X} /* end addhash */
  1207. X
  1208. X
  1209. Xdump(fd)
  1210. X     FILE *fd;
  1211. X{
  1212. Xint i;
  1213. Xstruct hash *current;
  1214. X
  1215. Xfprintf(fd,"# Macros:\n");
  1216. X
  1217. Xfor(i = 0; i < HASHSIZE; i++)
  1218. X  {
  1219. X    if (hashtab[i] != (struct hash *) NIL)
  1220. X      {
  1221. X    current = hashtab[i];
  1222. X    while(current != (struct hash *) NIL)
  1223. X      {
  1224. X
  1225. X        if((current->name[0] != '$') &&
  1226. X           (current->name[0] != '*') &&
  1227. X           (current->name[0] != '+') &&
  1228. X           (current->name[0] != '<') &&
  1229. X           (current->name[0] != '?') &&
  1230. X           (current->name[0] != '@'))
  1231. X          {
  1232. X        if(fd != stdout)
  1233. X          {
  1234. X            fprintf(fd,"%s = %s\n", current->name, current->entry);
  1235. X          }
  1236. X        else
  1237. X          {
  1238. X            fprintf(fd,"\t%s = %s\n", current->name, current->entry);
  1239. X          }
  1240. X          }
  1241. X        current = current->next;
  1242. X
  1243. X      }
  1244. X      }
  1245. X  }
  1246. X} /* end dump */
  1247. END_OF_FILE
  1248. if test 4626 -ne `wc -c <'src/shape/hash.c'`; then
  1249.     echo shar: \"'src/shape/hash.c'\" unpacked with wrong size!
  1250. fi
  1251. # end of 'src/shape/hash.c'
  1252. fi
  1253. if test -f 'src/shape/shape.h' -a "${1}" != "-c" ; then 
  1254.   echo shar: Will not clobber existing file \"'src/shape/shape.h'\"
  1255. else
  1256. echo shar: Extracting \"'src/shape/shape.h'\" \(4910 characters\)
  1257. sed "s/^X//" >'src/shape/shape.h' <<'END_OF_FILE'
  1258. X/*
  1259. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  1260. X *  and U. Pralle
  1261. X * 
  1262. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  1263. X * WARRANTY for any part of this software to work correctly or as described
  1264. X * in the manuals. We do not accept any liability for any kind of damage
  1265. X * caused by use of this software, such as loss of data, time, money, or 
  1266. X * effort.
  1267. X * 
  1268. X * Permission is granted to use, copy, modify, or distribute any part of
  1269. X * this software as long as this is done without asking for charge, and
  1270. X * provided that this copyright notice is retained as part of the source
  1271. X * files. You may charge a distribution fee for the physical act of
  1272. X * transferring a copy, and you may at your option offer warranty
  1273. X * protection in exchange for a fee.
  1274. X * 
  1275. X * Direct questions to: Tech. Univ. Berlin
  1276. X *              Wilfried Koch
  1277. X *              Sekr. FR 5-6 
  1278. X *              Franklinstr. 28/29
  1279. X *              D-1000 Berlin 10, West Germany
  1280. X * 
  1281. X *              Tel: +49-30-314-22972
  1282. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  1283. X */
  1284. X/*
  1285. X * $Log:    shape.h,v $
  1286. X * Revision 3.0  89/01/24  11:36:09  wolfgang
  1287. X * New System Generation
  1288. X * 
  1289. X * Revision 2.14  88/12/21  15:11:02  wolfgang
  1290. X * changes done for lint
  1291. X * 
  1292. X * Revision 2.13  88/12/19  13:22:04  wolfgang
  1293. X * bpoolflg, nobpoolflg, forceflg added.
  1294. X * 
  1295. X * Revision 2.12  88/11/08  11:02:39  wolfgang
  1296. X * explg & noexpflg added.
  1297. X * 
  1298. X * Revision 2.11  88/11/02  13:30:20  wolfgang
  1299. X * This version is part of a release
  1300. X * 
  1301. X * Revision 2.10  88/10/14  17:12:12  wolfgang
  1302. X * changes don for new handling of variants: struct vardefs.
  1303. X * 
  1304. X * Revision 2.9  88/09/22  16:15:45  wolfgang
  1305. X * struct linkreg changed: member newfn added.
  1306. X * 
  1307. X * Revision 2.8  88/09/15  17:25:27  wolfgang
  1308. X * struct varclass changed: int active added.
  1309. X * 
  1310. X * Revision 2.7  88/08/23  15:34:53  wolfgang
  1311. X * rebuildflg added.
  1312. X * 
  1313. X * Revision 2.6  88/08/22  10:16:40  wolfgang
  1314. X * Added constant: nostdfile (indicates that no standard input file has been
  1315. X * found).
  1316. X * 
  1317. X * Revision 2.5  88/08/19  14:09:46  wolfgang
  1318. X * *** empty log message ***
  1319. X * 
  1320. X * Revision 2.4  88/08/18  10:25:55  wolfgang
  1321. X * This version is part of a release
  1322. X * 
  1323. X * Revision 2.3  88/08/12  08:58:17  wolfgang
  1324. X * This version is part of a release
  1325. X * 
  1326. X */
  1327. X
  1328. X
  1329. Xtypedef int Bool;
  1330. X
  1331. X#define TRUE 1
  1332. X#define FALSE 0
  1333. X#define VOID int
  1334. X#define EOL '\n'
  1335. X#define EOS '\0'
  1336. X#define NIL ((char *) 0)
  1337. X
  1338. X#include "afs.h"
  1339. X#include <strings.h>
  1340. X
  1341. X#define SMILEY -1
  1342. X#define GRIMMY -2
  1343. X
  1344. Xextern int af_errno;
  1345. X
  1346. Xextern char *rindex();
  1347. Xextern char *index();
  1348. Xextern char *malloc();
  1349. Xextern char *realloc();
  1350. X
  1351. Xextern int errexit();
  1352. X
  1353. Xextern Bool pattern();
  1354. Xextern Bool attr();
  1355. Xextern Bool attrnot();
  1356. Xextern Bool attrvar();
  1357. Xextern Bool attrnotvar();
  1358. Xextern Bool attrlt();
  1359. Xextern Bool attrgt();
  1360. Xextern Bool attrle();
  1361. Xextern Bool attrge();
  1362. Xextern Bool attrmin();
  1363. Xextern Bool attrmax();
  1364. Xextern Bool getfromcid();
  1365. Xextern Bool msg();
  1366. Xextern Bool stopit();
  1367. Xextern Bool tunix();
  1368. X
  1369. X#define ATTRNAME "__ATTRS__="
  1370. X#define MAXATTRLENGTH 10000
  1371. X
  1372. X#define MAX_ATTR 10000
  1373. X#define MAXDEPTH 10
  1374. X
  1375. X#define MAXPATHLIST 256
  1376. Xextern char *pathlist[MAXPATHLIST][2];
  1377. Xextern int lastpath;
  1378. X
  1379. Xextern char *curvpath[];
  1380. X
  1381. Xextern char rbrule[];
  1382. Xextern char rbfile[];
  1383. X
  1384. XBool debugflg;
  1385. XBool envflg;
  1386. XBool fileflg;
  1387. XBool nostdfile;
  1388. XBool ignoreflg;
  1389. XBool goflg;
  1390. XBool noexflg;
  1391. XBool printflg;
  1392. XBool questflg;
  1393. XBool ruleflg;
  1394. XBool silentflg;
  1395. XBool touchflg;
  1396. XBool stdinflg;
  1397. XBool confid;
  1398. XBool rebuildflg;
  1399. XBool stopflg;
  1400. XBool tunixflg;
  1401. XBool logflg;
  1402. XBool expflg;
  1403. XBool noexpflg;
  1404. X
  1405. XBool bpoolflg;
  1406. XBool nobpoolflg;
  1407. XBool forceflg;
  1408. X
  1409. XFILE *cid;
  1410. XFILE *logfd;
  1411. X
  1412. XBool doublecolon;
  1413. Xextern Bool suffs_deleted;
  1414. X
  1415. Xstruct linked_list {
  1416. X  char *string;
  1417. X  struct linked_list *nextstring;
  1418. X};
  1419. X
  1420. Xstruct hash
  1421. X{
  1422. X  char *name;
  1423. X  char *entry;
  1424. X  struct hash *next;
  1425. X};
  1426. X
  1427. Xextern struct hash *hashtab[];
  1428. X
  1429. Xstruct cmds
  1430. X{
  1431. X  char *command;
  1432. X  struct cmds *nextcmd;
  1433. X};
  1434. X
  1435. X#define MAXTARGS 128
  1436. X#define MAXHERIT 32
  1437. X#define MAXDEPS 256
  1438. X#define MAXCMDS 32
  1439. Xstruct rules
  1440. X{
  1441. X  char *name;
  1442. X  Af_set date;
  1443. X  Bool done;
  1444. X  Bool doublecolon;
  1445. X  char *firstdep;                 /* possibly selection rule name */
  1446. X  char *deplist[MAXDEPS];
  1447. X  char *heritage[MAXHERIT];
  1448. X  char *targetlist[MAXHERIT];
  1449. X  struct cmds *cmdlist;
  1450. X  struct rules *nextrule;
  1451. X};
  1452. X
  1453. Xextern struct rules *ruletab[];
  1454. Xextern struct rules *stdruletab[];
  1455. Xextern int lastrule;    /* index of last std rule */
  1456. X
  1457. Xstruct list
  1458. X{
  1459. X  int (*selfunc)();
  1460. X  char *parn;
  1461. X  char *parv;
  1462. X  int i;
  1463. X  struct list *cont;
  1464. X};
  1465. X
  1466. Xextern struct selection_rules *sels[];
  1467. X
  1468. X
  1469. Xstruct linkreg {
  1470. X  char *fn;
  1471. X  char *newfn;
  1472. X  Bool busy_exist;
  1473. X  struct linkreg *next;
  1474. X};
  1475. X
  1476. X#define MAXVARIANTS 32
  1477. X#define MAXVMACROS 32 
  1478. X
  1479. Xstruct vardef {
  1480. X  char *name;
  1481. X  char *vmacros[MAXVMACROS];
  1482. X  char *vflags;
  1483. X  char *vpath;
  1484. X};
  1485. X
  1486. Xstruct varclass {
  1487. X  char *name;
  1488. X  int active;
  1489. X  char *variants[MAXVARIANTS];
  1490. X};
  1491. X
  1492. X#define MAXPREDS 32
  1493. X
  1494. Xstruct selection_rules
  1495. X{
  1496. X  char *name;
  1497. X  struct list *predlist[MAXPREDS];
  1498. X  struct selection_rules *next;
  1499. X};
  1500. X
  1501. END_OF_FILE
  1502. if test 4910 -ne `wc -c <'src/shape/shape.h'`; then
  1503.     echo shar: \"'src/shape/shape.h'\" unpacked with wrong size!
  1504. fi
  1505. # end of 'src/shape/shape.h'
  1506. fi
  1507. if test -f 'src/vc/vc_files.c' -a "${1}" != "-c" ; then 
  1508.   echo shar: Will not clobber existing file \"'src/vc/vc_files.c'\"
  1509. else
  1510. echo shar: Extracting \"'src/vc/vc_files.c'\" \(4862 characters\)
  1511. sed "s/^X//" >'src/vc/vc_files.c' <<'END_OF_FILE'
  1512. X/*
  1513. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  1514. X *  and U. Pralle
  1515. X * 
  1516. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  1517. X * WARRANTY for any part of this software to work correctly or as described
  1518. X * in the manuals. We do not accept any liability for any kind of damage
  1519. X * caused by use of this software, such as loss of data, time, money, or 
  1520. X * effort.
  1521. X * 
  1522. X * Permission is granted to use, copy, modify, or distribute any part of
  1523. X * this software as long as this is done without asking for charge, and
  1524. X * provided that this copyright notice is retained as part of the source
  1525. X * files. You may charge a distribution fee for the physical act of
  1526. X * transferring a copy, and you may at your option offer warranty
  1527. X * protection in exchange for a fee.
  1528. X * 
  1529. X * Direct questions to: Tech. Univ. Berlin
  1530. X *              Wilfried Koch
  1531. X *              Sekr. FR 5-6 
  1532. X *              Franklinstr. 28/29
  1533. X *              D-1000 Berlin 10, West Germany
  1534. X * 
  1535. X *              Tel: +49-30-314-22972
  1536. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  1537. X */
  1538. X#ifndef lint
  1539. Xstatic char *AFSid = "$Header: vc_files.c[1.9] Thu Feb 23 18:14:30 1989 axel@coma published $";
  1540. X#ifdef CFFLGS
  1541. Xstatic char *ConfFlg = CFFLGS;
  1542. X    /* should be defined from within Makefile */
  1543. X#endif
  1544. X#endif
  1545. X/*
  1546. X * Log for /u/shape/dist-tape/src/vc/vc_files.c[1.6]
  1547. X *     Thu Feb 23 18:14:30 1989 axel@coma published $
  1548. X *  --- empty log message ---
  1549. X *  vc_files.c[1.7] Thu Feb 23 18:14:30 1989 axel@coma published $
  1550. X *  --- empty log message ---
  1551. X *  vc_files.c[1.8] Thu Feb 23 18:14:30 1989 axel@coma save $
  1552. X *  --- empty log message ---
  1553. X *  vc_files.c[1.9] Thu Feb 23 18:14:30 1989 axel@coma published $
  1554. X *  --- empty log message ---
  1555. X */
  1556. X
  1557. X/*
  1558. X *
  1559. X * Functions to find, check for permission, and remote files.
  1560. X * This functions are highly operation system dependend.
  1561. X *
  1562. X * Currently this function are BSD43- and Ultrix1.0-proof. 
  1563. X *
  1564. X * Exports:
  1565. X *
  1566. X *   All functions described below return 1 for success or
  1567. X *   0 on failure. If return type is not "int" then on failure
  1568. X *   "(type-cast) NULL" is returned. See also descriptions below.
  1569. X *
  1570. X *   int GroupMember (gid)     WARNING: NOT ULTRIX COMPATIBLE
  1571. X *       int gid;
  1572. X *
  1573. X *         Checks if user is member of group gid.
  1574. X *
  1575. X *   int FileExecutable (file)
  1576. X *       char *file;
  1577. X *
  1578. X *   char *FindFile (file)
  1579. X *        char *file;
  1580. X *
  1581. X *        Returns the full absolute path name of file "file", if
  1582. X *        "file" exists. NULL otherwise. Searches the directories
  1583. X *        given in environment variable PATH. If path is not set,
  1584. X *        current working directory and "/bin" are checked.
  1585. X *
  1586. X *   char *FindProgram (file)
  1587. X *        char *file;
  1588. X *
  1589. X *        Acts as function FindFile(), but file must also be
  1590. X *        executable for caller.
  1591. X *
  1592. X *   RemoveFile (file)
  1593. X *        char *file;
  1594. X *
  1595. X *   int FileExists (file)
  1596. X *       char *file;
  1597. X */
  1598. X
  1599. X#include <sys/param.h>
  1600. X#include <sys/stat.h>
  1601. X#include <sys/file.h>
  1602. X#include <stdio.h>
  1603. X#include <strings.h>
  1604. X#include <afs.h>
  1605. X#include "afsapp.h"
  1606. X#include "locks.h"
  1607. X#include "vc_sysdep.h"
  1608. X
  1609. Xextern char *malloc(), *getenv();
  1610. X
  1611. X/**/
  1612. Xint FileExecutable (file)
  1613. X     char *file;
  1614. X{
  1615. X  return access (file, (X_OK | F_OK)) == -1 ? 0 : 1;
  1616. X}
  1617. X
  1618. X/**/
  1619. Xchar *FindFile (file)
  1620. X     char *file;
  1621. X{
  1622. X  char *path;
  1623. X  char *dir, *edir;
  1624. X  char *this;
  1625. X  int flen;            /* length of "file" */
  1626. X  flen = strlen (file) + 1;    /* for the good old null byte */
  1627. X  this = NULL;
  1628. X
  1629. X  /* get path from enivronment */
  1630. X  if (!(path = getenv (PATH_ENV_NAME)))
  1631. X    path = DEFAULT_PATH;
  1632. X
  1633. X  while (1) {
  1634. X    
  1635. X    if ((dir = path) == NULL)
  1636. X      return NULL;
  1637. X
  1638. X    /* find end of dir in string */
  1639. X    if (edir = index(path, ':')) {
  1640. X      *edir = '\0';        /* make "dir" null terminated */
  1641. X      path = edir + 1;        /* path points to next dir */
  1642. X    }
  1643. X    else
  1644. X      path = NULL;        /* end of path reached */
  1645. X
  1646. X    if (this) free (this);    /* no longer needed */
  1647. X
  1648. X    if ((this = malloc ((unsigned)(strlen (dir) + flen))) == NULL) {
  1649. X      fprintf (stderr, "FindFile(): can't malloc\n");
  1650. X      exit (1);
  1651. X    }
  1652. X
  1653. X    /* file found ? */
  1654. X    (void)sprintf (this, "%s/%s", dir, file);    /* construct new filename */
  1655. X    if (FileExists (this))
  1656. X      return this;        /* found */
  1657. X  }
  1658. X}
  1659. X  
  1660. Xchar *FindProgram (program)
  1661. X     char *program;
  1662. X{
  1663. X  /*
  1664. X   * returns the full pathname of "program", iff program is found
  1665. X   * and executable (for world). Otherwise NULL.
  1666. X   */
  1667. X
  1668. X  /* if program has already a '/' in it, asume existence */
  1669. X  if (!index (program, '/'))
  1670. X    if ((program = FindFile (program)) == NULL)
  1671. X      return NULL;        /* not found */
  1672. X
  1673. X  /* prg contains the absolute file name and file exists.*/
  1674. X  if (FileExecutable (program))
  1675. X    return program;
  1676. X  else
  1677. X    return NULL;
  1678. X}
  1679. X
  1680. XRemoveFile (file)
  1681. X     char *file;
  1682. X{
  1683. X  (void)unlink (file);
  1684. X}
  1685. X
  1686. XFileExists (file)
  1687. X     char *file;
  1688. X{
  1689. X  /*
  1690. X   * Returns 1 iff file exists, 0 otherwise.
  1691. X   */
  1692. X  struct stat sbuf;
  1693. X  
  1694. X  return !stat (file, &sbuf);
  1695. X}
  1696. X
  1697. END_OF_FILE
  1698. if test 4862 -ne `wc -c <'src/vc/vc_files.c'`; then
  1699.     echo shar: \"'src/vc/vc_files.c'\" unpacked with wrong size!
  1700. fi
  1701. # end of 'src/vc/vc_files.c'
  1702. fi
  1703. if test -f 'src/vc/vc_lock.c' -a "${1}" != "-c" ; then 
  1704.   echo shar: Will not clobber existing file \"'src/vc/vc_lock.c'\"
  1705. else
  1706. echo shar: Extracting \"'src/vc/vc_lock.c'\" \(4964 characters\)
  1707. sed "s/^X//" >'src/vc/vc_lock.c' <<'END_OF_FILE'
  1708. X/*
  1709. X * Copyright (C) 1989, 1990 W. Koch, A. Lampen, A. Mahler, W. Obst,
  1710. X *  and U. Pralle
  1711. X * 
  1712. X * This software is published on an as-is basis. There is ABSOLUTELY NO
  1713. X * WARRANTY for any part of this software to work correctly or as described
  1714. X * in the manuals. We do not accept any liability for any kind of damage
  1715. X * caused by use of this software, such as loss of data, time, money, or 
  1716. X * effort.
  1717. X * 
  1718. X * Permission is granted to use, copy, modify, or distribute any part of
  1719. X * this software as long as this is done without asking for charge, and
  1720. X * provided that this copyright notice is retained as part of the source
  1721. X * files. You may charge a distribution fee for the physical act of
  1722. X * transferring a copy, and you may at your option offer warranty
  1723. X * protection in exchange for a fee.
  1724. X * 
  1725. X * Direct questions to: Tech. Univ. Berlin
  1726. X *              Wilfried Koch
  1727. X *              Sekr. FR 5-6 
  1728. X *              Franklinstr. 28/29
  1729. X *              D-1000 Berlin 10, West Germany
  1730. X * 
  1731. X *              Tel: +49-30-314-22972
  1732. X *              E-mail: shape@coma.uucp or shape@db0tui62.bitnet
  1733. X */
  1734. X#ifndef lint
  1735. Xstatic char *AFSid = "$Header: vc_lock.c[3.7] Thu Feb 23 18:14:33 1989 axel@coma published $";
  1736. X#ifdef CFFLGS
  1737. Xstatic char *ConfFlg = CFFLGS;
  1738. X    /* should be defined from within Makefile */
  1739. X#endif
  1740. X#endif
  1741. X/*
  1742. X * Log for /u/shape/dist-tape/src/vc/vc_lock.c[3.4]
  1743. X *     Thu Feb 23 18:14:33 1989 axel@coma published $
  1744. X *  --- empty log message ---
  1745. X *  vc_lock.c[3.5] Thu Feb 23 18:14:33 1989 axel@coma published $
  1746. X *  --- empty log message ---
  1747. X *  vc_lock.c[3.6] Thu Feb 23 18:14:33 1989 axel@coma save $
  1748. X *  --- empty log message ---
  1749. X *  vc_lock.c[3.7] Thu Feb 23 18:14:33 1989 axel@coma published $
  1750. X *  --- empty log message ---
  1751. X */
  1752. X
  1753. X/*LINTLIBRARY*/
  1754. X#define _VC_LOCK_
  1755. X#include <sys/types.h>
  1756. X#include <sys/stat.h>
  1757. X#include <pwd.h>
  1758. X#include <strings.h>
  1759. X#include "afs.h"
  1760. X#include "afsapp.h"
  1761. X
  1762. XAf_user *vc_testlock (key, mode) Af_key *key; {
  1763. X  return af_testlock (key, mode);
  1764. X}
  1765. X
  1766. XAf_user *vc_lock (key, uid, mode) Af_key *key; Uid_t uid; {
  1767. X  Af_user alock;
  1768. X  struct passwd *pw;
  1769. X
  1770. X  pw = getpwuid ((int)uid);
  1771. X  if (pw) {
  1772. X    (void)strcpy (alock.af_username, pw->pw_name);
  1773. X    (void)gethostname (alock.af_userhost, MAXHOSTNAMELEN);
  1774. X    return af_lock (key, &alock, mode);
  1775. X  }
  1776. X  else {
  1777. X    return NULL;
  1778. X  }
  1779. X}
  1780. X
  1781. XAf_user *vc_unlock (key, mode) Af_key *key; {
  1782. X  Af_user *waslocker;
  1783. X  
  1784. X  waslocker = af_unlock (key, mode);
  1785. X  if (waslocker) {
  1786. X    if (af_rstate (key) == AF_BUSY)
  1787. X      af_sudattr (key, AF_REMOVE, INTENT);
  1788. X  }
  1789. X  return waslocker;
  1790. X}
  1791. X
  1792. Xchar *lockerid (lock) Af_user *lock; {
  1793. X  static char rst[256];
  1794. X
  1795. X  rst[0] = '\0';
  1796. X  if (lock) {
  1797. X    (void)sprintf (rst, "%s@%s", lock->af_username, lock->af_userhost);
  1798. X  }
  1799. X  return rst;
  1800. X}
  1801. X
  1802. XUid_t lockeruid (lock) Af_user *lock; {
  1803. X  char hostname[256];
  1804. X  struct passwd *pw;
  1805. X
  1806. X  if (!lock) return -1;
  1807. X  (void)gethostname (hostname, 256);
  1808. X
  1809. X  if (strcmp (hostname, lock->af_userhost) == 0) {
  1810. X    pw = getpwnam (lock->af_username);
  1811. X    if (pw)
  1812. X      return pw->pw_uid;
  1813. X    else 
  1814. X      return -1;
  1815. X  }
  1816. X  else 
  1817. X    return -1;
  1818. X}
  1819. X
  1820. Xint locked (lock) Af_user *lock; {
  1821. X  if (!lock) return 1;
  1822. X  return lock->af_username[0];
  1823. X}
  1824. X
  1825. Xchar *getintent (prompt, oldintent) char *prompt, *oldintent; {
  1826. X  char *tmpname, *mktemp(), *edname, cmd[128], *getenv(), messg[80], *malloc();
  1827. X  static char *notetxt;
  1828. X  FILE *tmpfil;
  1829. X  struct stat statbuf;
  1830. X  static int firsttime = TRUE;
  1831. X
  1832. X  if (!(isatty(fileno(stdin)))) {
  1833. X    return oldintent ? oldintent : EMPTYINTENT;
  1834. X  }
  1835. X  if ((!firsttime) && notetxt) {
  1836. X    if (ask_confirm ("Same intent as before ?", "yes")) {
  1837. X      return notetxt;
  1838. X    }
  1839. X    else {
  1840. X      free (notetxt);
  1841. X    }
  1842. X  }
  1843. X  firsttime = FALSE;
  1844. X  if (!ask_confirm (prompt, "yes"))
  1845. X    return oldintent ? oldintent : EMPTYINTENT;
  1846. X  tmpname = mktemp ("/tmp/afsXXXXXX");
  1847. X  Register (tmpname, TYPEF);
  1848. X  if (oldintent) {
  1849. X    FILE *t = fopen (tmpname, "w");
  1850. X    if (fwrite (oldintent, sizeof (char), (Size_t)strlen (oldintent), t) !=
  1851. X    strlen (oldintent)) {
  1852. X      logerr ("write failure on tmp-file");
  1853. X    }
  1854. X    (void)fclose (t);
  1855. X  }
  1856. X  if (edname = getenv ("EDITOR")) {
  1857. X    (void)sprintf (cmd, "%s %s", edname, tmpname);
  1858. X    (void)sprintf (messg, "starting up %s ...", edname);
  1859. X    logmsg (messg);
  1860. X    if (system (cmd) == NOSHELL) {
  1861. X      logerr ("couldn't execute shell");
  1862. X    }
  1863. X    else {
  1864. X      if ((tmpfil = fopen (tmpname, "r")) == NULL) {
  1865. X    logerr ("empty intent description");
  1866. X    return EMPTYINTENT;
  1867. X      }
  1868. X      else {
  1869. X    if (fstat (fileno(tmpfil), &statbuf) == -1) {
  1870. X      perror ("couldn't stat");
  1871. X    }
  1872. X    else {
  1873. X      notetxt = malloc ((unsigned)statbuf.st_size);
  1874. X      if (!notetxt) {
  1875. X        logerr ("not enough memory for intent text.");
  1876. X      }
  1877. X      (void)fread (notetxt, sizeof (char), 
  1878. X               (Size_t)statbuf.st_size, tmpfil);
  1879. X      (void)fclose (tmpfil);
  1880. X      (void)unlink (tmpname);
  1881. X      UnRegister (tmpname, TYPEF);
  1882. X      return notetxt;
  1883. X    }
  1884. X      }
  1885. X    }
  1886. X  }
  1887. X  logerr 
  1888. X   ("You must set the EDITOR environment variable to write a note of intent.");
  1889. X  return EMPTYINTENT;   /* maybe we should try to read from stdin */
  1890. X}
  1891. END_OF_FILE
  1892. if test 4964 -ne `wc -c <'src/vc/vc_lock.c'`; then
  1893.     echo shar: \"'src/vc/vc_lock.c'\" unpacked with wrong size!
  1894. fi
  1895. # end of 'src/vc/vc_lock.c'
  1896. fi
  1897. echo shar: End of archive 6 \(of 33\).
  1898. cp /dev/null ark6isdone
  1899. MISSING=""
  1900. 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
  1901.     if test ! -f ark${I}isdone ; then
  1902.     MISSING="${MISSING} ${I}"
  1903.     fi
  1904. done
  1905. if test "${MISSING}" = "" ; then
  1906.     echo You have unpacked all 33 archives.
  1907.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1908. else
  1909.     echo You still need to unpack the following archives:
  1910.     echo "        " ${MISSING}
  1911. fi
  1912. ##  End of shell archive.
  1913. exit 0
  1914.