ReactOS 0.4.15-dev-8102-g108db8f
content.c File Reference
#include "hhctrl.h"
#include "stream.h"
#include "resource.h"
#include "wine/debug.h"
Include dependency graph for content.c:

Go to the source code of this file.

Macros

#define NONAMELESSUNION
 

Enumerations

enum  insert_type_t { INSERT_NEXT , INSERT_CHILD }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (htmlhelp)
 
static void free_content_item (ContentItem *item)
 
static void parse_obj_node_param (ContentItem *item, ContentItem *hhc_root, const char *text, UINT code_page)
 
static ContentItemparse_hhc (HHInfo *, IStream *, ContentItem *, insert_type_t *)
 
static ContentIteminsert_item (ContentItem *item, ContentItem *new_item, insert_type_t insert_type)
 
static ContentItemparse_sitemap_object (HHInfo *info, stream_t *stream, ContentItem *hhc_root, insert_type_t *insert_type)
 
static ContentItemparse_ul (HHInfo *info, stream_t *stream, ContentItem *hhc_root)
 
static void insert_content_item (HWND hwnd, ContentItem *parent, ContentItem *item)
 
static void fill_content_tree (HWND hwnd, ContentItem *parent, ContentItem *item)
 
static void set_item_parents (ContentItem *parent, ContentItem *item)
 
void InitContent (HHInfo *info)
 
void ReleaseContent (HHInfo *info)
 
void ActivateContentTopic (HWND hWnd, LPCWSTR filename, ContentItem *item)
 

Macro Definition Documentation

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 20 of file content.c.

Enumeration Type Documentation

◆ insert_type_t

Enumerator
INSERT_NEXT 
INSERT_CHILD 

Definition at line 30 of file content.c.

30 {
insert_type_t
Definition: content.c:30
@ INSERT_NEXT
Definition: content.c:31
@ INSERT_CHILD
Definition: content.c:32

Function Documentation

◆ ActivateContentTopic()

void ActivateContentTopic ( HWND  hWnd,
LPCWSTR  filename,
ContentItem item 
)

Definition at line 330 of file content.c.

331{
332 if (lstrcmpiW(item->local, filename) == 0)
333 {
335 return;
336 }
337
338 if (item->next)
340
341 if (item->child)
343}
HWND hWnd
Definition: settings.c:17
int WINAPI lstrcmpiW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4261
const char * filename
Definition: ioapi.h:137
static ATOM item
Definition: dde.c:856
#define TVM_SELECTITEM
Definition: commctrl.h:3478
#define TVGN_CARET
Definition: commctrl.h:3461
void ActivateContentTopic(HWND hWnd, LPCWSTR filename, ContentItem *item)
Definition: content.c:330
LONG_PTR LPARAM
Definition: windef.h:208
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ActivateContentTopic(), and DoSync().

◆ fill_content_tree()

static void fill_content_tree ( HWND  hwnd,
ContentItem parent,
ContentItem item 
)
static

Definition at line 282 of file content.c.

283{
284 while(item) {
285 if(item->name) {
288 }else {
290 }
291 item = item->next;
292 }
293}
r parent
Definition: btrfs.c:3010
static void insert_content_item(HWND hwnd, ContentItem *parent, ContentItem *item)
Definition: content.c:265
static void fill_content_tree(HWND hwnd, ContentItem *parent, ContentItem *item)
Definition: content.c:282
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by fill_content_tree(), and InitContent().

◆ free_content_item()

static void free_content_item ( ContentItem item)
static

Definition at line 35 of file content.c.

36{
38
39 while(item) {
40 next = item->next;
41
42 free_content_item(item->child);
43
44 heap_free(item->name);
45 heap_free(item->local);
46 heap_free(item->merge.chm_file);
47 heap_free(item->merge.chm_index);
48
49 item = next;
50 }
51}
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
static unsigned __int64 next
Definition: rand_nt.c:6
static void free_content_item(ContentItem *item)
Definition: content.c:35

Referenced by free_content_item(), parse_sitemap_object(), and ReleaseContent().

◆ InitContent()

void InitContent ( HHInfo info)

Definition at line 304 of file content.c.

305{
307 insert_type_t insert_type;
308
309 info->content = heap_alloc_zero(sizeof(ContentItem));
310 SetChmPath(&info->content->merge, info->pCHMInfo->szFile, info->WinType.pszToc);
311
312 stream = GetChmStream(info->pCHMInfo, info->pCHMInfo->szFile, &info->content->merge);
313 if(!stream) {
314 TRACE("Could not get content stream\n");
315 return;
316 }
317
318 info->content->child = parse_hhc(info, stream, info->content, &insert_type);
319 IStream_Release(stream);
320
321 set_item_parents(NULL, info->content);
322 fill_content_tree(info->tabs[TAB_CONTENTS].hwnd, NULL, info->content);
323}
void SetChmPath(ChmPath *file, LPCWSTR base_file, LPCWSTR path)
Definition: chm.c:503
IStream * GetChmStream(CHMInfo *info, LPCWSTR parent_chm, ChmPath *chm_file)
Definition: chm.c:539
#define NULL
Definition: types.h:112
#define TAB_CONTENTS
Definition: hhctrl.h:116
#define TRACE(s)
Definition: solgame.cpp:4
Definition: parse.h:23
static ContentItem * parse_hhc(HHInfo *, IStream *, ContentItem *, insert_type_t *)
Definition: content.c:229
static void set_item_parents(ContentItem *parent, ContentItem *item)
Definition: content.c:295

Referenced by CreateViewer().

◆ insert_content_item()

static void insert_content_item ( HWND  hwnd,
ContentItem parent,
ContentItem item 
)
static

Definition at line 265 of file content.c.

266{
267 TVINSERTSTRUCTW tvis;
268
269 memset(&tvis, 0, sizeof(tvis));
271 tvis.u.item.cchTextMax = lstrlenW(item->name)+1;
272 tvis.u.item.pszText = item->name;
273 tvis.u.item.lParam = (LPARAM)item;
274 tvis.u.item.iImage = item->child ? HHTV_FOLDER : HHTV_DOCUMENT;
275 tvis.u.item.iSelectedImage = item->child ? HHTV_FOLDER : HHTV_DOCUMENT;
276 tvis.hParent = parent ? parent->id : 0;
277 tvis.hInsertAfter = TVI_LAST;
278
280}
#define lstrlenW
Definition: compat.h:750
#define HHTV_FOLDER
Definition: resource.h:62
#define HHTV_DOCUMENT
Definition: resource.h:61
#define TVI_LAST
Definition: commctrl.h:3370
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TVIF_IMAGE
Definition: commctrl.h:3267
struct _TREEITEM * HTREEITEM
Definition: commctrl.h:3264
#define TVM_INSERTITEMW
Definition: commctrl.h:3408
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define memset(x, y, z)
Definition: compat.h:39
HTREEITEM hParent
Definition: commctrl.h:3393
HTREEITEM hInsertAfter
Definition: commctrl.h:3394

Referenced by fill_content_tree().

◆ insert_item()

static ContentItem * insert_item ( ContentItem item,
ContentItem new_item,
insert_type_t  insert_type 
)
static

Definition at line 106 of file content.c.

107{
108 if(!item)
109 return new_item;
110
111 if(!new_item)
112 return item;
113
114 switch(insert_type) {
115 case INSERT_NEXT:
116 item->next = new_item;
117 return new_item;
118 case INSERT_CHILD:
119 if(item->child) {
120 ContentItem *iter = item->child;
121 while(iter->next)
122 iter = iter->next;
123 iter->next = new_item;
124 }else {
125 item->child = new_item;
126 }
127 return item;
128 }
129
130 return NULL;
131}
struct ContentItem * next
Definition: hhctrl.h:62

Referenced by parse_hhc(), and parse_ul().

◆ parse_hhc()

static ContentItem * parse_hhc ( HHInfo info,
IStream str,
ContentItem hhc_root,
insert_type_t insert_type 
)
static

Definition at line 229 of file content.c.

231{
233 strbuf_t node, node_name;
234 ContentItem *ret = NULL, *prev = NULL;
235
236 *insert_type = INSERT_NEXT;
237
239 strbuf_init(&node_name);
240
242
243 while(next_node(&stream, &node)) {
244 get_node_name(&node, &node_name);
245
246 TRACE("%s\n", node.buf);
247
248 if(!_strnicmp(node_name.buf, "ul", -1)) {
249 ContentItem *item = parse_ul(info, &stream, hhc_root);
250 prev = insert_item(prev, item, INSERT_CHILD);
251 if(!ret)
252 ret = prev;
253 *insert_type = INSERT_CHILD;
254 }
255
257 }
258
260 strbuf_free(&node_name);
261
262 return ret;
263}
static void strbuf_init(strbuf *buf)
Definition: registrar.c:82
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
void strbuf_free(strbuf_t *buf)
Definition: stream.c:38
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
void strbuf_zero(strbuf_t *buf)
Definition: stream.c:33
void stream_init(stream_t *stream, IStream *str)
Definition: stream.c:54
void get_node_name(strbuf_t *node, strbuf_t *name)
Definition: stream.c:88
const WCHAR * str
char * buf
Definition: stream.h:27
Definition: dlist.c:348
int ret
static ContentItem * insert_item(ContentItem *item, ContentItem *new_item, insert_type_t insert_type)
Definition: content.c:106
static ContentItem * parse_ul(HHInfo *info, stream_t *stream, ContentItem *hhc_root)
Definition: content.c:184

Referenced by InitContent(), and parse_sitemap_object().

◆ parse_obj_node_param()

static void parse_obj_node_param ( ContentItem item,
ContentItem hhc_root,
const char text,
UINT  code_page 
)
static

Definition at line 53 of file content.c.

54{
55 const char *ptr;
57 int len;
58
59 ptr = get_attr(text, "name", &len);
60 if(!ptr) {
61 WARN("name attr not found\n");
62 return;
63 }
64
65 if(!_strnicmp("name", ptr, len)) {
66 param = &item->name;
67 }else if(!_strnicmp("merge", ptr, len)) {
68 param = &merge;
69 }else if(!_strnicmp("local", ptr, len)) {
70 param = &item->local;
71 }else {
72 WARN("unhandled param %s\n", debugstr_an(ptr, len));
73 return;
74 }
75
76 ptr = get_attr(text, "value", &len);
77 if(!ptr) {
78 WARN("value attr not found\n");
79 return;
80 }
81
82 /*
83 * "merge" parameter data (referencing another CHM file) can be incorporated into the "local" parameter
84 * by specifying the filename in the format:
85 * MS-ITS:file.chm::/local_path.htm
86 */
87 if(param == &item->local && strstr(ptr, "::"))
88 {
89 const char *local = strstr(ptr, "::")+2;
90 int local_len = len-(local-ptr);
91
92 item->local = decode_html(local, local_len, code_page);
93 param = &merge;
94 }
95
96 *param = decode_html(ptr, len, code_page);
97
98 if(param == &merge) {
99 SetChmPath(&item->merge, hhc_root->merge.chm_file, merge);
101 }
102}
_STLP_MOVE_TO_STD_NAMESPACE _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2, _OutputIter __result)
Definition: _algo.c:1419
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
#define WARN(fmt,...)
Definition: debug.h:115
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:55
WCHAR * decode_html(const char *html_fragment, int html_fragment_len, UINT code_page)
Definition: help.c:1902
const char * get_attr(const char *node, const char *name, int *len)
Definition: stream.c:162
const WCHAR * text
Definition: package.c:1799
#define local
Definition: zutil.h:30
GLfloat param
Definition: glext.h:5796
GLenum GLsizei len
Definition: glext.h:6722
static PVOID ptr
Definition: dispmode.c:27
LPWSTR chm_file
Definition: hhctrl.h:55
ChmPath merge
Definition: hhctrl.h:68
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by parse_sitemap_object().

◆ parse_sitemap_object()

static ContentItem * parse_sitemap_object ( HHInfo info,
stream_t stream,
ContentItem hhc_root,
insert_type_t insert_type 
)
static

Definition at line 133 of file content.c.

135{
136 strbuf_t node, node_name;
138
139 *insert_type = INSERT_NEXT;
140
142 strbuf_init(&node_name);
143
144 item = heap_alloc_zero(sizeof(ContentItem));
145
146 while(next_node(stream, &node)) {
147 get_node_name(&node, &node_name);
148
149 TRACE("%s\n", node.buf);
150
151 if(!_strnicmp(node_name.buf, "/object", -1))
152 break;
153 if(!_strnicmp(node_name.buf, "param", -1))
154 parse_obj_node_param(item, hhc_root, node.buf, info->pCHMInfo->codePage);
155
157 }
158
160 strbuf_free(&node_name);
161
162 if(item->merge.chm_index) {
163 IStream *merge_stream;
164
165 merge_stream = GetChmStream(info->pCHMInfo, item->merge.chm_file, &item->merge);
166 if(merge_stream) {
167 item->child = parse_hhc(info, merge_stream, hhc_root, insert_type);
168 IStream_Release(merge_stream);
169 }else {
170 WARN("Could not get %s::%s stream\n", debugstr_w(item->merge.chm_file),
171 debugstr_w(item->merge.chm_file));
172
173 if(!item->name) {
175 item = NULL;
176 }
177 }
178
179 }
180
181 return item;
182}
#define debugstr_w
Definition: kernel32.h:32
static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text, UINT code_page)
Definition: content.c:53

Referenced by parse_ul().

◆ parse_ul()

static ContentItem * parse_ul ( HHInfo info,
stream_t stream,
ContentItem hhc_root 
)
static

Definition at line 184 of file content.c.

185{
186 strbuf_t node, node_name;
187 ContentItem *ret = NULL, *prev = NULL, *new_item = NULL;
188 insert_type_t it;
189
191 strbuf_init(&node_name);
192
193 while(next_node(stream, &node)) {
194 get_node_name(&node, &node_name);
195
196 TRACE("%s\n", node.buf);
197
198 if(!_strnicmp(node_name.buf, "object", -1)) {
199 const char *ptr;
200 int len;
201
202 static const char sz_text_sitemap[] = "text/sitemap";
203
204 ptr = get_attr(node.buf, "type", &len);
205
206 if(ptr && len == sizeof(sz_text_sitemap)-1
207 && !memcmp(ptr, sz_text_sitemap, len)) {
208 new_item = parse_sitemap_object(info, stream, hhc_root, &it);
209 prev = insert_item(prev, new_item, it);
210 if(!ret)
211 ret = prev;
212 }
213 }else if(!_strnicmp(node_name.buf, "ul", -1)) {
214 new_item = parse_ul(info, stream, hhc_root);
215 insert_item(prev, new_item, INSERT_CHILD);
216 }else if(!_strnicmp(node_name.buf, "/ul", -1)) {
217 break;
218 }
219
221 }
222
224 strbuf_free(&node_name);
225
226 return ret;
227}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static ContentItem * parse_sitemap_object(HHInfo *info, stream_t *stream, ContentItem *hhc_root, insert_type_t *insert_type)
Definition: content.c:133

Referenced by parse_hhc(), and parse_ul().

◆ ReleaseContent()

void ReleaseContent ( HHInfo info)

Definition at line 325 of file content.c.

326{
327 free_content_item(info->content);
328}

Referenced by ReleaseHelpViewer().

◆ set_item_parents()

static void set_item_parents ( ContentItem parent,
ContentItem item 
)
static

Definition at line 295 of file content.c.

296{
297 while(item) {
298 item->parent = parent;
299 set_item_parents(item, item->child);
300 item = item->next;
301 }
302}

Referenced by InitContent(), and set_item_parents().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( htmlhelp  )