#include <tcl.h>

int
FindCommandObjCmd(ClientData clientData, Tcl_Interp *interp,
	int objc, Tcl_Obj *CONST objv[]) {

	Tcl_Command cmd;

    if (objc != 2) {
		Tcl_WrongNumArgs(interp, 1, objv, "<command name>");
		return TCL_ERROR;
	}

	char *cmdName=Tcl_GetString(objv[1]);
	cmd = Tcl_FindCommand(interp, cmdName, (Tcl_Namespace *)NULL,
			/*flags*/ TCL_EVAL_GLOBAL);
	if (cmd == (Tcl_Command)NULL) {
		return TCL_ERROR;
	}

	return TCL_OK;
}


int
Fc_Init(Tcl_Interp *interp) {
#ifdef USE_TCL_STUBS
	if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
		return TCL_ERROR;
	}
#endif
	Tcl_CreateObjCommand(interp, "findcommand", FindCommandObjCmd,
			(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);

	Tcl_PkgProvide(interp, "fc", "1.0");

	return TCL_OK;
}
