lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


From within lua

//------------------------------
somevar = require "modulename";
data = "";
somevar.testfunc(data);
//-------------------------------

It works for anything normal like string "abc123" but as soon as I add binary data it stops functioning.

On 8/15/2012 6:58 AM, Daurnimator wrote:
On 15 August 2012 04:46, Digital <forumme5487@live.com> wrote:
I've been trying this for a very long time, never succeeded in passing binary data.

But here is a function:

static int testfunc(lua_State *L)
{
printf("test func\n");

char *arg1;
int i;
size_t len = 0;

arg1 = luaL_checklstring(L, 1, &len);
//arg1 = luaL_checkudata(L, 1, &len);
//arg1 = lua_touserdata(L, 1);
//len=strlen(arg1);
printf("Size = %s\n",arg1);

FILE *sfile;
sfile = fopen("testfilebinary.txt","wb");
fwrite(arg1,len,1,sfile);
fclose(sfile);

return 0;
}

I tried some udata variants as you can see. But that failed completely and wouldn't even return the normal type "abc123" strings.

Yes, I don't know how to change the time stamp or remove it if possible.


On 8/15/2012 1:41 AM, Patrick Rapin wrote:
It does work, just as long as I only send a normal string like "abcd1234"
etc.
Well, it that case, I don't understand. For Lua there is no
distinction between a "normal" and a "binary" string.
Please check again your code, that should be some stupid bug.
If you want further support, please send us all the test code needed
to produce the problem.

PS: there is a problem with the time stamp of your messages. Your
answers seem to arrive about 3.2 hours before my questions...






How do you call it?