1 /* archive-version.c:
2  *
3  ****************************************************************
4  * Copyright (C) 2003 Tom Lord
5  *
6  * See the file "COPYING" for further information about
7  * the copyright and warranty status of this work.
8  */
9 
10 
11 #include "hackerlab/bugs/panic.h"
12 #include "hackerlab/char/str.h"
13 #include "tla/libarch/archive-version.h"
14 
15 
16 
17 /* These must agree about the format version number.
18  */
19 static const int arch_archive_format_vsn = 2;
20 static const char arch_archive_format_vsn_id[] = "2";
21 const char arch_tree_format_1_str[] = "Hackerlab arch archive directory, format version 1.";
22 const char arch_tree_format_2_str[] = "Hackerlab arch archive directory, format version 2.";
23 static const char arch_tree_format_str[] = "Bazaar archive format 1 0";
24 
25 
26 
27 t_uchar *
arch_archive_version_for_new_archive(int tla_archive)28 arch_archive_version_for_new_archive (int tla_archive)
29 {
30   if (!tla_archive)
31     return str_save (0, (t_uchar *)arch_tree_format_str);
32   else
33     return str_save (0, (t_uchar *)arch_tree_format_2_str);
34 }
35 
36 
37 enum arch_archive_access
arch_archive_access(t_uchar * version)38 arch_archive_access (t_uchar * version)
39 {
40   if (!str_cmp (version, arch_tree_format_str))
41     return arch_archive_writable;
42   else if (!str_cmp (version, arch_tree_format_2_str))
43     return arch_archive_writable;
44   else if (!str_cmp (version, arch_tree_format_1_str))
45     return arch_archive_readable;
46   else
47     return arch_archive_incompatible;
48 }
49 
50 enum arch_archive_type
arch_archive_type(t_uchar * version)51 arch_archive_type (t_uchar * version)
52 {
53   if (!str_cmp (version, arch_tree_format_str))
54     return arch_archive_baz;
55   else if (!str_cmp (version, arch_tree_format_2_str))
56     return arch_archive_tla;
57   else if (!str_cmp (version, arch_tree_format_1_str))
58     return arch_archive_tla;
59   else
60     {
61       panic ("unknown archive type");
62       return (enum arch_archive_type)-1; /* not reached */
63     }
64 }
65 
66 
67 
68 
69 /* tag: Tom Lord Fri May 23 22:17:13 2003 (archive-version.c)
70  */
71