generic/tcl-augeas.c
static int
Rename_Cmd(ClientData cdata, Tcl_Interp *interp,
        int objc, Tcl_Obj *const objv[])
{
    augeas* aug;
    const char* src;
    const char* lbl;
    int aug_result;

    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, USAGE_RENAME);
        return TCL_ERROR;
    }

    aug = parse_id(cdata, interp, objv[1], 0);
    if (aug == NULL) {
        return TCL_ERROR;
    }

    src = Tcl_GetString(objv[2]);
    lbl = Tcl_GetString(objv[3]);

    aug_result = aug_rename(aug, src, lbl);

    if (aug_result > 0) {
        /* Return the number of nodes renamed. */
        Tcl_SetObjResult(interp, Tcl_NewIntObj(aug_result));

        return TCL_OK;
    } else if (aug_result == 0) {
        Tcl_SetObjResult(interp, Tcl_NewStringObj(ERROR_NO_NODES, -1));

        return TCL_ERROR;
    } else { /* aug_result < 0 */
        Tcl_SetObjResult(interp, Tcl_NewStringObj(ERROR_PATH, -1));

        return TCL_ERROR;
    }
}
/*
 * Change the label of all nodes that match src to lbl.
 * Usage: rename token src lbl
 * Return value: nothing.
 * Side effects: changes an Augeas object.
 */
Change the label of all nodes that match src to lbl.
Usage: rename token src lbl
Return value: nothing.
Side effects: changes an Augeas object.
Change the label of all nodes that match src to lbl . Usage : rename token src lbl Return value : nothing . Side effects : changes an Augeas object .
static int
Rename_Cmd(ClientData cdata, Tcl_Interp *interp,
        int objc, Tcl_Obj *const objv[])
{
    augeas* aug;
    const char* src;
    const char* lbl;
    int aug_result;
    if (objc != 4) {
        Tcl_WrongNumArgs(interp, 1, objv, USAGE_RENAME);
        return TCL_ERROR;
    }
    aug = parse_id(cdata, interp, objv[1], 0);
    if (aug == NULL) {
        return TCL_ERROR;
    }
    src = Tcl_GetString(objv[2]);
    lbl = Tcl_GetString(objv[3]);
    aug_result = aug_rename(aug, src, lbl);
    if (aug_result > 0) {
        Tcl_SetObjResult(interp, Tcl_NewIntObj(aug_result));
        return TCL_OK;
    } else if (aug_result == 0) {
        Tcl_SetObjResult(interp, Tcl_NewStringObj(ERROR_NO_NODES, -1));
        return TCL_ERROR;
    } else { 
        Tcl_SetObjResult(interp, Tcl_NewStringObj(ERROR_PATH, -1));
        return TCL_ERROR;
    }
}
static int Rename_Cmd ( ClientData cdata , Tcl_Interp * interp , int objc , Tcl_Obj * const objv [ ] ) { augeas * aug ; const char * src ; const char * lbl ; int aug_result ; if ( objc != 4 ) { Tcl_WrongNumArgs ( interp , 1 , objv , USAGE_RENAME ) ; return TCL_ERROR ; } aug = parse_id ( cdata , interp , objv [ 1 ] , 0 ) ; if ( aug == NULL ) { return TCL_ERROR ; } src = Tcl_GetString ( objv [ 2 ] ) ; lbl = Tcl_GetString ( objv [ 3 ] ) ; aug_result = aug_rename ( aug , src , lbl ) ; if ( aug_result > 0 ) { Tcl_SetObjResult ( interp , Tcl_NewIntObj ( aug_result ) ) ; return TCL_OK ; } else if ( aug_result == 0 ) { Tcl_SetObjResult ( interp , Tcl_NewStringObj ( ERROR_NO_NODES , -1 ) ) ; return TCL_ERROR ; } else { Tcl_SetObjResult ( interp , Tcl_NewStringObj ( ERROR_PATH , -1 ) ) ; return TCL_ERROR ; } }
Change the label of all nodes that match src to lbl.
Change the label of all nodes that match src to lbl .
/* Return the number of nodes renamed. */ /* aug_result < 0 */