ReactOS 0.4.15-dev-7953-g1f49173
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}
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
#define NULL
Definition: types.h:112
#define assert(x)
Definition: debug.h:53
GLenum GLsizei len
Definition: glext.h:6722
const char * filename
Definition: ioapi.h:137
struct chmcSection ** sections
Definition: chmc.h:199
int sections_num
Definition: chmc.h:197
UInt32 sect_id
Definition: chmc.h:169
UInt16 prefixlen
Definition: chmc.h:171
Definition: parser.c:56
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 if (chdir(absolute_name.substr(0, prefixlen).c_str()) == -1) // change to the project file's directory
60 {
61 cerr << "chdir: working directory couldn't be changed" << endl;
62 exit(0);
63 }
64 hhp_reader project_file(absolute_name);
65
66 struct chmcFile chm;
67 struct chmcConfig chm_config;
68
69 memset(&chm, 0, sizeof(struct chmcFile));
70 memset(&chm_config, 0, sizeof(struct chmcConfig));
71 chm_config.title = project_file.get_title_string().c_str();
72 chm_config.hhc = project_file.get_contents_file_string().c_str();
73 chm_config.hhk = project_file.get_index_file_string().c_str();
74 chm_config.deftopic = project_file.get_default_topic_string().c_str();
75 chm_config.language = project_file.get_language_code();
76 chm_config.tmpdir = ".";
77
78 int err;
79 err = chmc_init(&chm, replace_backslashes(project_file.get_compiled_file_string()).c_str(), &chm_config);
80 if (err)
81 {
82 cerr << "could not initialize chmc" << endl;
84 }
85
86 for (set<string>::iterator it = project_file.get_file_pathes_iterator_begin();
87 it != project_file.get_file_pathes_iterator_end(); ++it)
88 {
89 clog << "File: " << *it << endl;
90 struct stat buf;
91 stat(it->c_str(), &buf);
92 if ((chmc_add_file(&chm, it->c_str(), prefixlen, 1, NULL, buf.st_size)) ? chmcerr_code() : CHMC_NOERR)
93 {
94 cerr << "could not add file: " << *it << endl;
96 }
97 }
98
99 chmc_tree_done(&chm);
100 chmc_term(&chm);
101
102}
static int argc
Definition: ServiceArgs.c:12
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
Definition: _ostream.h:357
void chmc_term(struct chmcFile *chm)
Definition: chmc.c:461
int chmc_tree_done(struct chmcFile *chm)
Definition: chmc.c:728
int chmc_init(struct chmcFile *chm, const char *filename, struct chmcConfig *config)
Definition: chmc.c:133
_Self substr(size_type __pos=0, size_type __n=npos) const
Definition: _string.h:1022
const _CharT * c_str() const
Definition: _string.h:949
size_type find_last_of(const _Self &__s, size_type __pos=npos) const
Definition: _string.h:988
_Rep_type::iterator iterator
Definition: _set.h:73
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
struct chmcTreeNode * chmc_add_file(struct chmcFile *chm, const char *filename, UInt16 prefixlen, int sect_id, UChar *buf, UInt64 len)
Definition: chmc.c:598
#define cerr
Definition: iostream.cpp:39
#define clog
Definition: iostream.cpp:40
#define EXIT_FAILURE
Definition: jerror.c:33
#define argv
Definition: mplay32.c:18
#define chdir
Definition: syshdrs.h:69
#define err(...)
#define exit(n)
Definition: config.h:202
#define memset(x, y, z)
Definition: compat.h:39
int chmcerr_code(void)
Definition: err.c:42
#define CHMC_NOERR
Definition: err.h:39
string real_path(const char *path)
Definition: utils.cpp:43
string replace_backslashes(string s)
Definition: utils.cpp:63
Definition: chmc.h:192
Definition: stat.h:55