Ignore:
Timestamp:
Jan 7, 2009 9:31:14 AM (14 years ago)
Author:
dkearney
Message:

fixing rp library's get() function for retrieving encoded data. if the data is encoded there is no need to do xml entity translation. adding a function rappture's encode class for checking to see if a string has a proper header encode header. adding corresponding tcl functions and tests. also adjusting some of the int declarations to size_t.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/tcl/src/RpEncodeTclInterface.cc

    r1042 r1264  
    6868        Tcl_AppendResult(interp,
    6969            "wrong # args: should be \"",
    70             Tcl_GetString(objv[0])," binary <string>\"",
     70            Tcl_GetString(objv[0])," binary|encoded <string>\"",
    7171            (char*)NULL);
    7272        return TCL_ERROR;
     
    7878    const char *buf = (const char*) Tcl_GetByteArrayFromObj(objv[2],&bufLen);
    7979
    80     if (strcmp(type,"binary") == 0) {
     80    if (('b' == *type) && (strcmp(type,"binary") == 0)) {
    8181        if (Rappture::encoding::isbinary(buf,bufLen) != 0) {
    8282            // non-ascii character found, return yes
     
    8686        }
    8787        return TCL_OK;
     88    } else if (('e' == *type) && (strcmp(type,"encoded") == 0)) {
     89        if (Rappture::encoding::isencoded(buf,bufLen) != 0) {
     90            // valid "@@RP-ENC:" header found, return yes
     91            Tcl_AppendResult(interp, "yes", (char*)NULL);
     92        } else {
     93            Tcl_AppendResult(interp, "no",(char*)NULL);
     94        }
     95        return TCL_OK;
    8896    }
    8997    Tcl_AppendResult(interp, "bad option \"", type,
    90             "\": should be binary",
     98            "\": should be one of binary, encoded",
    9199            (char*)NULL);
    92100    return TCL_ERROR;
Note: See TracChangeset for help on using the changeset viewer.