mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
Merge branch 'master' of github.com:elua/elua
This commit is contained in:
commit
dca244112b
2
.gitignore
vendored
2
.gitignore
vendored
@ -15,4 +15,6 @@ mux*
|
||||
rfs_server*
|
||||
doc/dist
|
||||
doc/cache
|
||||
*~
|
||||
*.*~
|
||||
|
||||
|
@ -2,6 +2,15 @@
|
||||
eLua Project News
|
||||
-----------------
|
||||
|
||||
June 6th, 2011
|
||||
~~~~~~~~~~~~~~
|
||||
.New eLua website released
|
||||
We are glad to announce an experimental form of a new web site for the eLua community, which you can find online at: http://new.eluaproject.net
|
||||
|
||||
It will be hosted at this temporary URL while we hear your comments, suggestions and implement corrections. After this phase, it will become the new official site at the main site URL.
|
||||
|
||||
Thank you all for the support
|
||||
|
||||
February 2nd, 2011
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
.eLua v0.8 released
|
||||
|
47
src/shell.c
47
src/shell.c
@ -56,7 +56,8 @@ static void shell_help( char* args )
|
||||
printf( " ls or dir - lists filesystems files and sizes\n" );
|
||||
printf( " cat or type - lists file contents\n" );
|
||||
printf( " lua [args] - run Lua with the given arguments\n" );
|
||||
printf( " recv - receive a file via XMODEM and execute it\n" );
|
||||
printf( " recv [path] - receive a file via XMODEM, if there is a path, save"
|
||||
" there, otherwise run it.");
|
||||
printf( " cp <src> <dst> - copy source file 'src' to 'dst'\n" );
|
||||
printf( " ver - print eLua version\n" );
|
||||
}
|
||||
@ -144,21 +145,41 @@ static void shell_recv( char* args )
|
||||
p ++;
|
||||
printf( "done, got %u bytes\n", ( unsigned )( p - shell_prog ) );
|
||||
|
||||
// Execute
|
||||
if( ( L = lua_open() ) == NULL )
|
||||
// we've received an argument, try saving it to a file
|
||||
if( strcmp( args, "") != 0 )
|
||||
{
|
||||
printf( "Unable to create Lua state\n" );
|
||||
free( shell_prog );
|
||||
shell_prog = NULL;
|
||||
return;
|
||||
FILE *foutput = fopen( args, "w" );
|
||||
size_t file_sz = p - shell_prog;
|
||||
if( foutput == NULL )
|
||||
{
|
||||
printf( "unable to open file %s\n", args);
|
||||
free( shell_prog );
|
||||
shell_prog = NULL;
|
||||
return;
|
||||
}
|
||||
if( fwrite( shell_prog, sizeof( char ), file_sz, foutput ) == file_sz )
|
||||
printf( "received and saved as %s\n", args );
|
||||
else
|
||||
printf( "disk full, unable to save file %s\n", args );
|
||||
fclose( foutput );
|
||||
}
|
||||
luaL_openlibs( L );
|
||||
if( luaL_loadbuffer( L, shell_prog, p - shell_prog, "xmodem" ) != 0 )
|
||||
printf( "Error: %s\n", lua_tostring( L, -1 ) );
|
||||
else
|
||||
if( lua_pcall( L, 0, LUA_MULTRET, 0 ) != 0 )
|
||||
else // no arg, running the file with lua.
|
||||
{
|
||||
if( ( L = lua_open() ) == NULL )
|
||||
{
|
||||
printf( "Unable to create Lua state\n" );
|
||||
free( shell_prog );
|
||||
shell_prog = NULL;
|
||||
return;
|
||||
}
|
||||
luaL_openlibs( L );
|
||||
if( luaL_loadbuffer( L, shell_prog, p - shell_prog, "xmodem" ) != 0 )
|
||||
printf( "Error: %s\n", lua_tostring( L, -1 ) );
|
||||
lua_close( L );
|
||||
else
|
||||
if( lua_pcall( L, 0, LUA_MULTRET, 0 ) != 0 )
|
||||
printf( "Error: %s\n", lua_tostring( L, -1 ) );
|
||||
lua_close( L );
|
||||
}
|
||||
free( shell_prog );
|
||||
shell_prog = NULL;
|
||||
#endif // #ifndef BUILD_XMODEM
|
||||
|
Loading…
x
Reference in New Issue
Block a user