EnglishРусский  

   ..

   arr.c

   arr.h

   arrdata.c

   arrdata.h

   buf.c

   buf.h

   crc.c

   crc.h

   file.c

   file.h

   hash.c

   hash.h

   memory.c

   memory.h

   mix.c

   mix.h

   msg.c

   msg.h

   msglist.c

   msglist.g

   msglist.h

   number.c

   number.h

   str.c

   str.h

   types.h

Ads

Perfect Automation tool
All-In-One: Script editor, Launcher, Scheduler, Keyboard & Mouse Recorder. Try now!

CreateInstall
Freeware and commercial installers.

Cell Phone Batteries
Batteries Plus offers batteries for laptop, camcorder, cell phone, camera.

Gentee needs your help!
How to advertise with us
 
laptop battery

  1 /******************************************************************************
  2 *
  3 * Copyright (C) 2006, The Gentee Group. All rights reserved. 
  4 * This file is part of the Gentee open source project - http://www.gentee.com. 
  5 * 
  6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT"). 
  7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS 
  8 * ACCEPTANCE OF THE AGREEMENT.
  9 *
 10 * ID: msg 18.10.06 0.0.A.
 11 *
 12 * Author: Alexey Krivonogov
 13 *
 14 * Summary: Message functions.
 15 *
 16 ******************************************************************************/
 17 
 18 #include "../os/user/defines.h"
 19 #include "../genteeapi/gentee.h"
 20 #include "msg.h"
 21 #include "../compiler/lexem.h"
 22 
 23 #ifndef RUNTIME
 24    #include <setjmp.h> 
 25    extern jmp_buf stack_state;
 26 #endif
 27 
 28 uint _time;  
 29 
 30 /*-----------------------------------------------------------------------------
 31 *
 32 * ID: msg 23.10.06 0.0.A.
 33 * 
 34 * Summary: Show an error or information message
 35 *
 36 -----------------------------------------------------------------------------*/
 37 
 38 uint CDECLCALL msg( uint code, ... )
 39 {
 40    va_list args;
 41    msginfo minfo;
 42    plexem  plex;
 43 
 44    mem_zero( &minfo, sizeof( msginfo ));
 45    minfo.flag = code & 0xFFFF0000;
 46    minfo.code = code & 0xFFFF;
 47 
 48    va_start( args, code );
 49 
 50    if ( code & MSG_STR )
 51       minfo.namepar = str_ptr(( pstr )va_arg( args, int ));
 52    if ( code & MSG_POS || code & MSG_LEXEM )
 53       plex = ( plexem )va_arg( args, int );
 54    if ( code & MSG_VALSTR )
 55       minfo.namepar = ( pubyte )va_arg( args, int );
 56    if ( code & MSG_VALUE )
 57       minfo.uintpar = ( uint )va_arg( args, int );
 58 
 59 #ifndef RUNTIME
 60    if ( code & MSG_LEXNAME )
 61    {
 62       minfo.namepar = 0;
 63       switch ( plex->type )
 64       {
 65          case LEXEM_OPER: 
 66             minfo.namepar = ( pubyte )&plex->oper.name;
 67             break;
 68          case LEXEM_NAME: 
 69          case LEXEM_MACRO: 
 70             minfo.namepar = ( pubyte )lexem_getname( plex );
 71             break;
 72       }
 73       minfo.flag |= MSG_STR;
 74    }
 75 #endif
 76 //   for ( i = 0; i < 8; i++ )
 77 //      pars[i] = ( uint )va_arg( args, int );
 78    va_end( args );  
 79 
 80    if ( _compile && _compile->cur )
 81    {
 82       // Лишнее ???
 83       if ( _compile->cur->src->use > _pvm->pos )
 84          minfo.line = str_pos2line( _compile->cur->src, _pvm->pos, &minfo.pos );
 85       if ( minfo.flag & MSG_POS )
 86       {
 87          minfo.line = str_pos2line( _compile->cur->src, ( uint )plex, &minfo.pos );
 88       }
 89       if ( minfo.flag & MSG_LEXEM )
 90          minfo.line = str_pos2line( _compile->cur->src, plex->pos, &minfo.pos );
 91       minfo.filename = str_ptr( _compile->cur->filename ); 
 92       minfo.line++;
 93       minfo.pos++;
 94    }
 95    minfo.pattern = msgtext[ minfo.code ];
 96 
 97    if ( _gentee.message )
 98       _gentee.message( &minfo );
 99 
100    if ( minfo.flag & MSG_EXIT )
101    {
102       if ( !_compile || _compile->flag & CMPL_THREAD )
103          os_exitthread( 0 );
104 #ifndef RUNTIME
105       else
106 //         os_exitthread( 0 );
107          longjmp( stack_state, -1 );
108 #endif
109    }
110    return 1;	
111 }
112 
113 /*-----------------------------------------------------------------------------
114 *
115 * ID: print 26.12.06 0.0.A.
116 * 
117 * Summary: Print function for debugging
118 *
119 -----------------------------------------------------------------------------*/
120 
121 void  CDECLCALL print( pubyte output, ... ) 
122 {
123    va_list args;
124    uint    len;
125    ubyte   ok[ 512 ];
126 
127    va_start( args, output );
128    len = vsprintf( ok, output, args );
129    va_end( args );
130    _gentee.print( ok, len );
131 //   os_print( ok, len );
132 }
133 
134 uint STDCALL message( pmsginfo minfo )
135 {
136    uint      temp, time;
137    uint      line = 0, pos = 0;
138 
139    if ( minfo->flag & MSG_EXIT )
140    {
141       print( _compile ? "Compile error [ 0x%X %i ]: " :
142             "Run-time error [ 0x%X %i ]: ", minfo->code, minfo->code ); 
143       if ( minfo->line )
144          print( "%s\r\n[ Line: %i Pos: %i ] ", minfo->filename, 
145                  minfo->line, minfo->pos ); 
146    }
147    else 
148       if ( _gentee.flags & G_SILENT )
149          return 0;
150 
151    if ( minfo->flag & MSG_VALSTR )
152       print( minfo->pattern, minfo->uintpar, minfo->uintpar, minfo->namepar ); 
153    else
154       if ( minfo->flag & MSG_VALVAL )
155          print( minfo->pattern, minfo->uintpar, minfo->uintpar ); 
156       else
157          if ( minfo->flag & MSG_STR )
158             print( minfo->pattern, minfo->namepar ); 
159          else
160             if ( minfo->flag & MSG_VALUE )
161                print( minfo->pattern, minfo->uintpar ); 
162             else
163                print( minfo->pattern );
164    print( "\r\n" );
165 
166    switch ( minfo->code )
167    {
168       case MStart:
169          _time = os_time();
170          break;
171       case MEnd:
172          time = os_time() - _time;
173          temp = time % 60000;
174          print( "Summary Time: %i:%i:%i\r\n", 
175                   time / 60000, temp / 1000, temp % 1000 );
176          break;
177    }
178 //   if ( !( _gentee.flags & G_SILENT ) || minfo->flag & MSG_EXIT )
179 //       str_output( minfo->result );
180 
181    if ( minfo->flag & MSG_EXIT )
182    {
183       print( "\r\nPress any key...\r\n" );
184       os_getchar();
185    }
186    return 0;
187 }
Edit