home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 March / VPR9703A.ISO / VPR_DATA / DOGA / SOURCES / POLYEDIT.LZH / LIB / LIB.C < prev    next >
C/C++ Source or Header  |  1996-01-09  |  2KB  |  100 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. #include "_lib.h"
  7. #include "inlib.h"
  8.  
  9. extern    int        (**SystemFunc)();
  10.  
  11. int        (*LibErrorExec)(char*) = NULL ;
  12. int        (*LibWarningExec)(char*) = NULL ;
  13. #ifdef DYNAMIC
  14. Library    **LibAry ;
  15. #endif
  16.  
  17. /*    ライブラリの初期化    */
  18. int        __LibraryInit( func, lib )
  19. void    *func ;
  20. Library    **lib ;
  21. {
  22. #ifdef DYNAMIC
  23.     SystemFunc = (int(**)())func ;
  24.     LibAry = lib ;
  25. #endif
  26.     LibErrorExec = NULL ;
  27.     LibWarningExec = NULL ;
  28.     return 0 ;
  29. }
  30.  
  31. #ifdef DYNAMIC
  32. /*    ライブラリ番号を得る    */
  33. int        LibraryGet( name )
  34. char    *name ;
  35. {
  36.     int        i ;
  37.     Library    **lib = LibAry ;
  38.  
  39.     if ( lib == NULL )
  40.         return 0 ;
  41.  
  42.     for( i = 1 ; i < MAX_LIBS ; i++ )
  43.     {
  44.         if ( lib[i] != NULL && strcmp( lib[i]->name, name ) == 0 )
  45.         {
  46.             return i ;
  47.         }
  48.     }
  49.     return 0 ;
  50. }
  51.  
  52. /*    ライブラリ情報を得る    */
  53. Library    *LibraryGetInfo( no )
  54. int        no ;
  55. {
  56.     Library    **lib = LibAry ;
  57.  
  58.     if ( lib == NULL )
  59.         return NULL ;
  60.     else
  61.         return lib[no] ;
  62. }
  63. #endif
  64.  
  65. /*    エラーメッセージの表示    */
  66. int        MessageError( msg )
  67. char    *msg ;
  68. {
  69.     if ( LibErrorExec == NULL )
  70.     {
  71.         printf( "%s\n", msg );
  72.         exit( 1 );
  73.         return -1 ;
  74.     }
  75.     else
  76.         return (*LibErrorExec)( msg );
  77. }
  78.  
  79. /*    警告メッセージの表示    */
  80. int        MessageWarning( msg )
  81. char    *msg ;
  82. {
  83.     if ( LibWarningExec == NULL )
  84.     {
  85.         printf( "%s\n", msg );
  86.         return 0 ;
  87.     }
  88.     else
  89.         return (*LibWarningExec)( msg );
  90. }
  91.  
  92. /*    エラーメッセージ表示ルーチンの変更    */
  93. void    MessageSet( err, warn )
  94. void    *err, *warn ;
  95. {
  96.     LibErrorExec = err ;
  97.     LibWarningExec = warn ;
  98. }
  99.  
  100.