Enlightenment CVS committal

Author  : tsauerbeck
Project : e17
Module  : libs/embryo

Dir     : e17/libs/embryo/src/lib


Modified Files:
        embryo_args.c 


Log Message:
added getsarg() - copies the specified argument into a string buffer. use this 
instead of getarg(num, 0) if you want to retrieve all of the string
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/embryo/src/lib/embryo_args.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- embryo_args.c       9 Dec 2004 02:46:32 -0000       1.3
+++ embryo_args.c       29 Apr 2005 14:30:59 -0000      1.4
@@ -1,5 +1,14 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
 #include "embryo_private.h"
 
+#define STRSET(ep, par, str) { \
+   Embryo_Cell *___cptr; \
+   if ((___cptr = embryo_data_address_get(ep, par))) { \
+      embryo_data_string_set(ep, str, ___cptr); \
+   } }
+
 /* exported args api */
 
 static Embryo_Cell
@@ -51,6 +60,41 @@
    return 1;
 }
 
+static Embryo_Cell
+_embryo_args_getsarg(Embryo_Program *ep, Embryo_Cell *params)
+{
+   Embryo_Header *hdr;
+   unsigned char *data;
+   Embryo_Cell base_cell;
+   char *s;
+   int i = 0;
+
+   /* params[1] = arg_no */
+   /* params[2] = buf */
+   /* params[3] = buflen */
+   if (params[0] != (3 * sizeof(Embryo_Cell))) return 0;
+   if (params[3] <= 0) return 0; /* buflen must be > 0 */
+   hdr = (Embryo_Header *)ep->base;
+   data = ep->base + (int)hdr->dat;
+   base_cell = *(Embryo_Cell *)(data + (int)ep->frm +
+                         (((int)params[1] + 3) * sizeof(Embryo_Cell)));
+
+   s = alloca(params[3]);
+
+   while (i < params[3])
+     {
+       int offset = base_cell + (i * sizeof(Embryo_Cell));
+
+       s[i] = *(Embryo_Cell *)(data + offset);
+       if (!s[++i]) break;
+     }
+
+   s[i - 1] = 0;
+   STRSET(ep, params[2], s);
+
+   return i - 1; /* characters written minus terminator */
+}
+
 /* functions used by the rest of embryo */
 
 void
@@ -61,4 +105,5 @@
    embryo_program_native_call_add(ep, "setarg", _embryo_args_setarg);
    embryo_program_native_call_add(ep, "getfarg", _embryo_args_getarg);
    embryo_program_native_call_add(ep, "setfarg", _embryo_args_setarg);
+   embryo_program_native_call_add(ep, "getsarg", _embryo_args_getsarg);
 }




-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to