31 FILE *_iconsole_output_file;
 
   35   _iconsole_output_file = NULL;
 
   43   IConsoleStdLibRegister();
 
   46 static void IConsoleWriteToLogFile(
const char *
string)
 
   48   if (_iconsole_output_file != NULL) {
 
   51     if ((strlen(header) != 0 && fwrite(header, strlen(header), 1, _iconsole_output_file) != 1) ||
 
   52         fwrite(
string, strlen(
string), 1, _iconsole_output_file) != 1 ||
 
   53         fwrite(
"\n", 1, 1, _iconsole_output_file) != 1) {
 
   54       fclose(_iconsole_output_file);
 
   55       _iconsole_output_file = NULL;
 
   61 bool CloseConsoleLogIfActive()
 
   63   if (_iconsole_output_file != NULL) {
 
   65     fclose(_iconsole_output_file);
 
   66     _iconsole_output_file = NULL;
 
   76   CloseConsoleLogIfActive();
 
  113 #ifdef ENABLE_NETWORK 
  118     IConsoleWriteToLogFile(str);
 
  123   IConsoleWriteToLogFile(str);
 
  139   va_start(va, format);
 
  191   if (strcmp(arg, 
"on") == 0 || strcmp(arg, 
"true") == 0) {
 
  195   if (strcmp(arg, 
"off") == 0 || strcmp(arg, 
"false") == 0) {
 
  200   *value = strtoul(arg, &endptr, 0);
 
  201   return arg != endptr;
 
  217   T *item_before = NULL;
 
  220   while (item != NULL) {
 
  221     if (strcmp(item->name, item_new->name) > 0) 
break; 
 
  227   if (item_before == NULL) {
 
  230     item_before->next = item_new;
 
  233   item_new->next = item;
 
  244   for (
const char *p = name; *p != 
'\0'; p++) {
 
  245     if (*p != 
'_') *q++ = *p;
 
  260   item_new->
next = NULL;
 
  261   item_new->
proc = proc;
 
  262   item_new->
hook = hook;
 
  276   for (item = _iconsole_cmds; item != NULL; item = item->
next) {
 
  277     if (strcmp(item->
name, name) == 0) 
return item;
 
  290     IConsoleError(
"an alias with this name already exists; insertion aborted");
 
  295   char *cmd_aliased = 
stredup(cmd);
 
  298   item_new->
next = NULL;
 
  299   item_new->
cmdline = cmd_aliased;
 
  300   item_new->
name = new_alias;
 
  314   for (item = _iconsole_aliases; item != NULL; item = item->
next) {
 
  315     if (strcmp(item->
name, name) == 0) 
return item;
 
  330   char *alias_stream = alias_buffer;
 
  332   DEBUG(console, 6, 
"Requested command is an alias; parsing...");
 
  334   for (
const char *cmdptr = alias->
cmdline; *cmdptr != 
'\0'; cmdptr++) {
 
  337         alias_stream = 
strecpy(alias_stream, 
"\"", 
lastof(alias_buffer));
 
  343         alias_stream = alias_buffer;
 
  344         *alias_stream = 
'\0'; 
 
  353             for (uint i = 0; i != tokencount; i++) {
 
  354               if (i != 0) alias_stream = 
strecpy(alias_stream, 
" ", 
lastof(alias_buffer));
 
  355               alias_stream = 
strecpy(alias_stream, 
"\"", 
lastof(alias_buffer));
 
  356               alias_stream = 
strecpy(alias_stream, tokens[i], 
lastof(alias_buffer));
 
  357               alias_stream = 
strecpy(alias_stream, 
"\"", 
lastof(alias_buffer));
 
  363             alias_stream = 
strecpy(alias_stream, 
"\"", 
lastof(alias_buffer));
 
  364             for (uint i = 0; i != tokencount; i++) {
 
  365               if (i != 0) alias_stream = 
strecpy(alias_stream, 
" ", 
lastof(alias_buffer));
 
  366               alias_stream = 
strecpy(alias_stream, tokens[i], 
lastof(alias_buffer));
 
  368             alias_stream = 
strecpy(alias_stream, 
"\"", 
lastof(alias_buffer));
 
  373             int param = *cmdptr - 
'A';
 
  375             if (param < 0 || param >= tokencount) {
 
  376               IConsoleError(
"too many or wrong amount of parameters passed to alias, aborting");
 
  381             alias_stream = 
strecpy(alias_stream, 
"\"", 
lastof(alias_buffer));
 
  382             alias_stream = 
strecpy(alias_stream, tokens[param], 
lastof(alias_buffer));
 
  383             alias_stream = 
strecpy(alias_stream, 
"\"", 
lastof(alias_buffer));
 
  390         *alias_stream++ = *cmdptr;
 
  391         *alias_stream = 
'\0';
 
  395     if (alias_stream >= 
lastof(alias_buffer) - 1) {
 
  396       IConsoleError(
"Requested alias execution would overflow execution buffer");
 
  413   uint t_index, tstream_i;
 
  415   bool longtoken = 
false;
 
  416   bool foundtoken = 
false;
 
  418   if (cmdstr[0] == 
'#') 
return; 
 
  420   for (cmdptr = cmdstr; *cmdptr != 
'\0'; cmdptr++) {
 
  422       IConsoleError(
"command contains malformed characters, aborting");
 
  428   DEBUG(console, 4, 
"Executing cmdline: '%s'", cmdstr);
 
  430   memset(&tokens, 0, 
sizeof(tokens));
 
  431   memset(&tokenstream, 0, 
sizeof(tokenstream));
 
  436   for (cmdptr = cmdstr, t_index = 0, tstream_i = 0; *cmdptr != 
'\0'; cmdptr++) {
 
  437     if (t_index >= 
lengthof(tokens) || tstream_i >= 
lengthof(tokenstream)) 
break;
 
  441       if (!foundtoken) 
break;
 
  444         tokenstream[tstream_i] = *cmdptr;
 
  446         tokenstream[tstream_i] = 
'\0';
 
  453       longtoken = !longtoken;
 
  455         tokens[t_index++] = &tokenstream[tstream_i];
 
  460       if (cmdptr[1] == 
'"' && tstream_i + 1 < 
lengthof(tokenstream)) {
 
  461         tokenstream[tstream_i++] = *++cmdptr;
 
  466       tokenstream[tstream_i++] = *cmdptr;
 
  469         tokens[t_index++] = &tokenstream[tstream_i - 1];
 
  476   for (uint i = 0; tokens[i] != NULL; i++) {
 
  477     DEBUG(console, 8, 
"Token %d is: '%s'", i, tokens[i]);
 
  491         if (!cmd->
proc(t_index, tokens)) {