Differences From
Artifact [2342477e32]:
23 23 sqlite3 *db;
24 24 const char *cachedir;
25 25 time_t boottime;
26 26 };
27 27
28 28 struct appfs_thread_data globalThread;
29 29
30 -typedef enum {
31 - APPFS_OS_UNKNOWN,
32 - APPFS_OS_ALL,
33 - APPFS_OS_LINUX,
34 - APPFS_OS_MACOSX,
35 - APPFS_OS_FREEBSD,
36 - APPFS_OS_OPENBSD,
37 - APPFS_OS_SOLARIS
38 -} appfs_os_t;
39 -
40 -typedef enum {
41 - APPFS_CPU_UNKNOWN,
42 - APPFS_CPU_ALL,
43 - APPFS_CPU_AMD64,
44 - APPFS_CPU_I386,
45 - APPFS_CPU_ARM
46 -} appfs_cpuArch_t;
47 -
48 30 typedef enum {
49 31 APPFS_PATHTYPE_INVALID,
50 32 APPFS_PATHTYPE_FILE,
51 33 APPFS_PATHTYPE_DIRECTORY,
52 34 APPFS_PATHTYPE_SYMLINK
53 35 } appfs_pathtype_t;
54 36
55 -struct appfs_package {
56 - struct appfs_package *_next;
57 - int counter;
58 -
59 - char name[256];
60 - char version[64];
61 - char sha1[41];
62 - char os_str[64];
63 - char cpuArch_str[64];
64 - appfs_os_t os;
65 - appfs_cpuArch_t cpuArch;
66 - int isLatest;
67 -};
68 -
69 -struct appfs_site {
70 - struct appfs_site *_next;
71 - int counter;
72 -
73 - char name[256];
74 -};
75 -
76 37 struct appfs_children {
77 38 struct appfs_children *_next;
78 39 int counter;
79 40
80 41 char name[256];
81 42 };
82 43
................................................................................
98 59
99 60 struct appfs_sqlite3_query_cb_handle {
100 61 struct appfs_children *head;
101 62 int argc;
102 63 const char *fmt;
103 64 };
104 65
105 -static appfs_os_t appfs_convert_os_fromString(const char *os) {
106 - if (strcasecmp(os, "Linux") == 0) {
107 - return(APPFS_OS_LINUX);
108 - }
109 -
110 - if (strcasecmp(os, "Darwin") == 0 || strcasecmp(os, "Mac OS") == 0 || strcasecmp(os, "Mac OS X") == 0) {
111 - return(APPFS_OS_MACOSX);
112 - }
113 -
114 - if (strcasecmp(os, "noarch") == 0) {
115 - return(APPFS_OS_ALL);
116 - }
117 -
118 - return(APPFS_OS_UNKNOWN);
119 -}
120 -
121 -static const char *appfs_convert_os_toString(appfs_os_t os) {
122 - switch (os) {
123 - case APPFS_OS_ALL:
124 - return("noarch");
125 - case APPFS_OS_LINUX:
126 - return("linux");
127 - case APPFS_OS_MACOSX:
128 - return("macosx");
129 - case APPFS_OS_FREEBSD:
130 - return("freebsd");
131 - case APPFS_OS_OPENBSD:
132 - return("openbsd");
133 - case APPFS_OS_SOLARIS:
134 - return("freebsd");
135 - case APPFS_CPU_UNKNOWN:
136 - return("unknown");
137 - }
138 -
139 - return("unknown");
140 -}
141 -
142 -static appfs_cpuArch_t appfs_convert_cpuArch_fromString(const char *cpu) {
143 - if (strcasecmp(cpu, "amd64") == 0 || strcasecmp(cpu, "x86_64") == 0) {
144 - return(APPFS_CPU_AMD64);
145 - }
146 -
147 - if (strcasecmp(cpu, "i386") == 0 || \
148 - strcasecmp(cpu, "i486") == 0 || \
149 - strcasecmp(cpu, "i586") == 0 || \
150 - strcasecmp(cpu, "i686") == 0 || \
151 - strcasecmp(cpu, "ix86") == 0) {
152 - return(APPFS_CPU_I386);
153 - }
154 -
155 - if (strcasecmp(cpu, "arm") == 0) {
156 - return(APPFS_CPU_ARM);
157 - }
158 -
159 - if (strcasecmp(cpu, "noarch") == 0) {
160 - return(APPFS_CPU_ALL);
161 - }
162 -
163 - return(APPFS_CPU_UNKNOWN);
164 -}
165 -
166 -static const char *appfs_convert_cpuArch_toString(appfs_cpuArch_t cpu) {
167 - switch (cpu) {
168 - case APPFS_CPU_ALL:
169 - return("noarch");
170 - case APPFS_CPU_AMD64:
171 - return("amd64");
172 - case APPFS_CPU_I386:
173 - return("ix86");
174 - case APPFS_CPU_ARM:
175 - return("arm");
176 - case APPFS_CPU_UNKNOWN:
177 - return("unknown");
178 - }
179 -
180 - return("unknown");
181 -}
182 -
183 66 static Tcl_Interp *appfs_create_TclInterp(const char *cachedir) {
184 67 Tcl_Interp *interp;
185 68 int tcl_ret;
186 69
187 70 interp = Tcl_CreateInterp();
188 71 if (interp == NULL) {
189 72 fprintf(stderr, "Unable to create Tcl Interpreter. Aborting.\n");
................................................................................
644 527 appfs_free_list_children(dir_children);
645 528
646 529 return(0);
647 530 }
648 531 /* Get information about a path, and optionally list children */
649 532 static int appfs_get_path_info(const char *_path, struct appfs_pathinfo *pathinfo, struct appfs_children **children) {
650 533 struct appfs_children *dir_children;
651 - appfs_os_t os_val;
652 - appfs_cpuArch_t cpuArch_val;
653 534 char *hostname, *packagename, *os_cpuArch, *os, *cpuArch, *version;
654 535 char *path, *path_s;
655 536 char *package_hash;
656 537 char *sql;
657 538 int files_count;
658 539 int fileinfo_ret, retval;
659 540
................................................................................
737 618 }
738 619
739 620 os = os_cpuArch;
740 621 cpuArch = strchr(os_cpuArch, '-');
741 622 if (cpuArch) {
742 623 *cpuArch = '\0';
743 624 cpuArch++;
744 -
745 - cpuArch_val = appfs_convert_cpuArch_fromString(cpuArch);
746 - } else {
747 - cpuArch_val = APPFS_CPU_UNKNOWN;
748 625 }
749 626
750 - os_val = appfs_convert_os_fromString(os);
751 -
752 627 if (version == NULL) {
753 628 /* Request for version list for a package on an OS/CPU */
754 629 appfs_update_index(hostname);
755 630
756 631 sql = sqlite3_mprintf("SELECT DISTINCT version FROM packages WHERE hostname = %Q AND package = %Q AND os = %Q and cpuArch = %Q;", hostname, packagename, os, cpuArch);
757 632
758 633 free(path_s);