Skip to content

Commit

Permalink
Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
amadvance committed Jan 3, 2005
1 parent b37657c commit 3936143
Show file tree
Hide file tree
Showing 42 changed files with 328 additions and 141 deletions.
48 changes: 32 additions & 16 deletions advance/d2/d2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class convert {
unsigned level0;
unsigned level1;
unsigned level2;
bool numbered;
public:
convert(istream& Ais, ostream& Aos);
virtual ~convert();
Expand Down Expand Up @@ -171,6 +172,7 @@ class convert {

convert::convert(istream& Ais, ostream& Aos) : is(Ais), os(Aos)
{
numbered = true;
};

convert::~convert()
Expand Down Expand Up @@ -480,7 +482,7 @@ void convert::index_all(const string& file, unsigned depth)
string u;
s = token(j, file);
u = up(s);
if (u != "NAME" && u != "INDEX" && u != "SUBINDEX" && u != "SUBSUBINDEX") {
if (u != "NAME" && u != "NAME{NUMBER}" && u != "INDEX" && u != "SUBINDEX" && u != "SUBSUBINDEX") {
unsigned level = index_level(s);
if (depth >= level) {
next(level, index0, index1, index2);
Expand Down Expand Up @@ -516,7 +518,8 @@ void convert::run()

i = 0;
s = token(i, file);
if (up(s) == "NAME") {
if (up(s) == "NAME" || up(s) == "NAME{NUMBER}") {
numbered = up(s) == "NAME{NUMBER}";
s = token(i, file);
unsigned d = s.find(" - ");
header(trim(s.substr(0, d)), trim(s.substr(d+3)));
Expand Down Expand Up @@ -959,7 +962,7 @@ void convert_html::header(const string& a, const string& b)
os << "</head>" << endl;
os << "<body>" << endl;
if (b.length()) {
os << "<" HTML_H1 "><center>" << mask(b) << "</center></" HTML_H1 ">" << endl;
os << "<center><" HTML_H1 ">" << mask(b) << "</" HTML_H1 "></center>" << endl;
}
}

Expand Down Expand Up @@ -1011,26 +1014,32 @@ void convert_html::section_begin(unsigned level)
{
if (level == 0) {
os << "<" HTML_H1 ">";
os << "<a name=\"" << level0 << "\">";
os << level0;
os << "</a>";
if (numbered) {
os << "<a name=\"" << level0 << "\">";
os << level0;
os << "</a>";
}
os << " " << endl;
} else if (level == 1) {
if (level0) {
os << "<" HTML_H2 ">";
os << "<a name=\"" << level0 << "." << level1 << "\">";
os << level0 << "." << level1;
os << "</a>";
if (numbered) {
os << "<a name=\"" << level0 << "." << level1 << "\">";
os << level0 << "." << level1;
os << "</a>";
}
os << " " << endl;
} else {
os << "<" HTML_H2 ">" << endl;
}
} else {
if (level0 && level1) {
os << "<" HTML_H3 ">";
os << "<a name=\"" << level0 << "." << level1 << "." << level2 << "\">";
os << level0 << "." << level1 << "." << level2;
os << "</a>";
if (numbered) {
os << "<a name=\"" << level0 << "." << level1 << "." << level2 << "\">";
os << level0 << "." << level1 << "." << level2;
os << "</a>";
}
os << " " << endl;
} else {
os << "<" HTML_H3 ">" << endl;
Expand Down Expand Up @@ -1222,7 +1231,7 @@ class convert_frame : public convert_html {
void convert_frame::header(const string& a, const string& b)
{
if (b.length()) {
os << "<" HTML_H1 "><center>" << mask(b) << "</center></" HTML_H1 ">" << endl;
os << "<center><" HTML_H1 ">" << mask(b) << "</" HTML_H1 "></center>" << endl;
}
}

Expand Down Expand Up @@ -1327,11 +1336,18 @@ void convert_txt::section_text(const string& s)
ostringstream ss;
if (first_line) {
if (state == state_section0) {
ss << level0 << " " << up(mask(s));
if (numbered)
ss << level0 << " ";
ss << up(mask(s));
} else if (state == state_section1) {
ss << level0 << "." << level1 << " " << mask(s);
if (numbered)
ss << level0 << "." << level1 << " ";
ss << mask(s);
} else {
ss << "---- " << level0 << "." << level1 << "." << level2 << " " << mask(s) << " ----";
ss << "---- ";
if (numbered)
ss << level0 << "." << level1 << "." << level2 << " ";
ss << mask(s) << " ----";
}
first_line = false;
} else {
Expand Down
33 changes: 29 additions & 4 deletions advance/dos/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ adv_error target_script(const char* script)

tmp = getenv("TMP");
if (!tmp)
tmp = "\\";
tmp = getenv("TEMP");
if (!tmp) {
log_std(("ERROR:dos: getenv(TMP,TEMP) failed\n"));
return -1;
}

sncpy(file, FILE_MAXPATH, tmp);
if (file[0] && file[strlen(file)-1] != '\\')
Expand All @@ -369,7 +373,9 @@ adv_error target_script(const char* script)
goto err;
}

r = target_system(file);
__djgpp_exception_toggle();
r = system(file);
__djgpp_exception_toggle();

log_std(("dos: return %d\n", r));

Expand All @@ -383,21 +389,40 @@ adv_error target_script(const char* script)
return -1;
}

adv_error target_system(const char* cmd)
#define EXEC_MAX 1024

adv_error target_spawn_redirect(const char* file, const char** argv, const char* output)
{
int r;
char cmdline[EXEC_MAX];
unsigned i;

*cmdline = 0;

for(i=0;argv[i];++i) {
if (i)
sncat(cmdline, EXEC_MAX, " ");
sncat(cmdline, EXEC_MAX, argv[i]);
}

sncat(cmdline, EXEC_MAX, " > ");
sncat(cmdline, EXEC_MAX, output);

__djgpp_exception_toggle();
r = system(cmd);
r = system(cmdline);
__djgpp_exception_toggle();

return r;
}

adv_error target_spawn(const char* file, const char** argv)
{
int r;

__djgpp_exception_toggle();
r = spawnvp(P_WAIT, file, (char**)argv);
__djgpp_exception_toggle();

return r;
}

Expand Down
15 changes: 9 additions & 6 deletions advance/lib/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ extern "C" {
/** \addtogroup Target */
/*@{*/

/** Max command line length. */
#define TARGET_MAXCMD 1024

/** Max number of arguments. */
#define TARGET_MAXARG 64

Expand Down Expand Up @@ -193,18 +190,24 @@ adv_error target_apm_wakeup(void);

/**
* Execute a script.
* \return Like system("./script").
* \param script Text of the script to run.
* \return Like running a script containing the specified text.
*/
adv_error target_script(const char* script);

/**
* Execute an external program with pipe support.
* Execute an external program with output redirection.
* \param file Program to run.
* \param argv Arguments. Use 0 to terminate.
* \param output Output stream.
* \return Like system().
*/
adv_error target_system(const char* cmd);
adv_error target_spawn_redirect(const char* file, const char** argv, const char* output);

/**
* Execute an external program.
* \param file Program to run.
* \param argv Arguments. Use 0 to terminate.
* \return Like spawn().
*/
adv_error target_spawn(const char* file, const char** argv);
Expand Down
4 changes: 4 additions & 0 deletions advance/linux/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,10 @@ int event_compare(const void* void_a, const void* void_b)
return -1;
if (a->product > b->product)
return 1;
if (a->version < b->version)
return -1;
if (a->version > b->version)
return 1;

return strcmp(a->file, b->file);
}
Expand Down
16 changes: 13 additions & 3 deletions advance/linux/kevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct keyb_event_context {
struct termios oldkbdtermios;
struct termios newkbdtermios;
int oldkbmode;
int oldtrmode;
int f; /**< Handle of the console interface. */
adv_bool disable_special_flag; /**< Disable special hotkeys. */
unsigned map_up_to_low[KEYB_MAX];
Expand Down Expand Up @@ -853,7 +854,16 @@ adv_error keyb_event_enable(adv_bool graphics)
}
}

if (!event_state.passive_flag && event_state.graphics_flag) {
if (event_state.graphics_flag) {
if (ioctl(event_state.f, KDGETMODE, &event_state.oldtrmode) != 0) {
error_set("Error enabling the event keyboard driver. Function ioctl(KDGETMODE) failed.\n");
goto err_mode;
}

if (event_state.oldtrmode == KD_GRAPHICS) {
log_std(("WARNING:keyb:event: terminal already in KD_GRAPHICS mode\n"));
}

/* set the console in graphics mode, it only disable the cursor and the echo */
log_std(("keyb:event: ioctl(KDSETMODE, KD_GRAPHICS)\n"));
if (ioctl(event_state.f, KDSETMODE, KD_GRAPHICS) < 0) {
Expand Down Expand Up @@ -887,8 +897,8 @@ void keyb_event_disable(void)
{
log_std(("keyb:event: keyb_event_disable()\n"));

if (!event_state.passive_flag && event_state.graphics_flag) {
if (ioctl(event_state.f, KDSETMODE, KD_TEXT) < 0) {
if (event_state.graphics_flag) {
if (ioctl(event_state.f, KDSETMODE, event_state.oldtrmode) < 0) {
/* ignore error */
log_std(("ERROR:keyb:event: ioctl(KDSETMODE, KD_TEXT) failed\n"));
}
Expand Down
16 changes: 13 additions & 3 deletions advance/linux/kraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct keyb_raw_context {
struct termios oldkbdtermios;
struct termios newkbdtermios;
int oldkbmode;
int oldtrmode;
int f; /**< Handle. */
adv_bool disable_special_flag; /**< Disable special hotkeys. */
unsigned map_up_to_low[KEYB_MAX]; /**< Key mapping. */
Expand Down Expand Up @@ -295,7 +296,16 @@ adv_error keyb_raw_enable(adv_bool graphics)
goto err_term;
}

if (!raw_state.passive_flag && raw_state.graphics_flag) {
if (raw_state.graphics_flag) {
if (ioctl(raw_state.f, KDGETMODE, &raw_state.oldtrmode) != 0) {
error_set("Error enabling the event keyboard driver. Function ioctl(KDGETMODE) failed.\n");
goto err_mode;
}

if (raw_state.oldtrmode == KD_GRAPHICS) {
log_std(("WARNING:keyb:raw: terminal already in KD_GRAPHICS mode\n"));
}

/* set the console in graphics mode, it only disable the cursor and the echo */
log_std(("keyb:raw: ioctl(KDSETMODE, KD_GRAPHICS)\n"));
if (ioctl(raw_state.f, KDSETMODE, KD_GRAPHICS) < 0) {
Expand Down Expand Up @@ -329,8 +339,8 @@ void keyb_raw_disable(void)
{
log_std(("keyb:raw: keyb_raw_disable()\n"));

if (!raw_state.passive_flag && raw_state.graphics_flag) {
if (ioctl(raw_state.f, KDSETMODE, KD_TEXT) < 0) {
if (raw_state.graphics_flag) {
if (ioctl(raw_state.f, KDSETMODE, raw_state.oldtrmode) < 0) {
/* ignore error */
log_std(("ERROR:keyb:raw: ioctl(KDSETMODE, KD_TEXT) failed\n"));
}
Expand Down
Loading

0 comments on commit 3936143

Please sign in to comment.