/ Check-in [f4534bd3]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sure the quota logic is usable as C++.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | quota-stdio
Files: files | file ages | folders
SHA1:f4534bd3023a599691018f35389a76045e49d831
User & Date: drh 2011-12-12 19:47:25
Context
2011-12-13
23:26
Enhancements to test_quota.c: Remove the external dependency on sqlite3_win32_utf8_to_msbc(). Add an extra parameter to quota_fflush() that will also do an fsync (or the equivalent). check-in: 92f4188f user: drh tags: quota-stdio
2011-12-12
19:47
Make sure the quota logic is usable as C++. check-in: f4534bd3 user: drh tags: quota-stdio
2011-12-03
00:13
Add the sqlite3_quota_fflush() interface. Enhance sqlite3_quota_remove() so that it can remove entire directories. check-in: abcb65af user: drh tags: quota-stdio
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/test_quota.c.

   901    901   */
   902    902   int sqlite3_quota_file(const char *zFilename){
   903    903     char *zFull;
   904    904     sqlite3_file *fd;
   905    905     int rc;
   906    906     int outFlags = 0;
   907    907     sqlite3_int64 iSize;
   908         -  fd = sqlite3_malloc(gQuota.sThisVfs.szOsFile + gQuota.sThisVfs.mxPathname+1);
          908  +  fd = (sqlite3_file*)sqlite3_malloc(gQuota.sThisVfs.szOsFile +
          909  +                                     gQuota.sThisVfs.mxPathname+1);
   909    910     if( fd==0 ) return SQLITE_NOMEM;
   910    911     zFull = gQuota.sThisVfs.szOsFile + (char*)fd;
   911    912     rc = gQuota.pOrigVfs->xFullPathname(gQuota.pOrigVfs, zFilename,
   912    913                                         gQuota.sThisVfs.mxPathname+1, zFull);
   913    914     if( rc==SQLITE_OK ){
   914    915       rc = quotaOpen(&gQuota.sThisVfs, zFull, fd, 
   915    916                      SQLITE_OPEN_READONLY | SQLITE_OPEN_MAIN_DB, &outFlags);
................................................................................
   939    940     quota_FILE *p = 0;
   940    941     char *zFull = 0;
   941    942     char *zFullTranslated;
   942    943     int rc;
   943    944     quotaGroup *pGroup;
   944    945     quotaFile *pFile;
   945    946   
   946         -  zFull = sqlite3_malloc(gQuota.sThisVfs.mxPathname + 1);
          947  +  zFull = (char*)sqlite3_malloc(gQuota.sThisVfs.mxPathname + 1);
   947    948     if( zFull==0 ) return 0;
   948    949     rc = gQuota.pOrigVfs->xFullPathname(gQuota.pOrigVfs, zFilename,
   949    950                                         gQuota.sThisVfs.mxPathname+1, zFull);
   950    951     if( rc ) goto quota_fopen_error;
   951         -  p = sqlite3_malloc(sizeof(*p));
          952  +  p = (quota_FILE*)sqlite3_malloc(sizeof(*p));
   952    953     if( p==0 ) goto quota_fopen_error;
   953    954     memset(p, 0, sizeof(*p));
   954    955     zFullTranslated = quota_utf8_to_mbcs(zFull);
   955    956     if( zFullTranslated==0 ) goto quota_fopen_error;
   956    957     p->f = fopen(zFullTranslated, zMode);
   957    958     quota_mbcs_free(zFullTranslated);
   958    959     if( p->f==0 ) goto quota_fopen_error;
................................................................................
  1093   1094     int rc;                 /* Result code */
  1094   1095     quotaGroup *pGroup;     /* Group containing zFilename */
  1095   1096     quotaFile *pFile;       /* A file in the group */
  1096   1097     quotaFile *pNextFile;   /* next file in the group */
  1097   1098     int diff;               /* Difference between filenames */
  1098   1099     char c;                 /* First character past end of pattern */
  1099   1100   
  1100         -  zFull = sqlite3_malloc(gQuota.sThisVfs.mxPathname + 1);
         1101  +  zFull = (char*)sqlite3_malloc(gQuota.sThisVfs.mxPathname + 1);
  1101   1102     if( zFull==0 ) return SQLITE_NOMEM;
  1102   1103     rc = gQuota.pOrigVfs->xFullPathname(gQuota.pOrigVfs, zFilename,
  1103   1104                                         gQuota.sThisVfs.mxPathname+1, zFull);
  1104   1105     if( rc ){
  1105   1106       sqlite3_free(zFull);
  1106   1107       return rc;
  1107   1108     }
................................................................................
  1434   1435     if( objc!=4 ){
  1435   1436       Tcl_WrongNumArgs(interp, 1, objv, "HANDLE SIZE NELEM");
  1436   1437       return TCL_ERROR;
  1437   1438     }
  1438   1439     p = sqlite3TestTextToPtr(Tcl_GetString(objv[1]));
  1439   1440     if( Tcl_GetIntFromObj(interp, objv[2], &sz) ) return TCL_ERROR;
  1440   1441     if( Tcl_GetIntFromObj(interp, objv[3], &nElem) ) return TCL_ERROR;
  1441         -  zBuf = sqlite3_malloc( sz*nElem + 1 );
         1442  +  zBuf = (char*)sqlite3_malloc( sz*nElem + 1 );
  1442   1443     if( zBuf==0 ){
  1443   1444       Tcl_SetResult(interp, "out of memory", TCL_STATIC);
  1444   1445       return TCL_ERROR;
  1445   1446     }
  1446   1447     got = sqlite3_quota_fread(zBuf, sz, nElem, p);
  1447   1448     if( got<0 ) got = 0;
  1448   1449     zBuf[got*sz] = 0;

Changes to src/test_quota.h.

    26     26   ** files within the group is less than the new quota, then the write
    27     27   ** continues as if nothing had happened.
    28     28   */
    29     29   #ifndef _QUOTA_H_
    30     30   #include "sqlite3.h"
    31     31   #include <stdio.h>
    32     32   
           33  +/* Make this callable from C++ */
           34  +#ifdef __cplusplus
           35  +extern "C" {
           36  +#endif
           37  +
    33     38   /*
    34     39   ** Initialize the quota VFS shim.  Use the VFS named zOrigVfsName
    35     40   ** as the VFS that does the actual work.  Use the default if
    36     41   ** zOrigVfsName==NULL.  
    37     42   **
    38     43   ** The quota VFS shim is named "quota".  It will become the default
    39     44   ** VFS if makeDefault is non-zero.
................................................................................
   189    194   ** All files are removed from quota management and deleted from disk.
   190    195   ** However, no attempt is made to remove empty directories.
   191    196   **
   192    197   ** This routine is a no-op for files that are not under quota management.
   193    198   */
   194    199   int sqlite3_quota_remove(const char *zFilename);
   195    200   
          201  +#ifdef __cplusplus
          202  +}  /* end of the 'extern "C"' block */
          203  +#endif
   196    204   #endif /* _QUOTA_H_ */