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