コード例 #1
0
ファイル: test_backup_c.cs プロジェクト: mbahar94/fracture
 static int Tcl_GetIndexFromObjStruct( Interp interp, TclObject to, BackupSubCommand[] table, int len, string msg, int flags, ref int index )
 {
   string zCmd = to.ToString();
   for ( index = 0 ; index < len ; index++ )
   {
     if ( zCmd == table[index].zCmd ) return 0;
   }
   return 1;
 }
コード例 #2
0
ファイル: test_backup_c.cs プロジェクト: mbahar94/fracture
    static int backupTestCmd(
    ClientData clientData,
    Tcl_Interp interp,
    int objc,
    Tcl_Obj[] objv
    )
    {
      BackupSubCommand[] aSub = new BackupSubCommand[] {
new BackupSubCommand("step",      BackupSubCommandEnum.BACKUP_STEP      , 1, "npage" ),
new BackupSubCommand("finish",    BackupSubCommandEnum.BACKUP_FINISH    , 0, ""      ),
new BackupSubCommand("remaining", BackupSubCommandEnum.BACKUP_REMAINING , 0, ""      ),
new BackupSubCommand("pagecount", BackupSubCommandEnum.BACKUP_PAGECOUNT , 0, ""      ),
new BackupSubCommand(null,0,0,null)
};

      sqlite3_backup p = (sqlite3_backup)clientData;
      int iCmd = 0;
      int rc;

      rc = Tcl_GetIndexFromObjStruct(
      interp, objv[1], aSub, aSub.Length, "option", 0, ref iCmd
      );
      if ( rc != TCL.TCL_OK )
      {
        return rc;
      }
      if ( objc != ( 2 + aSub[iCmd].nArg ) )
      {
        TCL.Tcl_WrongNumArgs( interp, 2, objv, aSub[iCmd].zArg );
        return TCL.TCL_ERROR;
      }

      switch ( aSub[iCmd].eCmd )
      {

        case BackupSubCommandEnum.BACKUP_FINISH:
          {
            string zCmdName;
            WrappedCommand cmdInfo = null;
            zCmdName = TCL.Tcl_GetString( objv[0] );
            TCL.Tcl_GetCommandInfo( interp, zCmdName, ref cmdInfo );
            cmdInfo.deleteProc = null;
            TCL.Tcl_SetCommandInfo( interp, zCmdName, cmdInfo );
            TCL.Tcl_DeleteCommand( interp, zCmdName );

            rc = sqlite3_backup_finish( p );
            TCL.Tcl_SetResult( interp, sqlite3TestErrorName( rc ), TCL.TCL_STATIC );
            break;
          }

        case BackupSubCommandEnum.BACKUP_STEP:
          {
            int nPage = 0;
            if ( TCL.Tcl_GetIntFromObj( interp, objv[2], ref nPage ) )
            {
              return TCL.TCL_ERROR;
            }
            rc = sqlite3_backup_step( p, nPage );
            TCL.Tcl_SetResult( interp, sqlite3TestErrorName( rc ), TCL.TCL_STATIC );
            break;
          }

        case BackupSubCommandEnum.BACKUP_REMAINING:
          TCL.Tcl_SetObjResult( interp, TCL.Tcl_NewIntObj( sqlite3_backup_remaining( p ) ) );
          break;

        case BackupSubCommandEnum.BACKUP_PAGECOUNT:
          TCL.Tcl_SetObjResult( interp, TCL.Tcl_NewIntObj( sqlite3_backup_pagecount( p ) ) );
          break;
      }

      return TCL.TCL_OK;
    }
コード例 #3
0
        static int backupTestCmd(
            ClientData clientData,
            Tcl_Interp interp,
            int objc,
            Tcl_Obj[] objv
            )
        {
            BackupSubCommand[] aSub = new BackupSubCommand[] {
                new BackupSubCommand("step", BackupSubCommandEnum.BACKUP_STEP, 1, "npage"),
                new BackupSubCommand("finish", BackupSubCommandEnum.BACKUP_FINISH, 0, ""),
                new BackupSubCommand("remaining", BackupSubCommandEnum.BACKUP_REMAINING, 0, ""),
                new BackupSubCommand("pagecount", BackupSubCommandEnum.BACKUP_PAGECOUNT, 0, ""),
                new BackupSubCommand(null, 0, 0, null)
            };

            sqlite3_backup p    = (sqlite3_backup)clientData;
            int            iCmd = 0;
            int            rc;

            rc = Tcl_GetIndexFromObjStruct(
                interp, objv[1], aSub, aSub.Length, "option", 0, ref iCmd
                );
            if (rc != TCL.TCL_OK)
            {
                return(rc);
            }
            if (objc != (2 + aSub[iCmd].nArg))
            {
                TCL.Tcl_WrongNumArgs(interp, 2, objv, aSub[iCmd].zArg);
                return(TCL.TCL_ERROR);
            }

            switch (aSub[iCmd].eCmd)
            {
            case BackupSubCommandEnum.BACKUP_FINISH:
            {
                string         zCmdName;
                WrappedCommand cmdInfo = null;
                zCmdName = TCL.Tcl_GetString(objv[0]);
                TCL.Tcl_GetCommandInfo(interp, zCmdName, ref cmdInfo);
                cmdInfo.deleteProc = null;
                TCL.Tcl_SetCommandInfo(interp, zCmdName, cmdInfo);
                TCL.Tcl_DeleteCommand(interp, zCmdName);

                rc = sqlite3_backup_finish(p);
                TCL.Tcl_SetResult(interp, sqlite3TestErrorName(rc), TCL.TCL_STATIC);
                break;
            }

            case BackupSubCommandEnum.BACKUP_STEP:
            {
                int nPage = 0;
                if (TCL.Tcl_GetIntFromObj(interp, objv[2], ref nPage))
                {
                    return(TCL.TCL_ERROR);
                }
                rc = sqlite3_backup_step(p, nPage);
                TCL.Tcl_SetResult(interp, sqlite3TestErrorName(rc), TCL.TCL_STATIC);
                break;
            }

            case BackupSubCommandEnum.BACKUP_REMAINING:
                TCL.Tcl_SetObjResult(interp, TCL.Tcl_NewIntObj(sqlite3_backup_remaining(p)));
                break;

            case BackupSubCommandEnum.BACKUP_PAGECOUNT:
                TCL.Tcl_SetObjResult(interp, TCL.Tcl_NewIntObj(sqlite3_backup_pagecount(p)));
                break;
            }

            return(TCL.TCL_OK);
        }