Subversion Repositories DevTools

Rev

Rev 1024 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1024 Rev 1026
Line 53... Line 53...
53
 
53
 
54
int debug_level = 0;
54
int debug_level = 0;
55
 
55
 
56
int mustAbort = 0;
56
int mustAbort = 0;
57
 
57
 
-
 
58
int exitCode = 0;
-
 
59
 
58
typedef struct
60
typedef struct
59
{
61
{
60
   int cmdLineNumber;
62
   int cmdLineNumber;
61
   fpos_t filepos;
63
   fpos_t filepos;
62
} stack_t;
64
} stack_t;
Line 435... Line 437...
435
      ERROR("Bad/missing count/value in NTEXT command");
437
      ERROR("Bad/missing count/value in NTEXT command");
436
   }
438
   }
437
}
439
}
438
 
440
 
439
 
441
 
-
 
442
void fn_ZTEXT(char * arg_ptr)
-
 
443
{
-
 
444
   char * initial_arg_ptr = arg_ptr;
-
 
445
 
-
 
446
   unsigned long value;
-
 
447
   int got_a_value;
-
 
448
 
-
 
449
   arg_ptr = next_value(arg_ptr, &value, &got_a_value);
-
 
450
   if (got_a_value)
-
 
451
   {
-
 
452
      if ( value <= 1 )
-
 
453
      {
-
 
454
         ERROR("ZTEXT length too short");
-
 
455
      }
-
 
456
      arg_ptr++;  /* skip past ',' character */
-
 
457
 
-
 
458
      if (*arg_ptr != 0)
-
 
459
      {
-
 
460
         DEBUG( DEBUG_OUTPUT_CMD_MASK, "ZTEXT %s", initial_arg_ptr );
-
 
461
 
-
 
462
         /* feed text to output */
-
 
463
         while ( (*arg_ptr != 0) && (value > 1) )
-
 
464
         {
-
 
465
            fputc(*arg_ptr++, op_stream);
-
 
466
            value--;
-
 
467
         }
-
 
468
 
-
 
469
         /* Pad output with 0's if necessary */
-
 
470
         while ( value > 0)
-
 
471
         {
-
 
472
            fputc(0, op_stream);
-
 
473
            value--;
-
 
474
         }
-
 
475
      }
-
 
476
      else
-
 
477
      {
-
 
478
         ERROR("Missing text from ZTEXT command");
-
 
479
      }
-
 
480
   }
-
 
481
   else
-
 
482
   {
-
 
483
      ERROR("Bad/missing count/value in ZTEXT command");
-
 
484
   }
-
 
485
}
-
 
486
 
-
 
487
 
440
/**************************************************************************/
488
/**************************************************************************/
441
 
489
 
442
void fn_FEED(char * arg_ptr)
490
void fn_FEED(char * arg_ptr)
443
{
491
{
444
   unsigned long count, i;
492
   unsigned long count, i;
Line 1396... Line 1444...
1396
            else if (strnicmp(cmd_line, "NTEXT", 5) == 0) {
1444
            else if (strnicmp(cmd_line, "NTEXT", 5) == 0) {
1397
               strip_trailing_comment( cmd_line );
1445
               strip_trailing_comment( cmd_line );
1398
               if (OutputFileOpen())
1446
               if (OutputFileOpen())
1399
                  fn_NTEXT(cmd_args);
1447
                  fn_NTEXT(cmd_args);
1400
            }
1448
            }
-
 
1449
            else if (strnicmp(cmd_line, "ZTEXT", 5) == 0) {
-
 
1450
               strip_trailing_comment( cmd_line );
-
 
1451
               if (OutputFileOpen())
-
 
1452
                  fn_ZTEXT(cmd_args);
-
 
1453
            }
1401
            else if (strnicmp(cmd_line, "ALIGN", 5) == 0) {
1454
            else if (strnicmp(cmd_line, "ALIGN", 5) == 0) {
1402
               strip_trailing_comment_and_spaces( cmd_line );
1455
               strip_trailing_comment_and_spaces( cmd_line );
1403
               if (OutputFileOpen())
1456
               if (OutputFileOpen())
1404
                  fn_ALIGNMENT(cmd_args, 2);
1457
                  fn_ALIGNMENT(cmd_args, 2);
1405
            }
1458
            }
Line 1477... Line 1530...
1477
                  printf("ERROR on line %u of command file\n\n", cmdLineNum);
1530
                  printf("ERROR on line %u of command file\n\n", cmdLineNum);
1478
                  printf("  %s\n", cmd_line);
1531
                  printf("  %s\n", cmd_line);
1479
                  printf("  ^\n");
1532
                  printf("  ^\n");
1480
                  printf("  |\n");
1533
                  printf("  |\n");
1481
                  printf("  | Unknown Command\n");
1534
                  printf("  | Unknown Command\n");
-
 
1535
                  mustAbort = 1;
1482
                  break;
1536
                  break;
1483
               }
1537
               }
1484
            }
1538
            }
1485
         }
1539
         }
1486
 
1540
 
Line 1534... Line 1588...
1534
   printf("  DW v,v,..,v            Add the specified list of 16-bit values to the output file\n");
1588
   printf("  DW v,v,..,v            Add the specified list of 16-bit values to the output file\n");
1535
   printf("  DL v,v,..,v            Add the specified list of 32-bit values to the output file\n");
1589
   printf("  DL v,v,..,v            Add the specified list of 32-bit values to the output file\n");
1536
   printf("  TEXT text              Add the specified text to the output file\n");
1590
   printf("  TEXT text              Add the specified text to the output file\n");
1537
   printf("  NTEXT v,text           Add exactly v characters of the specified text to the output file\n");
1591
   printf("  NTEXT v,text           Add exactly v characters of the specified text to the output file\n");
1538
   printf("                           - pad output file with 0's if insufficient text provided\n");
1592
   printf("                           - pad output file with 0's if insufficient text provided\n");
-
 
1593
   printf("  ZTEXT v,text           Add exactly v-1 characters and a NULL terminator of the specified text to the output file\n");
1539
   printf("  BIG_ENDIAN             Turn Big-endian on (default behaviour)\n");
1594
   printf("  BIG_ENDIAN             Turn Big-endian on (default behaviour)\n");
1540
   printf("  LITTLE_ENDIAN          Turn Big-endian off\n");
1595
   printf("  LITTLE_ENDIAN          Turn Big-endian off\n");
1541
   printf("  OUTPUT_FILE name       Opens a new Output File, closing the previous one\n");
1596
   printf("  OUTPUT_FILE name       Opens a new Output File, closing the previous one\n");
1542
   printf("  SEEKSTART offset       Seeks to the specified offset from the start of the output file\n");
1597
   printf("  SEEKSTART offset       Seeks to the specified offset from the start of the output file\n");
1543
   printf("  SEEKEND offset         Seeks to the specified offset from the end of the output file\n");
1598
   printf("  SEEKEND offset         Seeks to the specified offset from the end of the output file\n");
Line 1601... Line 1656...
1601
 
1656
 
1602
   newline();
1657
   newline();
1603
}
1658
}
1604
 
1659
 
1605
 
1660
 
1606
void main( int argc,        /* Number of strings in array argv          */
1661
int main( int argc,        /* Number of strings in array argv          */
1607
          char *argv[],    /* Array of command-line argument strings   */
1662
          char *argv[],    /* Array of command-line argument strings   */
1608
          char **envp )    /* Array of environment variable strings    */
1663
          char **envp )    /* Array of environment variable strings    */
1609
{
1664
{
1610
   char * pCmdFilename = NULL;
1665
   char * pCmdFilename = NULL;
1611
   char * pOutputFilename = NULL;
1666
   char * pOutputFilename = NULL;
Line 1696... Line 1751...
1696
   {
1751
   {
1697
      if( (op_stream = fopen( pOutputFilename, "wb" )) == NULL )
1752
      if( (op_stream = fopen( pOutputFilename, "wb" )) == NULL )
1698
      {
1753
      {
1699
         fclose(cmd_stream);
1754
         fclose(cmd_stream);
1700
         printf("ERROR : Could not open output file\n");
1755
         printf("ERROR : Could not open output file\n");
-
 
1756
         mustAbort = 1;
1701
         goto binflow_exit;
1757
         goto binflow_exit;
1702
      }
1758
      }
1703
      else
1759
      else
1704
      {
1760
      {
1705
         i_op_file_opened = TRUE;
1761
         i_op_file_opened = TRUE;
Line 1729... Line 1785...
1729
 
1785
 
1730
   if (i_ip_file_opened)
1786
   if (i_ip_file_opened)
1731
      fclose(ip_stream);
1787
      fclose(ip_stream);
1732
 
1788
 
1733
   if (i_had_input_stream_errors)
1789
   if (i_had_input_stream_errors)
-
 
1790
   {
1734
      printf("ERROR : Errors occurred when reading your input data file\n");
1791
      printf("ERROR : Errors occurred when reading your input data file\n");
-
 
1792
      mustAbort = 1;
-
 
1793
   }
-
 
1794
 
-
 
1795
   if (mustAbort)
-
 
1796
   {
-
 
1797
        exitCode = 1;
-
 
1798
        if ( pOutputFilename )
-
 
1799
            unlink (pOutputFilename);
-
 
1800
   }
-
 
1801
   return exitCode;
-
 
1802
   
1735
 
1803
 
1736
binflow_exit:
1804
binflow_exit:
-
 
1805
   exitCode = 2;
1737
   if (showUsage)
1806
   if (showUsage)
1738
   {
1807
   {
1739
      usage();
1808
      usage();
1740
   }
1809
   }
1741
   else if (showCommands)
1810
   else if (showCommands)
1742
   {
1811
   {
1743
      commands();
1812
      commands();
1744
   }
1813
   }
-
 
1814
 
-
 
1815
   return exitCode;
1745
}
1816
}
1746
 
1817
 
1747
 
1818
 
1748
 
1819
 
1749
/************************************************************************************************************/
1820
/************************************************************************************************************/