Hex Artifact Content
Not logged in

Artifact 2cb2adc7b455d394719197fc483a03cdaa249a84:

File src/configure.c part of check-in [ac3f1f2ba7] - Improvements to how ticket changes are displayed in the UI. The hyperlink is show with strick-through if the ticket is closed. The title is shown after the ticket hyperlink. SQL to determine the closed condition and the title can be set in the ticket setup screens. by drh on 2008-10-18 02:27:13.

0000: 2f 2a 0a 2a 2a 20 43 6f 70 79 72 69 67 68 74 20  /*.** Copyright 
0010: 28 63 29 20 32 30 30 38 20 44 2e 20 52 69 63 68  (c) 2008 D. Rich
0020: 61 72 64 20 48 69 70 70 0a 2a 2a 0a 2a 2a 20 54  ard Hipp.**.** T
0030: 68 69 73 20 70 72 6f 67 72 61 6d 20 69 73 20 66  his program is f
0040: 72 65 65 20 73 6f 66 74 77 61 72 65 3b 20 79 6f  ree software; yo
0050: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75  u can redistribu
0060: 74 65 20 69 74 20 61 6e 64 2f 6f 72 0a 2a 2a 20  te it and/or.** 
0070: 6d 6f 64 69 66 79 20 69 74 20 75 6e 64 65 72 20  modify it under 
0080: 74 68 65 20 74 65 72 6d 73 20 6f 66 20 74 68 65  the terms of the
0090: 20 47 4e 55 20 47 65 6e 65 72 61 6c 20 50 75 62   GNU General Pub
00a0: 6c 69 63 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 76  lic.** License v
00b0: 65 72 73 69 6f 6e 20 32 20 61 73 20 70 75 62 6c  ersion 2 as publ
00c0: 69 73 68 65 64 20 62 79 20 74 68 65 20 46 72 65  ished by the Fre
00d0: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64  e Software Found
00e0: 61 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 54 68 69  ation..**.** Thi
00f0: 73 20 70 72 6f 67 72 61 6d 20 69 73 20 64 69 73  s program is dis
0100: 74 72 69 62 75 74 65 64 20 69 6e 20 74 68 65 20  tributed in the 
0110: 68 6f 70 65 20 74 68 61 74 20 69 74 20 77 69 6c  hope that it wil
0120: 6c 20 62 65 20 75 73 65 66 75 6c 2c 0a 2a 2a 20  l be useful,.** 
0130: 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e 59 20  but WITHOUT ANY 
0140: 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 6f 75  WARRANTY; withou
0150: 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 6c 69  t even the impli
0160: 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 0a 2a  ed warranty of.*
0170: 2a 20 4d 45 52 43 48 41 4e 54 41 42 49 4c 49 54  * MERCHANTABILIT
0180: 59 20 6f 72 20 46 49 54 4e 45 53 53 20 46 4f 52  Y or FITNESS FOR
0190: 20 41 20 50 41 52 54 49 43 55 4c 41 52 20 50 55   A PARTICULAR PU
01a0: 52 50 4f 53 45 2e 20 20 53 65 65 20 74 68 65 20  RPOSE.  See the 
01b0: 47 4e 55 0a 2a 2a 20 47 65 6e 65 72 61 6c 20 50  GNU.** General P
01c0: 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 66 6f  ublic License fo
01d0: 72 20 6d 6f 72 65 20 64 65 74 61 69 6c 73 2e 0a  r more details..
01e0: 2a 2a 20 0a 2a 2a 20 59 6f 75 20 73 68 6f 75 6c  ** .** You shoul
01f0: 64 20 68 61 76 65 20 72 65 63 65 69 76 65 64 20  d have received 
0200: 61 20 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e  a copy of the GN
0210: 55 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63  U General Public
0220: 0a 2a 2a 20 4c 69 63 65 6e 73 65 20 61 6c 6f 6e  .** License alon
0230: 67 20 77 69 74 68 20 74 68 69 73 20 6c 69 62 72  g with this libr
0240: 61 72 79 3b 20 69 66 20 6e 6f 74 2c 20 77 72 69  ary; if not, wri
0250: 74 65 20 74 6f 20 74 68 65 0a 2a 2a 20 46 72 65  te to the.** Fre
0260: 65 20 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64  e Software Found
0270: 61 74 69 6f 6e 2c 20 49 6e 63 2e 2c 20 35 39 20  ation, Inc., 59 
0280: 54 65 6d 70 6c 65 20 50 6c 61 63 65 20 2d 20 53  Temple Place - S
0290: 75 69 74 65 20 33 33 30 2c 0a 2a 2a 20 42 6f 73  uite 330,.** Bos
02a0: 74 6f 6e 2c 20 4d 41 20 20 30 32 31 31 31 2d 31  ton, MA  02111-1
02b0: 33 30 37 2c 20 55 53 41 2e 0a 2a 2a 0a 2a 2a 20  307, USA..**.** 
02c0: 41 75 74 68 6f 72 20 63 6f 6e 74 61 63 74 20 69  Author contact i
02d0: 6e 66 6f 72 6d 61 74 69 6f 6e 3a 0a 2a 2a 20 20  nformation:.**  
02e0: 20 64 72 68 40 68 77 61 63 69 2e 63 6f 6d 0a 2a   drh@hwaci.com.*
02f0: 2a 20 20 20 68 74 74 70 3a 2f 2f 77 77 77 2e 68  *   http://www.h
0300: 77 61 63 69 2e 63 6f 6d 2f 64 72 68 2f 0a 2a 2a  waci.com/drh/.**
0310: 0a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  .***************
0320: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0330: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0340: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0350: 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a 2a  ****************
0360: 0a 2a 2a 0a 2a 2a 20 54 68 69 73 20 66 69 6c 65  .**.** This file
0370: 20 63 6f 6e 74 61 69 6e 73 20 63 6f 64 65 20 75   contains code u
0380: 73 65 64 20 74 6f 20 6d 61 6e 61 67 65 20 72 65  sed to manage re
0390: 70 6f 73 69 74 6f 72 79 20 63 6f 6e 66 69 67 75  pository configu
03a0: 72 61 74 69 6f 6e 73 2e 0a 2a 2a 20 42 79 20 22  rations..** By "
03b0: 72 65 73 70 6f 6e 73 69 74 6f 72 79 20 63 6f 6e  responsitory con
03c0: 66 69 67 75 72 65 22 20 77 65 20 6d 65 61 6e 20  figure" we mean 
03d0: 74 68 65 20 6c 6f 63 61 6c 20 73 74 61 74 65 20  the local state 
03e0: 6f 66 20 61 20 72 65 70 6f 73 69 74 6f 72 79 0a  of a repository.
03f0: 2a 2a 20 64 69 73 74 69 6e 63 74 20 66 72 6f 6d  ** distinct from
0400: 20 74 68 65 20 76 65 72 73 69 6f 6e 65 64 20 66   the versioned f
0410: 69 6c 65 73 2e 0a 2a 2f 0a 23 69 6e 63 6c 75 64  iles..*/.#includ
0420: 65 20 22 63 6f 6e 66 69 67 2e 68 22 0a 23 69 6e  e "config.h".#in
0430: 63 6c 75 64 65 20 22 63 6f 6e 66 69 67 75 72 65  clude "configure
0440: 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20 3c 61 73  .h".#include <as
0450: 73 65 72 74 2e 68 3e 0a 0a 23 69 66 20 49 4e 54  sert.h>..#if INT
0460: 45 52 46 41 43 45 0a 2f 2a 0a 2a 2a 20 43 6f 6e  ERFACE./*.** Con
0470: 66 69 67 75 72 61 74 69 6f 6e 20 74 72 61 6e 73  figuration trans
0480: 66 65 72 73 20 6f 63 63 75 72 20 69 6e 20 67 72  fers occur in gr
0490: 6f 75 70 73 2e 20 20 54 68 65 73 65 20 61 72 65  oups.  These are
04a0: 20 74 68 65 20 61 6c 6c 6f 77 65 64 0a 2a 2a 20   the allowed.** 
04b0: 67 72 6f 75 70 69 6e 67 73 3a 0a 2a 2f 0a 23 64  groupings:.*/.#d
04c0: 65 66 69 6e 65 20 43 4f 4e 46 49 47 53 45 54 5f  efine CONFIGSET_
04d0: 53 4b 49 4e 20 20 20 30 78 30 30 30 30 30 31 20  SKIN   0x000001 
04e0: 20 20 20 20 2f 2a 20 57 57 57 20 69 6e 74 65 72      /* WWW inter
04f0: 66 61 63 65 20 61 70 70 65 61 72 61 6e 63 65 20  face appearance 
0500: 2a 2f 0a 23 64 65 66 69 6e 65 20 43 4f 4e 46 49  */.#define CONFI
0510: 47 53 45 54 5f 54 4b 54 20 20 20 20 30 78 30 30  GSET_TKT    0x00
0520: 30 30 30 32 20 20 20 20 20 2f 2a 20 54 69 63 6b  0002     /* Tick
0530: 65 74 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e  et configuration
0540: 20 2a 2f 0a 23 64 65 66 69 6e 65 20 43 4f 4e 46   */.#define CONF
0550: 49 47 53 45 54 5f 50 52 4f 4a 20 20 20 30 78 30  IGSET_PROJ   0x0
0560: 30 30 30 30 34 20 20 20 20 20 2f 2a 20 50 72 6f  00004     /* Pro
0570: 6a 65 63 74 20 6e 61 6d 65 20 2a 2f 0a 23 64 65  ject name */.#de
0580: 66 69 6e 65 20 43 4f 4e 46 49 47 53 45 54 5f 53  fine CONFIGSET_S
0590: 48 55 4e 20 20 20 30 78 30 30 30 30 30 38 20 20  HUN   0x000008  
05a0: 20 20 20 2f 2a 20 53 68 75 6e 20 73 65 74 74 69     /* Shun setti
05b0: 6e 67 73 20 2a 2f 0a 23 64 65 66 69 6e 65 20 43  ngs */.#define C
05c0: 4f 4e 46 49 47 53 45 54 5f 55 53 45 52 20 20 20  ONFIGSET_USER   
05d0: 30 78 30 30 30 30 31 30 20 20 20 20 20 2f 2a 20  0x000010     /* 
05e0: 54 68 65 20 55 53 45 52 20 74 61 62 6c 65 20 2a  The USER table *
05f0: 2f 0a 0a 23 64 65 66 69 6e 65 20 43 4f 4e 46 49  /..#define CONFI
0600: 47 53 45 54 5f 41 4c 4c 20 20 20 20 30 78 66 66  GSET_ALL    0xff
0610: 66 66 66 66 20 20 20 20 20 2f 2a 20 45 76 65 72  ffff     /* Ever
0620: 79 74 68 69 6e 67 20 2a 2f 0a 0a 23 65 6e 64 69  ything */..#endi
0630: 66 20 2f 2a 20 49 4e 54 45 52 46 41 43 45 20 2a  f /* INTERFACE *
0640: 2f 0a 0a 2f 2a 0a 2a 2a 20 4e 61 6d 65 73 20 6f  /../*.** Names o
0650: 66 20 74 68 65 20 63 6f 6e 66 69 67 75 72 61 74  f the configurat
0660: 69 6f 6e 20 73 65 74 73 0a 2a 2f 0a 73 74 61 74  ion sets.*/.stat
0670: 69 63 20 73 74 72 75 63 74 20 7b 0a 20 20 63 6f  ic struct {.  co
0680: 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 3b  nst char *zName;
0690: 20 20 20 2f 2a 20 4e 61 6d 65 20 6f 66 20 74 68     /* Name of th
06a0: 65 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20  e configuration 
06b0: 73 65 74 20 2a 2f 0a 20 20 69 6e 74 20 67 72 6f  set */.  int gro
06c0: 75 70 4d 61 73 6b 3b 20 20 20 20 20 20 20 2f 2a  upMask;       /*
06d0: 20 4d 61 73 6b 20 66 6f 72 20 74 68 61 74 20 63   Mask for that c
06e0: 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 73 65 74  onfiguration set
06f0: 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 63 68 61 72   */.  const char
0700: 20 2a 7a 48 65 6c 70 3b 20 20 20 2f 2a 20 57 68   *zHelp;   /* Wh
0710: 61 74 20 69 74 20 64 6f 65 73 20 2a 2f 0a 7d 20  at it does */.} 
0720: 61 47 72 6f 75 70 4e 61 6d 65 5b 5d 20 3d 20 7b  aGroupName[] = {
0730: 0a 20 20 7b 20 22 73 6b 69 6e 22 2c 20 20 20 20  .  { "skin",    
0740: 20 20 20 20 20 43 4f 4e 46 49 47 53 45 54 5f 53       CONFIGSET_S
0750: 4b 49 4e 2c 20 20 22 57 65 62 20 69 6e 74 65 72  KIN,  "Web inter
0760: 66 61 63 65 20 61 70 70 61 72 61 6e 63 65 20 73  face apparance s
0770: 65 74 74 69 6e 67 73 22 20 7d 2c 0a 20 20 7b 20  ettings" },.  { 
0780: 22 74 69 63 6b 65 74 22 2c 20 20 20 20 20 20 20  "ticket",       
0790: 43 4f 4e 46 49 47 53 45 54 5f 54 4b 54 2c 20 20  CONFIGSET_TKT,  
07a0: 20 22 54 69 63 6b 65 74 20 73 65 74 75 70 22 2c   "Ticket setup",
07b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
07c0: 20 20 20 20 7d 2c 0a 20 20 7b 20 22 70 72 6f 6a      },.  { "proj
07d0: 65 63 74 22 2c 20 20 20 20 20 20 43 4f 4e 46 49  ect",      CONFI
07e0: 47 53 45 54 5f 50 52 4f 4a 2c 20 20 22 50 72 6f  GSET_PROJ,  "Pro
07f0: 6a 65 63 74 20 6e 61 6d 65 20 61 6e 64 20 64 65  ject name and de
0800: 73 63 72 69 70 74 69 6f 6e 22 20 20 20 20 20 7d  scription"     }
0810: 2c 0a 20 20 7b 20 22 73 68 75 6e 22 2c 20 20 20  ,.  { "shun",   
0820: 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45 54 5f        CONFIGSET_
0830: 53 48 55 4e 2c 20 20 22 4c 69 73 74 20 6f 66 20  SHUN,  "List of 
0840: 73 68 75 6e 6e 65 64 20 61 72 74 69 66 61 63 74  shunned artifact
0850: 73 22 20 20 20 20 20 20 20 20 7d 2c 0a 20 20 7b  s"        },.  {
0860: 20 22 75 73 65 72 22 2c 20 20 20 20 20 20 20 20   "user",        
0870: 20 43 4f 4e 46 49 47 53 45 54 5f 55 53 45 52 2c   CONFIGSET_USER,
0880: 20 20 22 55 73 65 72 73 20 61 6e 64 20 70 72 69    "Users and pri
0890: 76 69 6c 65 67 65 20 73 65 74 74 69 6e 67 73 22  vilege settings"
08a0: 20 20 20 20 20 7d 2c 0a 20 20 7b 20 22 61 6c 6c       },.  { "all
08b0: 22 2c 20 20 20 20 20 20 20 20 20 20 43 4f 4e 46  ",          CONF
08c0: 49 47 53 45 54 5f 41 4c 4c 2c 20 20 20 22 41 6c  IGSET_ALL,   "Al
08d0: 6c 20 6f 66 20 74 68 65 20 61 62 6f 76 65 22 20  l of the above" 
08e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
08f0: 7d 2c 0a 7d 3b 0a 0a 0a 2f 2a 0a 2a 2a 20 54 68  },.};.../*.** Th
0900: 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 69 73 20 61  e following is a
0910: 20 6c 69 73 74 20 6f 66 20 73 65 74 74 69 6e 67   list of setting
0920: 73 20 74 68 61 74 20 77 65 20 61 72 65 20 77 69  s that we are wi
0930: 6c 6c 69 6e 67 20 74 6f 0a 2a 2a 20 74 72 61 6e  lling to.** tran
0940: 73 66 65 72 2e 20 20 0a 2a 2a 0a 2a 2a 20 53 65  sfer.  .**.** Se
0950: 74 74 69 6e 67 20 6e 61 6d 65 73 20 74 68 61 74  tting names that
0960: 20 62 65 67 69 6e 20 77 69 74 68 20 61 6e 20 61   begin with an a
0970: 6c 70 68 61 62 65 74 69 63 20 63 68 61 72 61 63  lphabetic charac
0980: 74 65 72 73 20 72 65 66 65 72 20 74 6f 0a 2a 2a  ters refer to.**
0990: 20 73 69 6e 67 6c 65 20 65 6e 74 72 69 65 73 20   single entries 
09a0: 69 6e 20 74 68 65 20 43 4f 4e 46 49 47 20 74 61  in the CONFIG ta
09b0: 62 6c 65 2e 20 20 53 65 74 74 69 6e 67 20 6e 61  ble.  Setting na
09c0: 6d 65 73 20 74 68 61 74 20 62 65 67 69 6e 20 77  mes that begin w
09d0: 69 74 68 0a 2a 2a 20 22 40 22 20 61 72 65 20 66  ith.** "@" are f
09e0: 6f 72 20 73 70 65 63 69 61 6c 20 70 72 6f 63 65  or special proce
09f0: 73 73 69 6e 67 2e 0a 2a 2f 0a 73 74 61 74 69 63  ssing..*/.static
0a00: 20 73 74 72 75 63 74 20 7b 0a 20 20 63 6f 6e 73   struct {.  cons
0a10: 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 3b 20 20  t char *zName;  
0a20: 20 2f 2a 20 4e 61 6d 65 20 6f 66 20 74 68 65 20   /* Name of the 
0a30: 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 70 61  configuration pa
0a40: 72 61 6d 65 74 65 72 20 2a 2f 0a 20 20 69 6e 74  rameter */.  int
0a50: 20 67 72 6f 75 70 4d 61 73 6b 3b 20 20 20 20 20   groupMask;     
0a60: 20 20 2f 2a 20 57 68 69 63 68 20 63 6f 6e 66 69    /* Which confi
0a70: 67 20 67 72 6f 75 70 73 20 69 73 20 69 74 20 70  g groups is it p
0a80: 61 72 74 20 6f 66 20 2a 2f 0a 7d 20 61 43 6f 6e  art of */.} aCon
0a90: 66 69 67 5b 5d 20 3d 20 7b 0a 20 20 7b 20 22 63  fig[] = {.  { "c
0aa0: 73 73 22 2c 20 20 20 20 20 20 20 20 20 20 20 20  ss",            
0ab0: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0ac0: 54 5f 53 4b 49 4e 20 7d 2c 0a 20 20 7b 20 22 68  T_SKIN },.  { "h
0ad0: 65 61 64 65 72 22 2c 20 20 20 20 20 20 20 20 20  eader",         
0ae0: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0af0: 54 5f 53 4b 49 4e 20 7d 2c 0a 20 20 7b 20 22 66  T_SKIN },.  { "f
0b00: 6f 6f 74 65 72 22 2c 20 20 20 20 20 20 20 20 20  ooter",         
0b10: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0b20: 54 5f 53 4b 49 4e 20 7d 2c 0a 20 20 7b 20 22 70  T_SKIN },.  { "p
0b30: 72 6f 6a 65 63 74 2d 6e 61 6d 65 22 2c 20 20 20  roject-name",   
0b40: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0b50: 54 5f 50 52 4f 4a 20 7d 2c 0a 20 20 7b 20 22 70  T_PROJ },.  { "p
0b60: 72 6f 6a 65 63 74 2d 64 65 73 63 72 69 70 74 69  roject-descripti
0b70: 6f 6e 22 2c 20 20 20 20 43 4f 4e 46 49 47 53 45  on",    CONFIGSE
0b80: 54 5f 50 52 4f 4a 20 7d 2c 0a 20 20 7b 20 22 69  T_PROJ },.  { "i
0b90: 6e 64 65 78 2d 70 61 67 65 22 2c 20 20 20 20 20  ndex-page",     
0ba0: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0bb0: 54 5f 53 4b 49 4e 20 7d 2c 0a 20 20 7b 20 22 74  T_SKIN },.  { "t
0bc0: 69 6d 65 6c 69 6e 65 2d 62 6c 6f 63 6b 2d 6d 61  imeline-block-ma
0bd0: 72 6b 75 70 22 2c 20 20 43 4f 4e 46 49 47 53 45  rkup",  CONFIGSE
0be0: 54 5f 53 4b 49 4e 20 7d 2c 0a 20 20 7b 20 22 74  T_SKIN },.  { "t
0bf0: 69 6d 65 6c 69 6e 65 2d 6d 61 78 2d 63 6f 6d 6d  imeline-max-comm
0c00: 65 6e 74 22 2c 20 20 20 43 4f 4e 46 49 47 53 45  ent",   CONFIGSE
0c10: 54 5f 53 4b 49 4e 20 7d 2c 0a 20 20 7b 20 22 74  T_SKIN },.  { "t
0c20: 69 63 6b 65 74 2d 74 61 62 6c 65 22 2c 20 20 20  icket-table",   
0c30: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0c40: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 74  T_TKT  },.  { "t
0c50: 69 63 6b 65 74 2d 63 6f 6d 6d 6f 6e 22 2c 20 20  icket-common",  
0c60: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0c70: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 74  T_TKT  },.  { "t
0c80: 69 63 6b 65 74 2d 6e 65 77 70 61 67 65 22 2c 20  icket-newpage", 
0c90: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0ca0: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 74  T_TKT  },.  { "t
0cb0: 69 63 6b 65 74 2d 76 69 65 77 70 61 67 65 22 2c  icket-viewpage",
0cc0: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0cd0: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 74  T_TKT  },.  { "t
0ce0: 69 63 6b 65 74 2d 65 64 69 74 70 61 67 65 22 2c  icket-editpage",
0cf0: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0d00: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 74  T_TKT  },.  { "t
0d10: 69 63 6b 65 74 2d 72 65 70 6f 72 74 2d 74 65 6d  icket-report-tem
0d20: 70 6c 61 74 65 22 2c 20 43 4f 4e 46 49 47 53 45  plate", CONFIGSE
0d30: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 74  T_TKT  },.  { "t
0d40: 69 63 6b 65 74 2d 6b 65 79 2d 74 65 6d 70 6c 61  icket-key-templa
0d50: 74 65 22 2c 20 20 20 20 43 4f 4e 46 49 47 53 45  te",    CONFIGSE
0d60: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 74  T_TKT  },.  { "t
0d70: 69 63 6b 65 74 2d 74 69 74 6c 65 2d 65 78 70 72  icket-title-expr
0d80: 22 2c 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45  ",      CONFIGSE
0d90: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 74  T_TKT  },.  { "t
0da0: 69 63 6b 65 74 2d 63 6c 6f 73 65 64 2d 65 78 70  icket-closed-exp
0db0: 72 22 2c 20 20 20 20 20 43 4f 4e 46 49 47 53 45  r",     CONFIGSE
0dc0: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 40  T_TKT  },.  { "@
0dd0: 72 65 70 6f 72 74 66 6d 74 22 2c 20 20 20 20 20  reportfmt",     
0de0: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0df0: 54 5f 54 4b 54 20 20 7d 2c 0a 20 20 7b 20 22 40  T_TKT  },.  { "@
0e00: 75 73 65 72 22 2c 20 20 20 20 20 20 20 20 20 20  user",          
0e10: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0e20: 54 5f 55 53 45 52 20 7d 2c 0a 20 20 7b 20 22 40  T_USER },.  { "@
0e30: 73 68 75 6e 22 2c 20 20 20 20 20 20 20 20 20 20  shun",          
0e40: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0e50: 54 5f 53 48 55 4e 20 7d 2c 0a 7d 3b 0a 73 74 61  T_SHUN },.};.sta
0e60: 74 69 63 20 69 6e 74 20 69 43 6f 6e 66 69 67 20  tic int iConfig 
0e70: 3d 20 30 3b 0a 0a 2f 2a 0a 2a 2a 20 52 65 74 75  = 0;../*.** Retu
0e80: 72 6e 20 6e 61 6d 65 20 6f 66 20 66 69 72 73 74  rn name of first
0e90: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 70   configuration p
0ea0: 72 6f 70 65 72 74 79 20 6d 61 74 63 68 69 6e 67  roperty matching
0eb0: 20 74 68 65 20 67 69 76 65 6e 20 6d 61 73 6b 2e   the given mask.
0ec0: 0a 2a 2f 0a 63 6f 6e 73 74 20 63 68 61 72 20 2a  .*/.const char *
0ed0: 63 6f 6e 66 69 67 75 72 65 5f 66 69 72 73 74 5f  configure_first_
0ee0: 6e 61 6d 65 28 69 6e 74 20 69 4d 61 73 6b 29 7b  name(int iMask){
0ef0: 0a 20 20 69 43 6f 6e 66 69 67 20 3d 20 30 3b 0a  .  iConfig = 0;.
0f00: 20 20 72 65 74 75 72 6e 20 63 6f 6e 66 69 67 75    return configu
0f10: 72 65 5f 6e 65 78 74 5f 6e 61 6d 65 28 69 4d 61  re_next_name(iMa
0f20: 73 6b 29 3b 0a 7d 0a 63 6f 6e 73 74 20 63 68 61  sk);.}.const cha
0f30: 72 20 2a 63 6f 6e 66 69 67 75 72 65 5f 6e 65 78  r *configure_nex
0f40: 74 5f 6e 61 6d 65 28 69 6e 74 20 69 4d 61 73 6b  t_name(int iMask
0f50: 29 7b 0a 20 20 77 68 69 6c 65 28 20 69 43 6f 6e  ){.  while( iCon
0f60: 66 69 67 3c 63 6f 75 6e 74 28 61 43 6f 6e 66 69  fig<count(aConfi
0f70: 67 29 20 29 7b 0a 20 20 20 20 69 66 28 20 61 43  g) ){.    if( aC
0f80: 6f 6e 66 69 67 5b 69 43 6f 6e 66 69 67 5d 2e 67  onfig[iConfig].g
0f90: 72 6f 75 70 4d 61 73 6b 20 26 20 69 4d 61 73 6b  roupMask & iMask
0fa0: 20 29 7b 0a 20 20 20 20 20 20 72 65 74 75 72 6e   ){.      return
0fb0: 20 61 43 6f 6e 66 69 67 5b 69 43 6f 6e 66 69 67   aConfig[iConfig
0fc0: 2b 2b 5d 2e 7a 4e 61 6d 65 3b 0a 20 20 20 20 7d  ++].zName;.    }
0fd0: 65 6c 73 65 7b 0a 20 20 20 20 20 20 69 43 6f 6e  else{.      iCon
0fe0: 66 69 67 2b 2b 3b 0a 20 20 20 20 7d 0a 20 20 7d  fig++;.    }.  }
0ff0: 0a 20 20 72 65 74 75 72 6e 20 30 3b 0a 7d 0a 0a  .  return 0;.}..
1000: 2f 2a 0a 2a 2a 20 52 65 74 75 72 6e 20 74 68 65  /*.** Return the
1010: 20 6d 61 73 6b 20 66 6f 72 20 74 68 65 20 6e 61   mask for the na
1020: 6d 65 64 20 63 6f 6e 66 69 67 75 72 61 74 69 6f  med configuratio
1030: 6e 20 70 61 72 61 6d 65 74 65 72 20 69 66 20 69  n parameter if i
1040: 74 20 63 61 6e 20 62 65 0a 2a 2a 20 73 61 66 65  t can be.** safe
1050: 6c 79 20 65 78 70 6f 72 74 65 64 2e 20 20 52 65  ly exported.  Re
1060: 74 75 72 6e 20 30 20 69 66 20 74 68 65 20 70 61  turn 0 if the pa
1070: 72 61 6d 65 74 65 72 20 69 73 20 6e 6f 74 20 73  rameter is not s
1080: 61 66 65 20 74 6f 20 65 78 70 6f 72 74 2e 0a 2a  afe to export..*
1090: 2f 0a 69 6e 74 20 63 6f 6e 66 69 67 75 72 65 5f  /.int configure_
10a0: 69 73 5f 65 78 70 6f 72 74 61 62 6c 65 28 63 6f  is_exportable(co
10b0: 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 29  nst char *zName)
10c0: 7b 0a 20 20 69 6e 74 20 69 3b 0a 20 20 66 6f 72  {.  int i;.  for
10d0: 28 69 3d 30 3b 20 69 3c 63 6f 75 6e 74 28 61 43  (i=0; i<count(aC
10e0: 6f 6e 66 69 67 29 3b 20 69 2b 2b 29 7b 0a 20 20  onfig); i++){.  
10f0: 20 20 69 66 28 20 73 74 72 63 6d 70 28 7a 4e 61    if( strcmp(zNa
1100: 6d 65 2c 20 61 43 6f 6e 66 69 67 5b 69 5d 2e 7a  me, aConfig[i].z
1110: 4e 61 6d 65 29 3d 3d 30 20 29 7b 0a 20 20 20 20  Name)==0 ){.    
1120: 20 20 69 6e 74 20 6d 20 3d 20 61 43 6f 6e 66 69    int m = aConfi
1130: 67 5b 69 5d 2e 67 72 6f 75 70 4d 61 73 6b 3b 0a  g[i].groupMask;.
1140: 20 20 20 20 20 20 69 66 28 20 21 67 2e 6f 6b 41        if( !g.okA
1150: 64 6d 69 6e 20 29 7b 0a 20 20 20 20 20 20 20 20  dmin ){.        
1160: 6d 20 26 3d 20 7e 43 4f 4e 46 49 47 53 45 54 5f  m &= ~CONFIGSET_
1170: 55 53 45 52 3b 0a 20 20 20 20 20 20 7d 0a 20 20  USER;.      }.  
1180: 20 20 20 20 72 65 74 75 72 6e 20 6d 3b 0a 20 20      return m;.  
1190: 20 20 7d 0a 20 20 7d 0a 20 20 72 65 74 75 72 6e    }.  }.  return
11a0: 20 30 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 7a 4e 61   0;.}../*.** zNa
11b0: 6d 65 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65  me is one of the
11c0: 20 73 70 65 63 69 61 6c 20 63 6f 6e 66 69 67 75   special configu
11d0: 72 61 74 69 6f 6e 20 6e 61 6d 65 73 20 74 68 61  ration names tha
11e0: 74 20 72 65 66 65 72 73 20 74 6f 20 61 6e 20 65  t refers to an e
11f0: 6e 74 69 72 65 0a 2a 2a 20 74 61 62 6c 65 20 72  ntire.** table r
1200: 61 74 68 65 72 20 74 68 61 6e 20 61 20 73 69 6e  ather than a sin
1210: 67 6c 65 20 65 6e 74 72 79 20 69 6e 20 43 4f 4e  gle entry in CON
1220: 46 49 47 2e 20 20 53 70 65 63 69 61 6c 20 6e 61  FIG.  Special na
1230: 6d 65 73 20 61 72 65 20 22 40 72 65 70 6f 72 74  mes are "@report
1240: 66 6d 74 22 0a 2a 2a 20 61 6e 64 20 22 40 73 68  fmt".** and "@sh
1250: 75 6e 22 20 61 6e 64 20 22 40 75 73 65 72 22 2e  un" and "@user".
1260: 20 20 54 68 69 73 20 72 6f 75 74 69 6e 65 20 77    This routine w
1270: 72 69 74 65 73 20 53 51 4c 20 74 65 78 74 20 69  rites SQL text i
1280: 6e 74 6f 20 70 4f 75 74 20 74 68 61 74 20 77 68  nto pOut that wh
1290: 65 6e 0a 2a 2a 20 65 76 61 6c 75 61 74 65 64 20  en.** evaluated 
12a0: 77 69 6c 6c 20 70 6f 70 75 6c 61 74 65 20 74 68  will populate th
12b0: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20  e corresponding 
12c0: 74 61 62 6c 65 20 77 69 74 68 20 64 61 74 61 2e  table with data.
12d0: 0a 2a 2f 0a 76 6f 69 64 20 63 6f 6e 66 69 67 75  .*/.void configu
12e0: 72 65 5f 72 65 6e 64 65 72 5f 73 70 65 63 69 61  re_render_specia
12f0: 6c 5f 6e 61 6d 65 28 63 6f 6e 73 74 20 63 68 61  l_name(const cha
1300: 72 20 2a 7a 4e 61 6d 65 2c 20 42 6c 6f 62 20 2a  r *zName, Blob *
1310: 70 4f 75 74 29 7b 0a 20 20 53 74 6d 74 20 71 3b  pOut){.  Stmt q;
1320: 0a 20 20 69 66 28 20 73 74 72 63 6d 70 28 7a 4e  .  if( strcmp(zN
1330: 61 6d 65 2c 20 22 40 73 68 75 6e 22 29 3d 3d 30  ame, "@shun")==0
1340: 20 29 7b 0a 20 20 20 20 64 62 5f 70 72 65 70 61   ){.    db_prepa
1350: 72 65 28 26 71 2c 20 22 53 45 4c 45 43 54 20 75  re(&q, "SELECT u
1360: 75 69 64 20 46 52 4f 4d 20 73 68 75 6e 22 29 3b  uid FROM shun");
1370: 0a 20 20 20 20 77 68 69 6c 65 28 20 64 62 5f 73  .    while( db_s
1380: 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f  tep(&q)==SQLITE_
1390: 52 4f 57 20 29 7b 0a 20 20 20 20 20 20 62 6c 6f  ROW ){.      blo
13a0: 62 5f 61 70 70 65 6e 64 66 28 70 4f 75 74 2c 20  b_appendf(pOut, 
13b0: 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52  "INSERT OR IGNOR
13c0: 45 20 49 4e 54 4f 20 73 68 75 6e 20 56 41 4c 55  E INTO shun VALU
13d0: 45 53 28 27 25 73 27 29 3b 5c 6e 22 2c 20 0a 20  ES('%s');\n", . 
13e0: 20 20 20 20 20 20 20 64 62 5f 63 6f 6c 75 6d 6e         db_column
13f0: 5f 74 65 78 74 28 26 71 2c 20 30 29 0a 20 20 20  _text(&q, 0).   
1400: 20 20 20 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20     );.    }.    
1410: 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b  db_finalize(&q);
1420: 0a 20 20 7d 65 6c 73 65 20 69 66 28 20 73 74 72  .  }else if( str
1430: 63 6d 70 28 7a 4e 61 6d 65 2c 20 22 40 72 65 70  cmp(zName, "@rep
1440: 6f 72 74 66 6d 74 22 29 3d 3d 30 20 29 7b 0a 20  ortfmt")==0 ){. 
1450: 20 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71     db_prepare(&q
1460: 2c 20 22 53 45 4c 45 43 54 20 74 69 74 6c 65 2c  , "SELECT title,
1470: 20 63 6f 6c 73 2c 20 73 71 6c 63 6f 64 65 20 46   cols, sqlcode F
1480: 52 4f 4d 20 72 65 70 6f 72 74 66 6d 74 22 29 3b  ROM reportfmt");
1490: 0a 20 20 20 20 77 68 69 6c 65 28 20 64 62 5f 73  .    while( db_s
14a0: 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f  tep(&q)==SQLITE_
14b0: 52 4f 57 20 29 7b 0a 20 20 20 20 20 20 62 6c 6f  ROW ){.      blo
14c0: 62 5f 61 70 70 65 6e 64 66 28 70 4f 75 74 2c 20  b_appendf(pOut, 
14d0: 22 49 4e 53 45 52 54 20 49 4e 54 4f 20 5f 78 66  "INSERT INTO _xf
14e0: 65 72 5f 72 65 70 6f 72 74 66 6d 74 28 74 69 74  er_reportfmt(tit
14f0: 6c 65 2c 63 6f 6c 73 2c 73 71 6c 63 6f 64 65 29  le,cols,sqlcode)
1500: 20 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20   ".             
1510: 20 20 20 20 20 20 20 20 20 20 20 20 22 20 56 41              " VA
1520: 4c 55 45 53 28 25 51 2c 25 51 2c 25 51 29 3b 5c  LUES(%Q,%Q,%Q);\
1530: 6e 22 2c 20 0a 20 20 20 20 20 20 20 20 64 62 5f  n", .        db_
1540: 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20  column_text(&q, 
1550: 30 29 2c 0a 20 20 20 20 20 20 20 20 64 62 5f 63  0),.        db_c
1560: 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 31  olumn_text(&q, 1
1570: 29 2c 0a 20 20 20 20 20 20 20 20 64 62 5f 63 6f  ),.        db_co
1580: 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 32 29  lumn_text(&q, 2)
1590: 0a 20 20 20 20 20 20 29 3b 0a 20 20 20 20 7d 0a  .      );.    }.
15a0: 20 20 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28      db_finalize(
15b0: 26 71 29 3b 0a 20 20 7d 65 6c 73 65 20 69 66 28  &q);.  }else if(
15c0: 20 73 74 72 63 6d 70 28 7a 4e 61 6d 65 2c 20 22   strcmp(zName, "
15d0: 40 75 73 65 72 22 29 3d 3d 30 20 29 7b 0a 20 20  @user")==0 ){.  
15e0: 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c    db_prepare(&q,
15f0: 20 22 53 45 4c 45 43 54 20 6c 6f 67 69 6e 2c 20   "SELECT login, 
1600: 63 61 70 2c 20 69 6e 66 6f 2c 20 71 75 6f 74 65  cap, info, quote
1610: 28 70 68 6f 74 6f 29 20 46 52 4f 4d 20 75 73 65  (photo) FROM use
1620: 72 22 29 3b 0a 20 20 20 20 77 68 69 6c 65 28 20  r");.    while( 
1630: 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51 4c  db_step(&q)==SQL
1640: 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 20  ITE_ROW ){.     
1650: 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 70 4f   blob_appendf(pO
1660: 75 74 2c 20 22 49 4e 53 45 52 54 20 49 4e 54 4f  ut, "INSERT INTO
1670: 20 5f 78 66 65 72 5f 75 73 65 72 28 6c 6f 67 69   _xfer_user(logi
1680: 6e 2c 63 61 70 2c 69 6e 66 6f 2c 70 68 6f 74 6f  n,cap,info,photo
1690: 29 20 22 0a 20 20 20 20 20 20 20 20 20 20 20 20  ) ".            
16a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 20 56               " V
16b0: 41 4c 55 45 53 28 25 51 2c 25 51 2c 25 51 2c 25  ALUES(%Q,%Q,%Q,%
16c0: 73 29 3b 5c 6e 22 2c 0a 20 20 20 20 20 20 20 20  s);\n",.        
16d0: 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26  db_column_text(&
16e0: 71 2c 20 30 29 2c 0a 20 20 20 20 20 20 20 20 64  q, 0),.        d
16f0: 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71  b_column_text(&q
1700: 2c 20 31 29 2c 0a 20 20 20 20 20 20 20 20 64 62  , 1),.        db
1710: 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c  _column_text(&q,
1720: 20 32 29 2c 0a 20 20 20 20 20 20 20 20 64 62 5f   2),.        db_
1730: 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20  column_text(&q, 
1740: 33 29 0a 20 20 20 20 20 20 29 3b 0a 20 20 20 20  3).      );.    
1750: 7d 0a 20 20 20 20 64 62 5f 66 69 6e 61 6c 69 7a  }.    db_finaliz
1760: 65 28 26 71 29 3b 0a 20 20 7d 0a 7d 0a 0a 2f 2a  e(&q);.  }.}../*
1770: 0a 2a 2a 20 54 77 6f 20 53 51 4c 20 66 75 6e 63  .** Two SQL func
1780: 74 69 6f 6e 73 3a 0a 2a 2a 0a 2a 2a 20 20 20 20  tions:.**.**    
1790: 20 20 20 20 66 6c 61 67 5f 74 65 73 74 28 69 6e      flag_test(in
17a0: 74 29 0a 2a 2a 20 20 20 20 20 20 20 20 66 6c 61  t).**        fla
17b0: 67 5f 63 6c 65 61 72 28 69 6e 74 29 0a 2a 2a 0a  g_clear(int).**.
17c0: 2a 2a 20 54 68 65 20 66 6c 61 67 5f 74 65 73 74  ** The flag_test
17d0: 28 29 20 66 75 6e 63 74 69 6f 6e 20 74 61 6b 65  () function take
17e0: 73 20 74 68 65 20 69 6e 74 65 67 65 72 20 76 61  s the integer va
17f0: 6c 75 65 64 20 61 72 67 75 6d 65 6e 74 20 61 6e  lued argument an
1800: 64 0a 2a 2a 20 41 4e 44 73 20 69 74 20 61 67 61  d.** ANDs it aga
1810: 69 6e 73 74 20 74 68 65 20 73 74 61 74 69 63 20  inst the static 
1820: 76 61 72 69 61 62 6c 65 20 22 66 6c 61 67 5f 76  variable "flag_v
1830: 61 6c 75 65 22 20 62 65 6c 6f 77 2e 20 20 54 68  alue" below.  Th
1840: 65 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 72 65  e.** function re
1850: 74 75 72 6e 73 20 54 52 55 45 20 6f 72 20 66 61  turns TRUE or fa
1860: 6c 73 65 20 64 65 70 65 6e 64 69 6e 67 20 6f 6e  lse depending on
1870: 20 74 68 65 20 72 65 73 75 6c 74 2e 20 20 54 68   the result.  Th
1880: 65 0a 2a 2a 20 66 6c 61 67 5f 63 6c 65 61 72 28  e.** flag_clear(
1890: 29 20 66 75 6e 63 74 69 6f 6e 20 6d 61 73 6b 73  ) function masks
18a0: 20 6f 66 66 20 74 68 65 20 62 69 74 73 20 66 72   off the bits fr
18b0: 6f 6d 20 22 66 6c 61 67 5f 76 61 6c 75 65 22 20  om "flag_value" 
18c0: 74 68 61 74 0a 2a 2a 20 61 72 65 20 67 69 76 65  that.** are give
18d0: 6e 20 69 6e 20 74 68 65 20 61 72 67 75 6d 65 6e  n in the argumen
18e0: 74 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 66  t..**.** These f
18f0: 75 6e 63 74 69 6f 6e 73 20 61 72 65 20 75 73 65  unctions are use
1900: 64 20 62 65 6c 6f 77 20 69 6e 20 74 68 65 20 57  d below in the W
1910: 48 45 4e 20 63 6c 61 75 73 65 20 6f 66 20 61 20  HEN clause of a 
1920: 74 72 69 67 67 65 72 20 74 6f 0a 2a 2a 20 67 65  trigger to.** ge
1930: 74 20 74 68 65 20 74 72 69 67 67 65 72 20 74 6f  t the trigger to
1940: 20 66 69 72 65 20 65 78 61 63 74 6c 79 20 6f 6e   fire exactly on
1950: 63 65 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 69 6e  ce..*/.static in
1960: 74 20 66 6c 61 67 5f 76 61 6c 75 65 20 3d 20 30  t flag_value = 0
1970: 78 66 66 66 66 3b 0a 73 74 61 74 69 63 20 76 6f  xffff;.static vo
1980: 69 64 20 66 6c 61 67 5f 74 65 73 74 5f 66 75 6e  id flag_test_fun
1990: 63 74 69 6f 6e 28 0a 20 20 73 71 6c 69 74 65 33  ction(.  sqlite3
19a0: 5f 63 6f 6e 74 65 78 74 20 2a 63 6f 6e 74 65 78  _context *contex
19b0: 74 2c 0a 20 20 69 6e 74 20 61 72 67 63 2c 0a 20  t,.  int argc,. 
19c0: 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 2a   sqlite3_value *
19d0: 2a 61 72 67 76 0a 29 7b 0a 20 20 69 6e 74 20 6d  *argv.){.  int m
19e0: 20 3d 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65   = sqlite3_value
19f0: 5f 69 6e 74 28 61 72 67 76 5b 30 5d 29 3b 0a 20  _int(argv[0]);. 
1a00: 20 73 71 6c 69 74 65 33 5f 72 65 73 75 6c 74 5f   sqlite3_result_
1a10: 69 6e 74 28 63 6f 6e 74 65 78 74 2c 20 28 66 6c  int(context, (fl
1a20: 61 67 5f 76 61 6c 75 65 26 6d 29 21 3d 30 20 29  ag_value&m)!=0 )
1a30: 3b 0a 7d 0a 73 74 61 74 69 63 20 76 6f 69 64 20  ;.}.static void 
1a40: 66 6c 61 67 5f 63 6c 65 61 72 5f 66 75 6e 63 74  flag_clear_funct
1a50: 69 6f 6e 28 0a 20 20 73 71 6c 69 74 65 33 5f 63  ion(.  sqlite3_c
1a60: 6f 6e 74 65 78 74 20 2a 63 6f 6e 74 65 78 74 2c  ontext *context,
1a70: 0a 20 20 69 6e 74 20 61 72 67 63 2c 0a 20 20 73  .  int argc,.  s
1a80: 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 2a 2a 61  qlite3_value **a
1a90: 72 67 76 0a 29 7b 0a 20 20 69 6e 74 20 6d 20 3d  rgv.){.  int m =
1aa0: 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 69   sqlite3_value_i
1ab0: 6e 74 28 61 72 67 76 5b 30 5d 29 3b 0a 20 20 66  nt(argv[0]);.  f
1ac0: 6c 61 67 5f 76 61 6c 75 65 20 26 3d 20 7e 6d 3b  lag_value &= ~m;
1ad0: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 72 65 61 74 65  .}../*.** Create
1ae0: 20 74 68 65 20 74 65 6d 70 6f 72 61 72 79 20 5f   the temporary _
1af0: 78 66 65 72 5f 72 65 70 6f 72 74 66 6d 74 20 61  xfer_reportfmt a
1b00: 6e 64 20 5f 78 66 65 72 5f 75 73 65 72 20 74 61  nd _xfer_user ta
1b10: 62 6c 65 73 20 74 68 61 74 20 61 72 65 0a 2a 2a  bles that are.**
1b20: 20 6e 65 63 65 73 73 61 72 79 20 69 6e 20 6f 72   necessary in or
1b30: 64 65 72 20 74 6f 20 65 76 61 6c 75 74 65 20 74  der to evalute t
1b40: 68 65 20 53 51 4c 20 74 65 78 74 20 67 65 6e 65  he SQL text gene
1b50: 72 61 74 65 64 20 62 79 20 74 68 65 0a 2a 2a 20  rated by the.** 
1b60: 63 6f 6e 66 69 67 75 72 65 5f 72 65 6e 64 65 72  configure_render
1b70: 5f 73 70 65 63 69 61 6c 5f 6e 61 6d 65 28 29 20  _special_name() 
1b80: 72 6f 75 74 69 6e 65 2e 0a 2a 2a 0a 2a 2a 20 49  routine..**.** I
1b90: 66 20 72 65 70 6c 61 63 65 46 6c 61 67 20 69 73  f replaceFlag is
1ba0: 20 74 72 75 65 2c 20 74 68 65 6e 20 74 68 65 20   true, then the 
1bb0: 73 65 74 75 70 20 69 73 20 73 75 63 68 20 74 68  setup is such th
1bc0: 61 74 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 69  at the content i
1bd0: 6e 0a 2a 2a 20 74 68 65 20 53 51 4c 20 74 65 78  n.** the SQL tex
1be0: 74 20 77 69 6c 6c 20 63 6f 6d 70 6c 65 74 65 6c  t will completel
1bf0: 79 20 72 65 70 6c 61 63 65 20 74 68 65 20 63 75  y replace the cu
1c00: 72 72 65 6e 74 20 72 65 70 6f 73 69 74 6f 72 79  rrent repository
1c10: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 2e 0a   configuration..
1c20: 2a 2a 20 49 66 20 72 65 70 6c 61 63 65 46 6c 61  ** If replaceFla
1c30: 67 20 69 73 20 66 61 6c 73 65 2c 20 74 68 65 6e  g is false, then
1c40: 20 74 68 65 20 53 51 4c 20 74 65 78 74 20 77 69   the SQL text wi
1c50: 6c 6c 20 62 65 20 6d 65 72 67 65 64 20 77 69 74  ll be merged wit
1c60: 68 20 74 68 65 0a 2a 2a 20 65 78 69 73 74 69 6e  h the.** existin
1c70: 67 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 2e  g configuration.
1c80: 20 20 57 68 65 6e 20 6d 65 72 67 69 6e 67 2c 20    When merging, 
1c90: 65 78 69 73 74 69 6e 67 20 76 61 6c 75 65 73 20  existing values 
1ca0: 74 61 6b 65 20 70 72 69 6f 72 69 74 79 0a 2a 2a  take priority.**
1cb0: 20 6f 76 65 72 20 53 51 4c 20 74 65 78 74 20 76   over SQL text v
1cc0: 61 6c 75 65 73 2e 0a 2a 2f 0a 76 6f 69 64 20 63  alues..*/.void c
1cd0: 6f 6e 66 69 67 75 72 65 5f 70 72 65 70 61 72 65  onfigure_prepare
1ce0: 5f 74 6f 5f 72 65 63 65 69 76 65 28 69 6e 74 20  _to_receive(int 
1cf0: 72 65 70 6c 61 63 65 46 6c 61 67 29 7b 0a 20 20  replaceFlag){.  
1d00: 73 74 61 74 69 63 20 63 6f 6e 73 74 20 63 68 61  static const cha
1d10: 72 20 7a 53 51 4c 31 5b 5d 20 3d 0a 20 20 20 20  r zSQL1[] =.    
1d20: 40 20 43 52 45 41 54 45 20 54 45 4d 50 20 54 41  @ CREATE TEMP TA
1d30: 42 4c 45 20 5f 78 66 65 72 5f 72 65 70 6f 72 74  BLE _xfer_report
1d40: 66 6d 74 28 0a 20 20 20 20 40 20 20 20 20 72 6e  fmt(.    @    rn
1d50: 20 69 6e 74 65 67 65 72 20 70 72 69 6d 61 72 79   integer primary
1d60: 20 6b 65 79 2c 20 20 2d 2d 20 52 65 70 6f 72 74   key,  -- Report
1d70: 20 6e 75 6d 62 65 72 0a 20 20 20 20 40 20 20 20   number.    @   
1d80: 20 6f 77 6e 65 72 20 74 65 78 74 2c 20 20 20 20   owner text,    
1d90: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 4f 77 6e            -- Own
1da0: 65 72 20 6f 66 20 74 68 69 73 20 72 65 70 6f 72  er of this repor
1db0: 74 20 66 6f 72 6d 61 74 20 28 6e 6f 74 20 75 73  t format (not us
1dc0: 65 64 29 0a 20 20 20 20 40 20 20 20 20 74 69 74  ed).    @    tit
1dd0: 6c 65 20 74 65 78 74 20 55 4e 49 51 55 45 20 4f  le text UNIQUE O
1de0: 4e 20 43 4f 4e 46 4c 49 43 54 20 49 47 4e 4f 52  N CONFLICT IGNOR
1df0: 45 2c 20 20 2d 2d 20 54 69 74 6c 65 20 6f 66 20  E,  -- Title of 
1e00: 74 68 69 73 20 72 65 70 6f 72 74 0a 20 20 20 20  this report.    
1e10: 40 20 20 20 20 63 6f 6c 73 20 74 65 78 74 2c 20  @    cols text, 
1e20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d                --
1e30: 20 41 20 63 6f 6c 6f 72 2d 6b 65 79 20 73 70 65   A color-key spe
1e40: 63 69 66 69 63 61 74 69 6f 6e 0a 20 20 20 20 40  cification.    @
1e50: 20 20 20 20 73 71 6c 63 6f 64 65 20 74 65 78 74      sqlcode text
1e60: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20               -- 
1e70: 41 6e 20 53 51 4c 20 53 45 4c 45 43 54 20 73 74  An SQL SELECT st
1e80: 61 74 65 6d 65 6e 74 20 66 6f 72 20 74 68 69 73  atement for this
1e90: 20 72 65 70 6f 72 74 0a 20 20 20 20 40 20 29 3b   report.    @ );
1ea0: 0a 20 20 20 20 40 20 43 52 45 41 54 45 20 54 45  .    @ CREATE TE
1eb0: 4d 50 20 54 41 42 4c 45 20 5f 78 66 65 72 5f 75  MP TABLE _xfer_u
1ec0: 73 65 72 28 0a 20 20 20 20 40 20 20 20 75 69 64  ser(.    @   uid
1ed0: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59   INTEGER PRIMARY
1ee0: 20 4b 45 59 2c 20 20 20 20 20 20 20 20 2d 2d 20   KEY,        -- 
1ef0: 55 73 65 72 20 49 44 0a 20 20 20 20 40 20 20 20  User ID.    @   
1f00: 6c 6f 67 69 6e 20 54 45 58 54 20 55 4e 49 51 55  login TEXT UNIQU
1f10: 45 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 20 49 47  E ON CONFLICT IG
1f20: 4e 4f 52 45 2c 20 20 20 2d 2d 20 6c 6f 67 69 6e  NORE,   -- login
1f30: 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 75 73 65   name of the use
1f40: 72 0a 20 20 20 20 40 20 20 20 70 77 20 54 45 58  r.    @   pw TEX
1f50: 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20  T,              
1f60: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 70 61 73            -- pas
1f70: 73 77 6f 72 64 0a 20 20 20 20 40 20 20 20 63 61  sword.    @   ca
1f80: 70 20 54 45 58 54 2c 20 20 20 20 20 20 20 20 20  p TEXT,         
1f90: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d                --
1fa0: 20 43 61 70 61 62 69 6c 69 74 69 65 73 20 6f 66   Capabilities of
1fb0: 20 74 68 69 73 20 75 73 65 72 0a 20 20 20 20 40   this user.    @
1fc0: 20 20 20 63 6f 6f 6b 69 65 20 54 45 58 54 2c 20     cookie TEXT, 
1fd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1fe0: 20 20 20 2d 2d 20 57 57 57 20 6c 6f 67 69 6e 20     -- WWW login 
1ff0: 63 6f 6f 6b 69 65 0a 20 20 20 20 40 20 20 20 69  cookie.    @   i
2000: 70 61 64 64 72 20 54 45 58 54 2c 20 20 20 20 20  paddr TEXT,     
2010: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d                 -
2020: 2d 20 49 50 20 61 64 64 72 65 73 73 20 66 6f 72  - IP address for
2030: 20 77 68 69 63 68 20 63 6f 6f 6b 69 65 20 69 73   which cookie is
2040: 20 76 61 6c 69 64 0a 20 20 20 20 40 20 20 20 63   valid.    @   c
2050: 65 78 70 69 72 65 20 44 41 54 45 54 49 4d 45 2c  expire DATETIME,
2060: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d                 -
2070: 2d 20 54 69 6d 65 20 77 68 65 6e 20 63 6f 6f 6b  - Time when cook
2080: 69 65 20 65 78 70 69 72 65 73 0a 20 20 20 20 40  ie expires.    @
2090: 20 20 20 69 6e 66 6f 20 54 45 58 54 2c 20 20 20     info TEXT,   
20a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
20b0: 20 20 20 2d 2d 20 63 6f 6e 74 61 63 74 20 69 6e     -- contact in
20c0: 66 6f 72 6d 61 74 69 6f 6e 0a 20 20 20 20 40 20  formation.    @ 
20d0: 20 20 70 68 6f 74 6f 20 42 4c 4f 42 20 20 20 20    photo BLOB    
20e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
20f0: 20 20 2d 2d 20 4a 50 45 47 20 69 6d 61 67 65 20    -- JPEG image 
2100: 6f 66 20 74 68 69 73 20 75 73 65 72 0a 20 20 20  of this user.   
2110: 20 40 20 29 3b 0a 20 20 20 20 40 20 49 4e 53 45   @ );.    @ INSE
2120: 52 54 20 49 4e 54 4f 20 5f 78 66 65 72 5f 72 65  RT INTO _xfer_re
2130: 70 6f 72 74 66 6d 74 20 53 45 4c 45 43 54 20 2a  portfmt SELECT *
2140: 20 46 52 4f 4d 20 72 65 70 6f 72 74 66 6d 74 3b   FROM reportfmt;
2150: 0a 20 20 20 20 40 20 49 4e 53 45 52 54 20 49 4e  .    @ INSERT IN
2160: 54 4f 20 5f 78 66 65 72 5f 75 73 65 72 20 53 45  TO _xfer_user SE
2170: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 75 73 65 72  LECT * FROM user
2180: 3b 0a 20 20 3b 0a 20 20 64 62 5f 6d 75 6c 74 69  ;.  ;.  db_multi
2190: 5f 65 78 65 63 28 7a 53 51 4c 31 29 3b 0a 20 20  _exec(zSQL1);.  
21a0: 0a 20 20 2f 2a 20 57 68 65 6e 20 74 68 65 20 72  .  /* When the r
21b0: 65 70 6c 61 63 65 20 66 6c 61 67 20 69 73 20 73  eplace flag is s
21c0: 65 74 2c 20 61 64 64 20 74 72 69 67 67 65 72 73  et, add triggers
21d0: 20 74 68 61 74 20 72 75 6e 20 74 68 65 20 66 69   that run the fi
21e0: 72 73 74 20 74 69 6d 65 0a 20 20 2a 2a 20 74 68  rst time.  ** th
21f0: 61 74 20 6e 65 77 20 64 61 74 61 20 69 73 20 73  at new data is s
2200: 65 65 6e 2e 20 20 54 68 65 20 74 72 69 67 67 65  een.  The trigge
2210: 72 73 20 72 75 6e 20 6f 6e 6c 79 20 6f 6e 63 65  rs run only once
2220: 20 61 6e 64 20 64 65 6c 65 74 65 20 61 6c 6c 20   and delete all 
2230: 74 68 65 0a 20 20 2a 2a 20 65 78 69 73 74 69 6e  the.  ** existin
2240: 67 20 64 61 74 61 2e 0a 20 20 2a 2f 0a 20 20 69  g data..  */.  i
2250: 66 28 20 72 65 70 6c 61 63 65 46 6c 61 67 20 29  f( replaceFlag )
2260: 7b 0a 20 20 20 20 73 74 61 74 69 63 20 63 6f 6e  {.    static con
2270: 73 74 20 63 68 61 72 20 7a 53 51 4c 32 5b 5d 20  st char zSQL2[] 
2280: 3d 0a 20 20 20 20 20 20 40 20 43 52 45 41 54 45  =.      @ CREATE
2290: 20 54 52 49 47 47 45 52 20 5f 78 66 65 72 5f 72   TRIGGER _xfer_r
22a0: 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
22b0: 4f 4e 20 5f 78 66 65 72 5f 72 65 70 6f 72 74 66  ON _xfer_reportf
22c0: 6d 74 0a 20 20 20 20 20 20 40 20 57 48 45 4e 20  mt.      @ WHEN 
22d0: 66 6c 61 67 5f 74 65 73 74 28 31 29 20 42 45 47  flag_test(1) BEG
22e0: 49 4e 0a 20 20 20 20 20 20 40 20 20 20 44 45 4c  IN.      @   DEL
22f0: 45 54 45 20 46 52 4f 4d 20 5f 78 66 65 72 5f 72  ETE FROM _xfer_r
2300: 65 70 6f 72 74 66 6d 74 3b 0a 20 20 20 20 20 20  eportfmt;.      
2310: 40 20 20 20 53 45 4c 45 43 54 20 66 6c 61 67 5f  @   SELECT flag_
2320: 63 6c 65 61 72 28 31 29 3b 0a 20 20 20 20 20 20  clear(1);.      
2330: 40 20 45 4e 44 3b 0a 20 20 20 20 20 20 40 20 43  @ END;.      @ C
2340: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 5f 78  REATE TRIGGER _x
2350: 66 65 72 5f 72 32 20 42 45 46 4f 52 45 20 49 4e  fer_r2 BEFORE IN
2360: 53 45 52 54 20 4f 4e 20 5f 78 66 65 72 5f 75 73  SERT ON _xfer_us
2370: 65 72 0a 20 20 20 20 20 20 40 20 57 48 45 4e 20  er.      @ WHEN 
2380: 66 6c 61 67 5f 74 65 73 74 28 32 29 20 42 45 47  flag_test(2) BEG
2390: 49 4e 0a 20 20 20 20 20 20 40 20 20 20 44 45 4c  IN.      @   DEL
23a0: 45 54 45 20 46 52 4f 4d 20 5f 78 66 65 72 5f 75  ETE FROM _xfer_u
23b0: 73 65 72 3b 0a 20 20 20 20 20 20 40 20 20 20 53  ser;.      @   S
23c0: 45 4c 45 43 54 20 66 6c 61 67 5f 63 6c 65 61 72  ELECT flag_clear
23d0: 28 32 29 3b 0a 20 20 20 20 20 20 40 20 45 4e 44  (2);.      @ END
23e0: 3b 0a 20 20 20 20 20 20 40 20 43 52 45 41 54 45  ;.      @ CREATE
23f0: 20 54 45 4d 50 20 54 52 49 47 47 45 52 20 5f 78   TEMP TRIGGER _x
2400: 66 65 72 5f 72 33 20 42 45 46 4f 52 45 20 49 4e  fer_r3 BEFORE IN
2410: 53 45 52 54 20 4f 4e 20 73 68 75 6e 0a 20 20 20  SERT ON shun.   
2420: 20 20 20 40 20 57 48 45 4e 20 66 6c 61 67 5f 74     @ WHEN flag_t
2430: 65 73 74 28 34 29 20 42 45 47 49 4e 0a 20 20 20  est(4) BEGIN.   
2440: 20 20 20 40 20 20 20 44 45 4c 45 54 45 20 46 52     @   DELETE FR
2450: 4f 4d 20 73 68 75 6e 3b 0a 20 20 20 20 20 20 40  OM shun;.      @
2460: 20 20 20 53 45 4c 45 43 54 20 66 6c 61 67 5f 63     SELECT flag_c
2470: 6c 65 61 72 28 34 29 3b 0a 20 20 20 20 20 20 40  lear(4);.      @
2480: 20 45 4e 44 3b 0a 20 20 20 20 3b 0a 20 20 20 20   END;.    ;.    
2490: 73 71 6c 69 74 65 33 5f 63 72 65 61 74 65 5f 66  sqlite3_create_f
24a0: 75 6e 63 74 69 6f 6e 28 67 2e 64 62 2c 20 22 66  unction(g.db, "f
24b0: 6c 61 67 5f 74 65 73 74 22 2c 20 31 2c 20 53 51  lag_test", 1, SQ
24c0: 4c 49 54 45 5f 55 54 46 38 2c 20 30 2c 0a 20 20  LITE_UTF8, 0,.  
24d0: 20 20 20 20 20 20 20 66 6c 61 67 5f 74 65 73 74         flag_test
24e0: 5f 66 75 6e 63 74 69 6f 6e 2c 20 30 2c 20 30 29  _function, 0, 0)
24f0: 3b 0a 20 20 20 20 73 71 6c 69 74 65 33 5f 63 72  ;.    sqlite3_cr
2500: 65 61 74 65 5f 66 75 6e 63 74 69 6f 6e 28 67 2e  eate_function(g.
2510: 64 62 2c 20 22 66 6c 61 67 5f 63 6c 65 61 72 22  db, "flag_clear"
2520: 2c 20 31 2c 20 53 51 4c 49 54 45 5f 55 54 46 38  , 1, SQLITE_UTF8
2530: 2c 20 30 2c 0a 20 20 20 20 20 20 20 20 20 66 6c  , 0,.         fl
2540: 61 67 5f 63 6c 65 61 72 5f 66 75 6e 63 74 69 6f  ag_clear_functio
2550: 6e 2c 20 30 2c 20 30 29 3b 0a 20 20 20 20 66 6c  n, 0, 0);.    fl
2560: 61 67 5f 76 61 6c 75 65 20 3d 20 30 78 66 66 66  ag_value = 0xfff
2570: 66 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f  f;.    db_multi_
2580: 65 78 65 63 28 7a 53 51 4c 32 29 3b 0a 20 20 7d  exec(zSQL2);.  }
2590: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 41 66 74 65 72 20  .}../*.** After 
25a0: 72 65 63 65 69 76 69 6e 67 20 63 6f 6e 66 69 67  receiving config
25b0: 75 72 61 74 69 6f 6e 20 64 61 74 61 2c 20 63 61  uration data, ca
25c0: 6c 6c 20 74 68 69 73 20 72 6f 75 74 69 6e 65 20  ll this routine 
25d0: 74 6f 20 74 72 61 6e 73 66 65 72 0a 2a 2a 20 74  to transfer.** t
25e0: 68 65 20 72 65 73 75 6c 74 73 20 69 6e 74 6f 20  he results into 
25f0: 74 68 65 20 6d 61 69 6e 20 64 61 74 61 62 61 73  the main databas
2600: 65 2e 0a 2a 2f 0a 76 6f 69 64 20 63 6f 6e 66 69  e..*/.void confi
2610: 67 75 72 65 5f 66 69 6e 61 6c 69 7a 65 5f 72 65  gure_finalize_re
2620: 63 65 69 76 65 28 76 6f 69 64 29 7b 0a 20 20 73  ceive(void){.  s
2630: 74 61 74 69 63 20 63 6f 6e 73 74 20 63 68 61 72  tatic const char
2640: 20 7a 53 51 4c 5b 5d 20 3d 0a 20 20 20 20 40 20   zSQL[] =.    @ 
2650: 44 45 4c 45 54 45 20 46 52 4f 4d 20 75 73 65 72  DELETE FROM user
2660: 3b 0a 20 20 20 20 40 20 49 4e 53 45 52 54 20 49  ;.    @ INSERT I
2670: 4e 54 4f 20 75 73 65 72 20 53 45 4c 45 43 54 20  NTO user SELECT 
2680: 2a 20 46 52 4f 4d 20 5f 78 66 65 72 5f 75 73 65  * FROM _xfer_use
2690: 72 3b 0a 20 20 20 20 40 20 44 45 4c 45 54 45 20  r;.    @ DELETE 
26a0: 46 52 4f 4d 20 72 65 70 6f 72 74 66 6d 74 3b 0a  FROM reportfmt;.
26b0: 20 20 20 20 40 20 49 4e 53 45 52 54 20 49 4e 54      @ INSERT INT
26c0: 4f 20 72 65 70 6f 72 74 66 6d 74 20 53 45 4c 45  O reportfmt SELE
26d0: 43 54 20 2a 20 46 52 4f 4d 20 5f 78 66 65 72 5f  CT * FROM _xfer_
26e0: 72 65 70 6f 72 74 66 6d 74 3b 0a 20 20 20 20 40  reportfmt;.    @
26f0: 20 44 52 4f 50 20 54 41 42 4c 45 20 5f 78 66 65   DROP TABLE _xfe
2700: 72 5f 75 73 65 72 3b 0a 20 20 20 20 40 20 44 52  r_user;.    @ DR
2710: 4f 50 20 54 41 42 4c 45 20 5f 78 66 65 72 5f 72  OP TABLE _xfer_r
2720: 65 70 6f 72 74 66 6d 74 3b 0a 20 20 3b 0a 20 20  eportfmt;.  ;.  
2730: 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 7a 53  db_multi_exec(zS
2740: 51 4c 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 49 64  QL);.}../*.** Id
2750: 65 6e 74 69 66 79 20 61 20 63 6f 6e 66 69 67 75  entify a configu
2760: 72 61 74 69 6f 6e 20 67 72 6f 75 70 20 62 79 20  ration group by 
2770: 6e 61 6d 65 2e 20 20 52 65 74 75 72 6e 20 69 74  name.  Return it
2780: 73 20 6d 61 73 6b 2e 0a 2a 2a 20 54 68 72 6f 77  s mask..** Throw
2790: 20 61 6e 20 65 72 72 6f 72 20 69 66 20 6e 6f 20   an error if no 
27a0: 6d 61 74 63 68 2e 0a 2a 2f 0a 73 74 61 74 69 63  match..*/.static
27b0: 20 69 6e 74 20 66 69 6e 64 5f 61 72 65 61 28 63   int find_area(c
27c0: 6f 6e 73 74 20 63 68 61 72 20 2a 7a 29 7b 0a 20  onst char *z){. 
27d0: 20 69 6e 74 20 69 3b 0a 20 20 69 6e 74 20 6e 20   int i;.  int n 
27e0: 3d 20 73 74 72 6c 65 6e 28 7a 29 3b 0a 20 20 66  = strlen(z);.  f
27f0: 6f 72 28 69 3d 30 3b 20 69 3c 63 6f 75 6e 74 28  or(i=0; i<count(
2800: 61 47 72 6f 75 70 4e 61 6d 65 29 3b 20 69 2b 2b  aGroupName); i++
2810: 29 7b 0a 20 20 20 20 69 66 28 20 73 74 72 6e 63  ){.    if( strnc
2820: 6d 70 28 7a 2c 20 61 47 72 6f 75 70 4e 61 6d 65  mp(z, aGroupName
2830: 5b 69 5d 2e 7a 4e 61 6d 65 2c 20 6e 29 3d 3d 30  [i].zName, n)==0
2840: 20 29 7b 0a 20 20 20 20 20 20 72 65 74 75 72 6e   ){.      return
2850: 20 61 47 72 6f 75 70 4e 61 6d 65 5b 69 5d 2e 67   aGroupName[i].g
2860: 72 6f 75 70 4d 61 73 6b 3b 0a 20 20 20 20 7d 0a  roupMask;.    }.
2870: 20 20 7d 0a 20 20 70 72 69 6e 74 66 28 22 41 76    }.  printf("Av
2880: 61 69 6c 61 62 6c 65 20 63 6f 6e 66 69 67 75 72  ailable configur
2890: 61 74 69 6f 6e 20 61 72 65 61 73 3a 5c 6e 22 29  ation areas:\n")
28a0: 3b 0a 20 20 66 6f 72 28 69 3d 30 3b 20 69 3c 63  ;.  for(i=0; i<c
28b0: 6f 75 6e 74 28 61 47 72 6f 75 70 4e 61 6d 65 29  ount(aGroupName)
28c0: 3b 20 69 2b 2b 29 7b 0a 20 20 20 20 70 72 69 6e  ; i++){.    prin
28d0: 74 66 28 22 20 20 25 2d 31 30 73 20 25 73 5c 6e  tf("  %-10s %s\n
28e0: 22 2c 20 61 47 72 6f 75 70 4e 61 6d 65 5b 69 5d  ", aGroupName[i]
28f0: 2e 7a 4e 61 6d 65 2c 20 61 47 72 6f 75 70 4e 61  .zName, aGroupNa
2900: 6d 65 5b 69 5d 2e 7a 48 65 6c 70 29 3b 0a 20 20  me[i].zHelp);.  
2910: 7d 0a 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c  }.  fossil_fatal
2920: 28 22 6e 6f 20 73 75 63 68 20 63 6f 6e 66 69 67  ("no such config
2930: 75 72 61 74 69 6f 6e 20 61 72 65 61 3a 20 5c 22  uration area: \"
2940: 25 73 5c 22 22 2c 20 7a 29 3b 0a 20 20 72 65 74  %s\"", z);.  ret
2950: 75 72 6e 20 30 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20  urn 0;.}../*.** 
2960: 57 72 69 74 65 20 53 51 4c 20 74 65 78 74 20 69  Write SQL text i
2970: 6e 74 6f 20 66 69 6c 65 20 7a 46 69 6c 65 6e 61  nto file zFilena
2980: 6d 65 20 74 68 61 74 20 77 69 6c 6c 20 72 65 73  me that will res
2990: 74 6f 72 65 20 74 68 65 20 63 6f 6e 66 69 67 75  tore the configu
29a0: 72 61 74 69 6f 6e 0a 2a 2a 20 61 72 65 61 20 69  ration.** area i
29b0: 64 65 6e 74 69 66 69 65 64 20 62 79 20 6d 61 73  dentified by mas
29c0: 6b 20 74 6f 20 69 74 73 20 63 75 72 72 65 6e 74  k to its current
29d0: 20 73 74 61 74 65 20 66 72 6f 6d 20 61 6e 79 20   state from any 
29e0: 6f 74 68 65 72 20 73 74 61 74 65 2e 0a 2a 2f 0a  other state..*/.
29f0: 73 74 61 74 69 63 20 76 6f 69 64 20 65 78 70 6f  static void expo
2a00: 72 74 5f 63 6f 6e 66 69 67 28 0a 20 20 69 6e 74  rt_config(.  int
2a10: 20 6d 61 73 6b 2c 20 20 20 20 20 20 20 20 20 20   mask,          
2a20: 20 20 20 20 20 20 20 2f 2a 20 4d 61 73 6b 20 69         /* Mask i
2a30: 6e 64 69 63 61 74 69 6e 67 20 77 68 69 63 68 20  ndicating which 
2a40: 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 74 6f  configuration to
2a50: 20 65 78 70 6f 72 74 20 2a 2f 0a 20 20 63 6f 6e   export */.  con
2a60: 73 74 20 63 68 61 72 20 2a 7a 4d 61 73 6b 2c 20  st char *zMask, 
2a70: 20 20 20 20 20 20 20 2f 2a 20 4e 61 6d 65 20 6f         /* Name o
2a80: 66 20 74 68 65 20 63 6f 6e 66 69 67 75 72 61 74  f the configurat
2a90: 69 6f 6e 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 63  ion */.  const c
2aa0: 68 61 72 20 2a 7a 46 69 6c 65 6e 61 6d 65 20 20  har *zFilename  
2ab0: 20 20 20 2f 2a 20 57 72 69 74 65 20 69 6e 74 6f     /* Write into
2ac0: 20 74 68 69 73 20 66 69 6c 65 20 2a 2f 0a 29 7b   this file */.){
2ad0: 0a 20 20 69 6e 74 20 69 3b 0a 20 20 42 6c 6f 62  .  int i;.  Blob
2ae0: 20 6f 75 74 3b 0a 20 20 62 6c 6f 62 5f 7a 65 72   out;.  blob_zer
2af0: 6f 28 26 6f 75 74 29 3b 0a 20 20 62 6c 6f 62 5f  o(&out);.  blob_
2b00: 61 70 70 65 6e 64 66 28 26 6f 75 74 2c 20 0a 20  appendf(&out, . 
2b10: 20 20 20 22 2d 2d 20 54 68 65 20 5c 22 25 73 5c     "-- The \"%s\
2b20: 22 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20  " configuration 
2b30: 65 78 70 6f 72 74 65 64 20 66 72 6f 6d 5c 6e 22  exported from\n"
2b40: 0a 20 20 20 20 22 2d 2d 20 72 65 70 6f 73 69 74  .    "-- reposit
2b50: 6f 72 79 20 5c 22 25 73 5c 22 5c 6e 22 0a 20 20  ory \"%s\"\n".  
2b60: 20 20 22 2d 2d 20 6f 6e 20 25 73 5c 6e 22 2c 0a    "-- on %s\n",.
2b70: 20 20 20 20 7a 4d 61 73 6b 2c 20 67 2e 7a 52 65      zMask, g.zRe
2b80: 70 6f 73 69 74 6f 72 79 4e 61 6d 65 2c 0a 20 20  positoryName,.  
2b90: 20 20 64 62 5f 74 65 78 74 28 30 2c 20 22 53 45    db_text(0, "SE
2ba0: 4c 45 43 54 20 64 61 74 65 74 69 6d 65 28 27 6e  LECT datetime('n
2bb0: 6f 77 27 29 22 29 0a 20 20 29 3b 0a 20 20 66 6f  ow')").  );.  fo
2bc0: 72 28 69 3d 30 3b 20 69 3c 63 6f 75 6e 74 28 61  r(i=0; i<count(a
2bd0: 43 6f 6e 66 69 67 29 3b 20 69 2b 2b 29 7b 0a 20  Config); i++){. 
2be0: 20 20 20 69 66 28 20 28 61 43 6f 6e 66 69 67 5b     if( (aConfig[
2bf0: 69 5d 2e 67 72 6f 75 70 4d 61 73 6b 20 26 20 6d  i].groupMask & m
2c00: 61 73 6b 29 21 3d 30 20 29 7b 0a 20 20 20 20 20  ask)!=0 ){.     
2c10: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61   const char *zNa
2c20: 6d 65 20 3d 20 61 43 6f 6e 66 69 67 5b 69 5d 2e  me = aConfig[i].
2c30: 7a 4e 61 6d 65 3b 0a 20 20 20 20 20 20 69 66 28  zName;.      if(
2c40: 20 7a 4e 61 6d 65 5b 30 5d 21 3d 27 40 27 20 29   zName[0]!='@' )
2c50: 7b 0a 20 20 20 20 20 20 20 20 63 68 61 72 20 2a  {.        char *
2c60: 7a 56 61 6c 75 65 20 3d 20 64 62 5f 74 65 78 74  zValue = db_text
2c70: 28 30 2c 20 0a 20 20 20 20 20 20 20 20 20 20 20  (0, .           
2c80: 20 22 53 45 4c 45 43 54 20 76 61 6c 75 65 20 46   "SELECT value F
2c90: 52 4f 4d 20 63 6f 6e 66 69 67 20 57 48 45 52 45  ROM config WHERE
2ca0: 20 6e 61 6d 65 3d 25 51 22 2c 20 7a 4e 61 6d 65   name=%Q", zName
2cb0: 29 3b 0a 20 20 20 20 20 20 20 20 69 66 28 20 7a  );.        if( z
2cc0: 56 61 6c 75 65 20 29 7b 0a 20 20 20 20 20 20 20  Value ){.       
2cd0: 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28     blob_appendf(
2ce0: 26 6f 75 74 2c 22 52 45 50 4c 41 43 45 20 49 4e  &out,"REPLACE IN
2cf0: 54 4f 20 63 6f 6e 66 69 67 20 56 41 4c 55 45 53  TO config VALUES
2d00: 28 25 51 2c 25 51 29 3b 5c 6e 22 2c 20 0a 20 20  (%Q,%Q);\n", .  
2d10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2d20: 20 20 20 20 20 7a 4e 61 6d 65 2c 20 7a 56 61 6c       zName, zVal
2d30: 75 65 29 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20  ue);.        }. 
2d40: 20 20 20 20 20 20 20 66 72 65 65 28 7a 56 61 6c         free(zVal
2d50: 75 65 29 3b 0a 20 20 20 20 20 20 7d 65 6c 73 65  ue);.      }else
2d60: 7b 0a 20 20 20 20 20 20 20 20 63 6f 6e 66 69 67  {.        config
2d70: 75 72 65 5f 72 65 6e 64 65 72 5f 73 70 65 63 69  ure_render_speci
2d80: 61 6c 5f 6e 61 6d 65 28 7a 4e 61 6d 65 2c 20 26  al_name(zName, &
2d90: 6f 75 74 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20  out);.      }.  
2da0: 20 20 7d 0a 20 20 7d 0a 20 20 62 6c 6f 62 5f 77    }.  }.  blob_w
2db0: 72 69 74 65 5f 74 6f 5f 66 69 6c 65 28 26 6f 75  rite_to_file(&ou
2dc0: 74 2c 20 7a 46 69 6c 65 6e 61 6d 65 29 3b 0a 20  t, zFilename);. 
2dd0: 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 6f 75 74   blob_reset(&out
2de0: 29 3b 0a 7d 0a 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d  );.}.../*.** COM
2df0: 4d 41 4e 44 3a 20 63 6f 6e 66 69 67 75 72 61 74  MAND: configurat
2e00: 69 6f 6e 0a 2a 2a 0a 2a 2a 20 55 73 61 67 65 3a  ion.**.** Usage:
2e10: 20 25 66 6f 73 73 69 6c 20 63 6f 6e 66 69 67 75   %fossil configu
2e20: 72 65 20 4d 45 54 48 4f 44 20 2e 2e 2e 0a 2a 2a  re METHOD ....**
2e30: 0a 2a 2a 20 57 68 65 72 65 20 4d 45 54 48 4f 44  .** Where METHOD
2e40: 20 69 73 20 6f 6e 65 20 6f 66 3a 20 65 78 70 6f   is one of: expo
2e50: 72 74 20 69 6d 70 6f 72 74 20 6d 65 72 67 65 20  rt import merge 
2e60: 70 75 6c 6c 20 72 65 73 65 74 2e 20 20 41 6c 6c  pull reset.  All
2e70: 20 6d 65 74 68 6f 64 73 0a 2a 2a 20 61 63 63 65   methods.** acce
2e80: 70 74 20 74 68 65 20 2d 52 20 6f 72 20 2d 2d 72  pt the -R or --r
2e90: 65 70 6f 73 69 74 6f 72 79 20 6f 70 74 69 6f 6e  epository option
2ea0: 20 74 6f 20 73 70 65 63 69 66 69 63 20 61 20 72   to specific a r
2eb0: 65 70 6f 73 69 74 6f 72 79 2e 0a 2a 2a 0a 2a 2a  epository..**.**
2ec0: 20 20 20 20 25 66 6f 73 73 69 6c 20 63 6f 6e 66      %fossil conf
2ed0: 69 67 75 72 61 74 69 6f 6e 20 65 78 70 6f 72 74  iguration export
2ee0: 20 41 52 45 41 20 46 49 4c 45 4e 41 4d 45 0a 2a   AREA FILENAME.*
2ef0: 2a 0a 2a 2a 20 20 20 20 20 20 20 20 20 57 72 69  *.**         Wri
2f00: 74 65 20 74 6f 20 46 49 4c 45 4e 41 4d 45 20 65  te to FILENAME e
2f10: 78 70 6f 72 74 65 64 20 63 6f 6e 66 69 67 75 72  xported configur
2f20: 61 74 6f 6e 20 69 6e 66 6f 72 6d 61 74 69 6f 6e  aton information
2f30: 20 66 6f 72 20 41 52 45 41 2e 0a 2a 2a 20 20 20   for AREA..**   
2f40: 20 20 20 20 20 20 41 52 45 41 20 63 61 6e 20 62        AREA can b
2f50: 65 20 6f 6e 65 20 6f 66 3a 20 20 61 6c 6c 20 74  e one of:  all t
2f60: 69 63 6b 65 74 20 73 6b 69 6e 20 70 72 6f 6a 65  icket skin proje
2f70: 63 74 0a 2a 2a 0a 2a 2a 20 20 20 20 25 66 6f 73  ct.**.**    %fos
2f80: 73 69 6c 20 63 6f 6e 66 69 67 75 72 61 74 69 6f  sil configuratio
2f90: 6e 20 69 6d 70 6f 72 74 20 46 49 4c 45 4e 41 4d  n import FILENAM
2fa0: 45 0a 2a 2a 0a 2a 2a 20 20 20 20 20 20 20 20 20  E.**.**         
2fb0: 52 65 61 64 20 61 20 63 6f 6e 66 69 67 75 72 61  Read a configura
2fc0: 74 69 6f 6e 20 66 72 6f 6d 20 46 49 4c 45 4e 41  tion from FILENA
2fd0: 4d 45 2c 20 6f 76 65 72 77 72 69 74 69 6e 67 20  ME, overwriting 
2fe0: 74 68 65 20 63 75 72 72 65 6e 74 0a 2a 2a 20 20  the current.**  
2ff0: 20 20 20 20 20 20 20 63 6f 6e 66 69 67 75 72 61         configura
3000: 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 20 20 20 25  tion..**.**    %
3010: 66 6f 73 73 69 6c 20 63 6f 6e 66 69 67 75 72 61  fossil configura
3020: 74 69 6f 6e 20 6d 65 72 67 65 20 46 49 4c 45 4e  tion merge FILEN
3030: 41 4d 45 0a 2a 2a 0a 2a 2a 20 20 20 20 20 20 20  AME.**.**       
3040: 20 20 52 65 61 64 20 61 20 63 6f 6e 66 69 67 75    Read a configu
3050: 72 61 74 69 6f 6e 20 66 72 6f 6d 20 46 49 4c 45  ration from FILE
3060: 4e 41 4d 45 20 61 6e 64 20 6d 65 72 67 65 20 69  NAME and merge i
3070: 74 73 20 76 61 6c 75 65 73 20 69 6e 74 6f 0a 2a  ts values into.*
3080: 2a 20 20 20 20 20 20 20 20 20 74 68 65 20 63 75  *         the cu
3090: 72 72 65 6e 74 20 63 6f 6e 66 69 67 75 72 61 74  rrent configurat
30a0: 69 6f 6e 2e 20 20 45 78 69 73 74 69 6e 67 20 76  ion.  Existing v
30b0: 61 6c 75 65 73 20 74 61 6b 65 20 70 72 69 6f 72  alues take prior
30c0: 69 74 79 20 6f 76 65 72 0a 2a 2a 20 20 20 20 20  ity over.**     
30d0: 20 20 20 20 76 61 6c 75 65 73 20 72 65 61 64 20      values read 
30e0: 66 72 6f 6d 20 46 49 4c 45 4e 41 4d 45 2e 0a 2a  from FILENAME..*
30f0: 2a 0a 2a 2a 20 20 20 20 25 66 6f 73 73 69 6c 20  *.**    %fossil 
3100: 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 70 75  configuration pu
3110: 6c 6c 20 41 52 45 41 20 3f 55 52 4c 3f 0a 2a 2a  ll AREA ?URL?.**
3120: 0a 2a 2a 20 20 20 20 20 20 20 20 20 50 75 6c 6c  .**         Pull
3130: 20 61 6e 64 20 69 6e 73 74 61 6c 6c 20 74 68 65   and install the
3140: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 66   configuration f
3150: 72 6f 6d 20 61 20 64 69 66 66 65 72 65 6e 74 20  rom a different 
3160: 73 65 72 76 65 72 0a 2a 2a 20 20 20 20 20 20 20  server.**       
3170: 20 20 69 64 65 6e 74 69 66 69 65 64 20 62 79 20    identified by 
3180: 55 52 4c 2e 20 20 49 66 20 6e 6f 20 55 52 4c 20  URL.  If no URL 
3190: 69 73 20 73 70 65 63 69 66 69 65 64 2c 20 74 68  is specified, th
31a0: 65 6e 20 74 68 65 20 64 65 66 61 75 6c 74 0a 2a  en the default.*
31b0: 2a 20 20 20 20 20 20 20 20 20 73 65 72 76 65 72  *         server
31c0: 20 69 73 20 75 73 65 64 2e 0a 2a 2a 0a 2a 2a 20   is used..**.** 
31d0: 20 20 20 25 66 6f 73 73 69 6c 20 63 6f 6e 66 69     %fossil confi
31e0: 67 75 72 61 74 69 6f 6e 20 72 65 73 65 74 20 41  guration reset A
31f0: 52 45 41 0a 2a 2a 0a 2a 2a 20 20 20 20 20 20 20  REA.**.**       
3200: 20 20 52 65 73 74 6f 72 65 20 74 68 65 20 63 6f    Restore the co
3210: 6e 66 69 67 75 72 61 74 69 6f 6e 20 74 6f 20 74  nfiguration to t
3220: 68 65 20 64 65 66 61 75 6c 74 2e 20 20 41 52 45  he default.  ARE
3230: 41 20 61 73 20 61 62 6f 76 65 2e 0a 2a 2a 0a 2a  A as above..**.*
3240: 2a 20 57 41 52 4e 49 4e 47 3a 20 44 6f 20 6e 6f  * WARNING: Do no
3250: 74 20 69 6d 70 6f 72 74 2c 20 6d 65 72 67 65 2c  t import, merge,
3260: 20 6f 72 20 70 75 6c 6c 20 63 6f 6e 66 69 67 75   or pull configu
3270: 72 61 74 69 6f 6e 73 20 66 72 6f 6d 20 61 6e 20  rations from an 
3280: 75 6e 74 72 75 73 74 65 64 0a 2a 2a 20 73 6f 75  untrusted.** sou
3290: 72 63 65 2e 20 20 54 68 65 20 69 6e 62 6f 75 6e  rce.  The inboun
32a0: 64 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20  d configuration 
32b0: 69 73 20 6e 6f 74 20 63 68 65 63 6b 65 64 20 66  is not checked f
32c0: 6f 72 20 73 61 66 65 74 79 20 61 6e 64 20 63 61  or safety and ca
32d0: 6e 0a 2a 2a 20 69 6e 74 72 6f 64 75 63 65 20 73  n.** introduce s
32e0: 65 63 75 72 69 74 79 20 76 75 6c 6e 65 72 61 62  ecurity vulnerab
32f0: 69 6c 69 74 69 65 73 2e 0a 2a 2f 0a 76 6f 69 64  ilities..*/.void
3300: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 5f 63   configuration_c
3310: 6d 64 28 76 6f 69 64 29 7b 0a 20 20 69 6e 74 20  md(void){.  int 
3320: 6e 3b 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20  n;.  const char 
3330: 2a 7a 4d 65 74 68 6f 64 3b 0a 20 20 69 66 28 20  *zMethod;.  if( 
3340: 67 2e 61 72 67 63 3c 33 20 29 7b 0a 20 20 20 20  g.argc<3 ){.    
3350: 75 73 61 67 65 28 22 65 78 70 6f 72 74 7c 69 6d  usage("export|im
3360: 70 6f 72 74 7c 6d 65 72 67 65 7c 70 75 6c 6c 7c  port|merge|pull|
3370: 72 65 73 65 74 20 2e 2e 2e 22 29 3b 0a 20 20 7d  reset ...");.  }
3380: 0a 20 20 64 62 5f 66 69 6e 64 5f 61 6e 64 5f 6f  .  db_find_and_o
3390: 70 65 6e 5f 72 65 70 6f 73 69 74 6f 72 79 28 31  pen_repository(1
33a0: 29 3b 0a 20 20 7a 4d 65 74 68 6f 64 20 3d 20 67  );.  zMethod = g
33b0: 2e 61 72 67 76 5b 32 5d 3b 0a 20 20 6e 20 3d 20  .argv[2];.  n = 
33c0: 73 74 72 6c 65 6e 28 7a 4d 65 74 68 6f 64 29 3b  strlen(zMethod);
33d0: 0a 20 20 69 66 28 20 73 74 72 6e 63 6d 70 28 7a  .  if( strncmp(z
33e0: 4d 65 74 68 6f 64 2c 20 22 65 78 70 6f 72 74 22  Method, "export"
33f0: 2c 20 6e 29 3d 3d 30 20 29 7b 0a 20 20 20 20 69  , n)==0 ){.    i
3400: 6e 74 20 6d 61 73 6b 3b 0a 20 20 20 20 69 66 28  nt mask;.    if(
3410: 20 67 2e 61 72 67 63 21 3d 35 20 29 7b 0a 20 20   g.argc!=5 ){.  
3420: 20 20 20 20 75 73 61 67 65 28 22 65 78 70 6f 72      usage("expor
3430: 74 20 41 52 45 41 20 46 49 4c 45 4e 41 4d 45 22  t AREA FILENAME"
3440: 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 6d 61 73  );.    }.    mas
3450: 6b 20 3d 20 66 69 6e 64 5f 61 72 65 61 28 67 2e  k = find_area(g.
3460: 61 72 67 76 5b 33 5d 29 3b 0a 20 20 20 20 65 78  argv[3]);.    ex
3470: 70 6f 72 74 5f 63 6f 6e 66 69 67 28 6d 61 73 6b  port_config(mask
3480: 2c 20 67 2e 61 72 67 76 5b 33 5d 2c 20 67 2e 61  , g.argv[3], g.a
3490: 72 67 76 5b 34 5d 29 3b 0a 20 20 7d 65 6c 73 65  rgv[4]);.  }else
34a0: 0a 20 20 69 66 28 20 73 74 72 6e 63 6d 70 28 7a  .  if( strncmp(z
34b0: 4d 65 74 68 6f 64 2c 20 22 69 6d 70 6f 72 74 22  Method, "import"
34c0: 2c 20 6e 29 3d 3d 30 20 0a 20 20 20 20 20 20 20  , n)==0 .       
34d0: 7c 7c 20 73 74 72 6e 63 6d 70 28 7a 4d 65 74 68  || strncmp(zMeth
34e0: 6f 64 2c 20 22 6d 65 72 67 65 22 2c 20 6e 29 3d  od, "merge", n)=
34f0: 3d 30 20 29 7b 0a 20 20 20 20 42 6c 6f 62 20 69  =0 ){.    Blob i
3500: 6e 3b 0a 20 20 20 20 69 66 28 20 67 2e 61 72 67  n;.    if( g.arg
3510: 63 21 3d 34 20 29 20 75 73 61 67 65 28 6d 70 72  c!=4 ) usage(mpr
3520: 69 6e 74 66 28 22 25 73 20 46 49 4c 45 4e 41 4d  intf("%s FILENAM
3530: 45 22 2c 7a 4d 65 74 68 6f 64 29 29 3b 0a 20 20  E",zMethod));.  
3540: 20 20 62 6c 6f 62 5f 72 65 61 64 5f 66 72 6f 6d    blob_read_from
3550: 5f 66 69 6c 65 28 26 69 6e 2c 20 67 2e 61 72 67  _file(&in, g.arg
3560: 76 5b 33 5d 29 3b 0a 20 20 20 20 64 62 5f 62 65  v[3]);.    db_be
3570: 67 69 6e 5f 74 72 61 6e 73 61 63 74 69 6f 6e 28  gin_transaction(
3580: 29 3b 0a 20 20 20 20 63 6f 6e 66 69 67 75 72 65  );.    configure
3590: 5f 70 72 65 70 61 72 65 5f 74 6f 5f 72 65 63 65  _prepare_to_rece
35a0: 69 76 65 28 7a 4d 65 74 68 6f 64 5b 30 5d 3d 3d  ive(zMethod[0]==
35b0: 27 69 27 29 3b 0a 20 20 20 20 64 62 5f 6d 75 6c  'i');.    db_mul
35c0: 74 69 5f 65 78 65 63 28 22 25 73 22 2c 20 62 6c  ti_exec("%s", bl
35d0: 6f 62 5f 73 74 72 28 26 69 6e 29 29 3b 0a 20 20  ob_str(&in));.  
35e0: 20 20 63 6f 6e 66 69 67 75 72 65 5f 66 69 6e 61    configure_fina
35f0: 6c 69 7a 65 5f 72 65 63 65 69 76 65 28 29 3b 0a  lize_receive();.
3600: 20 20 20 20 64 62 5f 65 6e 64 5f 74 72 61 6e 73      db_end_trans
3610: 61 63 74 69 6f 6e 28 30 29 3b 0a 20 20 7d 65 6c  action(0);.  }el
3620: 73 65 0a 20 20 69 66 28 20 73 74 72 6e 63 6d 70  se.  if( strncmp
3630: 28 7a 4d 65 74 68 6f 64 2c 20 22 70 75 6c 6c 22  (zMethod, "pull"
3640: 2c 20 6e 29 3d 3d 30 20 29 7b 0a 20 20 20 20 69  , n)==0 ){.    i
3650: 6e 74 20 6d 61 73 6b 3b 0a 20 20 20 20 63 6f 6e  nt mask;.    con
3660: 73 74 20 63 68 61 72 20 2a 7a 53 65 72 76 65 72  st char *zServer
3670: 3b 0a 20 20 20 20 75 72 6c 5f 70 72 6f 78 79 5f  ;.    url_proxy_
3680: 6f 70 74 69 6f 6e 73 28 29 3b 0a 20 20 20 20 69  options();.    i
3690: 66 28 20 67 2e 61 72 67 63 21 3d 34 20 26 26 20  f( g.argc!=4 && 
36a0: 67 2e 61 72 67 63 21 3d 35 20 29 7b 0a 20 20 20  g.argc!=5 ){.   
36b0: 20 20 20 75 73 61 67 65 28 22 70 75 6c 6c 20 41     usage("pull A
36c0: 52 45 41 20 3f 55 52 4c 3f 22 29 3b 0a 20 20 20  REA ?URL?");.   
36d0: 20 7d 0a 20 20 20 20 6d 61 73 6b 20 3d 20 66 69   }.    mask = fi
36e0: 6e 64 5f 61 72 65 61 28 67 2e 61 72 67 76 5b 33  nd_area(g.argv[3
36f0: 5d 29 3b 0a 20 20 20 20 69 66 28 20 67 2e 61 72  ]);.    if( g.ar
3700: 67 63 3d 3d 35 20 29 7b 0a 20 20 20 20 20 20 7a  gc==5 ){.      z
3710: 53 65 72 76 65 72 20 3d 20 67 2e 61 72 67 76 5b  Server = g.argv[
3720: 34 5d 3b 0a 20 20 20 20 7d 65 6c 73 65 7b 0a 20  4];.    }else{. 
3730: 20 20 20 20 20 7a 53 65 72 76 65 72 20 3d 20 64       zServer = d
3740: 62 5f 67 65 74 28 22 6c 61 73 74 2d 73 79 6e 63  b_get("last-sync
3750: 2d 75 72 6c 22 2c 20 30 29 3b 0a 20 20 20 20 20  -url", 0);.     
3760: 20 69 66 28 20 7a 53 65 72 76 65 72 3d 3d 30 20   if( zServer==0 
3770: 29 7b 0a 20 20 20 20 20 20 20 20 66 6f 73 73 69  ){.        fossi
3780: 6c 5f 66 61 74 61 6c 28 22 6e 6f 20 73 65 72 76  l_fatal("no serv
3790: 65 72 20 73 70 65 63 69 66 69 65 64 22 29 3b 0a  er specified");.
37a0: 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20        }.    }.  
37b0: 20 20 75 72 6c 5f 70 61 72 73 65 28 7a 53 65 72    url_parse(zSer
37c0: 76 65 72 29 3b 0a 20 20 20 20 69 66 28 20 67 2e  ver);.    if( g.
37d0: 75 72 6c 49 73 46 69 6c 65 20 29 7b 0a 20 20 20  urlIsFile ){.   
37e0: 20 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28     fossil_fatal(
37f0: 22 6e 65 74 77 6f 72 6b 20 73 79 6e 63 20 6f 6e  "network sync on
3800: 6c 79 22 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20  ly");.    }.    
3810: 75 73 65 72 5f 73 65 6c 65 63 74 28 29 3b 0a 20  user_select();. 
3820: 20 20 20 63 6c 69 65 6e 74 5f 73 79 6e 63 28 30     client_sync(0
3830: 2c 30 2c 30 2c 6d 61 73 6b 29 3b 0a 20 20 7d 65  ,0,0,mask);.  }e
3840: 6c 73 65 0a 20 20 69 66 28 20 73 74 72 6e 63 6d  lse.  if( strncm
3850: 70 28 7a 4d 65 74 68 6f 64 2c 20 22 72 65 73 65  p(zMethod, "rese
3860: 74 22 2c 20 6e 29 3d 3d 30 20 29 7b 0a 20 20 20  t", n)==0 ){.   
3870: 20 69 6e 74 20 6d 61 73 6b 2c 20 69 3b 0a 20 20   int mask, i;.  
3880: 20 20 63 68 61 72 20 2a 7a 42 61 63 6b 75 70 3b    char *zBackup;
3890: 0a 20 20 20 20 69 66 28 20 67 2e 61 72 67 63 21  .    if( g.argc!
38a0: 3d 34 20 29 20 75 73 61 67 65 28 22 72 65 73 65  =4 ) usage("rese
38b0: 74 20 41 52 45 41 22 29 3b 0a 20 20 20 20 6d 61  t AREA");.    ma
38c0: 73 6b 20 3d 20 66 69 6e 64 5f 61 72 65 61 28 67  sk = find_area(g
38d0: 2e 61 72 67 76 5b 33 5d 29 3b 0a 20 20 20 20 7a  .argv[3]);.    z
38e0: 42 61 63 6b 75 70 20 3d 20 64 62 5f 74 65 78 74  Backup = db_text
38f0: 28 30 2c 20 0a 20 20 20 20 20 20 20 22 53 45 4c  (0, .       "SEL
3900: 45 43 54 20 73 74 72 66 74 69 6d 65 28 27 63 6f  ECT strftime('co
3910: 6e 66 69 67 2d 62 61 63 6b 75 70 2d 25 25 59 25  nfig-backup-%%Y%
3920: 25 6d 25 25 64 25 25 48 25 25 4d 25 25 66 27 2c  %m%%d%%H%%M%%f',
3930: 27 6e 6f 77 27 29 22 29 3b 0a 20 20 20 20 64 62  'now')");.    db
3940: 5f 62 65 67 69 6e 5f 74 72 61 6e 73 61 63 74 69  _begin_transacti
3950: 6f 6e 28 29 3b 0a 20 20 20 20 65 78 70 6f 72 74  on();.    export
3960: 5f 63 6f 6e 66 69 67 28 6d 61 73 6b 2c 20 67 2e  _config(mask, g.
3970: 61 72 67 76 5b 33 5d 2c 20 7a 42 61 63 6b 75 70  argv[3], zBackup
3980: 29 3b 0a 20 20 20 20 66 6f 72 28 69 3d 30 3b 20  );.    for(i=0; 
3990: 69 3c 63 6f 75 6e 74 28 61 43 6f 6e 66 69 67 29  i<count(aConfig)
39a0: 3b 20 69 2b 2b 29 7b 0a 20 20 20 20 20 20 63 6f  ; i++){.      co
39b0: 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 20  nst char *zName 
39c0: 3d 20 61 43 6f 6e 66 69 67 5b 69 5d 2e 7a 4e 61  = aConfig[i].zNa
39d0: 6d 65 3b 0a 20 20 20 20 20 20 69 66 28 20 28 61  me;.      if( (a
39e0: 43 6f 6e 66 69 67 5b 69 5d 2e 67 72 6f 75 70 4d  Config[i].groupM
39f0: 61 73 6b 20 26 20 6d 61 73 6b 29 3d 3d 30 20 29  ask & mask)==0 )
3a00: 20 63 6f 6e 74 69 6e 75 65 3b 0a 20 20 20 20 20   continue;.     
3a10: 20 69 66 28 20 7a 4e 61 6d 65 5b 30 5d 21 3d 27   if( zName[0]!='
3a20: 40 27 20 29 7b 0a 20 20 20 20 20 20 20 20 64 62  @' ){.        db
3a30: 5f 6d 75 6c 74 69 5f 65 78 65 63 28 22 44 45 4c  _multi_exec("DEL
3a40: 45 54 45 20 46 52 4f 4d 20 63 6f 6e 66 69 67 20  ETE FROM config 
3a50: 57 48 45 52 45 20 6e 61 6d 65 3d 25 51 22 2c 20  WHERE name=%Q", 
3a60: 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 7d 65  zName);.      }e
3a70: 6c 73 65 20 69 66 28 20 73 74 72 63 6d 70 28 7a  lse if( strcmp(z
3a80: 4e 61 6d 65 2c 22 40 75 73 65 72 22 29 3d 3d 30  Name,"@user")==0
3a90: 20 29 7b 0a 20 20 20 20 20 20 20 20 64 62 5f 6d   ){.        db_m
3aa0: 75 6c 74 69 5f 65 78 65 63 28 22 44 45 4c 45 54  ulti_exec("DELET
3ab0: 45 20 46 52 4f 4d 20 75 73 65 72 22 29 3b 0a 20  E FROM user");. 
3ac0: 20 20 20 20 20 20 20 64 62 5f 63 72 65 61 74 65         db_create
3ad0: 5f 64 65 66 61 75 6c 74 5f 75 73 65 72 73 28 29  _default_users()
3ae0: 3b 0a 20 20 20 20 20 20 7d 65 6c 73 65 20 69 66  ;.      }else if
3af0: 28 20 73 74 72 63 6d 70 28 7a 4e 61 6d 65 2c 22  ( strcmp(zName,"
3b00: 40 72 65 70 6f 72 74 66 6d 74 22 29 3d 3d 30 20  @reportfmt")==0 
3b10: 29 7b 0a 20 20 20 20 20 20 20 20 64 62 5f 6d 75  ){.        db_mu
3b20: 6c 74 69 5f 65 78 65 63 28 22 44 45 4c 45 54 45  lti_exec("DELETE
3b30: 20 46 52 4f 4d 20 72 65 70 6f 72 74 66 6d 74 22   FROM reportfmt"
3b40: 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d  );.      }.    }
3b50: 0a 20 20 20 20 64 62 5f 65 6e 64 5f 74 72 61 6e  .    db_end_tran
3b60: 73 61 63 74 69 6f 6e 28 30 29 3b 0a 20 20 20 20  saction(0);.    
3b70: 70 72 69 6e 74 66 28 22 43 6f 6e 66 69 67 75 72  printf("Configur
3b80: 61 74 69 6f 6e 20 72 65 73 65 74 20 74 6f 20 66  ation reset to f
3b90: 61 63 74 6f 72 79 20 64 65 66 61 75 6c 74 73 2e  actory defaults.
3ba0: 5c 6e 22 29 3b 0a 20 20 20 20 70 72 69 6e 74 66  \n");.    printf
3bb0: 28 22 54 6f 20 72 65 63 6f 76 65 72 2c 20 75 73  ("To recover, us
3bc0: 65 3a 20 20 25 73 20 25 73 20 69 6d 70 6f 72 74  e:  %s %s import
3bd0: 20 25 73 5c 6e 22 2c 20 0a 20 20 20 20 20 20 20   %s\n", .       
3be0: 20 20 20 20 20 67 2e 61 72 67 76 5b 30 5d 2c 20       g.argv[0], 
3bf0: 67 2e 61 72 67 76 5b 31 5d 2c 20 7a 42 61 63 6b  g.argv[1], zBack
3c00: 75 70 29 3b 0a 20 20 7d 65 6c 73 65 0a 20 20 7b  up);.  }else.  {
3c10: 0a 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 74 61  .    fossil_fata
3c20: 6c 28 22 4d 45 54 48 4f 44 20 73 68 6f 75 6c 64  l("METHOD should
3c30: 20 62 65 20 6f 6e 65 20 6f 66 3a 20 20 65 78 70   be one of:  exp
3c40: 6f 72 74 20 69 6d 70 6f 72 74 20 6d 65 72 67 65  ort import merge
3c50: 20 70 75 6c 6c 20 72 65 73 65 74 22 29 3b 0a 20   pull reset");. 
3c60: 20 7d 0a 7d 0a                                    }.}.