ReactOS  0.4.14-dev-583-g2a1ba2c
hhpcomp.cpp File Reference
#include <iostream>
#include <string>
#include <set>
#include <stdexcept>
#include <sys/stat.h>
#include "hhp_reader.h"
#include "utils.h"
#include <unistd.h>
#include "chmc/chmc.h"
#include "chmc/err.h"
Include dependency graph for hhpcomp.cpp:

Go to the source code of this file.

Functions

struct chmcTreeNodechmc_add_file (struct chmcFile *chm, const char *filename, UInt16 prefixlen, int sect_id, UChar *buf, UInt64 len)
 
int main (int argc, char **argv)
 

Function Documentation

◆ chmc_add_file()

struct chmcTreeNode* chmc_add_file ( struct chmcFile chm,
const char filename,
UInt16  prefixlen,
int  sect_id,
UChar buf,
UInt64  len 
)

Definition at line 598 of file chmc.c.

601 {
602  struct chmcSection *section;
603  struct chmcTreeNode *node;
604 
605  assert(chm);
606 
607  if (sect_id >= chm->sections_num)
608  return NULL;
609 
610  section = chm->sections[sect_id];
611 
613  section->offset, len);
614 
615  if ((node) && (len > 0))
616  section->offset += len;
617 
618  return node;
619 }
#define assert(x)
Definition: debug.h:53
struct chmcSection ** sections
Definition: chmc.h:199
UInt32 sect_id
Definition: chmc.h:169
Definition: parser.c:55
const char * filename
Definition: ioapi.h:135
static IMAGE_SECTION_HEADER section
Definition: loader.c:152
struct node node
smooth NULL
Definition: ftsmooth.c:416
struct chmcTreeNode * chmc_add_entry(struct chmcFile *chm, const char *name, UInt16 prefixlen, int sect_id, UChar *buf, UInt64 offset, UInt64 len)
Definition: chmc.c:429
int sections_num
Definition: chmc.h:197
GLenum GLsizei len
Definition: glext.h:6722
UInt16 prefixlen
Definition: chmc.h:171
Definition: dlist.c:348

Referenced by main().

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 48 of file hhpcomp.cpp.

49 {
50  if (argc != 2)
51  {
52  cerr << "Usage: hhpcomp <input.hhp>" << endl;
53  exit(0);
54  }
55 
56  string absolute_name = replace_backslashes(real_path(argv[1]));
57  int prefixlen = absolute_name.find_last_of('/');
58  clog << prefixlen << endl;
59  chdir(absolute_name.substr(0, prefixlen).c_str()); // change to the project file's directory
60  hhp_reader project_file(absolute_name);
61 
62  struct chmcFile chm;
63  struct chmcConfig chm_config;
64 
65  memset(&chm, 0, sizeof(struct chmcFile));
66  memset(&chm_config, 0, sizeof(struct chmcConfig));
67  chm_config.title = project_file.get_title_string().c_str();
68  chm_config.hhc = project_file.get_contents_file_string().c_str();
69  chm_config.hhk = project_file.get_index_file_string().c_str();
70  chm_config.deftopic = project_file.get_default_topic_string().c_str();
71  chm_config.language = project_file.get_language_code();
72  chm_config.tmpdir = ".";
73 
74  int err;
75  err = chmc_init(&chm, replace_backslashes(project_file.get_compiled_file_string()).c_str(), &chm_config);
76  if (err)
77  {
78  cerr << "could not initialize chmc" << endl;
80  }
81 
82  for (set<string>::iterator it = project_file.get_file_pathes_iterator_begin();
83  it != project_file.get_file_pathes_iterator_end(); ++it)
84  {
85  clog << "File: " << *it << endl;
86  struct stat buf;
87  stat(it->c_str(), &buf);
88  if ((chmc_add_file(&chm, it->c_str(), prefixlen, 1, NULL, buf.st_size)) ? chmcerr_code() : CHMC_NOERR)
89  {
90  cerr << "could not add file: " << *it << endl;
92  }
93  }
94 
95  chmc_tree_done(&chm);
96  chmc_term(&chm);
97 
98 }
static int argc
Definition: ServiceArgs.c:12
void chmc_term(struct chmcFile *chm)
Definition: chmc.c:461
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
int chmc_init(struct chmcFile *chm, const char *filename, struct chmcConfig *config)
Definition: chmc.c:133
#define argv
Definition: mplay32.c:18
int chmcerr_code(void)
Definition: err.c:42
#define chdir
Definition: syshdrs.h:69
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
string real_path(const char *path)
Definition: utils.cpp:42
smooth NULL
Definition: ftsmooth.c:416
string replace_backslashes(string s)
Definition: utils.cpp:62
_STLP_DECLSPEC _Stl_aligned_buffer< ostream > cerr
Definition: iostream.cpp:102
Definition: chmc.h:192
#define clog
Definition: iostream.cpp:40
#define EXIT_FAILURE
Definition: jerror.c:33
Definition: stat.h:55
#define err(...)
#define CHMC_NOERR
Definition: err.h:39
struct chmcTreeNode * chmc_add_file(struct chmcFile *chm, const char *filename, UInt16 prefixlen, int sect_id, UChar *buf, UInt64 len)
Definition: chmc.c:598
int chmc_tree_done(struct chmcFile *chm)
Definition: chmc.c:726
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
UInt16 prefixlen
Definition: chmc.h:171
void exit(int exitcode)
Definition: _exit.c:33
Definition: _set.h:46
#define memset(x, y, z)
Definition: compat.h:39