Hex Artifact Content
Not logged in

Artifact b4f6a922b2dc663216e49e8df9604db680d0b8a7:

File src/configure.c part of check-in [bf75ea9852] - The "configuration" command will now sync ticket report formats, shunned UUIDs, and user information (but not user passwords). Added the "config merge" method. Fix an initialization bug that was given Admin privilege to anonymous by default. by drh on 2008-10-04 20:40:27.

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 40  T_TKT  },.  { "@
0d70: 72 65 70 6f 72 74 66 6d 74 22 2c 20 20 20 20 20  reportfmt",     
0d80: 20 20 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 40  T_TKT  },.  { "@
0da0: 75 73 65 72 22 2c 20 20 20 20 20 20 20 20 20 20  user",          
0db0: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0dc0: 54 5f 55 53 45 52 20 7d 2c 0a 20 20 7b 20 22 40  T_USER },.  { "@
0dd0: 73 68 75 6e 22 2c 20 20 20 20 20 20 20 20 20 20  shun",          
0de0: 20 20 20 20 20 20 20 20 43 4f 4e 46 49 47 53 45          CONFIGSE
0df0: 54 5f 53 48 55 4e 20 7d 2c 0a 7d 3b 0a 73 74 61  T_SHUN },.};.sta
0e00: 74 69 63 20 69 6e 74 20 69 43 6f 6e 66 69 67 20  tic int iConfig 
0e10: 3d 20 30 3b 0a 0a 2f 2a 0a 2a 2a 20 52 65 74 75  = 0;../*.** Retu
0e20: 72 6e 20 6e 61 6d 65 20 6f 66 20 66 69 72 73 74  rn name of first
0e30: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 70   configuration p
0e40: 72 6f 70 65 72 74 79 20 6d 61 74 63 68 69 6e 67  roperty matching
0e50: 20 74 68 65 20 67 69 76 65 6e 20 6d 61 73 6b 2e   the given mask.
0e60: 0a 2a 2f 0a 63 6f 6e 73 74 20 63 68 61 72 20 2a  .*/.const char *
0e70: 63 6f 6e 66 69 67 75 72 65 5f 66 69 72 73 74 5f  configure_first_
0e80: 6e 61 6d 65 28 69 6e 74 20 69 4d 61 73 6b 29 7b  name(int iMask){
0e90: 0a 20 20 69 43 6f 6e 66 69 67 20 3d 20 30 3b 0a  .  iConfig = 0;.
0ea0: 20 20 72 65 74 75 72 6e 20 63 6f 6e 66 69 67 75    return configu
0eb0: 72 65 5f 6e 65 78 74 5f 6e 61 6d 65 28 69 4d 61  re_next_name(iMa
0ec0: 73 6b 29 3b 0a 7d 0a 63 6f 6e 73 74 20 63 68 61  sk);.}.const cha
0ed0: 72 20 2a 63 6f 6e 66 69 67 75 72 65 5f 6e 65 78  r *configure_nex
0ee0: 74 5f 6e 61 6d 65 28 69 6e 74 20 69 4d 61 73 6b  t_name(int iMask
0ef0: 29 7b 0a 20 20 77 68 69 6c 65 28 20 69 43 6f 6e  ){.  while( iCon
0f00: 66 69 67 3c 63 6f 75 6e 74 28 61 43 6f 6e 66 69  fig<count(aConfi
0f10: 67 29 20 29 7b 0a 20 20 20 20 69 66 28 20 61 43  g) ){.    if( aC
0f20: 6f 6e 66 69 67 5b 69 43 6f 6e 66 69 67 5d 2e 67  onfig[iConfig].g
0f30: 72 6f 75 70 4d 61 73 6b 20 26 20 69 4d 61 73 6b  roupMask & iMask
0f40: 20 29 7b 0a 20 20 20 20 20 20 72 65 74 75 72 6e   ){.      return
0f50: 20 61 43 6f 6e 66 69 67 5b 69 43 6f 6e 66 69 67   aConfig[iConfig
0f60: 2b 2b 5d 2e 7a 4e 61 6d 65 3b 0a 20 20 20 20 7d  ++].zName;.    }
0f70: 65 6c 73 65 7b 0a 20 20 20 20 20 20 69 43 6f 6e  else{.      iCon
0f80: 66 69 67 2b 2b 3b 0a 20 20 20 20 7d 0a 20 20 7d  fig++;.    }.  }
0f90: 0a 20 20 72 65 74 75 72 6e 20 30 3b 0a 7d 0a 0a  .  return 0;.}..
0fa0: 2f 2a 0a 2a 2a 20 52 65 74 75 72 6e 20 74 68 65  /*.** Return the
0fb0: 20 6d 61 73 6b 20 66 6f 72 20 74 68 65 20 6e 61   mask for the na
0fc0: 6d 65 64 20 63 6f 6e 66 69 67 75 72 61 74 69 6f  med configuratio
0fd0: 6e 20 70 61 72 61 6d 65 74 65 72 20 69 66 20 69  n parameter if i
0fe0: 74 20 63 61 6e 20 62 65 0a 2a 2a 20 73 61 66 65  t can be.** safe
0ff0: 6c 79 20 65 78 70 6f 72 74 65 64 2e 20 20 52 65  ly exported.  Re
1000: 74 75 72 6e 20 30 20 69 66 20 74 68 65 20 70 61  turn 0 if the pa
1010: 72 61 6d 65 74 65 72 20 69 73 20 6e 6f 74 20 73  rameter is not s
1020: 61 66 65 20 74 6f 20 65 78 70 6f 72 74 2e 0a 2a  afe to export..*
1030: 2f 0a 69 6e 74 20 63 6f 6e 66 69 67 75 72 65 5f  /.int configure_
1040: 69 73 5f 65 78 70 6f 72 74 61 62 6c 65 28 63 6f  is_exportable(co
1050: 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 29  nst char *zName)
1060: 7b 0a 20 20 69 6e 74 20 69 3b 0a 20 20 66 6f 72  {.  int i;.  for
1070: 28 69 3d 30 3b 20 69 3c 63 6f 75 6e 74 28 61 43  (i=0; i<count(aC
1080: 6f 6e 66 69 67 29 3b 20 69 2b 2b 29 7b 0a 20 20  onfig); i++){.  
1090: 20 20 69 66 28 20 73 74 72 63 6d 70 28 7a 4e 61    if( strcmp(zNa
10a0: 6d 65 2c 20 61 43 6f 6e 66 69 67 5b 69 5d 2e 7a  me, aConfig[i].z
10b0: 4e 61 6d 65 29 3d 3d 30 20 29 7b 0a 20 20 20 20  Name)==0 ){.    
10c0: 20 20 69 6e 74 20 6d 20 3d 20 61 43 6f 6e 66 69    int m = aConfi
10d0: 67 5b 69 5d 2e 67 72 6f 75 70 4d 61 73 6b 3b 0a  g[i].groupMask;.
10e0: 20 20 20 20 20 20 69 66 28 20 21 67 2e 6f 6b 41        if( !g.okA
10f0: 64 6d 69 6e 20 29 7b 0a 20 20 20 20 20 20 20 20  dmin ){.        
1100: 6d 20 26 3d 20 7e 43 4f 4e 46 49 47 53 45 54 5f  m &= ~CONFIGSET_
1110: 55 53 45 52 3b 0a 20 20 20 20 20 20 7d 0a 20 20  USER;.      }.  
1120: 20 20 20 20 72 65 74 75 72 6e 20 6d 3b 0a 20 20      return m;.  
1130: 20 20 7d 0a 20 20 7d 0a 20 20 72 65 74 75 72 6e    }.  }.  return
1140: 20 30 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 7a 4e 61   0;.}../*.** zNa
1150: 6d 65 20 69 73 20 6f 6e 65 20 6f 66 20 74 68 65  me is one of the
1160: 20 73 70 65 63 69 61 6c 20 63 6f 6e 66 69 67 75   special configu
1170: 72 61 74 69 6f 6e 20 6e 61 6d 65 73 20 74 68 61  ration names tha
1180: 74 20 72 65 66 65 72 73 20 74 6f 20 61 6e 20 65  t refers to an e
1190: 6e 74 69 72 65 0a 2a 2a 20 74 61 62 6c 65 20 72  ntire.** table r
11a0: 61 74 68 65 72 20 74 68 61 6e 20 61 20 73 69 6e  ather than a sin
11b0: 67 6c 65 20 65 6e 74 72 79 20 69 6e 20 43 4f 4e  gle entry in CON
11c0: 46 49 47 2e 20 20 53 70 65 63 69 61 6c 20 6e 61  FIG.  Special na
11d0: 6d 65 73 20 61 72 65 20 22 40 72 65 70 6f 72 74  mes are "@report
11e0: 66 6d 74 22 0a 2a 2a 20 61 6e 64 20 22 40 73 68  fmt".** and "@sh
11f0: 75 6e 22 20 61 6e 64 20 22 40 75 73 65 72 22 2e  un" and "@user".
1200: 20 20 54 68 69 73 20 72 6f 75 74 69 6e 65 20 77    This routine w
1210: 72 69 74 65 73 20 53 51 4c 20 74 65 78 74 20 69  rites SQL text i
1220: 6e 74 6f 20 70 4f 75 74 20 74 68 61 74 20 77 68  nto pOut that wh
1230: 65 6e 0a 2a 2a 20 65 76 61 6c 75 61 74 65 64 20  en.** evaluated 
1240: 77 69 6c 6c 20 70 6f 70 75 6c 61 74 65 20 74 68  will populate th
1250: 65 20 63 6f 72 72 65 73 70 6f 6e 64 69 6e 67 20  e corresponding 
1260: 74 61 62 6c 65 20 77 69 74 68 20 64 61 74 61 2e  table with data.
1270: 0a 2a 2f 0a 76 6f 69 64 20 63 6f 6e 66 69 67 75  .*/.void configu
1280: 72 65 5f 72 65 6e 64 65 72 5f 73 70 65 63 69 61  re_render_specia
1290: 6c 5f 6e 61 6d 65 28 63 6f 6e 73 74 20 63 68 61  l_name(const cha
12a0: 72 20 2a 7a 4e 61 6d 65 2c 20 42 6c 6f 62 20 2a  r *zName, Blob *
12b0: 70 4f 75 74 29 7b 0a 20 20 53 74 6d 74 20 71 3b  pOut){.  Stmt q;
12c0: 0a 20 20 69 66 28 20 73 74 72 63 6d 70 28 7a 4e  .  if( strcmp(zN
12d0: 61 6d 65 2c 20 22 40 73 68 75 6e 22 29 3d 3d 30  ame, "@shun")==0
12e0: 20 29 7b 0a 20 20 20 20 64 62 5f 70 72 65 70 61   ){.    db_prepa
12f0: 72 65 28 26 71 2c 20 22 53 45 4c 45 43 54 20 75  re(&q, "SELECT u
1300: 75 69 64 20 46 52 4f 4d 20 73 68 75 6e 22 29 3b  uid FROM shun");
1310: 0a 20 20 20 20 77 68 69 6c 65 28 20 64 62 5f 73  .    while( db_s
1320: 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f  tep(&q)==SQLITE_
1330: 52 4f 57 20 29 7b 0a 20 20 20 20 20 20 62 6c 6f  ROW ){.      blo
1340: 62 5f 61 70 70 65 6e 64 66 28 70 4f 75 74 2c 20  b_appendf(pOut, 
1350: 22 49 4e 53 45 52 54 20 4f 52 20 49 47 4e 4f 52  "INSERT OR IGNOR
1360: 45 20 49 4e 54 4f 20 73 68 75 6e 20 56 41 4c 55  E INTO shun VALU
1370: 45 53 28 27 25 73 27 29 3b 5c 6e 22 2c 20 0a 20  ES('%s');\n", . 
1380: 20 20 20 20 20 20 20 64 62 5f 63 6f 6c 75 6d 6e         db_column
1390: 5f 74 65 78 74 28 26 71 2c 20 30 29 0a 20 20 20  _text(&q, 0).   
13a0: 20 20 20 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20     );.    }.    
13b0: 64 62 5f 66 69 6e 61 6c 69 7a 65 28 26 71 29 3b  db_finalize(&q);
13c0: 0a 20 20 7d 65 6c 73 65 20 69 66 28 20 73 74 72  .  }else if( str
13d0: 63 6d 70 28 7a 4e 61 6d 65 2c 20 22 40 72 65 70  cmp(zName, "@rep
13e0: 6f 72 74 66 6d 74 22 29 3d 3d 30 20 29 7b 0a 20  ortfmt")==0 ){. 
13f0: 20 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71     db_prepare(&q
1400: 2c 20 22 53 45 4c 45 43 54 20 74 69 74 6c 65 2c  , "SELECT title,
1410: 20 63 6f 6c 73 2c 20 73 71 6c 63 6f 64 65 20 46   cols, sqlcode F
1420: 52 4f 4d 20 72 65 70 6f 72 74 66 6d 74 22 29 3b  ROM reportfmt");
1430: 0a 20 20 20 20 77 68 69 6c 65 28 20 64 62 5f 73  .    while( db_s
1440: 74 65 70 28 26 71 29 3d 3d 53 51 4c 49 54 45 5f  tep(&q)==SQLITE_
1450: 52 4f 57 20 29 7b 0a 20 20 20 20 20 20 62 6c 6f  ROW ){.      blo
1460: 62 5f 61 70 70 65 6e 64 66 28 70 4f 75 74 2c 20  b_appendf(pOut, 
1470: 22 49 4e 53 45 52 54 20 49 4e 54 4f 20 5f 78 66  "INSERT INTO _xf
1480: 65 72 5f 72 65 70 6f 72 74 66 6d 74 28 74 69 74  er_reportfmt(tit
1490: 6c 65 2c 63 6f 6c 73 2c 73 71 6c 63 6f 64 65 29  le,cols,sqlcode)
14a0: 20 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20   ".             
14b0: 20 20 20 20 20 20 20 20 20 20 20 20 22 20 56 41              " VA
14c0: 4c 55 45 53 28 25 51 2c 25 51 2c 25 51 29 3b 5c  LUES(%Q,%Q,%Q);\
14d0: 6e 22 2c 20 0a 20 20 20 20 20 20 20 20 64 62 5f  n", .        db_
14e0: 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20  column_text(&q, 
14f0: 30 29 2c 0a 20 20 20 20 20 20 20 20 64 62 5f 63  0),.        db_c
1500: 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 31  olumn_text(&q, 1
1510: 29 2c 0a 20 20 20 20 20 20 20 20 64 62 5f 63 6f  ),.        db_co
1520: 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20 32 29  lumn_text(&q, 2)
1530: 0a 20 20 20 20 20 20 29 3b 0a 20 20 20 20 7d 0a  .      );.    }.
1540: 20 20 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65 28      db_finalize(
1550: 26 71 29 3b 0a 20 20 7d 65 6c 73 65 20 69 66 28  &q);.  }else if(
1560: 20 73 74 72 63 6d 70 28 7a 4e 61 6d 65 2c 20 22   strcmp(zName, "
1570: 40 75 73 65 72 22 29 3d 3d 30 20 29 7b 0a 20 20  @user")==0 ){.  
1580: 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71 2c    db_prepare(&q,
1590: 20 22 53 45 4c 45 43 54 20 6c 6f 67 69 6e 2c 20   "SELECT login, 
15a0: 63 61 70 2c 20 69 6e 66 6f 2c 20 71 75 6f 74 65  cap, info, quote
15b0: 28 70 68 6f 74 6f 29 20 46 52 4f 4d 20 75 73 65  (photo) FROM use
15c0: 72 22 29 3b 0a 20 20 20 20 77 68 69 6c 65 28 20  r");.    while( 
15d0: 64 62 5f 73 74 65 70 28 26 71 29 3d 3d 53 51 4c  db_step(&q)==SQL
15e0: 49 54 45 5f 52 4f 57 20 29 7b 0a 20 20 20 20 20  ITE_ROW ){.     
15f0: 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 70 4f   blob_appendf(pO
1600: 75 74 2c 20 22 49 4e 53 45 52 54 20 49 4e 54 4f  ut, "INSERT INTO
1610: 20 5f 78 66 65 72 5f 75 73 65 72 28 6c 6f 67 69   _xfer_user(logi
1620: 6e 2c 63 61 70 2c 69 6e 66 6f 2c 70 68 6f 74 6f  n,cap,info,photo
1630: 29 20 22 0a 20 20 20 20 20 20 20 20 20 20 20 20  ) ".            
1640: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 20 56               " V
1650: 41 4c 55 45 53 28 25 51 2c 25 51 2c 25 51 2c 25  ALUES(%Q,%Q,%Q,%
1660: 73 29 3b 5c 6e 22 2c 0a 20 20 20 20 20 20 20 20  s);\n",.        
1670: 64 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26  db_column_text(&
1680: 71 2c 20 30 29 2c 0a 20 20 20 20 20 20 20 20 64  q, 0),.        d
1690: 62 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71  b_column_text(&q
16a0: 2c 20 31 29 2c 0a 20 20 20 20 20 20 20 20 64 62  , 1),.        db
16b0: 5f 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c  _column_text(&q,
16c0: 20 32 29 2c 0a 20 20 20 20 20 20 20 20 64 62 5f   2),.        db_
16d0: 63 6f 6c 75 6d 6e 5f 74 65 78 74 28 26 71 2c 20  column_text(&q, 
16e0: 33 29 0a 20 20 20 20 20 20 29 3b 0a 20 20 20 20  3).      );.    
16f0: 7d 0a 20 20 20 20 64 62 5f 66 69 6e 61 6c 69 7a  }.    db_finaliz
1700: 65 28 26 71 29 3b 0a 20 20 7d 0a 7d 0a 0a 2f 2a  e(&q);.  }.}../*
1710: 0a 2a 2a 20 54 77 6f 20 53 51 4c 20 66 75 6e 63  .** Two SQL func
1720: 74 69 6f 6e 73 3a 0a 2a 2a 0a 2a 2a 20 20 20 20  tions:.**.**    
1730: 20 20 20 20 66 6c 61 67 5f 74 65 73 74 28 69 6e      flag_test(in
1740: 74 29 0a 2a 2a 20 20 20 20 20 20 20 20 66 6c 61  t).**        fla
1750: 67 5f 63 6c 65 61 72 28 69 6e 74 29 0a 2a 2a 0a  g_clear(int).**.
1760: 2a 2a 20 54 68 65 20 66 6c 61 67 5f 74 65 73 74  ** The flag_test
1770: 28 29 20 66 75 6e 63 74 69 6f 6e 20 74 61 6b 65  () function take
1780: 73 20 74 68 65 20 69 6e 74 65 67 65 72 20 76 61  s the integer va
1790: 6c 75 65 64 20 61 72 67 75 6d 65 6e 74 20 61 6e  lued argument an
17a0: 64 0a 2a 2a 20 41 4e 44 73 20 69 74 20 61 67 61  d.** ANDs it aga
17b0: 69 6e 73 74 20 74 68 65 20 73 74 61 74 69 63 20  inst the static 
17c0: 76 61 72 69 61 62 6c 65 20 22 66 6c 61 67 5f 76  variable "flag_v
17d0: 61 6c 75 65 22 20 62 65 6c 6f 77 2e 20 20 54 68  alue" below.  Th
17e0: 65 0a 2a 2a 20 66 75 6e 63 74 69 6f 6e 20 72 65  e.** function re
17f0: 74 75 72 6e 73 20 54 52 55 45 20 6f 72 20 66 61  turns TRUE or fa
1800: 6c 73 65 20 64 65 70 65 6e 64 69 6e 67 20 6f 6e  lse depending on
1810: 20 74 68 65 20 72 65 73 75 6c 74 2e 20 20 54 68   the result.  Th
1820: 65 0a 2a 2a 20 66 6c 61 67 5f 63 6c 65 61 72 28  e.** flag_clear(
1830: 29 20 66 75 6e 63 74 69 6f 6e 20 6d 61 73 6b 73  ) function masks
1840: 20 6f 66 66 20 74 68 65 20 62 69 74 73 20 66 72   off the bits fr
1850: 6f 6d 20 22 66 6c 61 67 5f 76 61 6c 75 65 22 20  om "flag_value" 
1860: 74 68 61 74 0a 2a 2a 20 61 72 65 20 67 69 76 65  that.** are give
1870: 6e 20 69 6e 20 74 68 65 20 61 72 67 75 6d 65 6e  n in the argumen
1880: 74 2e 0a 2a 2a 0a 2a 2a 20 54 68 65 73 65 20 66  t..**.** These f
1890: 75 6e 63 74 69 6f 6e 73 20 61 72 65 20 75 73 65  unctions are use
18a0: 64 20 62 65 6c 6f 77 20 69 6e 20 74 68 65 20 57  d below in the W
18b0: 48 45 4e 20 63 6c 61 75 73 65 20 6f 66 20 61 20  HEN clause of a 
18c0: 74 72 69 67 67 65 72 20 74 6f 0a 2a 2a 20 67 65  trigger to.** ge
18d0: 74 20 74 68 65 20 74 72 69 67 67 65 72 20 74 6f  t the trigger to
18e0: 20 66 69 72 65 20 65 78 61 63 74 6c 79 20 6f 6e   fire exactly on
18f0: 63 65 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 69 6e  ce..*/.static in
1900: 74 20 66 6c 61 67 5f 76 61 6c 75 65 20 3d 20 30  t flag_value = 0
1910: 78 66 66 66 66 3b 0a 73 74 61 74 69 63 20 76 6f  xffff;.static vo
1920: 69 64 20 66 6c 61 67 5f 74 65 73 74 5f 66 75 6e  id flag_test_fun
1930: 63 74 69 6f 6e 28 0a 20 20 73 71 6c 69 74 65 33  ction(.  sqlite3
1940: 5f 63 6f 6e 74 65 78 74 20 2a 63 6f 6e 74 65 78  _context *contex
1950: 74 2c 0a 20 20 69 6e 74 20 61 72 67 63 2c 0a 20  t,.  int argc,. 
1960: 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 2a   sqlite3_value *
1970: 2a 61 72 67 76 0a 29 7b 0a 20 20 69 6e 74 20 6d  *argv.){.  int m
1980: 20 3d 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65   = sqlite3_value
1990: 5f 69 6e 74 28 61 72 67 76 5b 30 5d 29 3b 0a 20  _int(argv[0]);. 
19a0: 20 73 71 6c 69 74 65 33 5f 72 65 73 75 6c 74 5f   sqlite3_result_
19b0: 69 6e 74 28 63 6f 6e 74 65 78 74 2c 20 28 66 6c  int(context, (fl
19c0: 61 67 5f 76 61 6c 75 65 26 6d 29 21 3d 30 20 29  ag_value&m)!=0 )
19d0: 3b 0a 7d 0a 73 74 61 74 69 63 20 76 6f 69 64 20  ;.}.static void 
19e0: 66 6c 61 67 5f 63 6c 65 61 72 5f 66 75 6e 63 74  flag_clear_funct
19f0: 69 6f 6e 28 0a 20 20 73 71 6c 69 74 65 33 5f 63  ion(.  sqlite3_c
1a00: 6f 6e 74 65 78 74 20 2a 63 6f 6e 74 65 78 74 2c  ontext *context,
1a10: 0a 20 20 69 6e 74 20 61 72 67 63 2c 0a 20 20 73  .  int argc,.  s
1a20: 71 6c 69 74 65 33 5f 76 61 6c 75 65 20 2a 2a 61  qlite3_value **a
1a30: 72 67 76 0a 29 7b 0a 20 20 69 6e 74 20 6d 20 3d  rgv.){.  int m =
1a40: 20 73 71 6c 69 74 65 33 5f 76 61 6c 75 65 5f 69   sqlite3_value_i
1a50: 6e 74 28 61 72 67 76 5b 30 5d 29 3b 0a 20 20 66  nt(argv[0]);.  f
1a60: 6c 61 67 5f 76 61 6c 75 65 20 26 3d 20 7e 6d 3b  lag_value &= ~m;
1a70: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 43 72 65 61 74 65  .}../*.** Create
1a80: 20 74 68 65 20 74 65 6d 70 6f 72 61 72 79 20 5f   the temporary _
1a90: 78 66 65 72 5f 72 65 70 6f 72 74 66 6d 74 20 61  xfer_reportfmt a
1aa0: 6e 64 20 5f 78 66 65 72 5f 75 73 65 72 20 74 61  nd _xfer_user ta
1ab0: 62 6c 65 73 20 74 68 61 74 20 61 72 65 0a 2a 2a  bles that are.**
1ac0: 20 6e 65 63 65 73 73 61 72 79 20 69 6e 20 6f 72   necessary in or
1ad0: 64 65 72 20 74 6f 20 65 76 61 6c 75 74 65 20 74  der to evalute t
1ae0: 68 65 20 53 51 4c 20 74 65 78 74 20 67 65 6e 65  he SQL text gene
1af0: 72 61 74 65 64 20 62 79 20 74 68 65 0a 2a 2a 20  rated by the.** 
1b00: 63 6f 6e 66 69 67 75 72 65 5f 72 65 6e 64 65 72  configure_render
1b10: 5f 73 70 65 63 69 61 6c 5f 6e 61 6d 65 28 29 20  _special_name() 
1b20: 72 6f 75 74 69 6e 65 2e 0a 2a 2a 0a 2a 2a 20 49  routine..**.** I
1b30: 66 20 72 65 70 6c 61 63 65 46 6c 61 67 20 69 73  f replaceFlag is
1b40: 20 74 72 75 65 2c 20 74 68 65 6e 20 74 68 65 20   true, then the 
1b50: 73 65 74 75 70 20 69 73 20 73 75 63 68 20 74 68  setup is such th
1b60: 61 74 20 74 68 65 20 63 6f 6e 74 65 6e 74 20 69  at the content i
1b70: 6e 0a 2a 2a 20 74 68 65 20 53 51 4c 20 74 65 78  n.** the SQL tex
1b80: 74 20 77 69 6c 6c 20 63 6f 6d 70 6c 65 74 65 6c  t will completel
1b90: 79 20 72 65 70 6c 61 63 65 20 74 68 65 20 63 75  y replace the cu
1ba0: 72 72 65 6e 74 20 72 65 70 6f 73 69 74 6f 72 79  rrent repository
1bb0: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 2e 0a   configuration..
1bc0: 2a 2a 20 49 66 20 72 65 70 6c 61 63 65 46 6c 61  ** If replaceFla
1bd0: 67 20 69 73 20 66 61 6c 73 65 2c 20 74 68 65 6e  g is false, then
1be0: 20 74 68 65 20 53 51 4c 20 74 65 78 74 20 77 69   the SQL text wi
1bf0: 6c 6c 20 62 65 20 6d 65 72 67 65 64 20 77 69 74  ll be merged wit
1c00: 68 20 74 68 65 0a 2a 2a 20 65 78 69 73 74 69 6e  h the.** existin
1c10: 67 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 2e  g configuration.
1c20: 20 20 57 68 65 6e 20 6d 65 72 67 69 6e 67 2c 20    When merging, 
1c30: 65 78 69 73 74 69 6e 67 20 76 61 6c 75 65 73 20  existing values 
1c40: 74 61 6b 65 20 70 72 69 6f 72 69 74 79 0a 2a 2a  take priority.**
1c50: 20 6f 76 65 72 20 53 51 4c 20 74 65 78 74 20 76   over SQL text v
1c60: 61 6c 75 65 73 2e 0a 2a 2f 0a 76 6f 69 64 20 63  alues..*/.void c
1c70: 6f 6e 66 69 67 75 72 65 5f 70 72 65 70 61 72 65  onfigure_prepare
1c80: 5f 74 6f 5f 72 65 63 65 69 76 65 28 69 6e 74 20  _to_receive(int 
1c90: 72 65 70 6c 61 63 65 46 6c 61 67 29 7b 0a 20 20  replaceFlag){.  
1ca0: 73 74 61 74 69 63 20 63 6f 6e 73 74 20 63 68 61  static const cha
1cb0: 72 20 7a 53 51 4c 31 5b 5d 20 3d 0a 20 20 20 20  r zSQL1[] =.    
1cc0: 40 20 43 52 45 41 54 45 20 54 45 4d 50 20 54 41  @ CREATE TEMP TA
1cd0: 42 4c 45 20 5f 78 66 65 72 5f 72 65 70 6f 72 74  BLE _xfer_report
1ce0: 66 6d 74 28 0a 20 20 20 20 40 20 20 20 20 72 6e  fmt(.    @    rn
1cf0: 20 69 6e 74 65 67 65 72 20 70 72 69 6d 61 72 79   integer primary
1d00: 20 6b 65 79 2c 20 20 2d 2d 20 52 65 70 6f 72 74   key,  -- Report
1d10: 20 6e 75 6d 62 65 72 0a 20 20 20 20 40 20 20 20   number.    @   
1d20: 20 6f 77 6e 65 72 20 74 65 78 74 2c 20 20 20 20   owner text,    
1d30: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 4f 77 6e            -- Own
1d40: 65 72 20 6f 66 20 74 68 69 73 20 72 65 70 6f 72  er of this repor
1d50: 74 20 66 6f 72 6d 61 74 20 28 6e 6f 74 20 75 73  t format (not us
1d60: 65 64 29 0a 20 20 20 20 40 20 20 20 20 74 69 74  ed).    @    tit
1d70: 6c 65 20 74 65 78 74 20 55 4e 49 51 55 45 20 4f  le text UNIQUE O
1d80: 4e 20 43 4f 4e 46 4c 49 43 54 20 49 47 4e 4f 52  N CONFLICT IGNOR
1d90: 45 2c 20 20 2d 2d 20 54 69 74 6c 65 20 6f 66 20  E,  -- Title of 
1da0: 74 68 69 73 20 72 65 70 6f 72 74 0a 20 20 20 20  this report.    
1db0: 40 20 20 20 20 63 6f 6c 73 20 74 65 78 74 2c 20  @    cols text, 
1dc0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d                --
1dd0: 20 41 20 63 6f 6c 6f 72 2d 6b 65 79 20 73 70 65   A color-key spe
1de0: 63 69 66 69 63 61 74 69 6f 6e 0a 20 20 20 20 40  cification.    @
1df0: 20 20 20 20 73 71 6c 63 6f 64 65 20 74 65 78 74      sqlcode text
1e00: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 20               -- 
1e10: 41 6e 20 53 51 4c 20 53 45 4c 45 43 54 20 73 74  An SQL SELECT st
1e20: 61 74 65 6d 65 6e 74 20 66 6f 72 20 74 68 69 73  atement for this
1e30: 20 72 65 70 6f 72 74 0a 20 20 20 20 40 20 29 3b   report.    @ );
1e40: 0a 20 20 20 20 40 20 43 52 45 41 54 45 20 54 45  .    @ CREATE TE
1e50: 4d 50 20 54 41 42 4c 45 20 5f 78 66 65 72 5f 75  MP TABLE _xfer_u
1e60: 73 65 72 28 0a 20 20 20 20 40 20 20 20 75 69 64  ser(.    @   uid
1e70: 20 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59   INTEGER PRIMARY
1e80: 20 4b 45 59 2c 20 20 20 20 20 20 20 20 2d 2d 20   KEY,        -- 
1e90: 55 73 65 72 20 49 44 0a 20 20 20 20 40 20 20 20  User ID.    @   
1ea0: 6c 6f 67 69 6e 20 54 45 58 54 20 55 4e 49 51 55  login TEXT UNIQU
1eb0: 45 20 4f 4e 20 43 4f 4e 46 4c 49 43 54 20 49 47  E ON CONFLICT IG
1ec0: 4e 4f 52 45 2c 20 20 20 2d 2d 20 6c 6f 67 69 6e  NORE,   -- login
1ed0: 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 75 73 65   name of the use
1ee0: 72 0a 20 20 20 20 40 20 20 20 70 77 20 54 45 58  r.    @   pw TEX
1ef0: 54 2c 20 20 20 20 20 20 20 20 20 20 20 20 20 20  T,              
1f00: 20 20 20 20 20 20 20 20 20 20 2d 2d 20 70 61 73            -- pas
1f10: 73 77 6f 72 64 0a 20 20 20 20 40 20 20 20 63 61  sword.    @   ca
1f20: 70 20 54 45 58 54 2c 20 20 20 20 20 20 20 20 20  p TEXT,         
1f30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d                --
1f40: 20 43 61 70 61 62 69 6c 69 74 69 65 73 20 6f 66   Capabilities of
1f50: 20 74 68 69 73 20 75 73 65 72 0a 20 20 20 20 40   this user.    @
1f60: 20 20 20 63 6f 6f 6b 69 65 20 54 45 58 54 2c 20     cookie TEXT, 
1f70: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1f80: 20 20 20 2d 2d 20 57 57 57 20 6c 6f 67 69 6e 20     -- WWW login 
1f90: 63 6f 6f 6b 69 65 0a 20 20 20 20 40 20 20 20 69  cookie.    @   i
1fa0: 70 61 64 64 72 20 54 45 58 54 2c 20 20 20 20 20  paddr TEXT,     
1fb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d                 -
1fc0: 2d 20 49 50 20 61 64 64 72 65 73 73 20 66 6f 72  - IP address for
1fd0: 20 77 68 69 63 68 20 63 6f 6f 6b 69 65 20 69 73   which cookie is
1fe0: 20 76 61 6c 69 64 0a 20 20 20 20 40 20 20 20 63   valid.    @   c
1ff0: 65 78 70 69 72 65 20 44 41 54 45 54 49 4d 45 2c  expire DATETIME,
2000: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d                 -
2010: 2d 20 54 69 6d 65 20 77 68 65 6e 20 63 6f 6f 6b  - Time when cook
2020: 69 65 20 65 78 70 69 72 65 73 0a 20 20 20 20 40  ie expires.    @
2030: 20 20 20 69 6e 66 6f 20 54 45 58 54 2c 20 20 20     info TEXT,   
2040: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2050: 20 20 20 2d 2d 20 63 6f 6e 74 61 63 74 20 69 6e     -- contact in
2060: 66 6f 72 6d 61 74 69 6f 6e 0a 20 20 20 20 40 20  formation.    @ 
2070: 20 20 70 68 6f 74 6f 20 42 4c 4f 42 20 20 20 20    photo BLOB    
2080: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2090: 20 20 2d 2d 20 4a 50 45 47 20 69 6d 61 67 65 20    -- JPEG image 
20a0: 6f 66 20 74 68 69 73 20 75 73 65 72 0a 20 20 20  of this user.   
20b0: 20 40 20 29 3b 0a 20 20 20 20 40 20 49 4e 53 45   @ );.    @ INSE
20c0: 52 54 20 49 4e 54 4f 20 5f 78 66 65 72 5f 72 65  RT INTO _xfer_re
20d0: 70 6f 72 74 66 6d 74 20 53 45 4c 45 43 54 20 2a  portfmt SELECT *
20e0: 20 46 52 4f 4d 20 72 65 70 6f 72 74 66 6d 74 3b   FROM reportfmt;
20f0: 0a 20 20 20 20 40 20 49 4e 53 45 52 54 20 49 4e  .    @ INSERT IN
2100: 54 4f 20 5f 78 66 65 72 5f 75 73 65 72 20 53 45  TO _xfer_user SE
2110: 4c 45 43 54 20 2a 20 46 52 4f 4d 20 75 73 65 72  LECT * FROM user
2120: 3b 0a 20 20 3b 0a 20 20 64 62 5f 6d 75 6c 74 69  ;.  ;.  db_multi
2130: 5f 65 78 65 63 28 7a 53 51 4c 31 29 3b 0a 20 20  _exec(zSQL1);.  
2140: 0a 20 20 2f 2a 20 57 68 65 6e 20 74 68 65 20 72  .  /* When the r
2150: 65 70 6c 61 63 65 20 66 6c 61 67 20 69 73 20 73  eplace flag is s
2160: 65 74 2c 20 61 64 64 20 74 72 69 67 67 65 72 73  et, add triggers
2170: 20 74 68 61 74 20 72 75 6e 20 74 68 65 20 66 69   that run the fi
2180: 72 73 74 20 74 69 6d 65 0a 20 20 2a 2a 20 74 68  rst time.  ** th
2190: 61 74 20 6e 65 77 20 64 61 74 61 20 69 73 20 73  at new data is s
21a0: 65 65 6e 2e 20 20 54 68 65 20 74 72 69 67 67 65  een.  The trigge
21b0: 72 73 20 72 75 6e 20 6f 6e 6c 79 20 6f 6e 63 65  rs run only once
21c0: 20 61 6e 64 20 64 65 6c 65 74 65 20 61 6c 6c 20   and delete all 
21d0: 74 68 65 0a 20 20 2a 2a 20 65 78 69 73 74 69 6e  the.  ** existin
21e0: 67 20 64 61 74 61 2e 0a 20 20 2a 2f 0a 20 20 69  g data..  */.  i
21f0: 66 28 20 72 65 70 6c 61 63 65 46 6c 61 67 20 29  f( replaceFlag )
2200: 7b 0a 20 20 20 20 73 74 61 74 69 63 20 63 6f 6e  {.    static con
2210: 73 74 20 63 68 61 72 20 7a 53 51 4c 32 5b 5d 20  st char zSQL2[] 
2220: 3d 0a 20 20 20 20 20 20 40 20 43 52 45 41 54 45  =.      @ CREATE
2230: 20 54 52 49 47 47 45 52 20 5f 78 66 65 72 5f 72   TRIGGER _xfer_r
2240: 31 20 42 45 46 4f 52 45 20 49 4e 53 45 52 54 20  1 BEFORE INSERT 
2250: 4f 4e 20 5f 78 66 65 72 5f 72 65 70 6f 72 74 66  ON _xfer_reportf
2260: 6d 74 0a 20 20 20 20 20 20 40 20 57 48 45 4e 20  mt.      @ WHEN 
2270: 66 6c 61 67 5f 74 65 73 74 28 31 29 20 42 45 47  flag_test(1) BEG
2280: 49 4e 0a 20 20 20 20 20 20 40 20 20 20 44 45 4c  IN.      @   DEL
2290: 45 54 45 20 46 52 4f 4d 20 5f 78 66 65 72 5f 72  ETE FROM _xfer_r
22a0: 65 70 6f 72 74 66 6d 74 3b 0a 20 20 20 20 20 20  eportfmt;.      
22b0: 40 20 20 20 53 45 4c 45 43 54 20 66 6c 61 67 5f  @   SELECT flag_
22c0: 63 6c 65 61 72 28 31 29 3b 0a 20 20 20 20 20 20  clear(1);.      
22d0: 40 20 45 4e 44 3b 0a 20 20 20 20 20 20 40 20 43  @ END;.      @ C
22e0: 52 45 41 54 45 20 54 52 49 47 47 45 52 20 5f 78  REATE TRIGGER _x
22f0: 66 65 72 5f 72 32 20 42 45 46 4f 52 45 20 49 4e  fer_r2 BEFORE IN
2300: 53 45 52 54 20 4f 4e 20 5f 78 66 65 72 5f 75 73  SERT ON _xfer_us
2310: 65 72 0a 20 20 20 20 20 20 40 20 57 48 45 4e 20  er.      @ WHEN 
2320: 66 6c 61 67 5f 74 65 73 74 28 32 29 20 42 45 47  flag_test(2) BEG
2330: 49 4e 0a 20 20 20 20 20 20 40 20 20 20 44 45 4c  IN.      @   DEL
2340: 45 54 45 20 46 52 4f 4d 20 5f 78 66 65 72 5f 75  ETE FROM _xfer_u
2350: 73 65 72 3b 0a 20 20 20 20 20 20 40 20 20 20 53  ser;.      @   S
2360: 45 4c 45 43 54 20 66 6c 61 67 5f 63 6c 65 61 72  ELECT flag_clear
2370: 28 32 29 3b 0a 20 20 20 20 20 20 40 20 45 4e 44  (2);.      @ END
2380: 3b 0a 20 20 20 20 20 20 40 20 43 52 45 41 54 45  ;.      @ CREATE
2390: 20 54 45 4d 50 20 54 52 49 47 47 45 52 20 5f 78   TEMP TRIGGER _x
23a0: 66 65 72 5f 72 33 20 42 45 46 4f 52 45 20 49 4e  fer_r3 BEFORE IN
23b0: 53 45 52 54 20 4f 4e 20 73 68 75 6e 0a 20 20 20  SERT ON shun.   
23c0: 20 20 20 40 20 57 48 45 4e 20 66 6c 61 67 5f 74     @ WHEN flag_t
23d0: 65 73 74 28 34 29 20 42 45 47 49 4e 0a 20 20 20  est(4) BEGIN.   
23e0: 20 20 20 40 20 20 20 44 45 4c 45 54 45 20 46 52     @   DELETE FR
23f0: 4f 4d 20 73 68 75 6e 3b 0a 20 20 20 20 20 20 40  OM shun;.      @
2400: 20 20 20 53 45 4c 45 43 54 20 66 6c 61 67 5f 63     SELECT flag_c
2410: 6c 65 61 72 28 34 29 3b 0a 20 20 20 20 20 20 40  lear(4);.      @
2420: 20 45 4e 44 3b 0a 20 20 20 20 3b 0a 20 20 20 20   END;.    ;.    
2430: 73 71 6c 69 74 65 33 5f 63 72 65 61 74 65 5f 66  sqlite3_create_f
2440: 75 6e 63 74 69 6f 6e 28 67 2e 64 62 2c 20 22 66  unction(g.db, "f
2450: 6c 61 67 5f 74 65 73 74 22 2c 20 31 2c 20 53 51  lag_test", 1, SQ
2460: 4c 49 54 45 5f 55 54 46 38 2c 20 30 2c 0a 20 20  LITE_UTF8, 0,.  
2470: 20 20 20 20 20 20 20 66 6c 61 67 5f 74 65 73 74         flag_test
2480: 5f 66 75 6e 63 74 69 6f 6e 2c 20 30 2c 20 30 29  _function, 0, 0)
2490: 3b 0a 20 20 20 20 73 71 6c 69 74 65 33 5f 63 72  ;.    sqlite3_cr
24a0: 65 61 74 65 5f 66 75 6e 63 74 69 6f 6e 28 67 2e  eate_function(g.
24b0: 64 62 2c 20 22 66 6c 61 67 5f 63 6c 65 61 72 22  db, "flag_clear"
24c0: 2c 20 31 2c 20 53 51 4c 49 54 45 5f 55 54 46 38  , 1, SQLITE_UTF8
24d0: 2c 20 30 2c 0a 20 20 20 20 20 20 20 20 20 66 6c  , 0,.         fl
24e0: 61 67 5f 63 6c 65 61 72 5f 66 75 6e 63 74 69 6f  ag_clear_functio
24f0: 6e 2c 20 30 2c 20 30 29 3b 0a 20 20 20 20 66 6c  n, 0, 0);.    fl
2500: 61 67 5f 76 61 6c 75 65 20 3d 20 30 78 66 66 66  ag_value = 0xfff
2510: 66 3b 0a 20 20 20 20 64 62 5f 6d 75 6c 74 69 5f  f;.    db_multi_
2520: 65 78 65 63 28 7a 53 51 4c 32 29 3b 0a 20 20 7d  exec(zSQL2);.  }
2530: 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 41 66 74 65 72 20  .}../*.** After 
2540: 72 65 63 65 69 76 69 6e 67 20 63 6f 6e 66 69 67  receiving config
2550: 75 72 61 74 69 6f 6e 20 64 61 74 61 2c 20 63 61  uration data, ca
2560: 6c 6c 20 74 68 69 73 20 72 6f 75 74 69 6e 65 20  ll this routine 
2570: 74 6f 20 74 72 61 6e 73 66 65 72 0a 2a 2a 20 74  to transfer.** t
2580: 68 65 20 72 65 73 75 6c 74 73 20 69 6e 74 6f 20  he results into 
2590: 74 68 65 20 6d 61 69 6e 20 64 61 74 61 62 61 73  the main databas
25a0: 65 2e 0a 2a 2f 0a 76 6f 69 64 20 63 6f 6e 66 69  e..*/.void confi
25b0: 67 75 72 65 5f 66 69 6e 61 6c 69 7a 65 5f 72 65  gure_finalize_re
25c0: 63 65 69 76 65 28 76 6f 69 64 29 7b 0a 20 20 73  ceive(void){.  s
25d0: 74 61 74 69 63 20 63 6f 6e 73 74 20 63 68 61 72  tatic const char
25e0: 20 7a 53 51 4c 5b 5d 20 3d 0a 20 20 20 20 40 20   zSQL[] =.    @ 
25f0: 44 45 4c 45 54 45 20 46 52 4f 4d 20 75 73 65 72  DELETE FROM user
2600: 3b 0a 20 20 20 20 40 20 49 4e 53 45 52 54 20 49  ;.    @ INSERT I
2610: 4e 54 4f 20 75 73 65 72 20 53 45 4c 45 43 54 20  NTO user SELECT 
2620: 2a 20 46 52 4f 4d 20 5f 78 66 65 72 5f 75 73 65  * FROM _xfer_use
2630: 72 3b 0a 20 20 20 20 40 20 44 45 4c 45 54 45 20  r;.    @ DELETE 
2640: 46 52 4f 4d 20 72 65 70 6f 72 74 66 6d 74 3b 0a  FROM reportfmt;.
2650: 20 20 20 20 40 20 49 4e 53 45 52 54 20 49 4e 54      @ INSERT INT
2660: 4f 20 72 65 70 6f 72 74 66 6d 74 20 53 45 4c 45  O reportfmt SELE
2670: 43 54 20 2a 20 46 52 4f 4d 20 5f 78 66 65 72 5f  CT * FROM _xfer_
2680: 72 65 70 6f 72 74 66 6d 74 3b 0a 20 20 20 20 40  reportfmt;.    @
2690: 20 44 52 4f 50 20 54 41 42 4c 45 20 5f 78 66 65   DROP TABLE _xfe
26a0: 72 5f 75 73 65 72 3b 0a 20 20 20 20 40 20 44 52  r_user;.    @ DR
26b0: 4f 50 20 54 41 42 4c 45 20 5f 78 66 65 72 5f 72  OP TABLE _xfer_r
26c0: 65 70 6f 72 74 66 6d 74 3b 0a 20 20 3b 0a 20 20  eportfmt;.  ;.  
26d0: 64 62 5f 6d 75 6c 74 69 5f 65 78 65 63 28 7a 53  db_multi_exec(zS
26e0: 51 4c 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 49 64  QL);.}../*.** Id
26f0: 65 6e 74 69 66 79 20 61 20 63 6f 6e 66 69 67 75  entify a configu
2700: 72 61 74 69 6f 6e 20 67 72 6f 75 70 20 62 79 20  ration group by 
2710: 6e 61 6d 65 2e 20 20 52 65 74 75 72 6e 20 69 74  name.  Return it
2720: 73 20 6d 61 73 6b 2e 0a 2a 2a 20 54 68 72 6f 77  s mask..** Throw
2730: 20 61 6e 20 65 72 72 6f 72 20 69 66 20 6e 6f 20   an error if no 
2740: 6d 61 74 63 68 2e 0a 2a 2f 0a 73 74 61 74 69 63  match..*/.static
2750: 20 69 6e 74 20 66 69 6e 64 5f 61 72 65 61 28 63   int find_area(c
2760: 6f 6e 73 74 20 63 68 61 72 20 2a 7a 29 7b 0a 20  onst char *z){. 
2770: 20 69 6e 74 20 69 3b 0a 20 20 69 6e 74 20 6e 20   int i;.  int n 
2780: 3d 20 73 74 72 6c 65 6e 28 7a 29 3b 0a 20 20 66  = strlen(z);.  f
2790: 6f 72 28 69 3d 30 3b 20 69 3c 63 6f 75 6e 74 28  or(i=0; i<count(
27a0: 61 47 72 6f 75 70 4e 61 6d 65 29 3b 20 69 2b 2b  aGroupName); i++
27b0: 29 7b 0a 20 20 20 20 69 66 28 20 73 74 72 6e 63  ){.    if( strnc
27c0: 6d 70 28 7a 2c 20 61 47 72 6f 75 70 4e 61 6d 65  mp(z, aGroupName
27d0: 5b 69 5d 2e 7a 4e 61 6d 65 2c 20 6e 29 3d 3d 30  [i].zName, n)==0
27e0: 20 29 7b 0a 20 20 20 20 20 20 72 65 74 75 72 6e   ){.      return
27f0: 20 61 47 72 6f 75 70 4e 61 6d 65 5b 69 5d 2e 67   aGroupName[i].g
2800: 72 6f 75 70 4d 61 73 6b 3b 0a 20 20 20 20 7d 0a  roupMask;.    }.
2810: 20 20 7d 0a 20 20 70 72 69 6e 74 66 28 22 41 76    }.  printf("Av
2820: 61 69 6c 61 62 6c 65 20 63 6f 6e 66 69 67 75 72  ailable configur
2830: 61 74 69 6f 6e 20 61 72 65 61 73 3a 5c 6e 22 29  ation areas:\n")
2840: 3b 0a 20 20 66 6f 72 28 69 3d 30 3b 20 69 3c 63  ;.  for(i=0; i<c
2850: 6f 75 6e 74 28 61 47 72 6f 75 70 4e 61 6d 65 29  ount(aGroupName)
2860: 3b 20 69 2b 2b 29 7b 0a 20 20 20 20 70 72 69 6e  ; i++){.    prin
2870: 74 66 28 22 20 20 25 2d 31 30 73 20 25 73 5c 6e  tf("  %-10s %s\n
2880: 22 2c 20 61 47 72 6f 75 70 4e 61 6d 65 5b 69 5d  ", aGroupName[i]
2890: 2e 7a 4e 61 6d 65 2c 20 61 47 72 6f 75 70 4e 61  .zName, aGroupNa
28a0: 6d 65 5b 69 5d 2e 7a 48 65 6c 70 29 3b 0a 20 20  me[i].zHelp);.  
28b0: 7d 0a 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c  }.  fossil_fatal
28c0: 28 22 6e 6f 20 73 75 63 68 20 63 6f 6e 66 69 67  ("no such config
28d0: 75 72 61 74 69 6f 6e 20 61 72 65 61 3a 20 5c 22  uration area: \"
28e0: 25 73 5c 22 22 2c 20 7a 29 3b 0a 20 20 72 65 74  %s\"", z);.  ret
28f0: 75 72 6e 20 30 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20  urn 0;.}../*.** 
2900: 57 72 69 74 65 20 53 51 4c 20 74 65 78 74 20 69  Write SQL text i
2910: 6e 74 6f 20 66 69 6c 65 20 7a 46 69 6c 65 6e 61  nto file zFilena
2920: 6d 65 20 74 68 61 74 20 77 69 6c 6c 20 72 65 73  me that will res
2930: 74 6f 72 65 20 74 68 65 20 63 6f 6e 66 69 67 75  tore the configu
2940: 72 61 74 69 6f 6e 0a 2a 2a 20 61 72 65 61 20 69  ration.** area i
2950: 64 65 6e 74 69 66 69 65 64 20 62 79 20 6d 61 73  dentified by mas
2960: 6b 20 74 6f 20 69 74 73 20 63 75 72 72 65 6e 74  k to its current
2970: 20 73 74 61 74 65 20 66 72 6f 6d 20 61 6e 79 20   state from any 
2980: 6f 74 68 65 72 20 73 74 61 74 65 2e 0a 2a 2f 0a  other state..*/.
2990: 73 74 61 74 69 63 20 76 6f 69 64 20 65 78 70 6f  static void expo
29a0: 72 74 5f 63 6f 6e 66 69 67 28 0a 20 20 69 6e 74  rt_config(.  int
29b0: 20 6d 61 73 6b 2c 20 20 20 20 20 20 20 20 20 20   mask,          
29c0: 20 20 20 20 20 20 20 2f 2a 20 4d 61 73 6b 20 69         /* Mask i
29d0: 6e 64 69 63 61 74 69 6e 67 20 77 68 69 63 68 20  ndicating which 
29e0: 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 74 6f  configuration to
29f0: 20 65 78 70 6f 72 74 20 2a 2f 0a 20 20 63 6f 6e   export */.  con
2a00: 73 74 20 63 68 61 72 20 2a 7a 4d 61 73 6b 2c 20  st char *zMask, 
2a10: 20 20 20 20 20 20 20 2f 2a 20 4e 61 6d 65 20 6f         /* Name o
2a20: 66 20 74 68 65 20 63 6f 6e 66 69 67 75 72 61 74  f the configurat
2a30: 69 6f 6e 20 2a 2f 0a 20 20 63 6f 6e 73 74 20 63  ion */.  const c
2a40: 68 61 72 20 2a 7a 46 69 6c 65 6e 61 6d 65 20 20  har *zFilename  
2a50: 20 20 20 2f 2a 20 57 72 69 74 65 20 69 6e 74 6f     /* Write into
2a60: 20 74 68 69 73 20 66 69 6c 65 20 2a 2f 0a 29 7b   this file */.){
2a70: 0a 20 20 69 6e 74 20 69 3b 0a 20 20 42 6c 6f 62  .  int i;.  Blob
2a80: 20 6f 75 74 3b 0a 20 20 62 6c 6f 62 5f 7a 65 72   out;.  blob_zer
2a90: 6f 28 26 6f 75 74 29 3b 0a 20 20 62 6c 6f 62 5f  o(&out);.  blob_
2aa0: 61 70 70 65 6e 64 66 28 26 6f 75 74 2c 20 0a 20  appendf(&out, . 
2ab0: 20 20 20 22 2d 2d 20 54 68 65 20 5c 22 25 73 5c     "-- The \"%s\
2ac0: 22 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20  " configuration 
2ad0: 65 78 70 6f 72 74 65 64 20 66 72 6f 6d 5c 6e 22  exported from\n"
2ae0: 0a 20 20 20 20 22 2d 2d 20 72 65 70 6f 73 69 74  .    "-- reposit
2af0: 6f 72 79 20 5c 22 25 73 5c 22 5c 6e 22 0a 20 20  ory \"%s\"\n".  
2b00: 20 20 22 2d 2d 20 6f 6e 20 25 73 5c 6e 22 2c 0a    "-- on %s\n",.
2b10: 20 20 20 20 7a 4d 61 73 6b 2c 20 67 2e 7a 52 65      zMask, g.zRe
2b20: 70 6f 73 69 74 6f 72 79 4e 61 6d 65 2c 0a 20 20  positoryName,.  
2b30: 20 20 64 62 5f 74 65 78 74 28 30 2c 20 22 53 45    db_text(0, "SE
2b40: 4c 45 43 54 20 64 61 74 65 74 69 6d 65 28 27 6e  LECT datetime('n
2b50: 6f 77 27 29 22 29 0a 20 20 29 3b 0a 20 20 66 6f  ow')").  );.  fo
2b60: 72 28 69 3d 30 3b 20 69 3c 63 6f 75 6e 74 28 61  r(i=0; i<count(a
2b70: 43 6f 6e 66 69 67 29 3b 20 69 2b 2b 29 7b 0a 20  Config); i++){. 
2b80: 20 20 20 69 66 28 20 28 61 43 6f 6e 66 69 67 5b     if( (aConfig[
2b90: 69 5d 2e 67 72 6f 75 70 4d 61 73 6b 20 26 20 6d  i].groupMask & m
2ba0: 61 73 6b 29 21 3d 30 20 29 7b 0a 20 20 20 20 20  ask)!=0 ){.     
2bb0: 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61   const char *zNa
2bc0: 6d 65 20 3d 20 61 43 6f 6e 66 69 67 5b 69 5d 2e  me = aConfig[i].
2bd0: 7a 4e 61 6d 65 3b 0a 20 20 20 20 20 20 69 66 28  zName;.      if(
2be0: 20 7a 4e 61 6d 65 5b 30 5d 21 3d 27 40 27 20 29   zName[0]!='@' )
2bf0: 7b 0a 20 20 20 20 20 20 20 20 63 68 61 72 20 2a  {.        char *
2c00: 7a 56 61 6c 75 65 20 3d 20 64 62 5f 74 65 78 74  zValue = db_text
2c10: 28 30 2c 20 0a 20 20 20 20 20 20 20 20 20 20 20  (0, .           
2c20: 20 22 53 45 4c 45 43 54 20 76 61 6c 75 65 20 46   "SELECT value F
2c30: 52 4f 4d 20 63 6f 6e 66 69 67 20 57 48 45 52 45  ROM config WHERE
2c40: 20 6e 61 6d 65 3d 25 51 22 2c 20 7a 4e 61 6d 65   name=%Q", zName
2c50: 29 3b 0a 20 20 20 20 20 20 20 20 69 66 28 20 7a  );.        if( z
2c60: 56 61 6c 75 65 20 29 7b 0a 20 20 20 20 20 20 20  Value ){.       
2c70: 20 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28     blob_appendf(
2c80: 26 6f 75 74 2c 22 52 45 50 4c 41 43 45 20 49 4e  &out,"REPLACE IN
2c90: 54 4f 20 63 6f 6e 66 69 67 20 56 41 4c 55 45 53  TO config VALUES
2ca0: 28 25 51 2c 25 51 29 3b 5c 6e 22 2c 20 0a 20 20  (%Q,%Q);\n", .  
2cb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
2cc0: 20 20 20 20 20 7a 4e 61 6d 65 2c 20 7a 56 61 6c       zName, zVal
2cd0: 75 65 29 3b 0a 20 20 20 20 20 20 20 20 7d 0a 20  ue);.        }. 
2ce0: 20 20 20 20 20 20 20 66 72 65 65 28 7a 56 61 6c         free(zVal
2cf0: 75 65 29 3b 0a 20 20 20 20 20 20 7d 65 6c 73 65  ue);.      }else
2d00: 7b 0a 20 20 20 20 20 20 20 20 63 6f 6e 66 69 67  {.        config
2d10: 75 72 65 5f 72 65 6e 64 65 72 5f 73 70 65 63 69  ure_render_speci
2d20: 61 6c 5f 6e 61 6d 65 28 7a 4e 61 6d 65 2c 20 26  al_name(zName, &
2d30: 6f 75 74 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20  out);.      }.  
2d40: 20 20 7d 0a 20 20 7d 0a 20 20 62 6c 6f 62 5f 77    }.  }.  blob_w
2d50: 72 69 74 65 5f 74 6f 5f 66 69 6c 65 28 26 6f 75  rite_to_file(&ou
2d60: 74 2c 20 7a 46 69 6c 65 6e 61 6d 65 29 3b 0a 20  t, zFilename);. 
2d70: 20 62 6c 6f 62 5f 72 65 73 65 74 28 26 6f 75 74   blob_reset(&out
2d80: 29 3b 0a 7d 0a 0a 0a 2f 2a 0a 2a 2a 20 43 4f 4d  );.}.../*.** COM
2d90: 4d 41 4e 44 3a 20 63 6f 6e 66 69 67 75 72 61 74  MAND: configurat
2da0: 69 6f 6e 0a 2a 2a 0a 2a 2a 20 55 73 61 67 65 3a  ion.**.** Usage:
2db0: 20 25 66 6f 73 73 69 6c 20 63 6f 6e 66 69 67 75   %fossil configu
2dc0: 72 65 20 4d 45 54 48 4f 44 20 2e 2e 2e 0a 2a 2a  re METHOD ....**
2dd0: 0a 2a 2a 20 57 68 65 72 65 20 4d 45 54 48 4f 44  .** Where METHOD
2de0: 20 69 73 20 6f 6e 65 20 6f 66 3a 20 65 78 70 6f   is one of: expo
2df0: 72 74 20 69 6d 70 6f 72 74 20 6d 65 72 67 65 20  rt import merge 
2e00: 70 75 6c 6c 20 72 65 73 65 74 2e 20 20 41 6c 6c  pull reset.  All
2e10: 20 6d 65 74 68 6f 64 73 0a 2a 2a 20 61 63 63 65   methods.** acce
2e20: 70 74 20 74 68 65 20 2d 52 20 6f 72 20 2d 2d 72  pt the -R or --r
2e30: 65 70 6f 73 69 74 6f 72 79 20 6f 70 74 69 6f 6e  epository option
2e40: 20 74 6f 20 73 70 65 63 69 66 69 63 20 61 20 72   to specific a r
2e50: 65 70 6f 73 69 74 6f 72 79 2e 0a 2a 2a 0a 2a 2a  epository..**.**
2e60: 20 20 20 20 25 66 6f 73 73 69 6c 20 63 6f 6e 66      %fossil conf
2e70: 69 67 75 72 61 74 69 6f 6e 20 65 78 70 6f 72 74  iguration export
2e80: 20 41 52 45 41 20 46 49 4c 45 4e 41 4d 45 0a 2a   AREA FILENAME.*
2e90: 2a 0a 2a 2a 20 20 20 20 20 20 20 20 20 57 72 69  *.**         Wri
2ea0: 74 65 20 74 6f 20 46 49 4c 45 4e 41 4d 45 20 65  te to FILENAME e
2eb0: 78 70 6f 72 74 65 64 20 63 6f 6e 66 69 67 75 72  xported configur
2ec0: 61 74 6f 6e 20 69 6e 66 6f 72 6d 61 74 69 6f 6e  aton information
2ed0: 20 66 6f 72 20 41 52 45 41 2e 0a 2a 2a 20 20 20   for AREA..**   
2ee0: 20 20 20 20 20 20 41 52 45 41 20 63 61 6e 20 62        AREA can b
2ef0: 65 20 6f 6e 65 20 6f 66 3a 20 20 61 6c 6c 20 74  e one of:  all t
2f00: 69 63 6b 65 74 20 73 6b 69 6e 20 70 72 6f 6a 65  icket skin proje
2f10: 63 74 0a 2a 2a 0a 2a 2a 20 20 20 20 25 66 6f 73  ct.**.**    %fos
2f20: 73 69 6c 20 63 6f 6e 66 69 67 75 72 61 74 69 6f  sil configuratio
2f30: 6e 20 69 6d 70 6f 72 74 20 46 49 4c 45 4e 41 4d  n import FILENAM
2f40: 45 0a 2a 2a 0a 2a 2a 20 20 20 20 20 20 20 20 20  E.**.**         
2f50: 52 65 61 64 20 61 20 63 6f 6e 66 69 67 75 72 61  Read a configura
2f60: 74 69 6f 6e 20 66 72 6f 6d 20 46 49 4c 45 4e 41  tion from FILENA
2f70: 4d 45 2c 20 6f 76 65 72 77 72 69 74 69 6e 67 20  ME, overwriting 
2f80: 74 68 65 20 63 75 72 72 65 6e 74 0a 2a 2a 20 20  the current.**  
2f90: 20 20 20 20 20 20 20 63 6f 6e 66 69 67 75 72 61         configura
2fa0: 74 69 6f 6e 2e 0a 2a 2a 0a 2a 2a 20 20 20 20 25  tion..**.**    %
2fb0: 66 6f 73 73 69 6c 20 63 6f 6e 66 69 67 75 72 61  fossil configura
2fc0: 74 69 6f 6e 20 6d 65 72 67 65 20 46 49 4c 45 4e  tion merge FILEN
2fd0: 41 4d 45 0a 2a 2a 0a 2a 2a 20 20 20 20 20 20 20  AME.**.**       
2fe0: 20 20 52 65 61 64 20 61 20 63 6f 6e 66 69 67 75    Read a configu
2ff0: 72 61 74 69 6f 6e 20 66 72 6f 6d 20 46 49 4c 45  ration from FILE
3000: 4e 41 4d 45 20 61 6e 64 20 6d 65 72 67 65 20 69  NAME and merge i
3010: 74 73 20 76 61 6c 75 65 73 20 69 6e 74 6f 0a 2a  ts values into.*
3020: 2a 20 20 20 20 20 20 20 20 20 74 68 65 20 63 75  *         the cu
3030: 72 72 65 6e 74 20 63 6f 6e 66 69 67 75 72 61 74  rrent configurat
3040: 69 6f 6e 2e 20 20 45 78 69 73 74 69 6e 67 20 76  ion.  Existing v
3050: 61 6c 75 65 73 20 74 61 6b 65 20 70 72 69 6f 72  alues take prior
3060: 69 74 79 20 6f 76 65 72 0a 2a 2a 20 20 20 20 20  ity over.**     
3070: 20 20 20 20 76 61 6c 75 65 73 20 72 65 61 64 20      values read 
3080: 66 72 6f 6d 20 46 49 4c 45 4e 41 4d 45 2e 0a 2a  from FILENAME..*
3090: 2a 0a 2a 2a 20 20 20 20 25 66 6f 73 73 69 6c 20  *.**    %fossil 
30a0: 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 70 75  configuration pu
30b0: 6c 6c 20 41 52 45 41 20 3f 55 52 4c 3f 0a 2a 2a  ll AREA ?URL?.**
30c0: 0a 2a 2a 20 20 20 20 20 20 20 20 20 50 75 6c 6c  .**         Pull
30d0: 20 61 6e 64 20 69 6e 73 74 61 6c 6c 20 74 68 65   and install the
30e0: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20 66   configuration f
30f0: 72 6f 6d 20 61 20 64 69 66 66 65 72 65 6e 74 20  rom a different 
3100: 73 65 72 76 65 72 0a 2a 2a 20 20 20 20 20 20 20  server.**       
3110: 20 20 69 64 65 6e 74 69 66 69 65 64 20 62 79 20    identified by 
3120: 55 52 4c 2e 20 20 49 66 20 6e 6f 20 55 52 4c 20  URL.  If no URL 
3130: 69 73 20 73 70 65 63 69 66 69 65 64 2c 20 74 68  is specified, th
3140: 65 6e 20 74 68 65 20 64 65 66 61 75 6c 74 0a 2a  en the default.*
3150: 2a 20 20 20 20 20 20 20 20 20 73 65 72 76 65 72  *         server
3160: 20 69 73 20 75 73 65 64 2e 0a 2a 2a 0a 2a 2a 20   is used..**.** 
3170: 20 20 20 25 66 6f 73 73 69 6c 20 63 6f 6e 66 69     %fossil confi
3180: 67 75 72 61 74 69 6f 6e 20 72 65 73 65 74 20 41  guration reset A
3190: 52 45 41 0a 2a 2a 0a 2a 2a 20 20 20 20 20 20 20  REA.**.**       
31a0: 20 20 52 65 73 74 6f 72 65 20 74 68 65 20 63 6f    Restore the co
31b0: 6e 66 69 67 75 72 61 74 69 6f 6e 20 74 6f 20 74  nfiguration to t
31c0: 68 65 20 64 65 66 61 75 6c 74 2e 20 20 41 52 45  he default.  ARE
31d0: 41 20 61 73 20 61 62 6f 76 65 2e 0a 2a 2a 0a 2a  A as above..**.*
31e0: 2a 20 57 41 52 4e 49 4e 47 3a 20 44 6f 20 6e 6f  * WARNING: Do no
31f0: 74 20 69 6d 70 6f 72 74 2c 20 6d 65 72 67 65 2c  t import, merge,
3200: 20 6f 72 20 70 75 6c 6c 20 63 6f 6e 66 69 67 75   or pull configu
3210: 72 61 74 69 6f 6e 73 20 66 72 6f 6d 20 61 6e 20  rations from an 
3220: 75 6e 74 72 75 73 74 65 64 0a 2a 2a 20 73 6f 75  untrusted.** sou
3230: 72 63 65 2e 20 20 54 68 65 20 69 6e 62 6f 75 6e  rce.  The inboun
3240: 64 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 20  d configuration 
3250: 69 73 20 6e 6f 74 20 63 68 65 63 6b 65 64 20 66  is not checked f
3260: 6f 72 20 73 61 66 65 74 79 20 61 6e 64 20 63 61  or safety and ca
3270: 6e 0a 2a 2a 20 69 6e 74 72 6f 64 75 63 65 20 73  n.** introduce s
3280: 65 63 75 72 69 74 79 20 76 75 6c 6e 65 72 61 62  ecurity vulnerab
3290: 69 6c 69 74 69 65 73 2e 0a 2a 2f 0a 76 6f 69 64  ilities..*/.void
32a0: 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 5f 63   configuration_c
32b0: 6d 64 28 76 6f 69 64 29 7b 0a 20 20 69 6e 74 20  md(void){.  int 
32c0: 6e 3b 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20  n;.  const char 
32d0: 2a 7a 4d 65 74 68 6f 64 3b 0a 20 20 69 66 28 20  *zMethod;.  if( 
32e0: 67 2e 61 72 67 63 3c 33 20 29 7b 0a 20 20 20 20  g.argc<3 ){.    
32f0: 75 73 61 67 65 28 22 65 78 70 6f 72 74 7c 69 6d  usage("export|im
3300: 70 6f 72 74 7c 6d 65 72 67 65 7c 70 75 6c 6c 7c  port|merge|pull|
3310: 72 65 73 65 74 20 2e 2e 2e 22 29 3b 0a 20 20 7d  reset ...");.  }
3320: 0a 20 20 64 62 5f 66 69 6e 64 5f 61 6e 64 5f 6f  .  db_find_and_o
3330: 70 65 6e 5f 72 65 70 6f 73 69 74 6f 72 79 28 31  pen_repository(1
3340: 29 3b 0a 20 20 7a 4d 65 74 68 6f 64 20 3d 20 67  );.  zMethod = g
3350: 2e 61 72 67 76 5b 32 5d 3b 0a 20 20 6e 20 3d 20  .argv[2];.  n = 
3360: 73 74 72 6c 65 6e 28 7a 4d 65 74 68 6f 64 29 3b  strlen(zMethod);
3370: 0a 20 20 69 66 28 20 73 74 72 6e 63 6d 70 28 7a  .  if( strncmp(z
3380: 4d 65 74 68 6f 64 2c 20 22 65 78 70 6f 72 74 22  Method, "export"
3390: 2c 20 6e 29 3d 3d 30 20 29 7b 0a 20 20 20 20 69  , n)==0 ){.    i
33a0: 6e 74 20 6d 61 73 6b 3b 0a 20 20 20 20 69 66 28  nt mask;.    if(
33b0: 20 67 2e 61 72 67 63 21 3d 35 20 29 7b 0a 20 20   g.argc!=5 ){.  
33c0: 20 20 20 20 75 73 61 67 65 28 22 65 78 70 6f 72      usage("expor
33d0: 74 20 41 52 45 41 20 46 49 4c 45 4e 41 4d 45 22  t AREA FILENAME"
33e0: 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20 6d 61 73  );.    }.    mas
33f0: 6b 20 3d 20 66 69 6e 64 5f 61 72 65 61 28 67 2e  k = find_area(g.
3400: 61 72 67 76 5b 33 5d 29 3b 0a 20 20 20 20 65 78  argv[3]);.    ex
3410: 70 6f 72 74 5f 63 6f 6e 66 69 67 28 6d 61 73 6b  port_config(mask
3420: 2c 20 67 2e 61 72 67 76 5b 33 5d 2c 20 67 2e 61  , g.argv[3], g.a
3430: 72 67 76 5b 34 5d 29 3b 0a 20 20 7d 65 6c 73 65  rgv[4]);.  }else
3440: 0a 20 20 69 66 28 20 73 74 72 6e 63 6d 70 28 7a  .  if( strncmp(z
3450: 4d 65 74 68 6f 64 2c 20 22 69 6d 70 6f 72 74 22  Method, "import"
3460: 2c 20 6e 29 3d 3d 30 20 0a 20 20 20 20 20 20 20  , n)==0 .       
3470: 7c 7c 20 73 74 72 6e 63 6d 70 28 7a 4d 65 74 68  || strncmp(zMeth
3480: 6f 64 2c 20 22 6d 65 72 67 65 22 2c 20 6e 29 3d  od, "merge", n)=
3490: 3d 30 20 29 7b 0a 20 20 20 20 42 6c 6f 62 20 69  =0 ){.    Blob i
34a0: 6e 3b 0a 20 20 20 20 69 66 28 20 67 2e 61 72 67  n;.    if( g.arg
34b0: 63 21 3d 34 20 29 20 75 73 61 67 65 28 6d 70 72  c!=4 ) usage(mpr
34c0: 69 6e 74 66 28 22 25 73 20 46 49 4c 45 4e 41 4d  intf("%s FILENAM
34d0: 45 22 2c 7a 4d 65 74 68 6f 64 29 29 3b 0a 20 20  E",zMethod));.  
34e0: 20 20 62 6c 6f 62 5f 72 65 61 64 5f 66 72 6f 6d    blob_read_from
34f0: 5f 66 69 6c 65 28 26 69 6e 2c 20 67 2e 61 72 67  _file(&in, g.arg
3500: 76 5b 33 5d 29 3b 0a 20 20 20 20 64 62 5f 62 65  v[3]);.    db_be
3510: 67 69 6e 5f 74 72 61 6e 73 61 63 74 69 6f 6e 28  gin_transaction(
3520: 29 3b 0a 20 20 20 20 63 6f 6e 66 69 67 75 72 65  );.    configure
3530: 5f 70 72 65 70 61 72 65 5f 74 6f 5f 72 65 63 65  _prepare_to_rece
3540: 69 76 65 28 7a 4d 65 74 68 6f 64 5b 30 5d 3d 3d  ive(zMethod[0]==
3550: 27 69 27 29 3b 0a 20 20 20 20 64 62 5f 6d 75 6c  'i');.    db_mul
3560: 74 69 5f 65 78 65 63 28 22 25 73 22 2c 20 62 6c  ti_exec("%s", bl
3570: 6f 62 5f 73 74 72 28 26 69 6e 29 29 3b 0a 20 20  ob_str(&in));.  
3580: 20 20 63 6f 6e 66 69 67 75 72 65 5f 66 69 6e 61    configure_fina
3590: 6c 69 7a 65 5f 72 65 63 65 69 76 65 28 29 3b 0a  lize_receive();.
35a0: 20 20 20 20 64 62 5f 65 6e 64 5f 74 72 61 6e 73      db_end_trans
35b0: 61 63 74 69 6f 6e 28 30 29 3b 0a 20 20 7d 65 6c  action(0);.  }el
35c0: 73 65 0a 20 20 69 66 28 20 73 74 72 6e 63 6d 70  se.  if( strncmp
35d0: 28 7a 4d 65 74 68 6f 64 2c 20 22 70 75 6c 6c 22  (zMethod, "pull"
35e0: 2c 20 6e 29 3d 3d 30 20 29 7b 0a 20 20 20 20 69  , n)==0 ){.    i
35f0: 6e 74 20 6d 61 73 6b 3b 0a 20 20 20 20 63 6f 6e  nt mask;.    con
3600: 73 74 20 63 68 61 72 20 2a 7a 53 65 72 76 65 72  st char *zServer
3610: 3b 0a 20 20 20 20 75 72 6c 5f 70 72 6f 78 79 5f  ;.    url_proxy_
3620: 6f 70 74 69 6f 6e 73 28 29 3b 0a 20 20 20 20 69  options();.    i
3630: 66 28 20 67 2e 61 72 67 63 21 3d 34 20 26 26 20  f( g.argc!=4 && 
3640: 67 2e 61 72 67 63 21 3d 35 20 29 7b 0a 20 20 20  g.argc!=5 ){.   
3650: 20 20 20 75 73 61 67 65 28 22 70 75 6c 6c 20 41     usage("pull A
3660: 52 45 41 20 3f 55 52 4c 3f 22 29 3b 0a 20 20 20  REA ?URL?");.   
3670: 20 7d 0a 20 20 20 20 6d 61 73 6b 20 3d 20 66 69   }.    mask = fi
3680: 6e 64 5f 61 72 65 61 28 67 2e 61 72 67 76 5b 33  nd_area(g.argv[3
3690: 5d 29 3b 0a 20 20 20 20 69 66 28 20 67 2e 61 72  ]);.    if( g.ar
36a0: 67 63 3d 3d 35 20 29 7b 0a 20 20 20 20 20 20 7a  gc==5 ){.      z
36b0: 53 65 72 76 65 72 20 3d 20 67 2e 61 72 67 76 5b  Server = g.argv[
36c0: 34 5d 3b 0a 20 20 20 20 7d 65 6c 73 65 7b 0a 20  4];.    }else{. 
36d0: 20 20 20 20 20 7a 53 65 72 76 65 72 20 3d 20 64       zServer = d
36e0: 62 5f 67 65 74 28 22 6c 61 73 74 2d 73 79 6e 63  b_get("last-sync
36f0: 2d 75 72 6c 22 2c 20 30 29 3b 0a 20 20 20 20 20  -url", 0);.     
3700: 20 69 66 28 20 7a 53 65 72 76 65 72 3d 3d 30 20   if( zServer==0 
3710: 29 7b 0a 20 20 20 20 20 20 20 20 66 6f 73 73 69  ){.        fossi
3720: 6c 5f 66 61 74 61 6c 28 22 6e 6f 20 73 65 72 76  l_fatal("no serv
3730: 65 72 20 73 70 65 63 69 66 69 65 64 22 29 3b 0a  er specified");.
3740: 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a 20 20        }.    }.  
3750: 20 20 75 72 6c 5f 70 61 72 73 65 28 7a 53 65 72    url_parse(zSer
3760: 76 65 72 29 3b 0a 20 20 20 20 69 66 28 20 67 2e  ver);.    if( g.
3770: 75 72 6c 49 73 46 69 6c 65 20 29 7b 0a 20 20 20  urlIsFile ){.   
3780: 20 20 20 66 6f 73 73 69 6c 5f 66 61 74 61 6c 28     fossil_fatal(
3790: 22 6e 65 74 77 6f 72 6b 20 73 79 6e 63 20 6f 6e  "network sync on
37a0: 6c 79 22 29 3b 0a 20 20 20 20 7d 0a 20 20 20 20  ly");.    }.    
37b0: 75 73 65 72 5f 73 65 6c 65 63 74 28 29 3b 0a 20  user_select();. 
37c0: 20 20 20 63 6c 69 65 6e 74 5f 73 79 6e 63 28 30     client_sync(0
37d0: 2c 30 2c 30 2c 6d 61 73 6b 29 3b 0a 20 20 7d 65  ,0,0,mask);.  }e
37e0: 6c 73 65 0a 20 20 69 66 28 20 73 74 72 6e 63 6d  lse.  if( strncm
37f0: 70 28 7a 4d 65 74 68 6f 64 2c 20 22 72 65 73 65  p(zMethod, "rese
3800: 74 22 2c 20 6e 29 3d 3d 30 20 29 7b 0a 20 20 20  t", n)==0 ){.   
3810: 20 69 6e 74 20 6d 61 73 6b 2c 20 69 3b 0a 20 20   int mask, i;.  
3820: 20 20 63 68 61 72 20 2a 7a 42 61 63 6b 75 70 3b    char *zBackup;
3830: 0a 20 20 20 20 69 66 28 20 67 2e 61 72 67 63 21  .    if( g.argc!
3840: 3d 34 20 29 20 75 73 61 67 65 28 22 72 65 73 65  =4 ) usage("rese
3850: 74 20 41 52 45 41 22 29 3b 0a 20 20 20 20 6d 61  t AREA");.    ma
3860: 73 6b 20 3d 20 66 69 6e 64 5f 61 72 65 61 28 67  sk = find_area(g
3870: 2e 61 72 67 76 5b 33 5d 29 3b 0a 20 20 20 20 7a  .argv[3]);.    z
3880: 42 61 63 6b 75 70 20 3d 20 64 62 5f 74 65 78 74  Backup = db_text
3890: 28 30 2c 20 0a 20 20 20 20 20 20 20 22 53 45 4c  (0, .       "SEL
38a0: 45 43 54 20 73 74 72 66 74 69 6d 65 28 27 63 6f  ECT strftime('co
38b0: 6e 66 69 67 2d 62 61 63 6b 75 70 2d 25 25 59 25  nfig-backup-%%Y%
38c0: 25 6d 25 25 64 25 25 48 25 25 4d 25 25 66 27 2c  %m%%d%%H%%M%%f',
38d0: 27 6e 6f 77 27 29 22 29 3b 0a 20 20 20 20 64 62  'now')");.    db
38e0: 5f 62 65 67 69 6e 5f 74 72 61 6e 73 61 63 74 69  _begin_transacti
38f0: 6f 6e 28 29 3b 0a 20 20 20 20 65 78 70 6f 72 74  on();.    export
3900: 5f 63 6f 6e 66 69 67 28 6d 61 73 6b 2c 20 67 2e  _config(mask, g.
3910: 61 72 67 76 5b 33 5d 2c 20 7a 42 61 63 6b 75 70  argv[3], zBackup
3920: 29 3b 0a 20 20 20 20 66 6f 72 28 69 3d 30 3b 20  );.    for(i=0; 
3930: 69 3c 63 6f 75 6e 74 28 61 43 6f 6e 66 69 67 29  i<count(aConfig)
3940: 3b 20 69 2b 2b 29 7b 0a 20 20 20 20 20 20 63 6f  ; i++){.      co
3950: 6e 73 74 20 63 68 61 72 20 2a 7a 4e 61 6d 65 20  nst char *zName 
3960: 3d 20 61 43 6f 6e 66 69 67 5b 69 5d 2e 7a 4e 61  = aConfig[i].zNa
3970: 6d 65 3b 0a 20 20 20 20 20 20 69 66 28 20 28 61  me;.      if( (a
3980: 43 6f 6e 66 69 67 5b 69 5d 2e 67 72 6f 75 70 4d  Config[i].groupM
3990: 61 73 6b 20 26 20 6d 61 73 6b 29 3d 3d 30 20 29  ask & mask)==0 )
39a0: 20 63 6f 6e 74 69 6e 75 65 3b 0a 20 20 20 20 20   continue;.     
39b0: 20 69 66 28 20 7a 4e 61 6d 65 5b 30 5d 21 3d 27   if( zName[0]!='
39c0: 40 27 20 29 7b 0a 20 20 20 20 20 20 20 20 64 62  @' ){.        db
39d0: 5f 6d 75 6c 74 69 5f 65 78 65 63 28 22 44 45 4c  _multi_exec("DEL
39e0: 45 54 45 20 46 52 4f 4d 20 63 6f 6e 66 69 67 20  ETE FROM config 
39f0: 57 48 45 52 45 20 6e 61 6d 65 3d 25 51 22 2c 20  WHERE name=%Q", 
3a00: 7a 4e 61 6d 65 29 3b 0a 20 20 20 20 20 20 7d 65  zName);.      }e
3a10: 6c 73 65 20 69 66 28 20 73 74 72 63 6d 70 28 7a  lse if( strcmp(z
3a20: 4e 61 6d 65 2c 22 40 75 73 65 72 22 29 3d 3d 30  Name,"@user")==0
3a30: 20 29 7b 0a 20 20 20 20 20 20 20 20 64 62 5f 6d   ){.        db_m
3a40: 75 6c 74 69 5f 65 78 65 63 28 22 44 45 4c 45 54  ulti_exec("DELET
3a50: 45 20 46 52 4f 4d 20 75 73 65 72 22 29 3b 0a 20  E FROM user");. 
3a60: 20 20 20 20 20 20 20 64 62 5f 63 72 65 61 74 65         db_create
3a70: 5f 64 65 66 61 75 6c 74 5f 75 73 65 72 73 28 29  _default_users()
3a80: 3b 0a 20 20 20 20 20 20 7d 65 6c 73 65 20 69 66  ;.      }else if
3a90: 28 20 73 74 72 63 6d 70 28 7a 4e 61 6d 65 2c 22  ( strcmp(zName,"
3aa0: 40 72 65 70 6f 72 74 66 6d 74 22 29 3d 3d 30 20  @reportfmt")==0 
3ab0: 29 7b 0a 20 20 20 20 20 20 20 20 64 62 5f 6d 75  ){.        db_mu
3ac0: 6c 74 69 5f 65 78 65 63 28 22 44 45 4c 45 54 45  lti_exec("DELETE
3ad0: 20 46 52 4f 4d 20 72 65 70 6f 72 74 66 6d 74 22   FROM reportfmt"
3ae0: 29 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d  );.      }.    }
3af0: 0a 20 20 20 20 64 62 5f 65 6e 64 5f 74 72 61 6e  .    db_end_tran
3b00: 73 61 63 74 69 6f 6e 28 30 29 3b 0a 20 20 20 20  saction(0);.    
3b10: 70 72 69 6e 74 66 28 22 43 6f 6e 66 69 67 75 72  printf("Configur
3b20: 61 74 69 6f 6e 20 72 65 73 65 74 20 74 6f 20 66  ation reset to f
3b30: 61 63 74 6f 72 79 20 64 65 66 61 75 6c 74 73 2e  actory defaults.
3b40: 5c 6e 22 29 3b 0a 20 20 20 20 70 72 69 6e 74 66  \n");.    printf
3b50: 28 22 54 6f 20 72 65 63 6f 76 65 72 2c 20 75 73  ("To recover, us
3b60: 65 3a 20 20 25 73 20 25 73 20 69 6d 70 6f 72 74  e:  %s %s import
3b70: 20 25 73 5c 6e 22 2c 20 0a 20 20 20 20 20 20 20   %s\n", .       
3b80: 20 20 20 20 20 67 2e 61 72 67 76 5b 30 5d 2c 20       g.argv[0], 
3b90: 67 2e 61 72 67 76 5b 31 5d 2c 20 7a 42 61 63 6b  g.argv[1], zBack
3ba0: 75 70 29 3b 0a 20 20 7d 65 6c 73 65 0a 20 20 7b  up);.  }else.  {
3bb0: 0a 20 20 20 20 66 6f 73 73 69 6c 5f 66 61 74 61  .    fossil_fata
3bc0: 6c 28 22 4d 45 54 48 4f 44 20 73 68 6f 75 6c 64  l("METHOD should
3bd0: 20 62 65 20 6f 6e 65 20 6f 66 3a 20 20 65 78 70   be one of:  exp
3be0: 6f 72 74 20 69 6d 70 6f 72 74 20 6d 65 72 67 65  ort import merge
3bf0: 20 70 75 6c 6c 20 72 65 73 65 74 22 29 3b 0a 20   pull reset");. 
3c00: 20 7d 0a 7d 0a                                    }.}.