Exemplo n.º 1
0
MFUNC(modulefact, MCnop)
{
  // one argument expected
  MFnargsCheck(1);

  if(MFisInt(MFarg(1))) {
    long value = MFlong(MFarg(1));
    if (value > 0) 
      MFreturn(MFlong(fact(value)));
  } 

  MFreturn(MFcopy(MVargs));
} MFEND
Exemplo n.º 2
0
} MFEND

///////////////////////////////////////////////////////////////////////////////
MFUNC ( kernelPath, MCnop )
{ MFnargsCheck( 0 );
  MFreturn( MFstring(MUPV_env.progName) );
} MFEND
Exemplo n.º 3
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC ( kernelPid, MCnop )
{ MFnargsCheck( 0 );
  MFreturn( MFlong(MFprocId()) );
} MFEND
Exemplo n.º 4
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC ( userName, MCnop )
{ MFnargsCheck( 0 );

  char *user = MFprocUserName();  
  if( user == NULL ) 
      MFerror( "Not supported for this operating system" );

  MFreturn( MFstring(user) );
} MFEND
Exemplo n.º 5
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC( date, MCnop )
{ MFnargsCheck( 0 );

  time_t clock;
  time( &clock );

  char *string = ctime(&clock);
  string[24] = '\0';

  MFreturn( MFstring(string) );
} MFEND
Exemplo n.º 6
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC( busyWaiting, MCnop )
{ MFnargsCheck( 1 );
  MFargCheck  ( 1, DOM_INT );

    unsigned long sec = (unsigned long) MFlong( MFarg(1) );
    if( sec < 0L || sec > 60*60*24L ) 
        MFerror( "Integer is out of range 0..86400" );

    unsigned long   t1, t2;
    // 64Bit Windows: sizeof(int)<>sizeof(size_t)
    for( t1 = t2 = static_cast<unsigned long>(time(NULL)); (t2-t1) < sec; 
	 t2 = static_cast<unsigned long>(time(NULL)) ) ;
    MFreturn( MFcopy(MVnull) );
} MFEND
Exemplo n.º 7
0
} MFEND


///////////////////////////////////////////////////////////////////////////////
MFUNC( sleep, MCnop )
{ MFnargsCheck( 1 );
  MFargCheck  ( 1, DOM_INT );

  unsigned long sec = (unsigned long) MFlong( MFarg(1) );
  if( sec < 0L || sec > 60*60*24UL )   
      MFerror( "Integer is out of range 0..86400" );

#if   (defined MACINTOSH)
    MFerror( "Sorry, not supported on this platform" );
#elif (defined WIN32)
    Sleep( sec*1000UL );
#else
    sleep( sec );
#endif

    MFreturn( MFcopy(MVnull) );
} MFEND