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