Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / budb / struct_ops.c
1 /* Copyright (C) 1990, 1989 Transarc Corporation - All rights reserved */
2 /*
3  * (C) COPYRIGHT IBM CORPORATION 1989
4  * LICENSED MATERIALS - PROPERTY OF IBM
5  */
6
7 #include <afs/param.h>
8 #include <stdio.h>
9 #ifdef AFS_NT40_ENV
10 #include <winsock2.h>
11 #else
12 #include <netinet/in.h>
13 #include <sys/file.h>
14 #endif
15 #include <sys/types.h>
16 #include <afs/stds.h>
17 #include <afs/bubasics.h>
18 #include <rx/xdr.h>
19 #include <rx/rx.h>
20 #include <string.h>
21 #include "budb.h"
22 #include "budb_errs.h"
23 #include "database.h"
24
25
26 /* ----------------------------------
27  * structure printing utilities
28  * ----------------------------------
29  */
30
31 printDbHeader(ptr)
32      struct DbHeader *ptr;
33 {
34     printf("version = %d\n", ptr->dbversion);
35     printf("created = %s", ctime((time_t *)&ptr->created));
36     printf("cell = %s\n",ptr->cell);
37     printf("lastDumpId = %u\n", ptr->lastDumpId);
38     printf("lastInstanceId = %d\n", ptr->lastInstanceId);
39     printf("lastTapeId = %d\n", ptr->lastTapeId);
40 }
41
42 printDump(fid, dptr)
43      FILE *fid;
44      struct dump *dptr;
45 {
46     fprintf(fid,"id = %u\n", dptr->id);
47     fprintf(fid,"idHashChain = %d\n", dptr->idHashChain);
48     fprintf(fid,"name = %s\n", dptr->dumpName);
49     fprintf(fid,"vsname = %s\n", dptr->volumeSet);
50     fprintf(fid,"dumpPath = %s\n", dptr->dumpPath);
51     fprintf(fid,"nameHashChain = %d\n", dptr->nameHashChain);
52     fprintf(fid,"flags = 0x%x\n", dptr->flags);
53     fprintf(fid,"parent = %u\n", dptr->parent);
54     fprintf(fid,"created = %s", ctime((time_t *)&dptr->created));
55     fprintf(fid,"nVolumes = %d\n", dptr->nVolumes);
56     /* printTapeSet(&dptr->tapes); */
57     fprintf(fid,"firstTape = %d\n", dptr->firstTape);
58     /* printKtcPrincipal(&dptr->dumper); */
59
60 }
61
62 printDumpEntry(deptr)
63      struct budb_dumpEntry *deptr;
64 {
65     printf("id = %u\n", deptr->id);
66     printf("Initial id = %u\n", deptr->initialDumpID);
67     printf("Appended id = %u\n", deptr->appendedDumpID);
68     printf("parent = %u\n", deptr->parent);
69     printf("level = %d\n", deptr->level);
70     printf("flags = 0x%x", deptr->flags);
71        if (deptr->flags == 0)                   printf(": Successful");
72        if (deptr->flags & BUDB_DUMP_INCOMPLETE) printf(": Incomplete");
73        if (deptr->flags & BUDB_DUMP_TAPEERROR)  printf(": Tape error");
74        if (deptr->flags & BUDB_DUMP_INPROGRESS) printf(": In progress");
75        if (deptr->flags & BUDB_DUMP_ABORTED)    printf(": Aborted");
76        if (deptr->flags & BUDB_DUMP_ADSM)       printf(": (ADSM)");       /* XBSA interface to ADSM */
77        if (deptr->flags & BUDB_DUMP_BUTA)       printf(": (BUTA)");       /* buta dump */
78        printf("\n");
79     printf("volumeSet = %s\n", deptr->volumeSetName);
80     printf("dump path = %s\n", deptr->dumpPath);
81     printf("name = %s\n", deptr->name);
82     printf("created = %s", ctime((time_t *)&deptr->created));
83     printf("nVolumes = %d\n", deptr->nVolumes);
84
85     printTapeSet(&deptr->tapes, (deptr->flags & BUDB_DUMP_XBSA_NSS));
86     printPrincipal(&deptr->dumper);
87 }
88
89 /* printHashTable
90  *      print the hash table structure, i.e. the header structure.
91  */
92
93 printHashTable(fid, htptr)
94      FILE *fid;
95      struct hashTable *htptr;
96 {
97     fprintf(fid,"functionType = %d\n", htptr->functionType);
98     fprintf(fid,"threadOffset = %d\n", htptr->threadOffset);
99     fprintf(fid,"entries = %d\n", htptr->entries);
100     fprintf(fid,"length = %d\n", htptr->length);
101     fprintf(fid,"table = %d\n", htptr->table);
102     fprintf(fid,"progress = %d\n", htptr->progress);
103     fprintf(fid,"oldLength = %d\n", htptr->oldLength);
104     fprintf(fid,"oldTable = %d\n", htptr->oldTable);
105 }
106
107 /* printMemoryHashTable
108  *      print the hash table structure, i.e. the header structure.
109  */
110 printMemoryHashTable(fid, mhtptr)
111      FILE *fid;
112      struct memoryHashTable *mhtptr;
113 {
114     fprintf(fid,"threadOffset = %d\n", mhtptr->threadOffset);
115     fprintf(fid,"length = %d\n", mhtptr->length);
116     fprintf(fid,"progress = %d\n", mhtptr->progress);
117     fprintf(fid,"size = %d\n", mhtptr->size);
118     fprintf(fid,"oldsize = %d\n", mhtptr->oldSize);
119 }
120
121 printPrincipal(ptr)
122      struct ktc_principal *ptr;
123 {
124     printf("name = %s\n", ptr->name);
125     printf("instance = %s\n", ptr->instance);
126     printf("cell = %s\n", ptr->cell);
127 }
128
129 printStructDumpHeader(ptr)
130      struct structDumpHeader *ptr;
131 {
132     printf("type = %d\n", ptr->type);
133     printf("structure version = %d\n", ptr->structversion);
134     printf("size = %d bytes\n", ptr->size);
135 }
136
137 printTape(fid, tptr)
138      FILE *fid;
139      struct tape *tptr;
140 {
141     fprintf(fid,"name = %s\n", tptr->name);
142     fprintf(fid,"nameHashChain = %d\n", tptr->nameHashChain);
143     fprintf(fid,"flags = 0x%x\n", tptr->flags);
144     fprintf(fid,"written = %s", ctime((time_t *)&tptr->written));
145     fprintf(fid,"nMBytes = %d\n", tptr->nMBytes);
146     fprintf(fid,"nBytes = %d\n", tptr->nBytes);
147     fprintf(fid,"nFiles = %d\n", tptr->nFiles);
148     fprintf(fid,"nVolumes = %d\n", tptr->nVolumes);
149     fprintf(fid,"seq = %d\n", tptr->seq);
150     fprintf(fid,"dump = %d\n", tptr->dump);
151     fprintf(fid,"nextTape = %d\n", tptr->nextTape);
152     fprintf(fid,"firstVol = %d\n", tptr->firstVol);
153     fprintf(fid,"labelPos = %d\n", tptr->labelpos);
154     fprintf(fid,"useCount = %d\n", tptr->useCount);
155 }
156
157 printTapeEntry(teptr)
158      struct budb_tapeEntry *teptr;
159 {
160     printf("name = %s\n", teptr->name);
161     printf("flags = 0x%x", teptr->flags);
162        if (teptr->flags & BUDB_TAPE_TAPEERROR)    printf(": Error");
163        if (teptr->flags & BUDB_TAPE_DELETED)      printf(": Deleted");
164        if (teptr->flags & BUDB_TAPE_BEINGWRITTEN) printf(": In progress");
165        if (teptr->flags & BUDB_TAPE_ABORTED)      printf(": Aborted");
166        if (teptr->flags & BUDB_TAPE_STAGED)       printf(": Staged");
167        if (teptr->flags & BUDB_TAPE_WRITTEN)      printf(": Successful");
168        printf("\n");
169     printf("written = %s", ctime((time_t *)&teptr->written));
170     printf("expires = %s", cTIME((time_t *)&teptr->expires));
171     printf("kBytes Tape Used = %u\n", teptr->useKBytes);
172     printf("nMBytes Data = %d\n", teptr->nMBytes);
173     printf("nBytes  Data = %d\n", teptr->nBytes);
174     printf("nFiles = %d\n", teptr->nFiles);
175     printf("nVolumes = %d\n", teptr->nVolumes);
176     printf("seq = %d\n", teptr->seq);
177     printf("labelPos = %d\n", teptr->labelpos);
178     printf("useCount = %d\n", teptr->useCount);
179     printf("dump = %d\n", teptr->dump);
180 }
181
182 printTapeSet(tsptr, nss)
183      struct budb_tapeSet *tsptr;
184      afs_int32 nss;                 /* is the tapeserver name an accurate name */
185 {
186     printf("Group id  = %d\n",tsptr->id );
187     printf("tapeServer = %s%s\n",
188            tsptr->tapeServer, (nss?" (single server)":""));
189     printf("format = %s\n",tsptr->format);
190     printf("maxTapes = %d\n",tsptr->maxTapes);
191 /*  printf("a  = %d\n",tsptr->a ); */
192 /*  printf("b = %d\n",tsptr->b);   */
193     printf("Start Tape Seq = %d\n",tsptr->b);
194 }
195
196 printVolumeEntry(veptr)
197      struct budb_volumeEntry *veptr;
198 {
199     printf("name = %s\n", veptr->name);
200     printf("flags = 0x%x", veptr->flags);
201        if (veptr->flags & BUDB_VOL_TAPEERROR) printf(": Tape Error");
202        if (veptr->flags & BUDB_VOL_FILEERROR) printf(": File Error");
203        if (veptr->flags & BUDB_VOL_BEINGWRITTEN) printf(": In progress");
204        if (veptr->flags & BUDB_VOL_FIRSTFRAG)    printf(": First fragment");
205        if (veptr->flags & BUDB_VOL_LASTFRAG)     printf(": Last fragment");
206        if (veptr->flags & BUDB_VOL_ABORTED)      printf(": Aborted");
207        printf("\n");
208     printf("id = %d\n", veptr->id);
209     printf("server = %s\n", veptr->server);
210     printf("partition = %d\n", veptr->partition);
211     printf("tapeSeq = %d\n", veptr->tapeSeq);
212
213     printf("position = %d\n", veptr->position);
214     printf("clone = %s", ctime((time_t *)&veptr->clone));
215     printf("startByte = %d\n", veptr->startByte);
216     printf("nBytes = %d\n", veptr->nBytes);
217     printf("seq = %d\n", veptr->seq);
218
219     printf("dump = %d\n", veptr->dump);
220     printf("tape = %s\n", veptr->tape);
221 }
222   
223 printVolFragment(fid, vfptr)
224      FILE *fid;
225      struct volFragment *vfptr;
226 {
227     fprintf(fid,"vol = %d\n", vfptr->vol);
228     fprintf(fid,"sameNameChain = %d\n", vfptr->sameNameChain);
229     fprintf(fid,"tape = %d\n", vfptr->tape);
230     fprintf(fid,"sameTapeChain = %d\n", vfptr->sameTapeChain);
231     fprintf(fid,"position = %d\n", vfptr->position);
232     fprintf(fid,"clone = %s", ctime((time_t *)&vfptr->clone));
233     fprintf(fid,"incTime = %s", ctime((time_t *)&vfptr->incTime));
234     fprintf(fid,"startByte = %d\n", vfptr->startByte);
235     fprintf(fid,"nBytes = %d\n", vfptr->nBytes);
236     fprintf(fid,"flags = %d\n", vfptr->flags);
237     fprintf(fid,"sequence = %d\n", vfptr->sequence);
238 }
239
240 printVolInfo(fid, viptr)
241      FILE *fid;
242      struct volInfo *viptr;
243 {
244     fprintf(fid,"name = %s\n", viptr->name);
245     fprintf(fid,"nameHashChain = %d\n", viptr->nameHashChain);
246     fprintf(fid,"id = %d\n", viptr->id);
247     fprintf(fid,"server = %s\n", viptr->server);
248     fprintf(fid,"partition = %d\n", viptr->partition);
249     fprintf(fid,"flags = 0x%x\n", viptr->flags);
250     fprintf(fid,"sameNameHead = %d\n", viptr->sameNameHead);
251     fprintf(fid,"sameNameChain = %d\n", viptr->sameNameChain);
252     fprintf(fid,"firstFragment = %d\n", viptr->firstFragment);
253     fprintf(fid,"nFrags = %d\n", viptr->nFrags);
254 }
255
256
257 /* -----------------------------------------
258  * structure xdr routines
259  * ----------------------------------------- 
260  */
261
262 /* utilities - network to host conversion
263  *      currently used for debug only
264  */
265
266 volFragment_ntoh(netVfPtr, hostVfPtr)
267      struct volFragment *netVfPtr, *hostVfPtr;
268 {
269     hostVfPtr->vol = ntohl(netVfPtr->vol);
270     hostVfPtr->sameNameChain = ntohl(netVfPtr->sameNameChain);
271     hostVfPtr->tape = ntohl(netVfPtr->tape);
272     hostVfPtr->sameTapeChain = ntohl(netVfPtr->sameTapeChain);
273     hostVfPtr->position = ntohl(netVfPtr->position);
274     hostVfPtr->clone = ntohl(netVfPtr->clone);
275     hostVfPtr->incTime = ntohl(netVfPtr->incTime);
276     hostVfPtr->startByte = ntohl(netVfPtr->startByte);
277     hostVfPtr->nBytes = ntohl(netVfPtr->nBytes);
278     hostVfPtr->flags = ntohs(netVfPtr->flags);
279     hostVfPtr->sequence = ntohs(netVfPtr->sequence);
280 }
281
282 volInfo_ntoh(netViPtr, hostViPtr)
283      struct volInfo *netViPtr, *hostViPtr;
284 {
285     strcpy(hostViPtr->name, netViPtr->name);
286     hostViPtr->nameHashChain = ntohl(netViPtr->nameHashChain);
287     hostViPtr->id = ntohl(netViPtr->id);
288     strcpy(hostViPtr->server, netViPtr->server);
289     hostViPtr->partition = ntohl(netViPtr->partition);
290     hostViPtr->flags = ntohl(netViPtr->flags);
291     hostViPtr->sameNameHead = ntohl(netViPtr->sameNameHead);
292     hostViPtr->sameNameChain = ntohl(netViPtr->sameNameChain);
293     hostViPtr->firstFragment = ntohl(netViPtr->firstFragment);
294     hostViPtr->nFrags = ntohl(netViPtr->nFrags);
295 }
296
297 tape_ntoh(netTapePtr, hostTapePtr)
298      struct tape *netTapePtr, *hostTapePtr;
299 {
300     strcpy(hostTapePtr->name, netTapePtr->name);
301     hostTapePtr->nameHashChain = ntohl(netTapePtr->nameHashChain);
302     hostTapePtr->flags = ntohl(netTapePtr->flags);
303
304     /* tape id conversion here */
305     hostTapePtr->written = ntohl(netTapePtr->written);
306     hostTapePtr->nMBytes = ntohl(netTapePtr->nMBytes);
307     hostTapePtr->nBytes = ntohl(netTapePtr->nBytes);
308     hostTapePtr->nFiles = ntohl(netTapePtr->nFiles);
309     hostTapePtr->nVolumes = ntohl(netTapePtr->nVolumes);
310     hostTapePtr->seq = ntohl(netTapePtr->seq);
311     hostTapePtr->dump = ntohl(netTapePtr->dump);
312     hostTapePtr->nextTape = ntohl(netTapePtr->nextTape);
313     hostTapePtr->labelpos = ntohl(netTapePtr->labelpos);
314     hostTapePtr->firstVol = ntohl(netTapePtr->firstVol);
315     hostTapePtr->useCount = ntohl(netTapePtr->useCount);
316 }
317
318 dump_ntoh(netDumpPtr, hostDumpPtr)
319      struct dump *netDumpPtr, *hostDumpPtr;
320 {
321     hostDumpPtr->id = ntohl(netDumpPtr->id);    
322     hostDumpPtr->idHashChain = ntohl(netDumpPtr->idHashChain);
323     strcpy(hostDumpPtr->dumpName, netDumpPtr->dumpName);
324     strcpy(hostDumpPtr->dumpPath, netDumpPtr->dumpPath);
325     strcpy(hostDumpPtr->volumeSet, netDumpPtr->volumeSet);
326     hostDumpPtr->nameHashChain = ntohl(netDumpPtr->nameHashChain);
327     hostDumpPtr->flags = ntohl(netDumpPtr->flags);
328     hostDumpPtr->parent = ntohl(netDumpPtr->parent);
329     hostDumpPtr->created = ntohl(netDumpPtr->created);
330     hostDumpPtr->nVolumes = ntohl(netDumpPtr->nVolumes);
331     hostDumpPtr->level = ntohl(netDumpPtr->level);
332
333     tapeSet_ntoh(&netDumpPtr->tapes, &hostDumpPtr->tapes);
334
335     hostDumpPtr->firstTape = ntohl(netDumpPtr->firstTape);
336
337     principal_ntoh(&netDumpPtr->dumper, &hostDumpPtr->dumper);
338 }
339
340 DbHeader_ntoh(netptr, hostptr)
341      struct DbHeader *netptr, *hostptr;
342 {
343     hostptr->dbversion = ntohl(netptr->dbversion);
344     hostptr->created = ntohl(netptr->created);
345     strcpy(hostptr->cell, netptr->cell);
346     hostptr->lastDumpId = ntohl(netptr->lastDumpId);
347     hostptr->lastInstanceId = ntohl(netptr->lastInstanceId);
348     hostptr->lastTapeId = ntohl(netptr->lastTapeId);
349 }
350
351 dumpEntry_ntoh(netptr, hostptr)
352      struct budb_dumpEntry *netptr, *hostptr;
353 {
354     hostptr->id = ntohl(netptr->id);
355     hostptr->initialDumpID = ntohl(netptr->initialDumpID);
356     hostptr->appendedDumpID = ntohl(netptr->appendedDumpID);
357     hostptr->parent = ntohl(netptr->parent);
358     hostptr->level = ntohl(netptr->level);
359     hostptr->flags = ntohl(netptr->flags);
360     strcpy(hostptr->volumeSetName, netptr->volumeSetName);
361     strcpy(hostptr->dumpPath, netptr->dumpPath);
362     strcpy(hostptr->name, netptr->name);
363     hostptr->created = ntohl(netptr->created);
364     hostptr->incTime = ntohl(netptr->incTime);
365     hostptr->nVolumes = ntohl(netptr->nVolumes);
366
367     tapeSet_ntoh(&netptr->tapes, &hostptr->tapes);
368     principal_ntoh(&netptr->dumper, &hostptr->dumper);
369 }
370
371 principal_hton(hostptr, netptr)
372      struct ktc_principal *hostptr, *netptr;
373 {
374     strcpy(netptr->name, hostptr->name);
375     strcpy(netptr->instance, hostptr->instance);
376     strcpy(netptr->cell, hostptr->cell);
377 }
378
379 principal_ntoh(netptr, hostptr)
380      struct ktc_principal *netptr, *hostptr;
381 {
382     strcpy(hostptr->name, netptr->name);
383     strcpy(hostptr->instance, netptr->instance);
384     strcpy(hostptr->cell, netptr->cell);
385 }
386
387 structDumpHeader_hton(hostPtr, netPtr)
388      struct structDumpHeader *hostPtr, *netPtr;
389 {
390     netPtr->type = htonl(hostPtr->type);
391     netPtr->structversion = htonl(hostPtr->structversion);
392     netPtr->size = htonl(hostPtr->size);
393 }
394
395 structDumpHeader_ntoh(netPtr, hostPtr)
396      struct structDumpHeader *hostPtr, *netPtr;
397 {
398     hostPtr->type = ntohl(netPtr->type);
399     hostPtr->structversion = ntohl(netPtr->structversion);
400     hostPtr->size = ntohl(netPtr->size);
401 }
402
403 tapeEntry_ntoh(netptr, hostptr)
404      struct budb_tapeEntry *netptr, *hostptr;
405 {
406     strcpy(hostptr->name, netptr->name);
407     hostptr->flags = ntohl(netptr->flags);
408     hostptr->written = ntohl(netptr->written);
409     hostptr->expires = ntohl(netptr->expires);
410     hostptr->nMBytes = ntohl(netptr->nMBytes);
411     hostptr->nBytes = ntohl(netptr->nBytes);
412     hostptr->nFiles = ntohl(netptr->nFiles);
413     hostptr->nVolumes = ntohl(netptr->nVolumes);
414     hostptr->seq = ntohl(netptr->seq);
415     hostptr->labelpos = ntohl(netptr->labelpos);
416     hostptr->useCount = ntohl(netptr->useCount);
417     hostptr->useKBytes = ntohl(netptr->useKBytes);
418     hostptr->dump = ntohl(netptr->dump);
419 }
420
421 tapeSet_hton(hostptr, netptr)
422      struct budb_tapeSet *hostptr, *netptr;
423 {
424     netptr->id = htonl(hostptr->id);
425     strcpy(netptr->tapeServer, hostptr->tapeServer);    
426     strcpy(netptr->format, hostptr->format);    
427     netptr->maxTapes = htonl(hostptr->maxTapes);
428     netptr->a = htonl(hostptr->a);
429     netptr->b = htonl(hostptr->b);
430 }
431
432 tapeSet_ntoh(netptr, hostptr)
433      struct budb_tapeSet *netptr, *hostptr;
434 {
435     hostptr->id = ntohl(netptr->id);
436     strcpy(hostptr->tapeServer, netptr->tapeServer);    
437     strcpy(hostptr->format, netptr->format);    
438     hostptr->maxTapes = ntohl(netptr->maxTapes);
439     hostptr->a = ntohl(netptr->a);
440     hostptr->b = ntohl(netptr->b);
441 }
442
443 textBlock_hton(hostptr, netptr)
444      struct textBlock *hostptr, *netptr;
445 {
446     netptr->version = htonl(hostptr->version);
447     netptr->size = htonl(hostptr->size);
448     netptr->textAddr = htonl(hostptr->textAddr);
449     netptr->newsize = htonl(hostptr->newsize);
450     netptr->newTextAddr = htonl(hostptr->newTextAddr);
451 }
452
453 textBlock_ntoh(netptr, hostptr)
454      struct textBlock *netptr, *hostptr;
455 {
456     hostptr->version = ntohl(netptr->version);
457     hostptr->size = ntohl(netptr->size);
458     hostptr->textAddr = ntohl(netptr->textAddr);
459     hostptr->newsize = ntohl(netptr->newsize);
460     hostptr->newTextAddr = ntohl(netptr->newTextAddr);
461 }
462
463 textLock_hton(hostptr, netptr)
464      db_lockP   hostptr, netptr;
465 {
466     netptr->type = htonl(hostptr->type);
467     netptr->lockState = htonl(hostptr->lockState);
468     netptr->lockTime = htonl(hostptr->lockTime);
469     netptr->expires = htonl(hostptr->expires);
470     netptr->instanceId = htonl(hostptr->instanceId);
471     netptr->lockHost = htonl(hostptr->lockHost);
472 }
473
474 textLock_ntoh(netptr, hostptr)
475      db_lockP   netptr, hostptr;
476 {
477     hostptr->type = ntohl(netptr->type);
478     hostptr->lockState = ntohl(netptr->lockState);
479     hostptr->lockTime = ntohl(netptr->lockTime);
480     hostptr->expires = ntohl(netptr->expires);
481     hostptr->instanceId = ntohl(netptr->instanceId);
482     hostptr->lockHost = ntohl(netptr->lockHost);
483 }
484
485 volumeEntry_ntoh(netptr, hostptr)
486      struct budb_volumeEntry *netptr, *hostptr;
487 {
488     strcpy(hostptr->name, netptr->name);
489     hostptr->flags = ntohl(netptr->flags);
490     hostptr->id = ntohl(netptr->id);
491     strcpy(hostptr->server, netptr->server);
492     hostptr->partition = ntohl(netptr->partition);
493     hostptr->tapeSeq = ntohl(netptr->tapeSeq);
494
495     hostptr->position  = ntohl(netptr->position);
496     hostptr->clone = ntohl(netptr->clone);
497     hostptr->incTime = ntohl(netptr->incTime);
498     hostptr->startByte = ntohl(netptr->startByte);
499     hostptr->nBytes = ntohl(netptr->nBytes);
500     hostptr->seq = ntohl(netptr->seq);
501
502     hostptr->dump = ntohl(netptr->dump);
503     strcpy(hostptr->tape, netptr->tape);
504 }
505
506 /* -------------------------------------
507  * structure conversion & copy routines 
508  * -------------------------------------
509  */
510
511
512 copy_ktcPrincipal_to_budbPrincipal(ktcPtr, budbPtr)
513      struct ktc_principal *ktcPtr;
514      struct budb_principal *budbPtr;
515 {
516     strncpy(budbPtr->name, ktcPtr->name, sizeof(budbPtr->name));
517     strncpy(budbPtr->instance, ktcPtr->instance, sizeof(budbPtr->instance));
518     strncpy(budbPtr->cell, ktcPtr->cell, sizeof(budbPtr->cell));
519 }
520
521 /* dumpToBudbDump
522  * entry:
523  *      dumpPtr - host format
524  */
525
526 dumpToBudbDump(dumpPtr, budbDumpPtr)
527      dbDumpP dumpPtr;
528      struct budb_dumpEntry *budbDumpPtr;
529 {
530     budbDumpPtr->id = dumpPtr->id;
531     budbDumpPtr->initialDumpID = dumpPtr->initialDumpID;
532     budbDumpPtr->parent = dumpPtr->parent;
533     budbDumpPtr->level = dumpPtr->level;
534     budbDumpPtr->flags = dumpPtr->flags;
535
536     strcpy(budbDumpPtr->volumeSetName, dumpPtr->volumeSet);
537     strcpy(budbDumpPtr->dumpPath, dumpPtr->dumpPath);
538     strcpy(budbDumpPtr->name, dumpPtr->dumpName);
539
540     budbDumpPtr->created = dumpPtr->created;
541     budbDumpPtr->nVolumes = dumpPtr->nVolumes;
542
543     bcopy(&dumpPtr->tapes, &budbDumpPtr->tapes, sizeof(struct budb_tapeSet));
544     copy_ktcPrincipal_to_budbPrincipal(&dumpPtr->dumper, &budbDumpPtr->dumper);
545     return(0);
546 }
547
548 tapeToBudbTape(tapePtr, budbTapePtr)
549      struct tape *tapePtr;
550      struct budb_tapeEntry *budbTapePtr;
551 {
552     strcpy(budbTapePtr->name, tapePtr->name);
553     budbTapePtr->flags = tapePtr->flags;
554     budbTapePtr->written = tapePtr->written;
555     budbTapePtr->expires = tapePtr->expires;
556     budbTapePtr->nMBytes = tapePtr->nMBytes;
557     budbTapePtr->nBytes = tapePtr->nBytes;
558     budbTapePtr->nFiles = tapePtr->nFiles;
559     budbTapePtr->nVolumes = tapePtr->nVolumes;
560     budbTapePtr->seq = tapePtr->seq;
561     budbTapePtr->labelpos = tapePtr->labelpos;
562     budbTapePtr->useCount = tapePtr->useCount;
563     budbTapePtr->useKBytes = tapePtr->useKBytes;
564     return(0);
565 }
566
567 volsToBudbVol(volFragPtr, volInfoPtr, budbVolPtr)
568      struct volFragment *volFragPtr;
569      struct volInfo *volInfoPtr;
570      struct budb_volumeEntry *budbVolPtr;
571 {
572     strcpy(budbVolPtr->name, volInfoPtr->name);
573     budbVolPtr->flags = volInfoPtr->flags;
574     budbVolPtr->id = volInfoPtr->id;
575     strcpy(budbVolPtr->server, volInfoPtr->server);
576     budbVolPtr->partition = volInfoPtr->partition;
577     budbVolPtr->tapeSeq = 0;      /* Don't know it so mark invalid */
578
579     budbVolPtr->position = volFragPtr->position;
580     budbVolPtr->clone = volFragPtr->clone;
581     budbVolPtr->incTime = volFragPtr->incTime;
582     budbVolPtr->startByte = volFragPtr->startByte;
583     budbVolPtr->nBytes = volFragPtr->nBytes;
584     budbVolPtr->seq = volFragPtr->sequence;
585     return(0);
586 }
587
588 /* ----------------------------------
589  * structure initialization routines 
590  *  ---------------------------------
591  */
592
593 /* default_tapeset
594  *      this fills in the tape set with the current default tapeset
595  *      format;
596  * entry:
597  *      dumpname - volset.dumplevel
598  * exit:
599  *      0 - ok
600  *      n - error
601  */
602
603 default_tapeset(tapesetPtr, dumpname)
604      struct budb_tapeSet *tapesetPtr;
605      char *dumpname;
606 {
607     bzero(tapesetPtr, sizeof(*tapesetPtr));
608
609     strcpy(tapesetPtr->format, dumpname);
610     strcat(tapesetPtr->format, ".%d");
611     tapesetPtr->a = 1;
612     tapesetPtr->b = 1;
613     tapesetPtr->maxTapes = 0;
614 }