For future reference, you can hande this by using the Ns_ObjvObj
option/arg type which just gives you back the underlying Tcl object. 
You can then handle it however you like.


On 6/10/05, Vlad Seryakov <[EMAIL PROTECTED]> wrote:
> yes, parsing should check for nulls an dlimits, just to see if idea is
> coorrect. obkv parsing will not work here because i will need change on
> the fly TclObjvString and TclObjvByteArray.
> 
>      if (objc > param && !strcmp(Tcl_GetString(objv[param]),"-binary")) {
>          binary = 1;
>          param++;
>      }
>      if (objc > param && Tcl_GetIntFromObj(interp, objv[param++],
> &status) != TCL_OK) {
>          return TCL_ERROR;
>      }
>      if (objc > param) {
>          type = Tcl_GetString(objv[param++]);
>      }
>      if (objc > param) {
>        if (binary != 0) {
>            data = Tcl_GetByteArrayFromObj(objv[param], &len);
>        } else {
>            data = Tcl_GetStringFromObj(objv[param], &len);
>        }
>      }
> 
> 
> Zoran Vasiljevic wrote:
> >
> > Am 10.06.2005 um 17:50 schrieb Vlad Seryakov:
> >
> >> Second try :-)))
> >
> >
> > You'd get (probably) a sigsegv if somebody says:
> >
> >   ns_return -binary 200
> >
> > Yes, this arg parsing can be a PITA. Therefore I like
> > Stephens tclobjv code :-)
> > Unfortunately, it won't do the boolean flags, but we've
> > discussed that already many times.
> >
> > I'd still strenghten out the parsing with objc checking.
> >
> > Zoran
> >
> >>
> >> int
> >> NsTclReturnObjCmd(ClientData arg, Tcl_Interp *interp, int objc,
> >> Tcl_Obj *CONST objv[])
> >> {
> >>     Ns_Conn *conn;
> >>     unsigned char *data = 0, *type = 0;
> >>     int result, param = 1, status = 0, len = 0, binary = 0;
> >>
> >>     if (!strcmp(Tcl_GetString(objv[param]),"-binary")) {
> >>         binary = 1;
> >>         param++;
> >>     }
> >>     if (Tcl_GetIntFromObj(interp, objv[param++], &status) != TCL_OK) {
> >>         return TCL_ERROR;
> >>     }
> >>     type = Tcl_GetString(objv[param++]);
> >>     if (binary != 0) {
> >>         data = Tcl_GetByteArrayFromObj(objv[param], &len);
> >>     } else {
> >>         data = Tcl_GetStringFromObj(objv[param], &len);
> >>     }
> >>     if (data == NULL || type == NULL || status == 0) {
> >>         Tcl_WrongNumArgs(interp, 1, objv, "?-binary? status type
> >> string");
> >>         return TCL_ERROR;
> >>     }
> >>     if (GetConn(arg, interp, &conn) != TCL_OK) {
> >>         return TCL_ERROR;
> >>     }
> >>     if(binary != 0) {
> >>        result = Ns_ConnReturnData(conn, status, data, len, type);
> >>     } else {
> >>        result = Ns_ConnReturnCharData(conn, status, data, len, type);
> >>     }
> >>     return Result(interp, result);
> >> }
> >>
> >>
> >> Zoran Vasiljevic wrote:
> >>
> >>> Am 10.06.2005 um 17:23 schrieb Vlad Seryakov:
> >>>
> >>>> How about this, i tested it :
> >>>>
> >>>> int
> >>>> NsTclReturnObjCmd(ClientData arg, Tcl_Interp *interp, int objc,
> >>>> Tcl_Obj *CONST objv[])
> >>>>
> >>>>
> >>> Hm... I would say, if somebody wanted to do:
> >>>    ns_return 200 text/plain -binary
> >>> you'd have a problem, right?
> >>> Zoran
> >>> -------------------------------------------------------
> >>> This SF.Net email is sponsored by: NEC IT Guy Games.  How far can
> >>> you shotput
> >>> a projector? How fast can you ride your desk chair down the office
> >>> luge track?
> >>> If you want to score the big prize, get to know the little guy.
> >>> Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
> >>> _______________________________________________
> >>> naviserver-devel mailing list
> >>> naviserver-devel@lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
> >>>
> >>
> >> --
> >> Vlad Seryakov
> >> 571 262-8608 office
> >> [EMAIL PROTECTED]
> >> http://www.crystalballinc.com/vlad/
> >>
> >>
> >> -------------------------------------------------------
> >> This SF.Net email is sponsored by: NEC IT Guy Games.  How far can  you
> >> shotput
> >> a projector? How fast can you ride your desk chair down the office
> >> luge track?
> >> If you want to score the big prize, get to know the little guy.   Play
> >> to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
> >> _______________________________________________
> >> naviserver-devel mailing list
> >> naviserver-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
> >>
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you
> > shotput
> > a projector? How fast can you ride your desk chair down the office luge
> > track?
> > If you want to score the big prize, get to know the little guy.  Play to
> > win an NEC 61" plasma display: http://www.necitguy.com/?r=20
> > _______________________________________________
> > naviserver-devel mailing list
> > naviserver-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/naviserver-devel
> 
> --
> Vlad Seryakov
> 571 262-8608 office
> [EMAIL PROTECTED]
> http://www.crystalballinc.com/vlad/
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
> a projector? How fast can you ride your desk chair down the office luge track?
> If you want to score the big prize, get to know the little guy.
> Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
> _______________________________________________
> naviserver-devel mailing list
> naviserver-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/naviserver-devel
>

Reply via email to