SQLite

Hex Artifact Content
Login

Artifact 2a8ad1952d1d2ca9af0ce0465e56e6c023b5e15d:


0000: 2f 2a 0a 2a 2a 20 32 30 31 31 20 44 65 63 65 6d  /*.** 2011 Decem
0010: 62 65 72 20 31 0a 2a 2a 0a 2a 2a 20 54 68 65 20  ber 1.**.** The 
0020: 61 75 74 68 6f 72 20 64 69 73 63 6c 61 69 6d 73  author disclaims
0030: 20 63 6f 70 79 72 69 67 68 74 20 74 6f 20 74 68   copyright to th
0040: 69 73 20 73 6f 75 72 63 65 20 63 6f 64 65 2e 20  is source code. 
0050: 20 49 6e 20 70 6c 61 63 65 20 6f 66 0a 2a 2a 20   In place of.** 
0060: 61 20 6c 65 67 61 6c 20 6e 6f 74 69 63 65 2c 20  a legal notice, 
0070: 68 65 72 65 20 69 73 20 61 20 62 6c 65 73 73 69  here is a blessi
0080: 6e 67 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 4d 61 79  ng:.**.**    May
0090: 20 79 6f 75 20 64 6f 20 67 6f 6f 64 20 61 6e 64   you do good and
00a0: 20 6e 6f 74 20 65 76 69 6c 2e 0a 2a 2a 20 20 20   not evil..**   
00b0: 20 4d 61 79 20 79 6f 75 20 66 69 6e 64 20 66 6f   May you find fo
00c0: 72 67 69 76 65 6e 65 73 73 20 66 6f 72 20 79 6f  rgiveness for yo
00d0: 75 72 73 65 6c 66 20 61 6e 64 20 66 6f 72 67 69  urself and forgi
00e0: 76 65 20 6f 74 68 65 72 73 2e 0a 2a 2a 20 20 20  ve others..**   
00f0: 20 4d 61 79 20 79 6f 75 20 73 68 61 72 65 20 66   May you share f
0100: 72 65 65 6c 79 2c 20 6e 65 76 65 72 20 74 61 6b  reely, never tak
0110: 69 6e 67 20 6d 6f 72 65 20 74 68 61 6e 20 79 6f  ing more than yo
0120: 75 20 67 69 76 65 2e 0a 2a 2a 0a 2a 2a 2a 2a 2a  u give..**.*****
0130: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0140: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0150: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0160: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0170: 2a 2a 2a 2a 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20  ****.**.** This 
0180: 66 69 6c 65 20 63 6f 6e 74 61 69 6e 73 20 74 68  file contains th
0190: 65 20 69 6e 74 65 72 66 61 63 65 20 64 65 66 69  e interface defi
01a0: 6e 69 74 69 6f 6e 20 66 6f 72 20 74 68 65 20 71  nition for the q
01b0: 75 6f 74 61 20 61 20 56 46 53 20 73 68 69 6d 2e  uota a VFS shim.
01c0: 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 70 61 72 74  .**.** This part
01d0: 69 63 75 6c 61 72 20 73 68 69 6d 20 65 6e 66 6f  icular shim enfo
01e0: 72 63 65 73 20 61 20 71 75 6f 74 61 20 73 79 73  rces a quota sys
01f0: 74 65 6d 20 6f 6e 20 66 69 6c 65 73 2e 20 20 4f  tem on files.  O
0200: 6e 65 20 6f 72 20 6d 6f 72 65 0a 2a 2a 20 64 61  ne or more.** da
0210: 74 61 62 61 73 65 20 66 69 6c 65 73 20 61 72 65  tabase files are
0220: 20 69 6e 20 61 20 22 71 75 6f 74 61 20 67 72 6f   in a "quota gro
0230: 75 70 22 20 74 68 61 74 20 69 73 20 64 65 66 69  up" that is defi
0240: 6e 65 64 20 62 79 20 61 20 47 4c 4f 42 0a 2a 2a  ned by a GLOB.**
0250: 20 70 61 74 74 65 72 6e 2e 20 20 41 20 71 75 6f   pattern.  A quo
0260: 74 61 20 69 73 20 73 65 74 20 66 6f 72 20 74 68  ta is set for th
0270: 65 20 63 6f 6d 62 69 6e 65 64 20 73 69 7a 65 20  e combined size 
0280: 6f 66 20 61 6c 6c 20 66 69 6c 65 73 20 69 6e 20  of all files in 
0290: 74 68 65 0a 2a 2a 20 74 68 65 20 67 72 6f 75 70  the.** the group
02a0: 2e 20 20 41 20 71 75 6f 74 61 20 6f 66 20 7a 65  .  A quota of ze
02b0: 72 6f 20 6d 65 61 6e 73 20 22 6e 6f 20 6c 69 6d  ro means "no lim
02c0: 69 74 22 2e 20 20 49 66 20 74 68 65 20 74 6f 74  it".  If the tot
02d0: 61 6c 20 73 69 7a 65 0a 2a 2a 20 6f 66 20 61 6c  al size.** of al
02e0: 6c 20 66 69 6c 65 73 20 69 6e 20 74 68 65 20 71  l files in the q
02f0: 75 6f 74 61 20 67 72 6f 75 70 20 69 73 20 67 72  uota group is gr
0300: 65 61 74 65 72 20 74 68 61 6e 20 74 68 65 20 6c  eater than the l
0310: 69 6d 69 74 2c 20 74 68 65 6e 0a 2a 2a 20 77 72  imit, then.** wr
0320: 69 74 65 20 72 65 71 75 65 73 74 73 20 74 68 61  ite requests tha
0330: 74 20 61 74 74 65 6d 70 74 20 74 6f 20 65 6e 6c  t attempt to enl
0340: 61 72 67 65 20 61 20 66 69 6c 65 20 66 61 69 6c  arge a file fail
0350: 20 77 69 74 68 20 53 51 4c 49 54 45 5f 46 55 4c   with SQLITE_FUL
0360: 4c 2e 0a 2a 2a 0a 2a 2a 20 48 6f 77 65 76 65 72  L..**.** However
0370: 2c 20 62 65 66 6f 72 65 20 72 65 74 75 72 6e 69  , before returni
0380: 6e 67 20 53 51 4c 49 54 45 5f 46 55 4c 4c 2c 20  ng SQLITE_FULL, 
0390: 74 68 65 20 77 72 69 74 65 20 72 65 71 75 65 73  the write reques
03a0: 74 73 20 69 6e 76 6f 6b 65 0a 2a 2a 20 61 20 63  ts invoke.** a c
03b0: 61 6c 6c 62 61 63 6b 20 66 75 6e 63 74 69 6f 6e  allback function
03c0: 20 74 68 61 74 20 69 73 20 63 6f 6e 66 69 67 75   that is configu
03d0: 72 61 62 6c 65 20 66 6f 72 20 65 61 63 68 20 71  rable for each q
03e0: 75 6f 74 61 20 67 72 6f 75 70 2e 0a 2a 2a 20 54  uota group..** T
03f0: 68 69 73 20 63 61 6c 6c 62 61 63 6b 20 68 61 73  his callback has
0400: 20 74 68 65 20 6f 70 70 6f 72 74 75 6e 69 74 79   the opportunity
0410: 20 74 6f 20 65 6e 6c 61 72 67 65 20 74 68 65 20   to enlarge the 
0420: 71 75 6f 74 61 2e 20 20 49 66 20 74 68 65 0a 2a  quota.  If the.*
0430: 2a 20 63 61 6c 6c 62 61 63 6b 20 64 6f 65 73 20  * callback does 
0440: 65 6e 6c 61 72 67 65 20 74 68 65 20 71 75 6f 74  enlarge the quot
0450: 61 20 73 75 63 68 20 74 68 61 74 20 74 68 65 20  a such that the 
0460: 74 6f 74 61 6c 20 73 69 7a 65 20 6f 66 20 61 6c  total size of al
0470: 6c 0a 2a 2a 20 66 69 6c 65 73 20 77 69 74 68 69  l.** files withi
0480: 6e 20 74 68 65 20 67 72 6f 75 70 20 69 73 20 6c  n the group is l
0490: 65 73 73 20 74 68 61 6e 20 74 68 65 20 6e 65 77  ess than the new
04a0: 20 71 75 6f 74 61 2c 20 74 68 65 6e 20 74 68 65   quota, then the
04b0: 20 77 72 69 74 65 0a 2a 2a 20 63 6f 6e 74 69 6e   write.** contin
04c0: 75 65 73 20 61 73 20 69 66 20 6e 6f 74 68 69 6e  ues as if nothin
04d0: 67 20 68 61 64 20 68 61 70 70 65 6e 65 64 2e 0a  g had happened..
04e0: 2a 2f 0a 23 69 66 6e 64 65 66 20 5f 51 55 4f 54  */.#ifndef _QUOT
04f0: 41 5f 48 5f 0a 23 69 6e 63 6c 75 64 65 20 22 73  A_H_.#include "s
0500: 71 6c 69 74 65 33 2e 68 22 0a 23 69 6e 63 6c 75  qlite3.h".#inclu
0510: 64 65 20 3c 73 74 64 69 6f 2e 68 3e 0a 23 69 6e  de <stdio.h>.#in
0520: 63 6c 75 64 65 20 3c 73 79 73 2f 74 79 70 65 73  clude <sys/types
0530: 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 79  .h>.#include <sy
0540: 73 2f 73 74 61 74 2e 68 3e 0a 0a 2f 2a 20 4d 61  s/stat.h>../* Ma
0550: 6b 65 20 74 68 69 73 20 63 61 6c 6c 61 62 6c 65  ke this callable
0560: 20 66 72 6f 6d 20 43 2b 2b 20 2a 2f 0a 23 69 66   from C++ */.#if
0570: 64 65 66 20 5f 5f 63 70 6c 75 73 70 6c 75 73 0a  def __cplusplus.
0580: 65 78 74 65 72 6e 20 22 43 22 20 7b 0a 23 65 6e  extern "C" {.#en
0590: 64 69 66 0a 0a 2f 2a 0a 2a 2a 20 49 6e 69 74 69  dif../*.** Initi
05a0: 61 6c 69 7a 65 20 74 68 65 20 71 75 6f 74 61 20  alize the quota 
05b0: 56 46 53 20 73 68 69 6d 2e 20 20 55 73 65 20 74  VFS shim.  Use t
05c0: 68 65 20 56 46 53 20 6e 61 6d 65 64 20 7a 4f 72  he VFS named zOr
05d0: 69 67 56 66 73 4e 61 6d 65 0a 2a 2a 20 61 73 20  igVfsName.** as 
05e0: 74 68 65 20 56 46 53 20 74 68 61 74 20 64 6f 65  the VFS that doe
05f0: 73 20 74 68 65 20 61 63 74 75 61 6c 20 77 6f 72  s the actual wor
0600: 6b 2e 20 20 55 73 65 20 74 68 65 20 64 65 66 61  k.  Use the defa
0610: 75 6c 74 20 69 66 0a 2a 2a 20 7a 4f 72 69 67 56  ult if.** zOrigV
0620: 66 73 4e 61 6d 65 3d 3d 4e 55 4c 4c 2e 20 20 0a  fsName==NULL.  .
0630: 2a 2a 0a 2a 2a 20 54 68 65 20 71 75 6f 74 61 20  **.** The quota 
0640: 56 46 53 20 73 68 69 6d 20 69 73 20 6e 61 6d 65  VFS shim is name
0650: 64 20 22 71 75 6f 74 61 22 2e 20 20 49 74 20 77  d "quota".  It w
0660: 69 6c 6c 20 62 65 63 6f 6d 65 20 74 68 65 20 64  ill become the d
0670: 65 66 61 75 6c 74 0a 2a 2a 20 56 46 53 20 69 66  efault.** VFS if
0680: 20 6d 61 6b 65 44 65 66 61 75 6c 74 20 69 73 20   makeDefault is 
0690: 6e 6f 6e 2d 7a 65 72 6f 2e 0a 2a 2a 0a 2a 2a 20  non-zero..**.** 
06a0: 54 48 49 53 20 52 4f 55 54 49 4e 45 20 49 53 20  THIS ROUTINE IS 
06b0: 4e 4f 54 20 54 48 52 45 41 44 53 41 46 45 2e 20  NOT THREADSAFE. 
06c0: 20 43 61 6c 6c 20 74 68 69 73 20 72 6f 75 74 69   Call this routi
06d0: 6e 65 20 65 78 61 63 74 6c 79 20 6f 6e 63 65 0a  ne exactly once.
06e0: 2a 2a 20 64 75 72 69 6e 67 20 73 74 61 72 74 2d  ** during start-
06f0: 75 70 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74  up..*/.int sqlit
0700: 65 33 5f 71 75 6f 74 61 5f 69 6e 69 74 69 61 6c  e3_quota_initial
0710: 69 7a 65 28 63 6f 6e 73 74 20 63 68 61 72 20 2a  ize(const char *
0720: 7a 4f 72 69 67 56 66 73 4e 61 6d 65 2c 20 69 6e  zOrigVfsName, in
0730: 74 20 6d 61 6b 65 44 65 66 61 75 6c 74 29 3b 0a  t makeDefault);.
0740: 0a 2f 2a 0a 2a 2a 20 53 68 75 74 64 6f 77 6e 20  ./*.** Shutdown 
0750: 74 68 65 20 71 75 6f 74 61 20 73 79 73 74 65 6d  the quota system
0760: 2e 0a 2a 2a 0a 2a 2a 20 41 6c 6c 20 53 51 4c 69  ..**.** All SQLi
0770: 74 65 20 64 61 74 61 62 61 73 65 20 63 6f 6e 6e  te database conn
0780: 65 63 74 69 6f 6e 73 20 6d 75 73 74 20 62 65 20  ections must be 
0790: 63 6c 6f 73 65 64 20 62 65 66 6f 72 65 20 63 61  closed before ca
07a0: 6c 6c 69 6e 67 20 74 68 69 73 0a 2a 2a 20 72 6f  lling this.** ro
07b0: 75 74 69 6e 65 2e 0a 2a 2a 0a 2a 2a 20 54 48 49  utine..**.** THI
07c0: 53 20 52 4f 55 54 49 4e 45 20 49 53 20 4e 4f 54  S ROUTINE IS NOT
07d0: 20 54 48 52 45 41 44 53 41 46 45 2e 20 20 43 61   THREADSAFE.  Ca
07e0: 6c 6c 20 74 68 69 73 20 72 6f 75 74 69 6e 65 20  ll this routine 
07f0: 65 78 61 63 74 6c 79 20 6f 6e 63 65 20 77 68 69  exactly once whi
0800: 6c 65 0a 2a 2a 20 73 68 75 74 74 69 6e 67 20 64  le.** shutting d
0810: 6f 77 6e 20 69 6e 20 6f 72 64 65 72 20 74 6f 20  own in order to 
0820: 66 72 65 65 20 61 6c 6c 20 72 65 6d 61 69 6e 69  free all remaini
0830: 6e 67 20 71 75 6f 74 61 20 67 72 6f 75 70 73 2e  ng quota groups.
0840: 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f  .*/.int sqlite3_
0850: 71 75 6f 74 61 5f 73 68 75 74 64 6f 77 6e 28 76  quota_shutdown(v
0860: 6f 69 64 29 3b 0a 0a 2f 2a 0a 2a 2a 20 43 72 65  oid);../*.** Cre
0870: 61 74 65 20 6f 72 20 64 65 73 74 72 6f 79 20 61  ate or destroy a
0880: 20 71 75 6f 74 61 20 67 72 6f 75 70 2e 0a 2a 2a   quota group..**
0890: 0a 2a 2a 20 54 68 65 20 71 75 6f 74 61 20 67 72  .** The quota gr
08a0: 6f 75 70 20 69 73 20 64 65 66 69 6e 65 64 20 62  oup is defined b
08b0: 79 20 74 68 65 20 7a 50 61 74 74 65 72 6e 2e 20  y the zPattern. 
08c0: 20 57 68 65 6e 20 63 61 6c 6c 69 6e 67 20 74 68   When calling th
08d0: 69 73 20 72 6f 75 74 69 6e 65 0a 2a 2a 20 77 69  is routine.** wi
08e0: 74 68 20 61 20 7a 50 61 74 74 65 72 6e 20 66 6f  th a zPattern fo
08f0: 72 20 61 20 71 75 6f 74 61 20 67 72 6f 75 70 20  r a quota group 
0900: 74 68 61 74 20 61 6c 72 65 61 64 79 20 65 78 69  that already exi
0910: 73 74 73 2c 20 74 68 69 73 20 72 6f 75 74 69 6e  sts, this routin
0920: 65 0a 2a 2a 20 6d 65 72 65 6c 79 20 75 70 64 61  e.** merely upda
0930: 74 65 73 20 74 68 65 20 69 4c 69 6d 69 74 2c 20  tes the iLimit, 
0940: 78 43 61 6c 6c 62 61 63 6b 2c 20 61 6e 64 20 70  xCallback, and p
0950: 41 72 67 20 76 61 6c 75 65 73 20 66 6f 72 20 74  Arg values for t
0960: 68 61 74 20 71 75 6f 74 61 0a 2a 2a 20 67 72 6f  hat quota.** gro
0970: 75 70 2e 20 20 49 66 20 7a 50 61 74 74 65 72 6e  up.  If zPattern
0980: 20 69 73 20 6e 65 77 2c 20 74 68 65 6e 20 61 20   is new, then a 
0990: 6e 65 77 20 71 75 6f 74 61 20 67 72 6f 75 70 20  new quota group 
09a0: 69 73 20 63 72 65 61 74 65 64 2e 0a 2a 2a 0a 2a  is created..**.*
09b0: 2a 20 54 68 65 20 7a 50 61 74 74 65 72 6e 20 69  * The zPattern i
09c0: 73 20 61 6c 77 61 79 73 20 63 6f 6d 70 61 72 65  s always compare
09d0: 64 20 61 67 61 69 6e 73 74 20 74 68 65 20 66 75  d against the fu
09e0: 6c 6c 20 70 61 74 68 6e 61 6d 65 20 6f 66 20 74  ll pathname of t
09f0: 68 65 20 66 69 6c 65 2e 0a 2a 2a 20 45 76 65 6e  he file..** Even
0a00: 20 69 66 20 41 50 49 73 20 61 72 65 20 63 61 6c   if APIs are cal
0a10: 6c 65 64 20 77 69 74 68 20 72 65 6c 61 74 69 76  led with relativ
0a20: 65 20 70 61 74 68 6e 61 6d 65 73 2c 20 53 51 4c  e pathnames, SQL
0a30: 69 74 65 20 63 6f 6e 76 65 72 74 73 20 74 68 65  ite converts the
0a40: 0a 2a 2a 20 6e 61 6d 65 20 74 6f 20 61 20 66 75  .** name to a fu
0a50: 6c 6c 20 70 61 74 68 6e 61 6d 65 20 62 65 66 6f  ll pathname befo
0a60: 72 65 20 63 6f 6d 70 61 72 69 6e 67 20 69 74 20  re comparing it 
0a70: 61 67 61 69 6e 73 74 20 7a 50 61 74 74 65 72 6e  against zPattern
0a80: 2e 20 20 7a 50 61 74 74 65 72 6e 0a 2a 2a 20 69  .  zPattern.** i
0a90: 73 20 61 20 67 6c 6f 62 20 70 61 74 74 65 72 6e  s a glob pattern
0aa0: 20 77 69 74 68 20 74 68 65 20 66 6f 6c 6c 6f 77   with the follow
0ab0: 69 6e 67 20 6d 61 74 63 68 69 6e 67 20 72 75 6c  ing matching rul
0ac0: 65 73 3a 0a 2a 2a 0a 2a 2a 20 20 20 20 20 20 27  es:.**.**      '
0ad0: 2a 27 20 20 20 20 20 20 20 4d 61 74 63 68 65 73  *'       Matches
0ae0: 20 61 6e 79 20 73 65 71 75 65 6e 63 65 20 6f 66   any sequence of
0af0: 20 7a 65 72 6f 20 6f 72 20 6d 6f 72 65 20 63 68   zero or more ch
0b00: 61 72 61 63 74 65 72 73 2e 0a 2a 2a 0a 2a 2a 20  aracters..**.** 
0b10: 20 20 20 20 20 27 3f 27 20 20 20 20 20 20 20 4d       '?'       M
0b20: 61 74 63 68 65 73 20 65 78 61 63 74 6c 79 20 6f  atches exactly o
0b30: 6e 65 20 63 68 61 72 61 63 74 65 72 2e 0a 2a 2a  ne character..**
0b40: 0a 2a 2a 20 20 20 20 20 5b 2e 2e 2e 5d 20 20 20  .**     [...]   
0b50: 20 20 20 4d 61 74 63 68 65 73 20 6f 6e 65 20 63     Matches one c
0b60: 68 61 72 61 63 74 65 72 20 66 72 6f 6d 20 74 68  haracter from th
0b70: 65 20 65 6e 63 6c 6f 73 65 64 20 6c 69 73 74 20  e enclosed list 
0b80: 6f 66 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 20  of.**           
0b90: 20 20 20 20 20 63 68 61 72 61 63 74 65 72 73 2e       characters.
0ba0: 20 20 22 5d 22 20 63 61 6e 20 62 65 20 70 61 72    "]" can be par
0bb0: 74 20 6f 66 20 74 68 65 20 6c 69 73 74 20 69 66  t of the list if
0bc0: 20 69 74 20 69 73 0a 2a 2a 20 20 20 20 20 20 20   it is.**       
0bd0: 20 20 20 20 20 20 20 20 20 74 68 65 20 66 69 72           the fir
0be0: 73 74 20 63 68 61 72 61 63 74 65 72 2e 20 20 57  st character.  W
0bf0: 69 74 68 69 6e 20 74 68 65 20 6c 69 73 74 20 22  ithin the list "
0c00: 58 2d 59 22 20 6d 61 74 63 68 65 73 0a 2a 2a 20  X-Y" matches.** 
0c10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63                 c
0c20: 68 61 72 61 63 74 65 72 73 20 58 20 6f 72 20 59  haracters X or Y
0c30: 20 6f 72 20 61 6e 79 20 63 68 61 72 61 63 74 65   or any characte
0c40: 72 20 69 6e 20 62 65 74 77 65 65 6e 20 74 68 65  r in between the
0c50: 0a 2a 2a 20 20 20 20 20 20 20 20 20 20 20 20 20  .**             
0c60: 20 20 20 74 77 6f 2e 20 20 45 78 3a 20 20 22 5b     two.  Ex:  "[
0c70: 30 2d 39 5d 22 20 6d 61 74 63 68 65 73 20 61 6e  0-9]" matches an
0c80: 79 20 64 69 67 69 74 2e 0a 2a 2a 0a 2a 2a 20 20  y digit..**.**  
0c90: 20 20 20 5b 5e 2e 2e 2e 5d 20 20 20 20 20 4d 61     [^...]     Ma
0ca0: 74 63 68 65 73 20 6f 6e 65 20 63 68 61 72 61 63  tches one charac
0cb0: 74 65 72 20 6e 6f 74 20 69 6e 20 74 68 65 20 65  ter not in the e
0cc0: 6e 63 6c 6f 73 65 64 20 6c 69 73 74 2e 0a 2a 2a  nclosed list..**
0cd0: 0a 2a 2a 20 20 20 20 20 2f 20 20 20 20 20 20 20  .**     /       
0ce0: 20 20 20 4d 61 74 63 68 65 73 20 65 69 74 68 65     Matches eithe
0cf0: 72 20 2f 20 6f 72 20 5c 2e 20 20 54 68 69 73 20  r / or \.  This 
0d00: 61 6c 6c 6f 77 73 20 67 6c 6f 62 20 70 61 74 74  allows glob patt
0d10: 65 72 6e 73 0a 2a 2a 20 20 20 20 20 20 20 20 20  erns.**         
0d20: 20 20 20 20 20 20 20 63 6f 6e 74 61 69 6e 69 6e         containin
0d30: 67 20 2f 20 74 6f 20 77 6f 72 6b 20 6f 6e 20 62  g / to work on b
0d40: 6f 74 68 20 75 6e 69 78 20 61 6e 64 20 77 69 6e  oth unix and win
0d50: 64 6f 77 73 2e 0a 2a 2a 0a 2a 2a 20 4e 6f 74 65  dows..**.** Note
0d60: 20 74 68 61 74 2c 20 75 6e 6c 69 6b 65 20 75 6e   that, unlike un
0d70: 69 78 20 73 68 65 6c 6c 20 67 6c 6f 62 62 69 6e  ix shell globbin
0d80: 67 2c 20 74 68 65 20 64 69 72 65 63 74 6f 72 79  g, the directory
0d90: 20 73 65 70 61 72 61 74 6f 72 20 22 2f 22 0a 2a   separator "/".*
0da0: 2a 20 63 61 6e 20 6d 61 74 63 68 20 61 20 77 69  * can match a wi
0db0: 6c 64 63 61 72 64 2e 20 20 53 6f 2c 20 66 6f 72  ldcard.  So, for
0dc0: 20 65 78 61 6d 70 6c 65 2c 20 74 68 65 20 70 61   example, the pa
0dd0: 74 74 65 72 6e 20 22 2f 61 62 63 2f 78 79 7a 2f  ttern "/abc/xyz/
0de0: 22 20 22 2a 22 0a 2a 2a 20 6d 61 74 63 68 65 73  " "*".** matches
0df0: 20 61 6e 79 20 66 69 6c 65 73 20 61 6e 79 77 68   any files anywh
0e00: 65 72 65 20 69 6e 20 74 68 65 20 64 69 72 65 63  ere in the direc
0e10: 74 6f 72 79 20 68 69 65 72 61 72 63 68 79 20 62  tory hierarchy b
0e20: 65 6e 65 61 74 68 0a 2a 2a 20 2f 61 62 63 2f 78  eneath.** /abc/x
0e30: 79 7a 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 20 67 6c  yz..**.** The gl
0e40: 6f 62 20 61 6c 67 6f 72 69 74 68 6d 20 77 6f 72  ob algorithm wor
0e50: 6b 73 20 6f 6e 20 62 79 74 65 73 2e 20 20 4d 75  ks on bytes.  Mu
0e60: 6c 74 69 2d 62 79 74 65 20 55 54 46 38 20 63 68  lti-byte UTF8 ch
0e70: 61 72 61 63 74 65 72 73 20 61 72 65 0a 2a 2a 20  aracters are.** 
0e80: 6d 61 74 63 68 65 64 20 61 73 20 69 66 20 65 61  matched as if ea
0e90: 63 68 20 62 79 74 65 20 77 65 72 65 20 61 20 73  ch byte were a s
0ea0: 65 70 61 72 61 74 65 20 63 68 61 72 61 63 74 65  eparate characte
0eb0: 72 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 74 68 65 20  r..**.** If the 
0ec0: 69 4c 69 6d 69 74 20 66 6f 72 20 61 20 71 75 6f  iLimit for a quo
0ed0: 74 61 20 67 72 6f 75 70 20 69 73 20 73 65 74 20  ta group is set 
0ee0: 74 6f 20 7a 65 72 6f 2c 20 74 68 65 6e 20 74 68  to zero, then th
0ef0: 65 20 71 75 6f 74 61 20 67 72 6f 75 70 0a 2a 2a  e quota group.**
0f00: 20 69 73 20 64 69 73 61 62 6c 65 64 20 61 6e 64   is disabled and
0f10: 20 77 69 6c 6c 20 62 65 20 64 65 6c 65 74 65 64   will be deleted
0f20: 20 77 68 65 6e 20 74 68 65 20 6c 61 73 74 20 64   when the last d
0f30: 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74 69  atabase connecti
0f40: 6f 6e 20 75 73 69 6e 67 0a 2a 2a 20 74 68 65 20  on using.** the 
0f50: 71 75 6f 74 61 20 67 72 6f 75 70 20 69 73 20 63  quota group is c
0f60: 6c 6f 73 65 64 2e 0a 2a 2a 0a 2a 2a 20 43 61 6c  losed..**.** Cal
0f70: 6c 69 6e 67 20 74 68 69 73 20 72 6f 75 74 69 6e  ling this routin
0f80: 65 20 6f 6e 20 61 20 7a 50 61 74 74 65 72 6e 20  e on a zPattern 
0f90: 74 68 61 74 20 64 6f 65 73 20 6e 6f 74 20 65 78  that does not ex
0fa0: 69 73 74 20 61 6e 64 20 77 69 74 68 20 61 0a 2a  ist and with a.*
0fb0: 2a 20 7a 65 72 6f 20 69 4c 69 6d 69 74 20 69 73  * zero iLimit is
0fc0: 20 61 20 6e 6f 2d 6f 70 2e 0a 2a 2a 0a 2a 2a 20   a no-op..**.** 
0fd0: 41 20 71 75 6f 74 61 20 67 72 6f 75 70 20 6d 75  A quota group mu
0fe0: 73 74 20 65 78 69 73 74 20 77 69 74 68 20 61 20  st exist with a 
0ff0: 6e 6f 6e 2d 7a 65 72 6f 20 69 4c 69 6d 69 74 20  non-zero iLimit 
1000: 70 72 69 6f 72 20 74 6f 20 6f 70 65 6e 69 6e 67  prior to opening
1010: 0a 2a 2a 20 64 61 74 61 62 61 73 65 20 63 6f 6e  .** database con
1020: 6e 65 63 74 69 6f 6e 73 20 69 66 20 74 68 6f 73  nections if thos
1030: 65 20 63 6f 6e 6e 65 63 74 69 6f 6e 73 20 61 72  e connections ar
1040: 65 20 74 6f 20 70 61 72 74 69 63 69 70 61 74 65  e to participate
1050: 20 69 6e 20 74 68 65 0a 2a 2a 20 71 75 6f 74 61   in the.** quota
1060: 20 67 72 6f 75 70 2e 20 20 43 72 65 61 74 69 6e   group.  Creatin
1070: 67 20 61 20 71 75 6f 74 61 20 67 72 6f 75 70 20  g a quota group 
1080: 64 6f 65 73 20 6e 6f 74 20 61 66 66 65 63 74 20  does not affect 
1090: 64 61 74 61 62 61 73 65 20 63 6f 6e 6e 65 63 74  database connect
10a0: 69 6f 6e 73 0a 2a 2a 20 74 68 61 74 20 61 72 65  ions.** that are
10b0: 20 61 6c 72 65 61 64 79 20 6f 70 65 6e 2e 0a 2a   already open..*
10c0: 2a 0a 2a 2a 20 54 68 65 20 70 61 74 74 65 72 6e  *.** The pattern
10d0: 73 20 74 68 61 74 20 64 65 66 69 6e 65 20 74 68  s that define th
10e0: 65 20 76 61 72 69 6f 75 73 20 71 75 6f 74 61 20  e various quota 
10f0: 67 72 6f 75 70 73 20 73 68 6f 75 6c 64 20 62 65  groups should be
1100: 20 64 69 73 74 69 6e 63 74 2e 0a 2a 2a 20 49 66   distinct..** If
1110: 20 74 68 65 20 73 61 6d 65 20 66 69 6c 65 6e 61   the same filena
1120: 6d 65 20 6d 61 74 63 68 65 73 20 6d 6f 72 65 20  me matches more 
1130: 74 68 61 6e 20 6f 6e 65 20 71 75 6f 74 61 20 67  than one quota g
1140: 72 6f 75 70 20 70 61 74 74 65 72 6e 2c 20 74 68  roup pattern, th
1150: 65 6e 0a 2a 2a 20 74 68 65 20 62 65 68 61 76 69  en.** the behavi
1160: 6f 72 20 6f 66 20 74 68 69 73 20 70 61 63 6b 61  or of this packa
1170: 67 65 20 69 73 20 75 6e 64 65 66 69 6e 65 64 2e  ge is undefined.
1180: 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f  .*/.int sqlite3_
1190: 71 75 6f 74 61 5f 73 65 74 28 0a 20 20 63 6f 6e  quota_set(.  con
11a0: 73 74 20 63 68 61 72 20 2a 7a 50 61 74 74 65 72  st char *zPatter
11b0: 6e 2c 20 20 20 20 20 20 20 20 20 20 20 2f 2a 20  n,           /* 
11c0: 54 68 65 20 66 69 6c 65 6e 61 6d 65 20 70 61 74  The filename pat
11d0: 74 65 72 6e 20 2a 2f 0a 20 20 73 71 6c 69 74 65  tern */.  sqlite
11e0: 33 5f 69 6e 74 36 34 20 69 4c 69 6d 69 74 2c 20  3_int64 iLimit, 
11f0: 20 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 65 77            /* New
1200: 20 71 75 6f 74 61 20 74 6f 20 73 65 74 20 66 6f   quota to set fo
1210: 72 20 74 68 69 73 20 71 75 6f 74 61 20 67 72 6f  r this quota gro
1220: 75 70 20 2a 2f 0a 20 20 76 6f 69 64 20 28 2a 78  up */.  void (*x
1230: 43 61 6c 6c 62 61 63 6b 29 28 20 20 20 20 20 20  Callback)(      
1240: 20 20 20 20 20 20 20 20 2f 2a 20 43 61 6c 6c 62          /* Callb
1250: 61 63 6b 20 69 6e 76 6f 6b 65 64 20 77 68 65 6e  ack invoked when
1260: 20 67 6f 69 6e 67 20 6f 76 65 72 20 71 75 6f 74   going over quot
1270: 61 20 2a 2f 0a 20 20 20 20 20 63 6f 6e 73 74 20  a */.     const 
1280: 63 68 61 72 20 2a 7a 46 69 6c 65 6e 61 6d 65 2c  char *zFilename,
1290: 20 20 20 20 20 20 20 20 20 2f 2a 20 4e 61 6d 65           /* Name
12a0: 20 6f 66 20 66 69 6c 65 20 77 68 6f 73 65 20 73   of file whose s
12b0: 69 7a 65 20 69 6e 63 72 65 61 73 65 73 20 2a 2f  ize increases */
12c0: 0a 20 20 20 20 20 73 71 6c 69 74 65 33 5f 69 6e  .     sqlite3_in
12d0: 74 36 34 20 2a 70 69 4c 69 6d 69 74 2c 20 20 20  t64 *piLimit,   
12e0: 20 20 20 20 20 2f 2a 20 49 4e 2f 4f 55 54 3a 20       /* IN/OUT: 
12f0: 54 68 65 20 63 75 72 72 65 6e 74 20 6c 69 6d 69  The current limi
1300: 74 20 2a 2f 0a 20 20 20 20 20 73 71 6c 69 74 65  t */.     sqlite
1310: 33 5f 69 6e 74 36 34 20 69 53 69 7a 65 2c 20 20  3_int64 iSize,  
1320: 20 20 20 20 20 20 20 20 20 2f 2a 20 54 6f 74 61           /* Tota
1330: 6c 20 73 69 7a 65 20 6f 66 20 61 6c 6c 20 66 69  l size of all fi
1340: 6c 65 73 20 69 6e 20 74 68 65 20 67 72 6f 75 70  les in the group
1350: 20 2a 2f 0a 20 20 20 20 20 76 6f 69 64 20 2a 70   */.     void *p
1360: 41 72 67 20 20 20 20 20 20 20 20 20 20 20 20 20  Arg             
1370: 20 20 20 20 20 20 20 20 2f 2a 20 43 6c 69 65 6e          /* Clien
1380: 74 20 64 61 74 61 20 2a 2f 0a 20 20 29 2c 0a 20  t data */.  ),. 
1390: 20 76 6f 69 64 20 2a 70 41 72 67 2c 20 20 20 20   void *pArg,    
13a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
13b0: 20 2f 2a 20 63 6c 69 65 6e 74 20 64 61 74 61 20   /* client data 
13c0: 70 61 73 73 65 64 20 74 68 72 75 20 74 6f 20 63  passed thru to c
13d0: 61 6c 6c 62 61 63 6b 20 2a 2f 0a 20 20 76 6f 69  allback */.  voi
13e0: 64 20 28 2a 78 44 65 73 74 72 6f 79 29 28 76 6f  d (*xDestroy)(vo
13f0: 69 64 2a 29 20 20 20 20 20 20 20 20 20 2f 2a 20  id*)         /* 
1400: 4f 70 74 69 6f 6e 61 6c 20 64 65 73 74 72 75 63  Optional destruc
1410: 74 6f 72 20 66 6f 72 20 70 41 72 67 20 2a 2f 0a  tor for pArg */.
1420: 29 3b 0a 0a 2f 2a 0a 2a 2a 20 42 72 69 6e 67 20  );../*.** Bring 
1430: 74 68 65 20 6e 61 6d 65 64 20 66 69 6c 65 20 75  the named file u
1440: 6e 64 65 72 20 71 75 6f 74 61 20 6d 61 6e 61 67  nder quota manag
1450: 65 6d 65 6e 74 2c 20 61 73 73 75 6d 69 6e 67 20  ement, assuming 
1460: 69 74 73 20 6e 61 6d 65 20 6d 61 74 63 68 65 73  its name matches
1470: 0a 2a 2a 20 74 68 65 20 67 6c 6f 62 20 70 61 74  .** the glob pat
1480: 74 65 72 6e 20 6f 66 20 73 6f 6d 65 20 71 75 6f  tern of some quo
1490: 74 61 20 67 72 6f 75 70 2e 20 20 4f 72 20 69 66  ta group.  Or if
14a0: 20 69 74 20 69 73 20 61 6c 72 65 61 64 79 20 75   it is already u
14b0: 6e 64 65 72 0a 2a 2a 20 6d 61 6e 61 67 65 6d 65  nder.** manageme
14c0: 6e 74 2c 20 75 70 64 61 74 65 20 69 74 73 20 73  nt, update its s
14d0: 69 7a 65 2e 20 20 49 66 20 7a 46 69 6c 65 6e 61  ize.  If zFilena
14e0: 6d 65 20 64 6f 65 73 20 6e 6f 74 20 6d 61 74 63  me does not matc
14f0: 68 20 74 68 65 20 67 6c 6f 62 0a 2a 2a 20 70 61  h the glob.** pa
1500: 74 74 65 72 6e 20 6f 66 20 61 6e 79 20 71 75 6f  ttern of any quo
1510: 74 61 20 67 72 6f 75 70 2c 20 74 68 69 73 20 72  ta group, this r
1520: 6f 75 74 69 6e 65 20 69 73 20 61 20 6e 6f 2d 6f  outine is a no-o
1530: 70 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65  p..*/.int sqlite
1540: 33 5f 71 75 6f 74 61 5f 66 69 6c 65 28 63 6f 6e  3_quota_file(con
1550: 73 74 20 63 68 61 72 20 2a 7a 46 69 6c 65 6e 61  st char *zFilena
1560: 6d 65 29 3b 0a 0a 2f 2a 0a 2a 2a 20 54 68 65 20  me);../*.** The 
1570: 66 6f 6c 6c 6f 77 69 6e 67 20 6f 62 6a 65 63 74  following object
1580: 20 73 65 72 76 65 73 20 74 68 65 20 73 61 6d 65   serves the same
1590: 20 72 6f 6c 65 20 61 73 20 46 49 4c 45 20 69 6e   role as FILE in
15a0: 20 74 68 65 20 73 74 61 6e 64 61 72 64 20 43 0a   the standard C.
15b0: 2a 2a 20 6c 69 62 72 61 72 79 2e 20 20 49 74 20  ** library.  It 
15c0: 72 65 70 72 65 73 65 6e 74 73 20 61 6e 20 6f 70  represents an op
15d0: 65 6e 20 63 6f 6e 6e 65 63 74 69 6f 6e 20 74 6f  en connection to
15e0: 20 61 20 66 69 6c 65 20 6f 6e 20 64 69 73 6b 20   a file on disk 
15f0: 66 6f 72 20 49 2f 4f 2e 0a 2a 2a 0a 2a 2a 20 41  for I/O..**.** A
1600: 20 73 69 6e 67 6c 65 20 71 75 6f 74 61 5f 46 49   single quota_FI
1610: 4c 45 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65  LE should not be
1620: 20 75 73 65 64 20 62 79 20 74 77 6f 20 6f 72 20   used by two or 
1630: 6d 6f 72 65 20 74 68 72 65 61 64 73 20 61 74 20  more threads at 
1640: 74 68 65 0a 2a 2a 20 73 61 6d 65 20 74 69 6d 65  the.** same time
1650: 2e 20 20 4d 75 6c 74 69 70 6c 65 20 74 68 72 65  .  Multiple thre
1660: 61 64 73 20 63 61 6e 20 62 65 20 75 73 69 6e 67  ads can be using
1670: 20 64 69 66 66 65 72 65 6e 74 20 71 75 6f 74 61   different quota
1680: 5f 46 49 4c 45 20 6f 62 6a 65 63 74 73 0a 2a 2a  _FILE objects.**
1690: 20 73 69 6d 75 6c 74 61 6e 65 6f 75 73 6c 79 2c   simultaneously,
16a0: 20 62 75 74 20 6e 6f 74 20 74 68 65 20 73 61 6d   but not the sam
16b0: 65 20 71 75 6f 74 61 5f 46 49 4c 45 20 6f 62 6a  e quota_FILE obj
16c0: 65 63 74 2e 0a 2a 2f 0a 74 79 70 65 64 65 66 20  ect..*/.typedef 
16d0: 73 74 72 75 63 74 20 71 75 6f 74 61 5f 46 49 4c  struct quota_FIL
16e0: 45 20 71 75 6f 74 61 5f 46 49 4c 45 3b 0a 0a 2f  E quota_FILE;../
16f0: 2a 0a 2a 2a 20 43 72 65 61 74 65 20 61 20 6e 65  *.** Create a ne
1700: 77 20 71 75 6f 74 61 5f 46 49 4c 45 20 6f 62 6a  w quota_FILE obj
1710: 65 63 74 20 75 73 65 64 20 74 6f 20 72 65 61 64  ect used to read
1720: 20 61 6e 64 2f 6f 72 20 77 72 69 74 65 20 74 6f   and/or write to
1730: 20 74 68 65 0a 2a 2a 20 66 69 6c 65 20 7a 46 69   the.** file zFi
1740: 6c 65 6e 61 6d 65 2e 20 20 54 68 65 20 7a 4d 6f  lename.  The zMo
1750: 64 65 20 70 61 72 61 6d 65 74 65 72 20 69 73 20  de parameter is 
1760: 61 73 20 77 69 74 68 20 73 74 61 6e 64 61 72 64  as with standard
1770: 20 6c 69 62 72 61 72 79 20 7a 4d 6f 64 65 2e 0a   library zMode..
1780: 2a 2f 0a 71 75 6f 74 61 5f 46 49 4c 45 20 2a 73  */.quota_FILE *s
1790: 71 6c 69 74 65 33 5f 71 75 6f 74 61 5f 66 6f 70  qlite3_quota_fop
17a0: 65 6e 28 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a  en(const char *z
17b0: 46 69 6c 65 6e 61 6d 65 2c 20 63 6f 6e 73 74 20  Filename, const 
17c0: 63 68 61 72 20 2a 7a 4d 6f 64 65 29 3b 0a 0a 2f  char *zMode);../
17d0: 2a 0a 2a 2a 20 50 65 72 66 6f 72 6d 20 49 2f 4f  *.** Perform I/O
17e0: 20 61 67 61 69 6e 73 74 20 61 20 71 75 6f 74 61   against a quota
17f0: 5f 46 49 4c 45 20 6f 62 6a 65 63 74 2e 20 20 57  _FILE object.  W
1800: 68 65 6e 20 64 6f 69 6e 67 20 77 72 69 74 65 73  hen doing writes
1810: 2c 20 74 68 65 0a 2a 2a 20 71 75 6f 74 61 20 6d  , the.** quota m
1820: 65 63 68 61 6e 69 73 6d 20 6d 61 79 20 72 65 73  echanism may res
1830: 75 6c 74 20 69 6e 20 61 20 73 68 6f 72 74 20 77  ult in a short w
1840: 72 69 74 65 2c 20 69 6e 20 6f 72 64 65 72 20 74  rite, in order t
1850: 6f 20 70 72 65 76 65 6e 74 0a 2a 2a 20 74 68 65  o prevent.** the
1860: 20 73 75 6d 20 6f 66 20 73 69 7a 65 73 20 6f 66   sum of sizes of
1870: 20 61 6c 6c 20 66 69 6c 65 73 20 66 72 6f 6d 20   all files from 
1880: 67 6f 69 6e 67 20 6f 76 65 72 20 71 75 6f 74 61  going over quota
1890: 2e 0a 2a 2f 0a 73 69 7a 65 5f 74 20 73 71 6c 69  ..*/.size_t sqli
18a0: 74 65 33 5f 71 75 6f 74 61 5f 66 72 65 61 64 28  te3_quota_fread(
18b0: 76 6f 69 64 2a 2c 20 73 69 7a 65 5f 74 2c 20 73  void*, size_t, s
18c0: 69 7a 65 5f 74 2c 20 71 75 6f 74 61 5f 46 49 4c  ize_t, quota_FIL
18d0: 45 2a 29 3b 0a 73 69 7a 65 5f 74 20 73 71 6c 69  E*);.size_t sqli
18e0: 74 65 33 5f 71 75 6f 74 61 5f 66 77 72 69 74 65  te3_quota_fwrite
18f0: 28 63 6f 6e 73 74 20 76 6f 69 64 2a 2c 20 73 69  (const void*, si
1900: 7a 65 5f 74 2c 20 73 69 7a 65 5f 74 2c 20 71 75  ze_t, size_t, qu
1910: 6f 74 61 5f 46 49 4c 45 2a 29 3b 0a 0a 2f 2a 0a  ota_FILE*);../*.
1920: 2a 2a 20 46 6c 75 73 68 20 61 6c 6c 20 77 72 69  ** Flush all wri
1930: 74 74 65 6e 20 63 6f 6e 74 65 6e 74 20 68 65 6c  tten content hel
1940: 64 20 69 6e 20 6d 65 6d 6f 72 79 20 62 75 66 66  d in memory buff
1950: 65 72 73 20 6f 75 74 20 74 6f 20 64 69 73 6b 2e  ers out to disk.
1960: 0a 2a 2a 20 54 68 69 73 20 69 73 20 74 68 65 20  .** This is the 
1970: 65 71 75 69 76 61 6c 65 6e 74 20 6f 66 20 66 66  equivalent of ff
1980: 6c 75 73 68 28 29 20 69 6e 20 74 68 65 20 73 74  lush() in the st
1990: 61 6e 64 61 72 64 20 6c 69 62 72 61 72 79 2e 0a  andard library..
19a0: 2a 2a 0a 2a 2a 20 49 66 20 74 68 65 20 68 61 72  **.** If the har
19b0: 64 53 79 6e 63 20 70 61 72 61 6d 65 74 65 72 20  dSync parameter 
19c0: 69 73 20 74 72 75 65 20 28 6e 6f 6e 2d 7a 65 72  is true (non-zer
19d0: 6f 29 20 74 68 65 6e 20 74 68 69 73 20 72 6f 75  o) then this rou
19e0: 74 69 6e 65 0a 2a 2a 20 61 6c 73 6f 20 66 6f 72  tine.** also for
19f0: 63 65 73 20 4f 53 20 62 75 66 66 65 72 73 20 74  ces OS buffers t
1a00: 6f 20 64 69 73 6b 20 2d 20 74 68 65 20 65 71 75  o disk - the equ
1a10: 69 76 61 6c 65 6e 74 20 6f 66 20 66 73 79 6e 63  ivalent of fsync
1a20: 28 29 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 72  ()..**.** This r
1a30: 6f 75 74 69 6e 65 20 72 65 74 75 72 6e 20 7a 65  outine return ze
1a40: 72 6f 20 6f 6e 20 73 75 63 63 65 73 73 20 61 6e  ro on success an
1a50: 64 20 6e 6f 6e 2d 7a 65 72 6f 20 69 66 20 73 6f  d non-zero if so
1a60: 6d 65 74 68 69 6e 67 20 67 6f 65 73 0a 2a 2a 20  mething goes.** 
1a70: 77 72 6f 6e 67 2e 0a 2a 2f 0a 69 6e 74 20 73 71  wrong..*/.int sq
1a80: 6c 69 74 65 33 5f 71 75 6f 74 61 5f 66 66 6c 75  lite3_quota_fflu
1a90: 73 68 28 71 75 6f 74 61 5f 46 49 4c 45 2a 2c 20  sh(quota_FILE*, 
1aa0: 69 6e 74 20 68 61 72 64 53 79 6e 63 29 3b 0a 0a  int hardSync);..
1ab0: 2f 2a 0a 2a 2a 20 43 6c 6f 73 65 20 61 20 71 75  /*.** Close a qu
1ac0: 6f 74 61 5f 46 49 4c 45 20 6f 62 6a 65 63 74 20  ota_FILE object 
1ad0: 61 6e 64 20 66 72 65 65 20 61 6c 6c 20 61 73 73  and free all ass
1ae0: 6f 63 69 61 74 65 64 20 72 65 73 6f 75 72 63 65  ociated resource
1af0: 73 2e 20 20 54 68 65 0a 2a 2a 20 66 69 6c 65 20  s.  The.** file 
1b00: 72 65 6d 61 69 6e 73 20 75 6e 64 65 72 20 71 75  remains under qu
1b10: 6f 74 61 20 6d 61 6e 61 67 65 6d 65 6e 74 2e 0a  ota management..
1b20: 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 71  */.int sqlite3_q
1b30: 75 6f 74 61 5f 66 63 6c 6f 73 65 28 71 75 6f 74  uota_fclose(quot
1b40: 61 5f 46 49 4c 45 2a 29 3b 0a 0a 2f 2a 0a 2a 2a  a_FILE*);../*.**
1b50: 20 4d 6f 76 65 20 74 68 65 20 72 65 61 64 2f 77   Move the read/w
1b60: 72 69 74 65 20 70 6f 69 6e 74 65 72 20 66 6f 72  rite pointer for
1b70: 20 61 20 71 75 6f 74 61 5f 46 49 4c 45 20 6f 62   a quota_FILE ob
1b80: 6a 65 63 74 2e 20 20 4f 72 20 74 65 6c 6c 20 74  ject.  Or tell t
1b90: 68 65 0a 2a 2a 20 63 75 72 72 65 6e 74 20 6c 6f  he.** current lo
1ba0: 63 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 72 65  cation of the re
1bb0: 61 64 2f 77 72 69 74 65 20 70 6f 69 6e 74 65 72  ad/write pointer
1bc0: 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65 33  ..*/.int sqlite3
1bd0: 5f 71 75 6f 74 61 5f 66 73 65 65 6b 28 71 75 6f  _quota_fseek(quo
1be0: 74 61 5f 46 49 4c 45 2a 2c 20 6c 6f 6e 67 2c 20  ta_FILE*, long, 
1bf0: 69 6e 74 29 3b 0a 76 6f 69 64 20 73 71 6c 69 74  int);.void sqlit
1c00: 65 33 5f 71 75 6f 74 61 5f 72 65 77 69 6e 64 28  e3_quota_rewind(
1c10: 71 75 6f 74 61 5f 46 49 4c 45 2a 29 3b 0a 6c 6f  quota_FILE*);.lo
1c20: 6e 67 20 73 71 6c 69 74 65 33 5f 71 75 6f 74 61  ng sqlite3_quota
1c30: 5f 66 74 65 6c 6c 28 71 75 6f 74 61 5f 46 49 4c  _ftell(quota_FIL
1c40: 45 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 54 65 73 74  E*);../*.** Test
1c50: 20 74 68 65 20 65 72 72 6f 72 20 69 6e 64 69 63   the error indic
1c60: 61 74 6f 72 20 66 6f 72 20 74 68 65 20 67 69 76  ator for the giv
1c70: 65 6e 20 66 69 6c 65 2e 0a 2a 2a 0a 2a 2a 20 52  en file..**.** R
1c80: 65 74 75 72 6e 20 6e 6f 6e 2d 7a 65 72 6f 20 69  eturn non-zero i
1c90: 66 20 74 68 65 20 65 72 72 6f 72 20 69 6e 64 69  f the error indi
1ca0: 63 61 74 6f 72 20 69 73 20 73 65 74 2e 0a 2a 2f  cator is set..*/
1cb0: 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 71 75 6f  .int sqlite3_quo
1cc0: 74 61 5f 66 65 72 72 6f 72 28 71 75 6f 74 61 5f  ta_ferror(quota_
1cd0: 46 49 4c 45 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 54  FILE*);../*.** T
1ce0: 72 75 6e 63 61 74 65 20 61 20 66 69 6c 65 20 70  runcate a file p
1cf0: 72 65 76 69 6f 75 73 6c 79 20 6f 70 65 6e 65 64  reviously opened
1d00: 20 62 79 20 73 71 6c 69 74 65 33 5f 71 75 6f 74   by sqlite3_quot
1d10: 61 5f 66 6f 70 65 6e 28 29 2e 20 20 52 65 74 75  a_fopen().  Retu
1d20: 72 6e 0a 2a 2a 20 7a 65 72 6f 20 6f 6e 20 73 75  rn.** zero on su
1d30: 63 63 65 73 73 20 61 6e 64 20 6e 6f 6e 2d 7a 65  ccess and non-ze
1d40: 72 6f 20 6f 6e 20 61 6e 79 20 6b 69 6e 64 20 6f  ro on any kind o
1d50: 66 20 66 61 69 6c 75 72 65 2e 0a 2a 2a 0a 2a 2a  f failure..**.**
1d60: 20 54 68 65 20 6e 65 77 53 69 7a 65 20 61 72 67   The newSize arg
1d70: 75 6d 65 6e 74 20 6d 75 73 74 20 62 65 20 6c 65  ument must be le
1d80: 73 73 20 74 68 61 6e 20 6f 72 20 65 71 75 61 6c  ss than or equal
1d90: 20 74 6f 20 74 68 65 20 63 75 72 72 65 6e 74 20   to the current 
1da0: 66 69 6c 65 20 73 69 7a 65 2e 0a 2a 2a 20 41 6e  file size..** An
1db0: 79 20 61 74 74 65 6d 70 74 20 74 6f 20 22 74 72  y attempt to "tr
1dc0: 75 6e 63 61 74 65 22 20 61 20 66 69 6c 65 20 74  uncate" a file t
1dd0: 6f 20 61 20 6c 61 72 67 65 72 20 73 69 7a 65 20  o a larger size 
1de0: 72 65 73 75 6c 74 73 20 69 6e 20 0a 2a 2a 20 75  results in .** u
1df0: 6e 64 65 66 69 6e 65 64 20 62 65 68 61 76 69 6f  ndefined behavio
1e00: 72 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69 74 65  r..*/.int sqlite
1e10: 33 5f 71 75 6f 74 61 5f 66 74 72 75 6e 63 61 74  3_quota_ftruncat
1e20: 65 28 71 75 6f 74 61 5f 46 49 4c 45 2a 2c 20 73  e(quota_FILE*, s
1e30: 71 6c 69 74 65 33 5f 69 6e 74 36 34 20 6e 65 77  qlite3_int64 new
1e40: 53 69 7a 65 29 3b 0a 0a 2f 2a 0a 2a 2a 20 52 65  Size);../*.** Re
1e50: 74 75 72 6e 20 74 68 65 20 6c 61 73 74 20 6d 6f  turn the last mo
1e60: 64 69 66 69 63 61 74 69 6f 6e 20 74 69 6d 65 20  dification time 
1e70: 6f 66 20 74 68 65 20 6f 70 65 6e 65 64 20 66 69  of the opened fi
1e80: 6c 65 2c 20 69 6e 20 73 65 63 6f 6e 64 73 0a 2a  le, in seconds.*
1e90: 2a 20 73 69 6e 63 65 20 31 39 37 30 2e 0a 2a 2f  * since 1970..*/
1ea0: 0a 69 6e 74 20 73 71 6c 69 74 65 33 5f 71 75 6f  .int sqlite3_quo
1eb0: 74 61 5f 66 69 6c 65 5f 6d 74 69 6d 65 28 71 75  ta_file_mtime(qu
1ec0: 6f 74 61 5f 46 49 4c 45 2a 2c 20 74 69 6d 65 5f  ota_FILE*, time_
1ed0: 74 20 2a 70 54 69 6d 65 29 3b 0a 0a 2f 2a 0a 2a  t *pTime);../*.*
1ee0: 2a 20 52 65 74 75 72 6e 20 74 68 65 20 73 69 7a  * Return the siz
1ef0: 65 20 6f 66 20 74 68 65 20 66 69 6c 65 20 61 73  e of the file as
1f00: 20 69 74 20 69 73 20 6b 6e 6f 77 6e 20 74 6f 20   it is known to 
1f10: 74 68 65 20 71 75 6f 74 61 20 73 79 73 74 65 6d  the quota system
1f20: 2e 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 73 69 7a  ..**.** This siz
1f30: 65 20 6d 69 67 68 74 20 62 65 20 64 69 66 66 65  e might be diffe
1f40: 72 65 6e 74 20 66 72 6f 6d 20 74 68 65 20 74 72  rent from the tr
1f50: 75 65 20 73 69 7a 65 20 6f 66 20 74 68 65 20 66  ue size of the f
1f60: 69 6c 65 20 6f 6e 0a 2a 2a 20 64 69 73 6b 20 69  ile on.** disk i
1f70: 66 20 73 6f 6d 65 20 6f 75 74 73 69 64 65 20 70  f some outside p
1f80: 72 6f 63 65 73 73 20 68 61 73 20 6d 6f 64 69 66  rocess has modif
1f90: 69 65 64 20 74 68 65 20 66 69 6c 65 20 77 69 74  ied the file wit
1fa0: 68 6f 75 74 20 75 73 69 6e 67 20 74 68 65 0a 2a  hout using the.*
1fb0: 2a 20 71 75 6f 74 61 20 6d 65 63 68 61 6e 69 73  * quota mechanis
1fc0: 6d 2c 20 6f 72 20 69 66 20 63 61 6c 6c 73 20 74  m, or if calls t
1fd0: 6f 20 73 71 6c 69 74 65 33 5f 71 75 6f 74 61 5f  o sqlite3_quota_
1fe0: 66 77 72 69 74 65 28 29 20 68 61 76 65 20 6f 63  fwrite() have oc
1ff0: 63 75 72 72 65 64 0a 2a 2a 20 77 68 69 63 68 20  curred.** which 
2000: 68 61 76 65 20 69 6e 63 72 65 61 73 65 64 20 74  have increased t
2010: 68 65 20 66 69 6c 65 20 73 69 7a 65 2c 20 62 75  he file size, bu
2020: 74 20 74 68 6f 73 65 20 77 72 69 74 65 73 20 68  t those writes h
2030: 61 76 65 20 6e 6f 74 20 79 65 74 20 62 65 65 6e  ave not yet been
2040: 0a 2a 2a 20 66 6f 72 63 65 64 20 74 6f 20 64 69  .** forced to di
2050: 73 6b 20 75 73 69 6e 67 20 73 71 6c 69 74 65 33  sk using sqlite3
2060: 5f 71 75 6f 74 61 5f 66 66 6c 75 73 68 28 29 2e  _quota_fflush().
2070: 0a 2a 2a 0a 2a 2a 20 52 65 74 75 72 6e 20 2d 31  .**.** Return -1
2080: 20 69 66 20 74 68 65 20 66 69 6c 65 20 69 73 20   if the file is 
2090: 6e 6f 74 20 70 61 72 74 69 63 69 70 61 74 69 6e  not participatin
20a0: 67 20 69 6e 20 71 75 6f 74 61 20 6d 61 6e 61 67  g in quota manag
20b0: 65 6d 65 6e 74 2e 0a 2a 2f 0a 73 71 6c 69 74 65  ement..*/.sqlite
20c0: 33 5f 69 6e 74 36 34 20 73 71 6c 69 74 65 33 5f  3_int64 sqlite3_
20d0: 71 75 6f 74 61 5f 66 69 6c 65 5f 73 69 7a 65 28  quota_file_size(
20e0: 71 75 6f 74 61 5f 46 49 4c 45 2a 29 3b 0a 0a 2f  quota_FILE*);../
20f0: 2a 0a 2a 2a 20 52 65 74 75 72 6e 20 74 68 65 20  *.** Return the 
2100: 74 72 75 65 20 73 69 7a 65 20 6f 66 20 74 68 65  true size of the
2110: 20 66 69 6c 65 2e 0a 2a 2a 0a 2a 2a 20 54 68 65   file..**.** The
2120: 20 74 72 75 65 20 73 69 7a 65 20 73 68 6f 75 6c   true size shoul
2130: 64 20 62 65 20 74 68 65 20 73 61 6d 65 20 61 73  d be the same as
2140: 20 74 68 65 20 73 69 7a 65 20 6f 66 20 74 68 65   the size of the
2150: 20 66 69 6c 65 20 61 73 20 6b 6e 6f 77 6e 0a 2a   file as known.*
2160: 2a 20 74 6f 20 74 68 65 20 71 75 6f 74 61 20 73  * to the quota s
2170: 79 73 74 65 6d 2c 20 68 6f 77 65 76 65 72 20 74  ystem, however t
2180: 68 65 20 73 69 7a 65 73 20 6d 69 67 68 74 20 62  he sizes might b
2190: 65 20 64 69 66 66 65 72 65 6e 74 20 69 66 20 74  e different if t
21a0: 68 65 0a 2a 2a 20 66 69 6c 65 20 68 61 73 20 62  he.** file has b
21b0: 65 65 6e 20 65 78 74 65 6e 64 65 64 20 6f 72 20  een extended or 
21c0: 74 72 75 6e 63 61 74 65 64 20 76 69 61 20 73 6f  truncated via so
21d0: 6d 65 20 6f 75 74 73 69 64 65 20 70 72 6f 63 65  me outside proce
21e0: 73 73 20 6f 72 20 69 66 0a 2a 2a 20 70 65 6e 64  ss or if.** pend
21f0: 69 6e 67 20 77 72 69 74 65 73 20 68 61 76 65 20  ing writes have 
2200: 6e 6f 74 20 79 65 74 20 62 65 65 6e 20 66 6c 75  not yet been flu
2210: 73 68 65 64 20 74 6f 20 64 69 73 6b 2e 0a 2a 2a  shed to disk..**
2220: 0a 2a 2a 20 52 65 74 75 72 6e 20 2d 31 20 69 66  .** Return -1 if
2230: 20 74 68 65 20 66 69 6c 65 20 64 6f 65 73 20 6e   the file does n
2240: 6f 74 20 65 78 69 73 74 20 6f 72 20 69 66 20 74  ot exist or if t
2250: 68 65 20 73 69 7a 65 20 6f 66 20 74 68 65 20 66  he size of the f
2260: 69 6c 65 0a 2a 2a 20 63 61 6e 6e 6f 74 20 62 65  ile.** cannot be
2270: 20 64 65 74 65 72 6d 69 6e 65 64 20 66 6f 72 20   determined for 
2280: 73 6f 6d 65 20 72 65 61 73 6f 6e 2e 0a 2a 2f 0a  some reason..*/.
2290: 73 71 6c 69 74 65 33 5f 69 6e 74 36 34 20 73 71  sqlite3_int64 sq
22a0: 6c 69 74 65 33 5f 71 75 6f 74 61 5f 66 69 6c 65  lite3_quota_file
22b0: 5f 74 72 75 65 73 69 7a 65 28 71 75 6f 74 61 5f  _truesize(quota_
22c0: 46 49 4c 45 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 44  FILE*);../*.** D
22d0: 65 74 65 72 6d 69 6e 65 20 74 68 65 20 61 6d 6f  etermine the amo
22e0: 75 6e 74 20 6f 66 20 64 61 74 61 20 69 6e 20 62  unt of data in b
22f0: 79 74 65 73 20 61 76 61 69 6c 61 62 6c 65 20 66  ytes available f
2300: 6f 72 20 72 65 61 64 69 6e 67 0a 2a 2a 20 69 6e  or reading.** in
2310: 20 74 68 65 20 67 69 76 65 6e 20 66 69 6c 65 2e   the given file.
2320: 0a 2a 2a 0a 2a 2a 20 52 65 74 75 72 6e 20 2d 31  .**.** Return -1
2330: 20 69 66 20 74 68 65 20 61 6d 6f 75 6e 74 20 63   if the amount c
2340: 61 6e 6e 6f 74 20 62 65 20 64 65 74 65 72 6d 69  annot be determi
2350: 6e 65 64 20 66 6f 72 20 73 6f 6d 65 20 72 65 61  ned for some rea
2360: 73 6f 6e 2e 0a 2a 2f 0a 6c 6f 6e 67 20 73 71 6c  son..*/.long sql
2370: 69 74 65 33 5f 71 75 6f 74 61 5f 66 69 6c 65 5f  ite3_quota_file_
2380: 61 76 61 69 6c 61 62 6c 65 28 71 75 6f 74 61 5f  available(quota_
2390: 46 49 4c 45 2a 29 3b 0a 0a 2f 2a 0a 2a 2a 20 44  FILE*);../*.** D
23a0: 65 6c 65 74 65 20 61 20 66 69 6c 65 20 66 72 6f  elete a file fro
23b0: 6d 20 74 68 65 20 64 69 73 6b 2c 20 69 66 20 74  m the disk, if t
23c0: 68 61 74 20 66 69 6c 65 20 69 73 20 75 6e 64 65  hat file is unde
23d0: 72 20 71 75 6f 74 61 20 6d 61 6e 61 67 65 6d 65  r quota manageme
23e0: 6e 74 2e 0a 2a 2a 20 41 64 6a 75 73 74 20 71 75  nt..** Adjust qu
23f0: 6f 74 61 73 20 61 63 63 6f 72 64 69 6e 67 6c 79  otas accordingly
2400: 2e 0a 2a 2a 0a 2a 2a 20 49 66 20 7a 46 69 6c 65  ..**.** If zFile
2410: 6e 61 6d 65 20 69 73 20 74 68 65 20 6e 61 6d 65  name is the name
2420: 20 6f 66 20 61 20 64 69 72 65 63 74 6f 72 79 20   of a directory 
2430: 74 68 61 74 20 6d 61 74 63 68 65 73 20 6f 6e 65  that matches one
2440: 20 6f 66 20 74 68 65 0a 2a 2a 20 71 75 6f 74 61   of the.** quota
2450: 20 67 6c 6f 62 20 70 61 74 74 65 72 6e 73 2c 20   glob patterns, 
2460: 74 68 65 6e 20 61 6c 6c 20 66 69 6c 65 73 20 75  then all files u
2470: 6e 64 65 72 20 71 75 6f 74 61 20 6d 61 6e 61 67  nder quota manag
2480: 65 6d 65 6e 74 20 74 68 61 74 0a 2a 2a 20 61 72  ement that.** ar
2490: 65 20 63 6f 6e 74 61 69 6e 65 64 20 77 69 74 68  e contained with
24a0: 69 6e 20 74 68 61 74 20 64 69 72 65 63 74 6f 72  in that director
24b0: 79 20 61 72 65 20 64 65 6c 65 74 65 64 2e 0a 2a  y are deleted..*
24c0: 2a 0a 2a 2a 20 41 20 73 74 61 6e 64 61 72 64 20  *.** A standard 
24d0: 53 51 4c 69 74 65 20 72 65 73 75 6c 74 20 63 6f  SQLite result co
24e0: 64 65 20 69 73 20 72 65 74 75 72 6e 65 64 20 28  de is returned (
24f0: 53 51 4c 49 54 45 5f 4f 4b 2c 20 53 51 4c 49 54  SQLITE_OK, SQLIT
2500: 45 5f 4e 4f 4d 45 4d 2c 20 65 74 63 2e 29 0a 2a  E_NOMEM, etc.).*
2510: 2a 20 57 68 65 6e 20 64 65 6c 65 74 69 6e 67 20  * When deleting 
2520: 61 20 64 69 72 65 63 74 6f 72 79 20 6f 66 20 66  a directory of f
2530: 69 6c 65 73 2c 20 69 66 20 74 68 65 20 64 65 6c  iles, if the del
2540: 65 74 69 6f 6e 20 6f 66 20 61 6e 79 20 6f 6e 65  etion of any one
2550: 0a 2a 2a 20 66 69 6c 65 20 66 61 69 6c 73 20 28  .** file fails (
2560: 66 6f 72 20 65 78 61 6d 70 6c 65 20 64 75 65 20  for example due 
2570: 74 6f 20 61 6e 20 49 2f 4f 20 65 72 72 6f 72 29  to an I/O error)
2580: 2c 20 74 68 65 6e 20 74 68 69 73 20 72 6f 75 74  , then this rout
2590: 69 6e 65 0a 2a 2a 20 72 65 74 75 72 6e 73 20 69  ine.** returns i
25a0: 6d 6d 65 64 69 61 74 65 6c 79 2c 20 77 69 74 68  mmediately, with
25b0: 20 74 68 65 20 65 72 72 6f 72 20 63 6f 64 65 2c   the error code,
25c0: 20 61 6e 64 20 64 6f 65 73 20 6e 6f 74 20 74 72   and does not tr
25d0: 79 20 74 6f 20 0a 2a 2a 20 64 65 6c 65 74 65 20  y to .** delete 
25e0: 61 6e 79 20 6f 66 20 74 68 65 20 6f 74 68 65 72  any of the other
25f0: 20 66 69 6c 65 73 20 69 6e 20 74 68 65 20 73 70   files in the sp
2600: 65 63 69 66 69 65 64 20 64 69 72 65 63 74 6f 72  ecified director
2610: 79 2e 0a 2a 2a 0a 2a 2a 20 41 6c 6c 20 66 69 6c  y..**.** All fil
2620: 65 73 20 61 72 65 20 72 65 6d 6f 76 65 64 20 66  es are removed f
2630: 72 6f 6d 20 71 75 6f 74 61 20 6d 61 6e 61 67 65  rom quota manage
2640: 6d 65 6e 74 20 61 6e 64 20 64 65 6c 65 74 65 64  ment and deleted
2650: 20 66 72 6f 6d 20 64 69 73 6b 2e 0a 2a 2a 20 48   from disk..** H
2660: 6f 77 65 76 65 72 2c 20 6e 6f 20 61 74 74 65 6d  owever, no attem
2670: 70 74 20 69 73 20 6d 61 64 65 20 74 6f 20 72 65  pt is made to re
2680: 6d 6f 76 65 20 65 6d 70 74 79 20 64 69 72 65 63  move empty direc
2690: 74 6f 72 69 65 73 2e 0a 2a 2a 0a 2a 2a 20 54 68  tories..**.** Th
26a0: 69 73 20 72 6f 75 74 69 6e 65 20 69 73 20 61 20  is routine is a 
26b0: 6e 6f 2d 6f 70 20 66 6f 72 20 66 69 6c 65 73 20  no-op for files 
26c0: 74 68 61 74 20 61 72 65 20 6e 6f 74 20 75 6e 64  that are not und
26d0: 65 72 20 71 75 6f 74 61 20 6d 61 6e 61 67 65 6d  er quota managem
26e0: 65 6e 74 2e 0a 2a 2f 0a 69 6e 74 20 73 71 6c 69  ent..*/.int sqli
26f0: 74 65 33 5f 71 75 6f 74 61 5f 72 65 6d 6f 76 65  te3_quota_remove
2700: 28 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 46 69  (const char *zFi
2710: 6c 65 6e 61 6d 65 29 3b 0a 0a 23 69 66 64 65 66  lename);..#ifdef
2720: 20 5f 5f 63 70 6c 75 73 70 6c 75 73 0a 7d 20 20   __cplusplus.}  
2730: 2f 2a 20 65 6e 64 20 6f 66 20 74 68 65 20 27 65  /* end of the 'e
2740: 78 74 65 72 6e 20 22 43 22 27 20 62 6c 6f 63 6b  xtern "C"' block
2750: 20 2a 2f 0a 23 65 6e 64 69 66 0a 23 65 6e 64 69   */.#endif.#endi
2760: 66 20 2f 2a 20 5f 51 55 4f 54 41 5f 48 5f 20 2a  f /* _QUOTA_H_ *
2770: 2f 0a                                            /.