• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

The MinGW.org Installation Manager Tool


Commit MetaInfo

Révision9b1e7fdd6ec29ba4cef95665722de7684c75b355 (tree)
l'heure2009-05-01 23:23:51
AuteurJohn E. <tdragon@user...>
CommiterJohn E.

Message de Log

Preserve file attributes in archives, UI code modularization

Change Summary

Modification

--- a/archiveread.c
+++ b/archiveread.c
@@ -73,7 +73,9 @@ int ArchiveRead_ExtractEntryToBase
7373 (ArchiveReader* reader,
7474 char const* base_path)
7575 {
76- return ((ArchiveReaderStruct*)reader)->internal_extract_entry_to_base(reader, base_path);
76+ return ((ArchiveReaderStruct*)reader)->internal_extract_entry_to_base(
77+ reader, base_path
78+ );
7779 }
7880
7981
--- a/archiveread7z.c
+++ b/archiveread7z.c
@@ -109,76 +109,81 @@ int ArchiveRead7z_ExtractEntryToBase
109109 READER7Z(reader)->db.Database.Files[READER7Z(reader)->entry].Name);
110110
111111 if (ArchiveRead7z_EntryIsDirectory(reader))
112- return ArchiveRead_EnsureDirectory(fullpath, strlen(base_path));
113-
114- int rmostsep = strlen(fullpath) - 1;
115- while (rmostsep > 0
116- && fullpath[rmostsep] != '/' && fullpath[rmostsep] != '\\')
117- --rmostsep;
118- if (rmostsep > 0)
119112 {
120- char save = fullpath[rmostsep];
121- fullpath[rmostsep] = 0;
122113 if (!ArchiveRead_EnsureDirectory(fullpath, strlen(base_path)))
123- {
124- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
125- "Failed to create directory '%s' for extraction", fullpath);
126114 return 0;
127- }
128- fullpath[rmostsep] = save;
129115 }
130-
131- if (!READER7Z(reader)->instream.filep)
116+ else
132117 {
133- READER7Z(reader)->instream.filep =
134- fopen(READER7Z(reader)->path, "rb");
118+ int rmostsep = strlen(fullpath) - 1;
119+ while (rmostsep > 0
120+ && fullpath[rmostsep] != '/' && fullpath[rmostsep] != '\\')
121+ --rmostsep;
122+ if (rmostsep > 0)
123+ {
124+ char save = fullpath[rmostsep];
125+ fullpath[rmostsep] = 0;
126+ if (!ArchiveRead_EnsureDirectory(fullpath, strlen(base_path)))
127+ {
128+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
129+ "Failed to create directory '%s' for extraction", fullpath);
130+ return 0;
131+ }
132+ fullpath[rmostsep] = save;
133+ }
134+
135135 if (!READER7Z(reader)->instream.filep)
136136 {
137+ READER7Z(reader)->instream.filep =
138+ fopen(READER7Z(reader)->path, "rb");
139+ if (!READER7Z(reader)->instream.filep)
140+ {
141+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
142+ "Failed to reopen file '%s' for entry extraction",
143+ READER7Z(reader)->path);
144+ return 0;
145+ }
146+ }
147+
148+ size_t offset, outSizeProcessed;
149+ SZ_RESULT res = SzExtract(&(READER7Z(reader)->instream.sz_stream),
150+ &(READER7Z(reader)->db), READER7Z(reader)->entry,
151+ &(READER7Z(reader)->blockIndex),
152+ &(READER7Z(reader)->outBuffer),
153+ &(READER7Z(reader)->outBufferSize), &offset, &outSizeProcessed,
154+ &g_allocImp, &g_allocTempImp);
155+ if (res == SZE_CRC_ERROR)
156+ {
137157 ArchiveRead_SetError((ArchiveReaderStruct*)reader,
138- "Failed to reopen file '%s' for entry extraction",
139- READER7Z(reader)->path);
158+ "Bad CRC for entry '%s'",
159+ READER7Z(reader)->db.Database.Files[READER7Z(reader)->entry].Name);
160+ return 0;
161+ }
162+ else if (res != SZ_OK)
163+ {
164+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
165+ "7zlib failed to unpack entry '%s'",
166+ READER7Z(reader)->db.Database.Files[READER7Z(reader)->entry].Name);
140167 return 0;
141168 }
142- }
143169
144- size_t offset, outSizeProcessed;
145- SZ_RESULT res = SzExtract(&(READER7Z(reader)->instream.sz_stream),
146- &(READER7Z(reader)->db), READER7Z(reader)->entry,
147- &(READER7Z(reader)->blockIndex),
148- &(READER7Z(reader)->outBuffer),
149- &(READER7Z(reader)->outBufferSize), &offset, &outSizeProcessed,
150- &g_allocImp, &g_allocTempImp);
151- if (res == SZE_CRC_ERROR)
152- {
153- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
154- "Bad CRC for entry '%s'",
155- READER7Z(reader)->db.Database.Files[READER7Z(reader)->entry].Name);
156- return 0;
157- }
158- else if (res != SZ_OK)
159- {
160- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
161- "7zlib failed to unpack entry '%s'",
162- READER7Z(reader)->db.Database.Files[READER7Z(reader)->entry].Name);
163- return 0;
164- }
170+ char tmppath[PATH_MAX + 1];
171+ snprintf(tmppath, PATH_MAX + 1, "%s.tmp", fullpath);
165172
166- char tmppath[PATH_MAX + 1];
167- snprintf(tmppath, PATH_MAX + 1, "%s.tmp", fullpath);
173+ FILE* outfile = fopen(tmppath, "wb");
174+ if (!outfile)
175+ {
176+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
177+ "Failed to open output file '%s'", tmppath);
178+ return 0;
179+ }
180+ fwrite(READER7Z(reader)->outBuffer + offset, 1, outSizeProcessed,
181+ outfile);
182+ fclose(outfile);
168183
169- FILE* outfile = fopen(tmppath, "wb");
170- if (!outfile)
171- {
172- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
173- "Failed to open output file '%s'", tmppath);
174- return 0;
184+ remove(fullpath);
185+ rename(tmppath, fullpath);
175186 }
176- fwrite(READER7Z(reader)->outBuffer + offset, 1, outSizeProcessed,
177- outfile);
178- fclose(outfile);
179-
180- remove(fullpath);
181- rename(tmppath, fullpath);
182187
183188 if (READER7Z(reader)->db.Database.Files[READER7Z(reader)->entry].AreAttributesDefined)
184189 SetFileAttributes(fullpath, READER7Z(reader)->db.Database.Files[READER7Z(reader)->entry].Attributes);
@@ -222,6 +227,7 @@ void* ArchiveRead7z_OpenFile(char const* file)
222227 SZ_RESULT ret = SzArchiveOpen(&instream.sz_stream, &reader->db, &g_allocImp,
223228 &g_allocTempImp);
224229 fclose(instream.filep);
230+ instream.filep = 0;
225231 if (ret != SZ_OK)
226232 {
227233 ArchiveRead_SetError(&reader->base,
--- a/archivereadtar.c
+++ b/archivereadtar.c
@@ -385,65 +385,71 @@ int ArchiveReadTar_ExtractEntryToBase
385385 READERTAR(reader)->entry_path);
386386
387387 if (ArchiveReadTar_EntryIsDirectory(reader))
388- return ArchiveRead_EnsureDirectory(fullpath, strlen(base_path));
389-
390- int rmostsep = strlen(fullpath) - 1;
391- while (rmostsep > 0
392- && fullpath[rmostsep] != '/' && fullpath[rmostsep] != '\\')
393- --rmostsep;
394- if (rmostsep > 0)
395388 {
396- char save = fullpath[rmostsep];
397- fullpath[rmostsep] = 0;
398389 if (!ArchiveRead_EnsureDirectory(fullpath, strlen(base_path)))
399- {
400- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
401- "Failed to create directory '%s' for extraction", fullpath);
402390 return 0;
403- }
404- fullpath[rmostsep] = save;
405391 }
406-
407- char tmppath[PATH_MAX + 1];
408- snprintf(tmppath, PATH_MAX + 1, "%s.tmp", fullpath);
409-
410- FILE* outfile = fopen(tmppath, "wb");
411- if (!outfile)
392+ else
412393 {
413- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
414- "Failed to open file '%s' for output", tmppath);
415- return 0;
416- }
394+ int rmostsep = strlen(fullpath) - 1;
395+ while (rmostsep > 0
396+ && fullpath[rmostsep] != '/' && fullpath[rmostsep] != '\\')
397+ --rmostsep;
398+ if (rmostsep > 0)
399+ {
400+ char save = fullpath[rmostsep];
401+ fullpath[rmostsep] = 0;
402+ if (!ArchiveRead_EnsureDirectory(fullpath, strlen(base_path)))
403+ {
404+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
405+ "Failed to create directory '%s' for extraction", fullpath);
406+ return 0;
407+ }
408+ fullpath[rmostsep] = save;
409+ }
417410
418- char buf[BLOCKSIZE];
419- while (READERTAR(reader)->entry_data > 0)
420- {
421- if (DecompressRead(READERTAR(reader), buf, BLOCKSIZE) != BLOCKSIZE)
411+ char tmppath[PATH_MAX + 1];
412+ snprintf(tmppath, PATH_MAX + 1, "%s.tmp", fullpath);
413+
414+ FILE* outfile = fopen(tmppath, "wb");
415+ if (!outfile)
422416 {
423417 ArchiveRead_SetError((ArchiveReaderStruct*)reader,
424- "Failed to read %d bytes from decompression stream", BLOCKSIZE);
425- fclose(outfile);
426- remove(tmppath);
418+ "Failed to open file '%s' for output", tmppath);
427419 return 0;
428420 }
429- int write = (READERTAR(reader)->entry_data < BLOCKSIZE) ?
430- READERTAR(reader)->entry_data : BLOCKSIZE;
431- if (fwrite(buf, 1, write, outfile) != write)
421+
422+ char buf[BLOCKSIZE];
423+ while (READERTAR(reader)->entry_data > 0)
432424 {
433- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
434- "Failed to write %d bytes to '%s'", write, tmppath);
435- fclose(outfile);
436- remove(tmppath);
437- return 0;
425+ if (DecompressRead(READERTAR(reader), buf, BLOCKSIZE) != BLOCKSIZE)
426+ {
427+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
428+ "Failed to read %d bytes from decompression stream", BLOCKSIZE);
429+ fclose(outfile);
430+ remove(tmppath);
431+ return 0;
432+ }
433+ int write = (READERTAR(reader)->entry_data < BLOCKSIZE) ?
434+ READERTAR(reader)->entry_data : BLOCKSIZE;
435+ if (fwrite(buf, 1, write, outfile) != write)
436+ {
437+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
438+ "Failed to write %d bytes to '%s'", write, tmppath);
439+ fclose(outfile);
440+ remove(tmppath);
441+ return 0;
442+ }
443+ READERTAR(reader)->entry_data -= write;
438444 }
439- READERTAR(reader)->entry_data -= write;
440- }
441- fclose(outfile);
445+ fclose(outfile);
446+
447+ remove(fullpath);
448+ rename(tmppath, fullpath);
442449
443- remove(fullpath);
444- rename(tmppath, fullpath);
450+ setfiletime(fullpath, READERTAR(reader)->entry_time);
451+ }
445452
446- setfiletime(fullpath, READERTAR(reader)->entry_time);
447453 chmod(fullpath, READERTAR(reader)->entry_mode);
448454
449455 return 1;
--- a/archivereadzip.c
+++ b/archivereadzip.c
@@ -117,84 +117,90 @@ int ArchiveReadZip_ExtractEntryToBase
117117 READERZIP(reader)->entry_path);
118118
119119 if (ArchiveReadZip_EntryIsDirectory(reader))
120- return ArchiveRead_EnsureDirectory(fullpath, strlen(base_path));
121-
122- int rmostsep = strlen(fullpath) - 1;
123- while (rmostsep > 0
124- && fullpath[rmostsep] != '/' && fullpath[rmostsep] != '\\')
125- --rmostsep;
126- if (rmostsep > 0)
127120 {
128- char save = fullpath[rmostsep];
129- fullpath[rmostsep] = 0;
130121 if (!ArchiveRead_EnsureDirectory(fullpath, strlen(base_path)))
122+ return 0;
123+ }
124+ else
125+ {
126+ int rmostsep = strlen(fullpath) - 1;
127+ while (rmostsep > 0
128+ && fullpath[rmostsep] != '/' && fullpath[rmostsep] != '\\')
129+ --rmostsep;
130+ if (rmostsep > 0)
131+ {
132+ char save = fullpath[rmostsep];
133+ fullpath[rmostsep] = 0;
134+ if (!ArchiveRead_EnsureDirectory(fullpath, strlen(base_path)))
135+ {
136+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
137+ "Failed to create directory '%s' for extraction", fullpath);
138+ return 0;
139+ }
140+ fullpath[rmostsep] = save;
141+ }
142+
143+ if (unzOpenCurrentFile(READERZIP(reader)->zf) != UNZ_OK)
131144 {
132145 ArchiveRead_SetError((ArchiveReaderStruct*)reader,
133- "Failed to create directory '%s' for extraction", fullpath);
146+ "minizip couldn't open entry '%s' for extraction",
147+ READERZIP(reader)->entry_path);
134148 return 0;
135149 }
136- fullpath[rmostsep] = save;
137- }
138150
139- if (unzOpenCurrentFile(READERZIP(reader)->zf) != UNZ_OK)
140- {
141- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
142- "minizip couldn't open entry '%s' for extraction",
143- READERZIP(reader)->entry_path);
144- return 0;
145- }
151+ char tmppath[PATH_MAX + 1];
152+ snprintf(tmppath, PATH_MAX + 1, "%s.tmp", fullpath);
146153
147- char tmppath[PATH_MAX + 1];
148- snprintf(tmppath, PATH_MAX + 1, "%s.tmp", fullpath);
154+ FILE* outfile = fopen(tmppath, "wb");
155+ if (!outfile)
156+ {
157+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
158+ "Failed to open file '%s' for output", tmppath);
159+ unzCloseCurrentFile(READERZIP(reader)->zf);
160+ return 0;
161+ }
149162
150- FILE* outfile = fopen(tmppath, "wb");
151- if (!outfile)
152- {
153- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
154- "Failed to open file '%s' for output", tmppath);
155- unzCloseCurrentFile(READERZIP(reader)->zf);
156- return 0;
157- }
163+ int const buf_size = 1024 * 1024;
164+ char* buf = malloc(buf_size);
165+ int read;
166+ while ((read = unzReadCurrentFile(READERZIP(reader)->zf, buf, buf_size)) > 0)
167+ {
168+ if (fwrite(buf, 1, read, outfile) != read)
169+ {
170+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
171+ "Failed to write %d bytes to '%s'", read, tmppath);
172+ free(buf);
173+ fclose(outfile);
174+ remove(tmppath);
175+ unzCloseCurrentFile(READERZIP(reader)->zf);
176+ return 0;
177+ }
178+ }
179+ free(buf);
180+ fclose(outfile);
158181
159- int const buf_size = 1024 * 1024;
160- char* buf = malloc(buf_size);
161- int read;
162- while ((read = unzReadCurrentFile(READERZIP(reader)->zf, buf, buf_size)) > 0)
163- {
164- if (fwrite(buf, 1, read, outfile) != read)
182+ int close_result = unzCloseCurrentFile(READERZIP(reader)->zf);
183+ if (read < 0)
165184 {
166185 ArchiveRead_SetError((ArchiveReaderStruct*)reader,
167- "Failed to write %d bytes to '%s'", read, tmppath);
168- free(buf);
169- fclose(outfile);
186+ "minizip error extracting entry '%s'", READERZIP(reader)->entry_path);
187+ remove(tmppath);
188+ return 0;
189+ }
190+ if (close_result == UNZ_CRCERROR)
191+ {
192+ ArchiveRead_SetError((ArchiveReaderStruct*)reader,
193+ "Bad CRC extracting entry '%s'", READERZIP(reader)->entry_path);
170194 remove(tmppath);
171- unzCloseCurrentFile(READERZIP(reader)->zf);
172195 return 0;
173196 }
174- }
175- free(buf);
176- fclose(outfile);
177197
178- int close_result = unzCloseCurrentFile(READERZIP(reader)->zf);
179- if (read < 0)
180- {
181- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
182- "minizip error extracting entry '%s'", READERZIP(reader)->entry_path);
183- remove(tmppath);
184- return 0;
185- }
186- if (close_result == UNZ_CRCERROR)
187- {
188- ArchiveRead_SetError((ArchiveReaderStruct*)reader,
189- "Bad CRC extracting entry '%s'", READERZIP(reader)->entry_path);
190- remove(tmppath);
191- return 0;
192- }
198+ remove(fullpath);
199+ rename(tmppath, fullpath);
193200
194- remove(fullpath);
195- rename(tmppath, fullpath);
201+ setfiletime(fullpath, READERZIP(reader)->entry_info.dosDate);
202+ }
196203
197- setfiletime(fullpath, READERZIP(reader)->entry_info.dosDate);
198204 SetFileAttributes(fullpath, READERZIP(reader)->entry_info.external_fa);
199205
200206 return 1;
--- a/categorytree.c
+++ b/categorytree.c
@@ -9,6 +9,7 @@
99 #define WIN32_LEAN_AND_MEAN
1010 #include <windows.h>
1111 #include <commctrl.h>
12+#include <stdio.h>
1213 #include "mainwnd.hh"
1314 #include "packagelist.hh"
1415 #include "pkgindex.hh"
@@ -57,6 +58,57 @@ void CategoryTree_Reload()
5758 0, (LPARAM)(LPTVINSERTSTRUCT)&tvins);
5859 }
5960 }
60- int cats[] = {0, -1};
61- PackageList_SetCategories(cats);
61+ int cats = -1;
62+ PackageList_SetCategories(&cats);
63+}
64+
65+
66+int CategoryTree_WM_NOTIFY
67+ (HWND hwndDlg,
68+ WPARAM wParam,
69+ LPARAM lParam,
70+ int* return_value_out __attribute__((unused)))
71+{
72+ switch (((LPNMHDR)lParam)->code)
73+ {
74+ case TVN_SELCHANGED:
75+ if (((LPNMTREEVIEW)lParam)->itemNew.lParam < 0)
76+ {
77+ HWND htv = GetDlgItem(hwndDlg, IDC_CATLIST);
78+ int childct = 0;
79+ HTREEITEM child = TreeView_GetChild(htv,
80+ ((LPNMTREEVIEW)lParam)->itemNew.hItem);
81+ for (; child; child = TreeView_GetNextSibling(htv, child))
82+ ++childct;
83+ int cats[childct + 1];
84+ cats[childct] = -1;
85+ for (child = TreeView_GetChild(htv,
86+ ((LPNMTREEVIEW)lParam)->itemNew.hItem);
87+ child;
88+ child = TreeView_GetNextSibling(htv, child))
89+ {
90+ TVITEM tvitem;
91+ tvitem.hItem = child;
92+ tvitem.mask = TVIF_PARAM;
93+ if (TreeView_GetItem(htv, &tvitem))
94+ cats[childct - 1] = tvitem.lParam - 1;
95+ else
96+ cats[childct - 1] = -1;
97+ --childct;
98+ }
99+ PackageList_SetCategories(cats);
100+ }
101+ else if (((LPNMTREEVIEW)lParam)->itemNew.lParam == 0)
102+ {
103+ int cats = -1;
104+ PackageList_SetCategories(&cats);
105+ }
106+ else
107+ {
108+ int cats[] = {((LPNMTREEVIEW)lParam)->itemNew.lParam - 1, -1};
109+ PackageList_SetCategories(cats);
110+ }
111+ break;
112+ }
113+ return 0;
62114 }
--- a/categorytree.hh
+++ b/categorytree.hh
@@ -6,12 +6,21 @@
66 #define CATEGORYTREE_HH_INC
77
88
9+#define WIN32_LEAN_AND_MEAN
10+#include <windows.h>
11+
12+
913 #ifdef __cplusplus
1014 extern "C" {
1115 #endif
1216
1317
1418 void CategoryTree_Reload();
19+int CategoryTree_WM_NOTIFY
20+ (HWND hwndDlg,
21+ WPARAM wParam,
22+ LPARAM lParam,
23+ int* return_value_out);
1524
1625
1726 #ifdef __cplusplus
--- a/download.c
+++ b/download.c
@@ -7,7 +7,8 @@
77
88 typedef struct CallbackInfo
99 {
10- int (*next_callback)(size_t, size_t);
10+ int (*next_callback)(size_t, size_t, void*);
11+ void* callback_param;
1112 } CallbackInfo;
1213
1314 int DLCallback
@@ -18,14 +19,15 @@ int DLCallback
1819 double ulnow)
1920 {
2021 return ((CallbackInfo*)clientp)->next_callback((size_t)dltotal,
21- (size_t)dlnow);
22+ (size_t)dlnow, ((CallbackInfo*)clientp)->callback_param);
2223 }
2324
2425
2526 int DownloadFile
2627 (const char* url,
2728 const char* local,
28- int (*prog_callback)(size_t, size_t))
29+ int (*prog_callback)(size_t, size_t, void*),
30+ void* callback_param)
2931 {
3032 int ret = 1;
3133
@@ -51,6 +53,7 @@ int DownloadFile
5153 curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, DLCallback);
5254 CallbackInfo info;
5355 info.next_callback = prog_callback;
56+ info.callback_param = callback_param;
5457 curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &info);
5558 }
5659 else
--- a/download.hh
+++ b/download.hh
@@ -17,7 +17,8 @@ extern "C" {
1717 int DownloadFile
1818 (const char* url,
1919 const char* local,
20- int (*prog_callback)(size_t, size_t));
20+ int (*prog_callback)(size_t, size_t, void*),
21+ void* callback_param);
2122
2223
2324 #ifdef __cplusplus
--- a/mainwnd.c
+++ b/mainwnd.c
@@ -16,6 +16,7 @@
1616 #include "ui_general.hh"
1717 #include "pkgindex.hh"
1818 #include "packagelist.hh"
19+#include "categorytree.hh"
1920
2021
2122 HWND g_hmainwnd = 0;
@@ -100,7 +101,7 @@ BOOL CALLBACK MainWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
100101
101102 HWND hcb = GetDlgItem(hwndDlg, IDC_CATTYPE);
102103 SendMessage(hcb, CB_ADDSTRING, 0, (LPARAM)"Category");
103- SendMessage(hcb, CB_ADDSTRING, 0, (LPARAM)"State");
104+ SendMessage(hcb, CB_ADDSTRING, 0, (LPARAM)"Installed");
104105 SendMessage(hcb, CB_ADDSTRING, 0, (LPARAM)"Release Status");
105106 SendMessage(hcb, CB_SETCURSEL, 0, 0);
106107
@@ -153,19 +154,22 @@ BOOL CALLBACK MainWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
153154 case IDM_SOURCES_REPOSITORIES:
154155 EditReposDlg();
155156 return TRUE;
156- case IDC_CATLIST:
157- if (HIWORD(wParam) == LBN_SELCHANGE)
158- {
159- //UI_OnCategoryChange(ListBox_GetCurSel((HWND)lParam));
160- return TRUE;
161- }
162- break;
163157 }
164158 break;
165159
166160 case WM_NOTIFY:
167161 switch (((LPNMHDR)lParam)->idFrom)
168162 {
163+ case IDC_CATLIST:
164+ {
165+ int retval;
166+ if (CategoryTree_WM_NOTIFY(hwndDlg, wParam, lParam, &retval))
167+ {
168+ SetWindowLong(hwndDlg, DWL_MSGRESULT, retval);
169+ return TRUE;
170+ }
171+ }
172+ break;
169173 case IDC_COMPLIST:
170174 switch (((LPNMHDR)lParam)->code)
171175 {
--- a/mingw-get.cbp
+++ b/mingw-get.cbp
@@ -33,6 +33,7 @@
3333 <Add option="-Wall" />
3434 <Add option="-pipe" />
3535 <Add option="-mthreads" />
36+ <Add option="-fno-exceptions" />
3637 <Add option="-D_WIN32_IE=0x0400" />
3738 <Add option="-DCURL_STATICLIB" />
3839 <Add directory="$(#curl.include)" />
@@ -41,7 +42,6 @@
4142 </Compiler>
4243 <Linker>
4344 <Add library="curl" />
44- <Add library="z" />
4545 <Add library="shfolder" />
4646 <Add library="shell32" />
4747 <Add library="gdi32" />
@@ -52,7 +52,6 @@
5252 <Add library="wsock32" />
5353 <Add library="wldap32" />
5454 <Add directory="$(#curl.lib)" />
55- <Add directory="$(#zlib)" />
5655 </Linker>
5756 <Unit filename="7z\7zCrc.c">
5857 <Option compilerVar="CC" />
--- a/packagelist.c
+++ b/packagelist.c
@@ -186,14 +186,8 @@ void PackageList_SetCategories(const int* categories)
186186 {
187187 ListView_DeleteAllItems(g_hpackagelist);
188188
189- if (*categories == -1)
190- {
191- PackageView_SetPackage(-1);
192- return;
193- }
194-
195189 int have_item = 0;
196- if (*categories == 0)
190+ if (*categories == -1)
197191 {
198192 int i = 0;
199193 for (; i < PkgIndex_NumPackages(); ++i)
--- a/pkgindex.cpp
+++ b/pkgindex.cpp
@@ -163,12 +163,19 @@ extern "C" int PkgIndex_Load()
163163 const char* name = NonEmptyAttribute(cat_el, "name");
164164 if (!name)
165165 continue;
166- g_pkgindex.headings.back().second.push_back(
167- g_pkgindex.categories.size()
168- );
169- g_pkgindex.category_ids[id] = g_pkgindex.categories.size();
170- g_pkgindex.categories.push_back(std::make_pair(std::string(id),
171- std::string(name)));
166+ StringIntMap::const_iterator found =
167+ g_pkgindex.category_ids.find(id);
168+ if (found != g_pkgindex.category_ids.end())
169+ g_pkgindex.headings.back().second.push_back(found->second);
170+ else
171+ {
172+ g_pkgindex.headings.back().second.push_back(
173+ g_pkgindex.categories.size()
174+ );
175+ g_pkgindex.category_ids[id] = g_pkgindex.categories.size();
176+ g_pkgindex.categories.push_back(std::make_pair(std::string(id),
177+ std::string(name)));
178+ }
172179 }
173180 g_pkgindex.headings.back().second.push_back(-1);
174181 }
--- a/ui_general.c
+++ b/ui_general.c
@@ -19,9 +19,6 @@
1919 #include "categorytree.hh"
2020
2121
22-ProgressThreadInfo* g_dlthreadinfo = 0;
23-
24-
2522 void LastError_MsgBox(const char* title)
2623 {
2724 MessageBox(g_hmainwnd, MGGetErrors()[0], title, MB_OK | MB_ICONERROR);
@@ -29,26 +26,22 @@ void LastError_MsgBox(const char* title)
2926 }
3027
3128
32-int ListDownloadCallback(size_t total, size_t current)
29+int ListDownloadCallback(size_t total, size_t current, void* param)
3330 {
34- return ProgressThread_IsCancelled(g_dlthreadinfo) ? 1 : 0;
31+ return ProgressThread_IsCancelled((ProgressThreadInfo*)param) ? 1 : 0;
3532 }
3633
3734 int UpdateListThread(ProgressThreadInfo* info, void* param)
3835 {
39- g_dlthreadinfo = info;
40-
4136 ProgressThread_NewStatus(info, "Downloading updated manifest...");
4237
4338 char localpath[PATH_MAX + 1];
4439 snprintf(localpath, PATH_MAX + 1, "%s\\mingw_avail.mft", GetBinDir());
4540 int dlresult = DownloadFile(
4641 "http://localhost:1330/mingwinst/mingw_avail.mft", localpath,
47- ListDownloadCallback
42+ ListDownloadCallback, info
4843 );
4944
50- g_dlthreadinfo = 0;
51-
5245 if (dlresult > 0 && dlresult != 2)
5346 dlresult = -dlresult;
5447 return dlresult;
@@ -63,3 +56,8 @@ void UI_UpdateLists()
6356 CategoryTree_Reload();
6457 return;
6558 }
59+
60+
61+void UI_ApplyChanges()
62+{
63+}
--- a/ui_general.hh
+++ b/ui_general.hh
@@ -12,6 +12,7 @@ extern "C" {
1212
1313
1414 void UI_UpdateLists();
15+void UI_ApplyChanges();
1516
1617 void LastError_MsgBox(const char* title);
1718