ReactOS  0.4.14-dev-98-gb0d4763
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

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 }
#define TVM_SELECTITEM
Definition: commctrl.h:3450
#define TVGN_CARET
Definition: commctrl.h:3433
HWND hWnd
Definition: settings.c:17
const char * filename
Definition: ioapi.h:135
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
LONG_PTR LPARAM
Definition: windef.h:208
void ActivateContentTopic(HWND hWnd, LPCWSTR filename, ContentItem *item)
Definition: content.c:330
static ATOM item
Definition: dde.c:856
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) {
287  fill_content_tree(hwnd, item, item->child);
288  }else {
289  fill_content_tree(hwnd, parent, item->child);
290  }
291  item = item->next;
292  }
293 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
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
r parent
Definition: btrfs.c:2897
static ATOM item
Definition: dde.c:856

Referenced by 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 void free_content_item(ContentItem *item)
Definition: content.c:35
static unsigned __int64 next
Definition: rand_nt.c:6
static ATOM item
Definition: dde.c:856
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

Referenced by parse_sitemap_object(), and ReleaseContent().

◆ InitContent()

void InitContent ( HHInfo info)

Definition at line 304 of file content.c.

305 {
306  IStream *stream;
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 }
#define TAB_CONTENTS
Definition: hhctrl.h:116
smooth NULL
Definition: ftsmooth.c:416
static void set_item_parents(ContentItem *parent, ContentItem *item)
Definition: content.c:295
static ContentItem * parse_hhc(HHInfo *, IStream *, ContentItem *, insert_type_t *)
Definition: content.c:229
#define TRACE(s)
Definition: solgame.cpp:4
static void fill_content_tree(HWND hwnd, ContentItem *parent, ContentItem *item)
Definition: content.c:282
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
insert_type_t
Definition: content.c:30
void SetChmPath(ChmPath *file, LPCWSTR base_file, LPCWSTR path)
Definition: chm.c:496
IStream * GetChmStream(CHMInfo *info, LPCWSTR parent_chm, ChmPath *chm_file)
Definition: chm.c:532

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 = strlenW(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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HTREEITEM hParent
Definition: commctrl.h:3365
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define TVM_INSERTITEMW
Definition: commctrl.h:3380
struct _TREEITEM * HTREEITEM
Definition: commctrl.h:3236
#define HHTV_FOLDER
Definition: resource.h:58
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3243
HTREEITEM hInsertAfter
Definition: commctrl.h:3366
LONG_PTR LPARAM
Definition: windef.h:208
#define TVI_LAST
Definition: commctrl.h:3342
r parent
Definition: btrfs.c:2897
#define HHTV_DOCUMENT
Definition: resource.h:57
static ATOM item
Definition: dde.c:856
#define TVIF_TEXT
Definition: commctrl.h:3238
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define TVIF_IMAGE
Definition: commctrl.h:3239
#define TVIF_PARAM
Definition: commctrl.h:3240
#define memset(x, y, z)
Definition: compat.h:39

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 }
smooth NULL
Definition: ftsmooth.c:416
struct ContentItem * next
Definition: hhctrl.h:62
static ATOM item
Definition: dde.c:856

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 
238  strbuf_init(&node);
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(!strcasecmp(node_name.buf, "ul")) {
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 
256  strbuf_zero(&node);
257  }
258 
259  strbuf_free(&node);
260  strbuf_free(&node_name);
261 
262  return ret;
263 }
void get_node_name(strbuf_t *node, strbuf_t *name)
Definition: stream.c:88
#define strcasecmp
Definition: fake.h:9
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
struct node node
void strbuf_free(strbuf_t *buf)
Definition: stream.c:38
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static void strbuf_init(strbuf *buf)
Definition: registrar.c:83
int ret
Definition: parse.h:22
GLuint GLuint stream
Definition: glext.h:7522
static ContentItem * insert_item(ContentItem *item, ContentItem *new_item, insert_type_t insert_type)
Definition: content.c:106
void stream_init(stream_t *stream, IStream *str)
Definition: stream.c:54
static ATOM item
Definition: dde.c:856
static ContentItem * parse_ul(HHInfo *info, stream_t *stream, ContentItem *hhc_root)
Definition: content.c:184
void strbuf_zero(strbuf_t *buf)
Definition: stream.c:33
Definition: dlist.c:348
char * buf
Definition: stream.h:27

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;
56  LPWSTR *param, merge;
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(!strncasecmp("name", ptr, len)) {
66  param = &item->name;
67  }else if(!strncasecmp("merge", ptr, len)) {
68  param = &merge;
69  }else if(!strncasecmp("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);
100  heap_free(merge);
101  }
102 }
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
const WCHAR * text
Definition: package.c:1827
const char * get_attr(const char *node, const char *name, int *len)
Definition: stream.c:162
#define WARN(fmt,...)
Definition: debug.h:111
ChmPath merge
Definition: hhctrl.h:68
_STLP_MOVE_TO_STD_NAMESPACE _OutputIter merge(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2, _OutputIter __result)
Definition: _algo.c:1419
static PVOID ptr
Definition: dispmode.c:27
#define strncasecmp
Definition: fake.h:10
WCHAR * decode_html(const char *html_fragment, int html_fragment_len, UINT code_page)
Definition: help.c:1890
LPWSTR chm_file
Definition: hhctrl.h:55
GLfloat param
Definition: glext.h:5796
static __inline const char * debugstr_an(const char *s, int n)
Definition: compat.h:47
GLenum GLsizei len
Definition: glext.h:6722
#define local
Definition: zutil.h:30
void SetChmPath(ChmPath *file, LPCWSTR base_file, LPCWSTR path)
Definition: chm.c:496
static ATOM item
Definition: dde.c:856
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static BOOL heap_free(void *mem)
Definition: appwiz.h:75

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;
137  ContentItem *item;
138 
139  *insert_type = INSERT_NEXT;
140 
141  strbuf_init(&node);
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(!strcasecmp(node_name.buf, "/object"))
152  break;
153  if(!strcasecmp(node_name.buf, "param"))
154  parse_obj_node_param(item, hhc_root, node.buf, info->pCHMInfo->codePage);
155 
156  strbuf_zero(&node);
157  }
158 
159  strbuf_free(&node);
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 }
void get_node_name(strbuf_t *node, strbuf_t *name)
Definition: stream.c:88
#define strcasecmp
Definition: fake.h:9
#define WARN(fmt,...)
Definition: debug.h:111
static void free_content_item(ContentItem *item)
Definition: content.c:35
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
struct node node
#define debugstr_w
Definition: kernel32.h:32
void strbuf_free(strbuf_t *buf)
Definition: stream.c:38
smooth NULL
Definition: ftsmooth.c:416
static ContentItem * parse_hhc(HHInfo *, IStream *, ContentItem *, insert_type_t *)
Definition: content.c:229
#define TRACE(s)
Definition: solgame.cpp:4
static void strbuf_init(strbuf *buf)
Definition: registrar.c:83
Definition: parse.h:22
static ATOM item
Definition: dde.c:856
static void parse_obj_node_param(ContentItem *item, ContentItem *hhc_root, const char *text, UINT code_page)
Definition: content.c:53
IStream * GetChmStream(CHMInfo *info, LPCWSTR parent_chm, ChmPath *chm_file)
Definition: chm.c:532
void strbuf_zero(strbuf_t *buf)
Definition: stream.c:33
Definition: dlist.c:348
char * buf
Definition: stream.h:27

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 
190  strbuf_init(&node);
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(!strcasecmp(node_name.buf, "object")) {
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(!strcasecmp(node_name.buf, "ul")) {
214  new_item = parse_ul(info, stream, hhc_root);
215  insert_item(prev, new_item, INSERT_CHILD);
216  }else if(!strcasecmp(node_name.buf, "/ul")) {
217  break;
218  }
219 
220  strbuf_zero(&node);
221  }
222 
223  strbuf_free(&node);
224  strbuf_free(&node_name);
225 
226  return ret;
227 }
void get_node_name(strbuf_t *node, strbuf_t *name)
Definition: stream.c:88
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define strcasecmp
Definition: fake.h:9
const char * get_attr(const char *node, const char *name, int *len)
Definition: stream.c:162
static ContentItem * parse_sitemap_object(HHInfo *info, stream_t *stream, ContentItem *hhc_root, insert_type_t *insert_type)
Definition: content.c:133
BOOL next_node(stream_t *stream, strbuf_t *buf)
Definition: stream.c:140
struct node node
static PVOID ptr
Definition: dispmode.c:27
void strbuf_free(strbuf_t *buf)
Definition: stream.c:38
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
static void strbuf_init(strbuf *buf)
Definition: registrar.c:83
int ret
Definition: parse.h:22
static ContentItem * insert_item(ContentItem *item, ContentItem *new_item, insert_type_t insert_type)
Definition: content.c:106
insert_type_t
Definition: content.c:30
GLenum GLsizei len
Definition: glext.h:6722
static ContentItem * parse_ul(HHInfo *info, stream_t *stream, ContentItem *hhc_root)
Definition: content.c:184
void strbuf_zero(strbuf_t *buf)
Definition: stream.c:33
Definition: dlist.c:348
char * buf
Definition: stream.h:27

Referenced by parse_hhc().

◆ ReleaseContent()

void ReleaseContent ( HHInfo info)

Definition at line 325 of file content.c.

326 {
327  free_content_item(info->content);
328 }
static void free_content_item(ContentItem *item)
Definition: content.c:35

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 }
static void set_item_parents(ContentItem *parent, ContentItem *item)
Definition: content.c:295
r parent
Definition: btrfs.c:2897
static ATOM item
Definition: dde.c:856

Referenced by InitContent().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( htmlhelp  )