revtools.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /******************************************************************************
  2. *
  3. * project name: TIGCC Tools Suite
  4. * file name: revtools.h
  5. * initial date: 23/08/2000
  6. * author: thomas.nussbaumer@gmx.net
  7. * description: macros for automatic handling of version number output
  8. * which is in sync with the CVS version number
  9. *
  10. * examine one of the pctools source codes to see how it works ;-)
  11. *
  12. * [NO CVS ID HERE BY INTENTION]
  13. *
  14. ******************************************************************************/
  15. //-----------------------------------------------------------------------------
  16. // [Usage]
  17. //
  18. // (1) include this file into your tool
  19. //
  20. //
  21. // (2) AFTER (!!) all includes put the following lines into your source code:
  22. //
  23. // #ifdef CVS_FILE_REVISION
  24. // #undef CVS_FILE_REVISION
  25. // #endif
  26. // ----------------------------------------------------------------------------
  27. // DON'T EDIT THE NEXT REVISION BY HAND! THIS IS DONE AUTOMATICALLY BY THE
  28. // CVS SYSTEM !!!
  29. // ----------------------------------------------------------------------------
  30. // #define CVS_FILE_REVISION "$Revision$"
  31. //
  32. // It must be placed AFTER (!!) all includes otherwise the macros may be
  33. // expanded wrong where you use them. For example: if you have added the above
  34. // lines at the top of your file and include afterwards a file which does
  35. // the same, the version of the included file will be used further due to the
  36. // #undef CVS_FILE_REVISION. Everything clear?
  37. //
  38. //
  39. // (3) to output the cvs revision number you can now to a simple:
  40. //
  41. // printf(CVSREV_PRINTPARAMS)
  42. //
  43. // if your file has, for example, the revision 1.3 the following string will
  44. // be printed: v1.03
  45. //
  46. // the prefix before the subversion is used to get equal-sized output strings
  47. // for mainversions between 1 ... 9 and subversion between 1 .. 99
  48. //
  49. // if your program leaves that range and you need to have equal-sized output
  50. // strings you have to implement it by your own by using the
  51. // CVSREV_MAIN and CVSREV_SUB macros which returns the main and sub versions
  52. // as plain integers. if there is something wrong with your revision string
  53. // CVSREV_MAIN and/or CVSREV_SUB will deliver 0, which is no valid CVS main
  54. // or subversion number.
  55. //
  56. // i will suggest that you use the CVS system. its simple to handle, keeps
  57. // track of your revisions and their history and with the smart macros below
  58. // you haven't to worry anymore about the version output strings of your
  59. // program. if you want a special version number you can force CVS at every
  60. // time to give this version number to your program (0 is not allowed as
  61. // main and subversion number - thats the only pity)
  62. //
  63. // within this tools suite every tool will use the automatic version handling
  64. // but the tool suite version number itself will be handled "by hand".
  65. // this number shouldn't change that quickly as with the tools.
  66. //
  67. //-----------------------------------------------------------------------------
  68. #ifndef __REV_TOOLS_H__
  69. #define __REV_TOOLS_H__
  70. #include <stdio.h>
  71. #include <stdlib.h>
  72. #include <string.h>
  73. //-----------------------------------------------------------------------------
  74. // just used internally
  75. //-----------------------------------------------------------------------------
  76. #define CVS_TRUNC_PREFIX ((strlen((CVS_FILE_REVISION))<=11) ? 0 : (CVS_FILE_REVISION+11))
  77. #define CVS_FIND_COMMA (strchr(CVS_TRUNC_PREFIX,'.'))
  78. #define CVSREV_MAIN (int)(!(CVS_TRUNC_PREFIX) ? 0 : atoi(CVS_TRUNC_PREFIX))
  79. #define CVSREV_SUB (int)(!(CVS_TRUNC_PREFIX) ? 0 : (!(CVS_FIND_COMMA) ? 0 : atoi(CVS_FIND_COMMA+1)))
  80. //-----------------------------------------------------------------------------
  81. // NOTE: THE FOLLOWING MACRO WILL ONLY HANDLE MAIN VERSION < 10 AT CONSTANT
  82. // LENGTH !!!
  83. // (subversions from 1 .. 99 are mapped to 01 .. 99)
  84. //
  85. // the following macro may be used to setup a printf(),sprintf() or fprintf()
  86. // call
  87. //-----------------------------------------------------------------------------
  88. #define CVSREV_PRINTPARAMS "v%d.%02d",CVSREV_MAIN,CVSREV_SUB
  89. #define PRINT_ID(name) fprintf(stderr,"\n");fprintf(stderr, name" ");\
  90. fprintf(stderr,CVSREV_PRINTPARAMS);\
  91. fprintf(stderr," - TIGCC Tools Suite v"TTV_MAIN TTV_SUB"\n" \
  92. "(c) thomas.nussbaumer@gmx.net " TTV_DATE"\n\n");
  93. #endif
  94. //#############################################################################
  95. //###################### NO MORE FAKES BEYOND THIS LINE #######################
  96. //#############################################################################