Hex Artifact Content
Not logged in

Artifact e0b71a54048cda68ddffe3481391d79146137c2b:

File src/tkt.c part of check-in [8ef26c5e72] - Subscript interpreter is now running. by drh on 2007-11-03 04:01:55.

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 37 20 44 2e 20 52 69 63 68  (c) 2007 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 72 65 6e 64 65 72 20 61 6e 64 20 63  sed render and c
0390: 6f 6e 74 72 6f 6c 20 74 69 63 6b 65 74 20 65 6e  ontrol ticket en
03a0: 74 72 79 0a 2a 2a 20 61 6e 64 20 64 69 73 70 6c  try.** and displ
03b0: 61 79 20 70 61 67 65 73 2e 0a 2a 2f 0a 23 69 66  ay pages..*/.#if
03c0: 20 30 0a 23 69 6e 63 6c 75 64 65 20 22 63 6f 6e   0.#include "con
03d0: 66 69 67 2e 68 22 0a 23 69 6e 63 6c 75 64 65 20  fig.h".#include 
03e0: 22 74 6b 74 2e 68 22 0a 23 69 6e 63 6c 75 64 65  "tkt.h".#include
03f0: 20 3c 61 73 73 65 72 74 2e 68 3e 0a 0a 2f 2a 0a   <assert.h>../*.
0400: 2a 2a 20 46 6c 61 67 73 20 74 6f 20 69 6e 64 69  ** Flags to indi
0410: 63 61 74 65 20 77 68 61 74 20 6b 69 6e 64 20 6f  cate what kind o
0420: 66 20 74 69 63 6b 65 74 20 73 74 72 69 6e 67 20  f ticket string 
0430: 69 73 20 62 65 69 6e 67 20 67 65 6e 65 72 61 74  is being generat
0440: 65 64 2e 0a 2a 2a 20 41 20 62 69 74 6d 61 73 6b  ed..** A bitmask
0450: 20 6f 66 20 74 68 65 73 65 20 69 73 20 61 73 73   of these is ass
0460: 6f 63 69 61 74 65 64 20 77 69 74 68 20 65 61 63  ociated with eac
0470: 68 20 76 65 72 62 20 69 6e 20 6f 72 64 65 72 20  h verb in order 
0480: 74 6f 20 69 6e 64 69 63 61 74 65 0a 2a 2a 20 77  to indicate.** w
0490: 68 69 63 68 20 76 65 72 62 73 20 67 6f 20 6f 6e  hich verbs go on
04a0: 20 77 68 69 63 68 20 70 61 67 65 73 2e 0a 2a 2f   which pages..*/
04b0: 0a 23 64 65 66 69 6e 65 20 4d 5f 4e 45 57 20 20  .#define M_NEW  
04c0: 30 78 30 31 0a 23 64 65 66 69 6e 65 20 4d 5f 45  0x01.#define M_E
04d0: 44 49 54 20 30 78 30 32 0a 23 64 65 66 69 6e 65  DIT 0x02.#define
04e0: 20 4d 5f 56 49 45 57 20 30 78 30 34 0a 0a 2f 2a   M_VIEW 0x04../*
04f0: 0a 2a 2a 20 54 68 65 20 53 75 62 73 63 72 69 70  .** The Subscrip
0500: 74 20 69 6e 74 65 72 70 72 65 74 65 72 20 75 73  t interpreter us
0510: 65 64 20 74 6f 20 70 61 72 73 65 20 74 68 65 20  ed to parse the 
0520: 74 69 63 6b 65 74 20 63 6f 6e 66 69 67 75 72 65  ticket configure
0530: 0a 2a 2a 20 61 6e 64 20 74 6f 20 72 65 6e 64 65  .** and to rende
0540: 72 20 74 69 63 6b 65 74 20 73 63 72 65 65 6e 73  r ticket screens
0550: 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 73 74 72 75  ..*/.static stru
0560: 63 74 20 53 75 62 73 63 72 69 70 74 20 2a 70 49  ct Subscript *pI
0570: 6e 74 65 72 70 20 3d 20 30 3b 0a 0a 2f 2a 0a 2a  nterp = 0;../*.*
0580: 2a 20 54 68 65 20 6c 69 73 74 20 6f 66 20 64 61  * The list of da
0590: 74 61 62 61 73 65 20 66 69 65 6c 64 73 20 69 6e  tabase fields in
05a0: 20 74 68 65 20 74 69 63 6b 65 74 20 74 61 62 6c   the ticket tabl
05b0: 65 2e 0a 2a 2a 20 54 68 69 73 20 69 73 20 74 68  e..** This is th
05c0: 65 20 75 73 65 72 2d 64 65 66 69 6e 65 64 20 6c  e user-defined l
05d0: 69 73 74 20 69 6e 20 74 68 65 20 63 6f 6e 66 69  ist in the confi
05e0: 67 75 72 61 74 69 6f 6e 20 66 69 6c 65 2e 0a 2a  guration file..*
05f0: 2a 20 41 64 64 20 74 68 65 20 22 74 6b 74 5f 22  * Add the "tkt_"
0600: 20 70 72 65 66 69 78 20 74 6f 20 61 6c 6c 20 6f   prefix to all o
0610: 66 20 74 68 65 73 65 20 6e 61 6d 65 73 20 69 6e  f these names in
0620: 20 74 68 65 20 72 65 61 6c 20 74 61 62 6c 65 2e   the real table.
0630: 0a 2a 2a 20 54 68 65 20 72 65 61 6c 20 74 61 62  .** The real tab
0640: 6c 65 20 61 6c 73 6f 20 63 6f 6e 74 61 69 6e 73  le also contains
0650: 20 73 6f 6d 65 20 61 64 64 69 74 69 6f 6e 20 66   some addition f
0660: 69 65 6c 64 73 20 6e 6f 74 20 66 6f 75 6e 64 0a  ields not found.
0670: 2a 2a 20 68 65 72 65 2e 0a 2a 2f 0a 73 74 61 74  ** here..*/.stat
0680: 69 63 20 69 6e 74 20 6e 46 69 65 6c 64 20 3d 20  ic int nField = 
0690: 30 3b 0a 73 74 61 74 69 63 20 42 6c 6f 62 20 66  0;.static Blob f
06a0: 69 65 6c 64 4c 69 73 74 3b 0a 73 74 61 74 69 63  ieldList;.static
06b0: 20 63 68 61 72 20 2a 2a 61 7a 46 69 65 6c 64 20   char **azField 
06c0: 3d 20 30 3b 0a 73 74 61 74 69 63 20 63 68 61 72  = 0;.static char
06d0: 20 2a 2a 61 7a 56 61 6c 75 65 20 3d 20 30 3b 0a   **azValue = 0;.
06e0: 73 74 61 74 69 63 20 75 6e 73 69 67 6e 65 64 20  static unsigned 
06f0: 63 68 61 72 20 2a 61 43 68 61 6e 67 65 64 20 3d  char *aChanged =
0700: 20 30 3b 0a 0a 2f 2a 0a 2a 2a 20 43 6f 6d 70 61   0;../*.** Compa
0710: 72 65 20 74 77 6f 20 65 6e 74 72 69 65 73 20 69  re two entries i
0720: 6e 20 61 7a 46 69 65 6c 64 20 66 6f 72 20 73 6f  n azField for so
0730: 72 74 69 6e 67 20 70 75 72 70 6f 73 65 73 0a 2a  rting purposes.*
0740: 2f 0a 73 74 61 74 69 63 20 69 6e 74 20 6e 61 6d  /.static int nam
0750: 65 43 6d 70 72 28 76 6f 69 64 20 2a 61 2c 20 76  eCmpr(void *a, v
0760: 6f 69 64 20 2a 62 29 7b 0a 20 20 72 65 74 75 72  oid *b){.  retur
0770: 6e 20 73 74 72 63 6d 70 28 28 63 68 61 72 2a 29  n strcmp((char*)
0780: 61 2c 20 28 63 68 61 72 2a 29 62 29 3b 0a 7d 0a  a, (char*)b);.}.
0790: 0a 2f 2a 0a 2a 2a 20 53 75 62 73 63 72 69 70 74  ./*.** Subscript
07a0: 20 63 6f 6d 6d 61 6e 64 3a 20 20 20 20 20 20 4c   command:      L
07b0: 49 53 54 20 73 65 74 66 69 65 6c 64 73 0a 2a 2a  IST setfields.**
07c0: 0a 2a 2a 20 50 61 72 73 65 20 75 70 20 74 68 65  .** Parse up the
07d0: 20 6c 69 73 74 20 61 6e 64 20 70 6f 70 75 6c 61   list and popula
07e0: 74 65 20 74 68 65 20 6e 46 69 65 6c 64 20 61 6e  te the nField an
07f0: 64 20 61 7a 46 69 65 6c 64 20 76 61 72 69 61 62  d azField variab
0800: 6c 65 73 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 69  les..*/.static i
0810: 6e 74 20 73 65 74 46 69 65 6c 64 73 43 6d 64 28  nt setFieldsCmd(
0820: 73 74 72 75 63 74 20 53 75 62 73 63 72 69 70 74  struct Subscript
0830: 20 2a 70 2c 20 76 6f 69 64 20 2a 70 4e 6f 74 55   *p, void *pNotU
0840: 73 65 64 29 7b 0a 20 20 69 66 28 20 53 62 53 5f  sed){.  if( SbS_
0850: 52 65 71 75 69 72 65 53 74 61 63 6b 28 70 2c 20  RequireStack(p, 
0860: 31 29 20 29 20 72 65 74 75 72 6e 20 31 3b 0a 20  1) ) return 1;. 
0870: 20 69 66 28 20 6e 46 69 65 6c 64 3d 3d 30 20 29   if( nField==0 )
0880: 7b 0a 20 20 20 20 63 68 61 72 20 2a 7a 46 69 65  {.    char *zFie
0890: 6c 64 4c 69 73 74 3b 0a 20 20 20 20 69 6e 74 20  ldList;.    int 
08a0: 6e 46 69 65 6c 64 4c 69 73 74 2c 20 69 3b 0a 20  nFieldList, i;. 
08b0: 20 20 20 42 6c 6f 62 20 66 69 65 6c 64 3b 0a 20     Blob field;. 
08c0: 20 20 20 62 6c 6f 62 5f 7a 65 72 6f 28 26 66 69     blob_zero(&fi
08d0: 65 6c 64 4c 69 73 74 29 3b 0a 20 20 20 20 7a 46  eldList);.    zF
08e0: 69 65 6c 64 4c 69 73 74 20 3d 20 53 62 53 5f 53  ieldList = SbS_S
08f0: 74 61 63 6b 56 61 6c 75 65 28 70 2c 20 30 2c 20  tackValue(p, 0, 
0900: 26 6e 46 69 65 6c 64 4c 69 73 74 29 3b 0a 20 20  &nFieldList);.  
0910: 20 20 62 6c 6f 62 5f 61 70 70 65 6e 64 66 28 26    blob_appendf(&
0920: 66 69 65 6c 64 4c 69 73 74 2c 20 7a 46 69 65 6c  fieldList, zFiel
0930: 64 4c 69 73 74 2c 20 6e 46 69 65 6c 64 4c 69 73  dList, nFieldLis
0940: 74 29 3b 0a 20 20 20 20 77 68 69 6c 65 28 20 62  t);.    while( b
0950: 6c 6f 62 5f 74 6f 6b 65 6e 28 26 66 69 65 6c 64  lob_token(&field
0960: 4c 69 73 74 2c 20 26 66 69 65 6c 64 29 20 29 7b  List, &field) ){
0970: 0a 20 20 20 20 20 20 6e 46 69 65 6c 64 2b 2b 3b  .      nField++;
0980: 0a 20 20 20 20 7d 0a 20 20 20 20 61 7a 46 69 65  .    }.    azFie
0990: 6c 64 20 3d 20 6d 61 6c 6c 6f 63 28 20 73 69 7a  ld = malloc( siz
09a0: 65 6f 66 28 61 7a 46 69 65 6c 64 5b 30 5d 29 2a  eof(azField[0])*
09b0: 6e 46 69 65 6c 64 2a 32 20 2b 20 6e 46 69 65 6c  nField*2 + nFiel
09c0: 64 20 29 3b 0a 20 20 20 20 69 66 28 20 61 7a 46  d );.    if( azF
09d0: 69 65 6c 64 20 29 7b 0a 20 20 20 20 20 20 61 7a  ield ){.      az
09e0: 56 61 6c 75 65 20 3d 20 26 61 7a 46 69 65 6c 64  Value = &azField
09f0: 5b 6e 46 69 65 6c 64 5d 3b 0a 20 20 20 20 20 20  [nField];.      
0a00: 61 43 68 61 6e 67 65 64 20 3d 20 28 75 6e 73 69  aChanged = (unsi
0a10: 67 6e 65 64 20 63 68 61 72 2a 29 26 61 7a 56 61  gned char*)&azVa
0a20: 6c 75 65 5b 6e 46 69 65 6c 64 5d 3b 0a 20 20 20  lue[nField];.   
0a30: 20 20 20 62 6c 6f 62 5f 72 65 77 69 6e 64 28 26     blob_rewind(&
0a40: 66 69 65 6c 64 4c 69 73 74 29 3b 0a 20 20 20 20  fieldList);.    
0a50: 20 20 69 20 3d 20 30 3b 0a 20 20 20 20 20 20 77    i = 0;.      w
0a60: 68 69 6c 65 28 20 62 6c 6f 62 5f 74 6f 6b 65 6e  hile( blob_token
0a70: 28 26 66 69 65 6c 64 4c 69 73 74 2c 20 26 66 69  (&fieldList, &fi
0a80: 65 6c 64 29 20 29 7b 0a 20 20 20 20 20 20 20 20  eld) ){.        
0a90: 61 7a 46 69 65 6c 64 5b 69 5d 20 3d 20 62 6c 6f  azField[i] = blo
0aa0: 62 5f 74 65 72 6d 69 6e 61 74 65 28 26 66 69 65  b_terminate(&fie
0ab0: 6c 64 29 3b 0a 20 20 20 20 20 20 20 20 61 7a 56  ld);.        azV
0ac0: 61 6c 75 65 5b 69 5d 20 3d 20 30 3b 0a 20 20 20  alue[i] = 0;.   
0ad0: 20 20 20 20 20 61 43 68 61 6e 67 65 64 5b 69 5d       aChanged[i]
0ae0: 20 3d 20 30 3b 0a 20 20 20 20 20 20 7d 0a 20 20   = 0;.      }.  
0af0: 20 20 7d 0a 20 20 20 20 71 73 6f 72 74 28 61 7a    }.    qsort(az
0b00: 46 69 65 6c 64 2c 20 6e 46 69 65 6c 64 2c 20 73  Field, nField, s
0b10: 69 7a 65 6f 66 28 61 7a 46 69 65 6c 64 5b 30 5d  izeof(azField[0]
0b20: 29 2c 20 6e 61 6d 65 43 6d 70 72 29 3b 0a 20 20  ), nameCmpr);.  
0b30: 7d 0a 20 20 53 62 53 5f 50 6f 70 28 70 2c 20 31  }.  SbS_Pop(p, 1
0b40: 29 3b 0a 20 20 72 65 74 75 72 6e 20 30 3b 0a 7d  );.  return 0;.}
0b50: 0a 0a 2f 2a 0a 2a 2a 20 46 69 6e 64 20 74 68 65  ../*.** Find the
0b60: 20 74 65 78 74 20 6f 66 20 74 68 65 20 66 69 65   text of the fie
0b70: 6c 64 20 77 68 6f 73 65 20 6e 61 6d 65 20 69 73  ld whose name is
0b80: 20 74 68 65 20 4e 74 68 20 65 6c 65 6d 65 6e 74   the Nth element
0b90: 20 64 6f 77 6e 0a 2a 2a 20 6f 6e 20 74 68 65 20   down.** on the 
0ba0: 53 75 62 73 63 72 69 70 74 20 73 74 61 63 6b 2e  Subscript stack.
0bb0: 20 20 30 20 6d 65 61 6e 73 20 74 68 65 20 74 6f    0 means the to
0bc0: 70 20 6f 66 20 74 68 65 20 73 74 61 63 6b 2e 0a  p of the stack..
0bd0: 2a 2a 0a 2a 2a 20 46 69 72 73 74 20 63 68 65 63  **.** First chec
0be0: 6b 20 66 6f 72 20 61 20 76 61 6c 75 65 20 66 6f  k for a value fo
0bf0: 72 20 74 68 69 73 20 66 69 65 6c 64 20 61 73 20  r this field as 
0c00: 70 61 73 73 65 64 20 69 6e 20 76 69 61 0a 2a 2a  passed in via.**
0c10: 20 43 47 49 20 70 61 72 61 6d 65 74 65 72 2e 20   CGI parameter. 
0c20: 20 49 66 20 6e 6f 74 20 66 6f 75 6e 64 2c 20 74   If not found, t
0c30: 68 65 6e 20 75 73 65 20 74 68 65 20 76 61 6c 75  hen use the valu
0c40: 65 20 66 72 6f 6d 20 74 68 65 0a 2a 2a 20 64 61  e from the.** da
0c50: 74 61 62 61 73 65 2e 0a 2a 2f 0a 73 74 61 74 69  tabase..*/.stati
0c60: 63 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 66 69  c const char *fi
0c70: 65 6c 64 5f 76 61 6c 75 65 28 69 6e 74 20 4e 29  eld_value(int N)
0c80: 7b 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a  {.  const char *
0c90: 7a 46 4e 61 6d 65 3b 0a 20 20 69 6e 74 20 6e 46  zFName;.  int nF
0ca0: 4e 61 6d 65 3b 0a 20 20 63 68 61 72 20 2a 7a 4e  Name;.  char *zN
0cb0: 61 6d 65 3b 0a 20 20 69 6e 74 20 69 3b 0a 20 20  ame;.  int i;.  
0cc0: 63 6f 6e 73 74 20 63 68 61 72 20 2a 7a 56 61 6c  const char *zVal
0cd0: 75 65 3b 0a 20 20 0a 20 20 7a 46 4e 61 6d 65 20  ue;.  .  zFName 
0ce0: 3d 20 53 62 53 5f 53 74 61 63 6b 56 61 6c 75 65  = SbS_StackValue
0cf0: 28 70 49 6e 74 65 72 70 2c 20 4e 2c 20 26 6e 46  (pInterp, N, &nF
0d00: 4e 61 6d 65 29 3b 0a 20 20 69 66 28 20 7a 46 69  Name);.  if( zFi
0d10: 65 6c 64 3d 3d 30 20 29 7b 0a 20 20 20 20 72 65  eld==0 ){.    re
0d20: 74 75 72 6e 20 30 3b 0a 20 20 7d 0a 20 20 7a 4e  turn 0;.  }.  zN
0d30: 61 6d 65 20 3d 20 6d 70 72 69 6e 74 66 28 22 25  ame = mprintf("%
0d40: 2e 2a 73 22 2c 20 6e 46 4e 61 6d 65 2c 20 7a 46  .*s", nFName, zF
0d50: 4e 61 6d 65 29 3b 0a 20 20 7a 56 61 6c 75 65 20  Name);.  zValue 
0d60: 3d 20 50 28 7a 4e 61 6d 65 29 3b 0a 20 20 69 66  = P(zName);.  if
0d70: 28 20 7a 56 61 6c 75 65 3d 3d 30 20 29 7b 0a 20  ( zValue==0 ){. 
0d80: 20 20 20 66 6f 72 28 69 3d 30 3b 20 69 3c 6e 46     for(i=0; i<nF
0d90: 69 65 6c 64 3b 20 69 2b 2b 29 7b 0a 20 20 20 20  ield; i++){.    
0da0: 20 20 69 66 28 20 73 74 72 63 6d 70 28 61 7a 46    if( strcmp(azF
0db0: 69 65 6c 64 5b 69 5d 2c 20 7a 4e 61 6d 65 29 3d  ield[i], zName)=
0dc0: 3d 30 20 29 7b 0a 20 20 20 20 20 20 20 20 7a 56  =0 ){.        zV
0dd0: 61 6c 75 65 20 3d 20 61 7a 56 61 6c 75 65 5b 69  alue = azValue[i
0de0: 5d 3b 0a 20 20 20 20 20 20 20 20 62 72 65 61 6b  ];.        break
0df0: 3b 0a 20 20 20 20 20 20 7d 0a 20 20 20 20 7d 0a  ;.      }.    }.
0e00: 20 20 7d 0a 20 20 66 72 65 65 28 7a 4e 61 6d 65    }.  free(zName
0e10: 29 3b 0a 20 20 72 65 74 75 72 6e 20 7a 56 61 6c  );.  return zVal
0e20: 75 65 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 46 69 6c  ue;.}../*.** Fil
0e30: 6c 20 69 6e 20 74 68 65 20 61 7a 56 61 6c 75 65  l in the azValue
0e40: 5b 5d 20 61 72 72 61 79 20 77 69 74 68 20 74 68  [] array with th
0e50: 65 20 63 6f 6e 74 65 6e 74 73 20 6f 66 20 74 68  e contents of th
0e60: 65 20 74 69 63 6b 65 74 0a 2a 2a 20 74 61 62 6c  e ticket.** tabl
0e70: 65 20 66 6f 72 20 74 68 65 20 65 6e 74 72 79 20  e for the entry 
0e80: 64 65 74 65 72 6d 69 6e 65 64 20 62 79 20 74 68  determined by th
0e90: 65 20 22 6e 61 6d 65 22 20 43 47 49 20 70 61 72  e "name" CGI par
0ea0: 61 6d 65 74 65 72 2e 0a 2a 2f 0a 73 74 61 74 69  ameter..*/.stati
0eb0: 63 20 76 6f 69 64 20 66 65 74 63 68 4f 72 69 67  c void fetchOrig
0ec0: 69 6e 61 6c 56 61 6c 75 65 73 28 76 6f 69 64 29  inalValues(void)
0ed0: 7b 0a 20 20 42 6c 6f 62 20 73 71 6c 3b 0a 20 20  {.  Blob sql;.  
0ee0: 53 74 6d 74 20 71 3b 0a 20 20 69 6e 74 20 69 3b  Stmt q;.  int i;
0ef0: 0a 20 20 63 68 61 72 20 2a 7a 53 65 70 20 3d 20  .  char *zSep = 
0f00: 22 53 45 4c 45 43 54 20 22 3b 0a 20 20 62 6c 6f  "SELECT ";.  blo
0f10: 62 5f 7a 65 72 6f 28 26 73 71 6c 29 3b 0a 20 20  b_zero(&sql);.  
0f20: 66 6f 72 28 69 3d 30 3b 20 69 3c 6e 46 69 65 6c  for(i=0; i<nFiel
0f30: 64 3b 20 69 2b 2b 29 7b 0a 20 20 20 20 62 6c 6f  d; i++){.    blo
0f40: 62 5f 61 70 70 65 6e 64 66 28 26 73 71 6c 2c 20  b_appendf(&sql, 
0f50: 22 25 73 74 6b 74 5f 25 73 22 2c 20 7a 53 65 70  "%stkt_%s", zSep
0f60: 2c 20 61 7a 46 69 65 6c 64 5b 69 5d 29 3b 0a 20  , azField[i]);. 
0f70: 20 20 20 7a 53 65 70 20 3d 20 22 2c 20 22 3b 0a     zSep = ", ";.
0f80: 20 20 7d 0a 20 20 62 6c 6f 62 5f 61 70 70 65 6e    }.  blob_appen
0f90: 64 66 28 22 20 46 52 4f 4d 20 74 69 63 6b 65 74  df(" FROM ticket
0fa0: 20 57 48 45 52 45 20 75 75 69 64 3d 25 51 22 2c   WHERE uuid=%Q",
0fb0: 20 50 44 28 22 6e 61 6d 65 22 2c 22 22 29 29 3b   PD("name",""));
0fc0: 0a 20 20 64 62 5f 70 72 65 70 61 72 65 28 26 71  .  db_prepare(&q
0fd0: 2c 20 22 25 62 22 2c 20 26 73 71 6c 29 3b 0a 20  , "%b", &sql);. 
0fe0: 20 69 66 28 20 64 62 5f 73 74 65 70 28 26 71 29   if( db_step(&q)
0ff0: 3d 3d 53 51 4c 49 54 45 5f 52 4f 57 20 29 7b 0a  ==SQLITE_ROW ){.
1000: 20 20 20 20 66 6f 72 28 69 3d 30 3b 20 69 3c 6e      for(i=0; i<n
1010: 46 69 65 6c 64 3b 20 69 2b 2b 29 7b 0a 20 20 20  Field; i++){.   
1020: 20 20 20 61 7a 56 61 6c 75 65 5b 69 5d 20 3d 20     azValue[i] = 
1030: 64 62 5f 63 6f 6c 75 6d 6e 5f 6d 61 6c 6c 6f 63  db_column_malloc
1040: 28 26 71 2c 20 69 29 3b 0a 20 20 20 20 7d 0a 20  (&q, i);.    }. 
1050: 20 7d 0a 20 20 64 62 5f 66 69 6e 61 6c 69 7a 65   }.  db_finalize
1060: 28 26 71 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 53  (&q);.}../*.** S
1070: 75 62 73 63 72 69 70 74 20 63 6f 6d 6d 61 6e 64  ubscript command
1080: 3a 20 20 20 20 20 20 46 49 45 4c 44 20 77 69 6b  :      FIELD wik
1090: 69 76 69 65 77 0a 2a 2f 0a 73 74 61 74 69 63 20  iview.*/.static 
10a0: 69 6e 74 20 77 69 6b 69 56 69 65 77 43 6d 64 28  int wikiViewCmd(
10b0: 73 74 72 75 63 74 20 53 75 62 73 63 72 69 70 74  struct Subscript
10c0: 20 2a 70 2c 20 76 6f 69 64 20 2a 70 4e 6f 74 55   *p, void *pNotU
10d0: 73 65 64 29 7b 0a 20 20 69 66 28 20 53 62 53 5f  sed){.  if( SbS_
10e0: 52 65 71 75 69 72 65 53 74 61 63 6b 28 70 2c 20  RequireStack(p, 
10f0: 32 29 20 29 20 72 65 74 75 72 6e 20 31 3b 0a 20  2) ) return 1;. 
1100: 20 0a 20 20 53 62 53 5f 50 6f 70 28 70 2c 20 31   .  SbS_Pop(p, 1
1110: 29 3b 0a 20 20 72 65 74 75 72 6e 20 30 3b 0a 7d  );.  return 0;.}
1120: 0a 0a 0a 2f 2a 0a 2a 2a 20 43 72 65 61 74 65 20  .../*.** Create 
1130: 61 6e 20 53 75 62 73 63 72 69 70 74 20 69 6e 74  an Subscript int
1140: 65 72 70 72 65 74 65 72 20 61 70 70 72 6f 70 72  erpreter appropr
1150: 69 61 74 65 20 66 6f 72 20 70 72 6f 63 65 73 73  iate for process
1160: 69 6e 67 0a 2a 2a 20 54 69 63 6b 65 74 20 70 61  ing.** Ticket pa
1170: 67 65 73 2e 0a 2a 2f 0a 73 74 61 74 69 63 20 76  ges..*/.static v
1180: 6f 69 64 20 74 6b 74 5f 73 63 72 65 65 6e 5f 69  oid tkt_screen_i
1190: 6e 69 74 28 69 6e 74 20 66 6c 61 67 73 29 7b 0a  nit(int flags){.
11a0: 20 20 63 68 61 72 20 2a 7a 43 6f 6e 66 69 67 3b    char *zConfig;
11b0: 0a 20 20 69 6e 74 20 69 3b 0a 20 20 73 74 61 74  .  int i;.  stat
11c0: 69 63 20 63 6f 6e 73 74 20 73 74 72 75 63 74 20  ic const struct 
11d0: 7b 0a 20 20 20 20 20 63 6f 6e 73 74 20 63 68 61  {.     const cha
11e0: 72 20 2a 7a 4e 61 6d 65 3b 0a 20 20 20 20 20 69  r *zName;.     i
11f0: 6e 74 20 28 2a 78 56 65 72 62 29 3b 0a 20 20 20  nt (*xVerb);.   
1200: 20 20 69 6e 74 20 6d 61 73 6b 3b 0a 20 20 7d 20    int mask;.  } 
1210: 61 56 65 72 62 5b 5d 20 3d 20 7b 0a 20 20 20 20  aVerb[] = {.    
1220: 7b 20 22 6e 6f 74 22 2c 20 20 20 20 20 20 20 20  { "not",        
1230: 20 20 20 20 20 20 6e 6f 74 43 6d 64 2c 20 20 20        notCmd,   
1240: 20 20 20 20 20 20 20 20 20 20 20 20 20 4d 5f 4e               M_N
1250: 45 57 7c 4d 5f 45 44 49 54 7c 4d 5f 56 49 45 57  EW|M_EDIT|M_VIEW
1260: 20 7d 2c 0a 20 20 20 20 7b 20 22 6d 61 78 22 2c   },.    { "max",
1270: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 61                ma
1280: 78 43 6d 64 2c 20 20 20 20 20 20 20 20 20 20 20  xCmd,           
1290: 20 20 20 20 20 4d 5f 4e 45 57 7c 4d 5f 45 44 49       M_NEW|M_EDI
12a0: 54 7c 4d 5f 56 49 45 57 20 7d 2c 0a 20 20 20 20  T|M_VIEW },.    
12b0: 7b 20 22 61 6e 64 22 2c 20 20 20 20 20 20 20 20  { "and",        
12c0: 20 20 20 20 20 20 61 6e 64 43 6d 64 2c 20 20 20        andCmd,   
12d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 4d 5f 4e               M_N
12e0: 45 57 7c 4d 5f 45 44 49 54 7c 4d 5f 56 49 45 57  EW|M_EDIT|M_VIEW
12f0: 20 7d 2c 0a 20 20 20 20 7b 20 22 77 69 6b 69 76   },.    { "wikiv
1300: 69 65 77 22 2c 20 20 20 20 20 20 20 20 20 77 69  iew",         wi
1310: 6b 69 56 69 65 77 43 6d 64 2c 20 20 20 20 20 20  kiViewCmd,      
1320: 20 20 20 20 20 4d 5f 4e 45 57 7c 4d 5f 45 44 49       M_NEW|M_EDI
1330: 54 7c 4d 5f 56 49 45 57 20 7d 2c 0a 20 20 20 20  T|M_VIEW },.    
1340: 7b 20 22 74 65 78 74 76 69 65 77 22 2c 20 20 20  { "textview",   
1350: 20 20 20 20 20 20 74 65 78 74 56 69 65 77 43 6d        textViewCm
1360: 64 2c 20 20 20 20 20 20 20 20 20 20 20 4d 5f 4e  d,           M_N
1370: 45 57 7c 4d 5f 45 44 49 54 7c 4d 5f 56 49 45 57  EW|M_EDIT|M_VIEW
1380: 20 7d 2c 0a 20 20 20 20 7b 20 22 6c 69 6e 65 63   },.    { "linec
1390: 6f 75 6e 74 22 2c 20 20 20 20 20 20 20 20 6c 69  ount",        li
13a0: 6e 65 43 6f 75 6e 74 43 6d 64 2c 20 20 20 20 20  neCountCmd,     
13b0: 20 20 20 20 20 4d 5f 4e 45 57 7c 4d 5f 45 44 49       M_NEW|M_EDI
13c0: 54 7c 4d 5f 56 49 45 57 20 7d 2c 0a 20 20 20 20  T|M_VIEW },.    
13d0: 7b 20 22 63 67 69 70 61 72 61 6d 22 2c 20 20 20  { "cgiparam",   
13e0: 20 20 20 20 20 20 63 67 69 50 61 72 61 6d 43 6d        cgiParamCm
13f0: 64 2c 20 20 20 20 20 20 20 20 20 20 20 4d 5f 4e  d,           M_N
1400: 45 57 7c 4d 5f 45 44 49 54 7c 4d 5f 56 49 45 57  EW|M_EDIT|M_VIEW
1410: 20 7d 2c 0a 20 20 20 20 7b 20 22 65 6e 61 62 6c   },.    { "enabl
1420: 65 5f 6f 75 74 70 75 74 22 2c 20 20 20 20 65 6e  e_output",    en
1430: 61 62 6c 65 4f 75 74 70 75 74 43 6d 64 2c 20 20  ableOutputCmd,  
1440: 20 20 20 20 20 4d 5f 4e 45 57 7c 4d 5f 45 44 49       M_NEW|M_EDI
1450: 54 7c 4d 5f 56 49 45 57 20 7d 2c 0a 20 20 20 20  T|M_VIEW },.    
1460: 7b 20 22 69 73 5f 61 6e 6f 6e 22 2c 20 20 20 20  { "is_anon",    
1470: 20 20 20 20 20 20 69 73 41 6e 6f 6e 43 6d 64 2c        isAnonCmd,
1480: 20 20 20 20 20 20 20 20 20 20 20 20 20 4d 5f 4e               M_N
1490: 45 57 7c 4d 5f 45 44 49 54 7c 4d 5f 56 49 45 57  EW|M_EDIT|M_VIEW
14a0: 20 7d 2c 0a 20 20 20 20 7b 20 22 6f 6b 5f 77 72   },.    { "ok_wr
14b0: 74 6b 74 22 2c 20 20 20 20 20 20 20 20 20 6f 6b  tkt",         ok
14c0: 57 72 54 6b 74 43 6d 64 2c 20 20 20 20 20 20 20  WrTktCmd,       
14d0: 20 20 20 20 20 4d 5f 4e 45 57 7c 4d 5f 45 44 49       M_NEW|M_EDI
14e0: 54 7c 4d 5f 56 49 45 57 20 7d 2c 0a 20 20 20 20  T|M_VIEW },.    
14f0: 7b 20 22 64 65 66 61 75 6c 74 5f 76 61 6c 75 65  { "default_value
1500: 22 2c 20 20 20 20 64 66 6c 74 56 61 6c 75 65 43  ",    dfltValueC
1510: 6d 64 2c 20 20 20 20 20 20 20 20 20 20 4d 5f 4e  md,          M_N
1520: 45 57 20 20 20 20 20 20 20 20 20 20 20 20 20 20  EW              
1530: 20 7d 2c 0a 20 20 20 20 7b 20 22 74 65 78 74 65   },.    { "texte
1540: 64 69 74 22 2c 20 20 20 20 20 20 20 20 20 74 65  dit",         te
1550: 78 74 45 64 69 74 43 6d 64 2c 20 20 20 20 20 20  xtEditCmd,      
1560: 20 20 20 20 20 4d 5f 4e 45 57 7c 4d 5f 45 44 49       M_NEW|M_EDI
1570: 54 20 20 20 20 20 20 20 20 7d 2c 0a 20 20 20 20  T        },.    
1580: 7b 20 22 63 6f 6d 62 6f 62 6f 78 22 2c 20 20 20  { "combobox",   
1590: 20 20 20 20 20 20 63 6f 6d 62 6f 42 6f 78 43 6d        comboBoxCm
15a0: 64 2c 20 20 20 20 20 20 20 20 20 20 20 4d 5f 4e  d,           M_N
15b0: 45 57 7c 4d 5f 45 44 49 54 20 20 20 20 20 20 20  EW|M_EDIT       
15c0: 20 7d 2c 0a 20 20 20 20 7b 20 22 6d 75 6c 74 69   },.    { "multi
15d0: 6c 69 6e 65 65 64 69 74 22 2c 20 20 20 20 6d 75  lineedit",    mu
15e0: 6c 74 69 4c 69 6e 65 45 64 69 74 43 6d 64 2c 20  ltiLineEditCmd, 
15f0: 20 20 20 20 20 4d 5f 4e 45 57 7c 4d 5f 45 44 49       M_NEW|M_EDI
1600: 54 20 20 20 20 20 20 20 20 7d 2c 0a 20 20 20 20  T        },.    
1610: 7b 20 22 6d 75 6c 74 69 6c 69 6e 65 61 70 70 65  { "multilineappe
1620: 6e 64 22 2c 20 20 6d 75 6c 74 69 41 70 70 65 6e  nd",  multiAppen
1630: 64 43 6d 64 2c 20 20 20 20 20 20 20 20 20 20 20  dCmd,           
1640: 20 20 20 4d 5f 45 44 49 54 20 20 20 20 20 20 20     M_EDIT       
1650: 20 7d 2c 0a 20 20 20 20 7b 20 22 61 75 78 62 75   },.    { "auxbu
1660: 74 74 6f 6e 22 2c 20 20 20 20 20 20 20 20 61 75  tton",        au
1670: 78 42 75 74 74 6f 6e 43 6d 64 2c 20 20 20 20 20  xButtonCmd,     
1680: 20 20 20 20 20 4d 5f 4e 45 57 7c 4d 5f 45 44 49       M_NEW|M_EDI
1690: 54 20 20 20 20 20 20 20 20 7d 2c 0a 20 20 20 20  T        },.    
16a0: 7b 20 22 73 75 62 6d 69 74 62 75 74 74 6f 6e 22  { "submitbutton"
16b0: 2c 20 20 20 20 20 73 75 62 6d 69 74 42 75 74 74  ,     submitButt
16c0: 6f 6e 43 6d 64 2c 20 20 20 20 20 20 20 4d 5f 4e  onCmd,       M_N
16d0: 45 57 7c 4d 5f 45 44 49 54 20 20 20 20 20 20 20  EW|M_EDIT       
16e0: 20 7d 2c 0a 20 20 7d 3b 0a 0a 20 20 70 49 6e 74   },.  };..  pInt
16f0: 65 72 70 20 3d 20 53 62 53 5f 43 72 65 61 74 65  erp = SbS_Create
1700: 28 29 3b 0a 20 20 53 62 53 5f 41 64 64 56 65 72  ();.  SbS_AddVer
1710: 62 28 70 49 6e 74 65 72 70 2c 20 22 73 65 74 66  b(pInterp, "setf
1720: 69 65 6c 64 73 22 2c 20 73 65 74 46 69 65 6c 64  ields", setField
1730: 73 43 6d 64 2c 20 30 29 3b 0a 20 20 7a 43 6f 6e  sCmd, 0);.  zCon
1740: 66 69 67 20 3d 20 64 62 5f 67 65 74 28 22 74 69  fig = db_get("ti
1750: 63 6b 65 74 2d 63 6f 6e 66 69 67 22 2c 22 22 29  cket-config","")
1760: 3b 0a 20 20 53 62 53 5f 45 76 61 6c 28 70 49 6e  ;.  SbS_Eval(pIn
1770: 74 65 72 2c 20 7a 43 6f 6e 66 69 67 2c 20 2d 31  ter, zConfig, -1
1780: 29 3b 0a 20 20 66 6f 72 28 69 3d 30 3b 20 69 3c  );.  for(i=0; i<
1790: 73 69 7a 65 6f 66 28 61 56 65 72 62 29 2f 73 69  sizeof(aVerb)/si
17a0: 7a 65 6f 66 28 61 56 65 72 62 5b 30 5d 29 3b 20  zeof(aVerb[0]); 
17b0: 69 2b 2b 29 7b 0a 20 20 20 20 69 66 28 20 66 6c  i++){.    if( fl
17c0: 61 67 73 20 26 20 61 56 65 72 62 5b 69 5d 2e 6d  ags & aVerb[i].m
17d0: 61 73 6b 20 29 7b 0a 20 20 20 20 20 20 53 62 53  ask ){.      SbS
17e0: 5f 41 64 64 56 65 72 62 28 70 49 6e 74 65 72 70  _AddVerb(pInterp
17f0: 2c 20 61 56 65 72 62 5b 69 5d 2e 7a 4e 61 6d 65  , aVerb[i].zName
1800: 2c 20 61 56 65 72 62 5b 69 5d 2e 78 56 65 72 62  , aVerb[i].xVerb
1810: 2c 20 30 29 3b 0a 20 20 20 20 7d 0a 20 20 7d 0a  , 0);.    }.  }.
1820: 20 20 2f 2a 20 45 78 74 72 61 63 74 20 61 70 70    /* Extract app
1830: 72 6f 70 72 69 61 74 65 20 74 65 6d 70 6c 61 74  ropriate templat
1840: 65 20 2a 2f 0a 20 20 72 65 74 75 72 6e 20 70 49  e */.  return pI
1850: 6e 74 65 72 70 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20  nterp;.}../*.** 
1860: 50 41 47 45 3a 20 74 6b 74 6e 65 77 0a 2a 2f 0a  PAGE: tktnew.*/.
1870: 76 6f 69 64 20 74 6b 74 6e 65 77 5f 70 61 67 65  void tktnew_page
1880: 28 76 6f 69 64 29 7b 0a 20 20 73 74 72 75 63 74  (void){.  struct
1890: 20 53 75 62 73 63 72 69 70 74 20 2a 70 49 6e 74   Subscript *pInt
18a0: 65 72 70 3b 0a 20 20 63 6f 6e 73 74 20 63 68 61  erp;.  const cha
18b0: 72 20 2a 7a 50 61 67 65 3b 0a 20 20 69 6e 74 20  r *zPage;.  int 
18c0: 6e 50 61 67 65 3b 0a 0a 20 20 74 6b 74 5f 73 63  nPage;..  tkt_sc
18d0: 72 65 65 6e 5f 69 6e 69 74 28 4d 5f 4e 45 57 29  reen_init(M_NEW)
18e0: 3b 0a 20 20 69 66 28 20 50 28 22 73 75 62 6d 69  ;.  if( P("submi
18f0: 74 22 29 21 3d 30 20 29 7b 0a 20 20 20 20 2f 2f  t")!=0 ){.    //
1900: 20 2a 20 43 6f 6e 73 74 72 75 63 74 20 74 68 65   * Construct the
1910: 20 74 69 63 6b 65 74 20 61 72 74 69 66 61 63 74   ticket artifact
1920: 0a 20 20 20 20 2f 2f 20 20 20 20 2b 20 50 72 65  .    //    + Pre
1930: 66 69 78 0a 20 20 20 20 2f 2f 20 20 20 20 2b 20  fix.    //    + 
1940: 46 69 65 6c 64 2f 56 61 6c 75 65 20 70 61 69 72  Field/Value pair
1950: 73 20 69 6e 20 73 6f 72 74 65 64 20 6f 72 64 65  s in sorted orde
1960: 72 0a 20 20 20 20 2f 2f 20 20 20 20 2b 20 53 75  r.    //    + Su
1970: 66 66 69 78 0a 20 20 20 20 2f 2f 20 2a 20 52 65  ffix.    // * Re
1980: 67 69 73 74 65 72 20 74 68 65 20 61 72 74 69 66  gister the artif
1990: 61 63 74 0a 20 20 20 20 2f 2f 20 2a 20 55 70 64  act.    // * Upd
19a0: 61 74 65 20 74 68 65 20 74 69 63 6b 65 74 20 74  ate the ticket t
19b0: 61 62 6c 65 0a 20 20 20 20 2f 2f 20 2a 20 72 65  able.    // * re
19c0: 64 69 72 65 63 74 20 74 6f 20 74 68 65 20 74 69  direct to the ti
19d0: 63 6b 65 74 20 76 69 65 77 65 72 0a 20 20 7d 0a  cket viewer.  }.
19e0: 20 20 73 74 79 6c 65 5f 68 65 61 64 65 72 28 22    style_header("
19f0: 4e 65 77 20 54 69 63 6b 65 74 22 29 3b 0a 20 20  New Ticket");.  
1a00: 40 20 54 68 69 73 20 77 69 6c 6c 20 62 65 63 6f  @ This will beco
1a10: 6d 65 20 61 20 70 61 67 65 20 66 6f 72 20 65 6e  me a page for en
1a20: 74 65 72 69 6e 67 20 6e 65 77 20 74 69 63 6b 65  tering new ticke
1a30: 74 73 2e 0a 20 20 73 74 79 6c 65 5f 66 6f 6f 74  ts..  style_foot
1a40: 65 72 28 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a 20 50  er();.}../*.** P
1a50: 41 47 45 3a 20 74 6b 74 76 69 65 77 0a 2a 2a 20  AGE: tktview.** 
1a60: 55 52 4c 3a 20 74 6b 74 76 69 65 77 3f 6e 61 6d  URL: tktview?nam
1a70: 65 3d 55 55 49 44 0a 2a 2a 0a 2a 2f 0a 76 6f 69  e=UUID.**.*/.voi
1a80: 64 20 74 6b 74 65 64 69 74 5f 70 61 67 65 28 76  d tktedit_page(v
1a90: 6f 69 64 29 7b 0a 20 20 73 74 72 75 63 74 20 53  oid){.  struct S
1aa0: 75 62 73 63 72 69 70 74 20 2a 70 49 6e 74 65 72  ubscript *pInter
1ab0: 70 3b 0a 20 20 63 6f 6e 73 74 20 63 68 61 72 20  p;.  const char 
1ac0: 2a 7a 50 61 67 65 3b 0a 20 20 69 6e 74 20 6e 50  *zPage;.  int nP
1ad0: 61 67 65 3b 0a 0a 20 20 74 6b 74 5f 73 63 72 65  age;..  tkt_scre
1ae0: 65 6e 5f 69 6e 69 74 28 4d 5f 56 49 45 57 29 3b  en_init(M_VIEW);
1af0: 0a 20 20 73 74 79 6c 65 5f 68 65 61 64 65 72 28  .  style_header(
1b00: 22 56 69 65 77 20 54 69 63 6b 65 74 22 29 3b 0a  "View Ticket");.
1b10: 20 20 40 20 54 68 69 73 20 77 69 6c 6c 20 62 65    @ This will be
1b20: 63 6f 6d 65 20 61 20 70 61 67 65 20 66 6f 72 20  come a page for 
1b30: 65 6e 74 65 72 69 6e 67 20 6e 65 77 20 74 69 63  entering new tic
1b40: 6b 65 74 73 2e 0a 20 20 73 74 79 6c 65 5f 66 6f  kets..  style_fo
1b50: 6f 74 65 72 28 29 3b 0a 7d 0a 0a 2f 2a 0a 2a 2a  oter();.}../*.**
1b60: 20 50 41 47 45 3a 20 74 6b 74 65 64 69 74 0a 2a   PAGE: tktedit.*
1b70: 2a 20 55 52 4c 3a 20 74 6b 74 65 64 69 74 3f 6e  * URL: tktedit?n
1b80: 61 6d 65 3d 55 55 49 44 0a 2a 2a 0a 2a 2f 0a 76  ame=UUID.**.*/.v
1b90: 6f 69 64 20 74 6b 74 65 64 69 74 5f 70 61 67 65  oid tktedit_page
1ba0: 28 76 6f 69 64 29 7b 0a 20 20 73 74 72 75 63 74  (void){.  struct
1bb0: 20 53 75 62 73 63 72 69 70 74 20 2a 70 49 6e 74   Subscript *pInt
1bc0: 65 72 70 3b 0a 20 20 63 6f 6e 73 74 20 63 68 61  erp;.  const cha
1bd0: 72 20 2a 7a 50 61 67 65 3b 0a 20 20 69 6e 74 20  r *zPage;.  int 
1be0: 6e 50 61 67 65 3b 0a 0a 20 20 74 6b 74 5f 73 63  nPage;..  tkt_sc
1bf0: 72 65 65 6e 5f 69 6e 69 74 28 4d 5f 45 44 49 54  reen_init(M_EDIT
1c00: 29 3b 0a 20 20 69 66 28 20 50 28 22 73 75 62 6d  );.  if( P("subm
1c10: 69 74 22 29 20 29 7b 0a 20 20 20 20 2f 2f 20 2a  it") ){.    // *
1c20: 20 43 6f 6e 73 74 72 75 63 74 20 74 69 63 6b 65   Construct ticke
1c30: 74 20 63 68 61 6e 67 65 20 61 72 74 69 66 61 63  t change artifac
1c40: 74 0a 20 20 20 20 2f 2f 20 20 20 2b 20 20 50 72  t.    //   +  Pr
1c50: 65 66 69 78 0a 20 20 20 20 2f 2f 20 20 20 2b 20  efix.    //   + 
1c60: 20 4d 6f 64 69 66 69 65 64 20 66 69 65 6c 64 2f   Modified field/
1c70: 76 61 6c 75 65 20 70 61 69 72 73 20 69 6e 20 73  value pairs in s
1c80: 6f 72 74 65 64 20 6f 72 64 65 72 0a 20 20 20 20  orted order.    
1c90: 2f 2f 20 20 20 2b 20 20 53 75 66 66 69 78 0a 20  //   +  Suffix. 
1ca0: 20 20 20 2f 2f 20 2a 20 52 65 67 69 73 74 65 72     // * Register
1cb0: 20 74 68 65 20 61 72 74 69 66 61 63 74 0a 20 20   the artifact.  
1cc0: 20 20 2f 2f 20 2a 20 55 70 64 61 74 65 20 74 68    // * Update th
1cd0: 65 20 74 69 63 6b 65 74 20 74 61 62 6c 65 0a 20  e ticket table. 
1ce0: 20 20 20 2f 2f 20 2a 20 72 65 64 69 72 65 63 74     // * redirect
1cf0: 20 74 6f 20 74 68 65 20 74 69 63 6b 65 74 20 76   to the ticket v
1d00: 69 65 77 65 72 0a 20 20 7d 0a 20 20 73 74 79 6c  iewer.  }.  styl
1d10: 65 5f 68 65 61 64 65 72 28 22 45 64 69 74 20 54  e_header("Edit T
1d20: 69 63 6b 65 74 22 29 3b 0a 20 20 40 20 54 68 69  icket");.  @ Thi
1d30: 73 20 77 69 6c 6c 20 62 65 63 6f 6d 65 20 61 20  s will become a 
1d40: 70 61 67 65 20 66 6f 72 20 65 6e 74 65 72 69 6e  page for enterin
1d50: 67 20 6e 65 77 20 74 69 63 6b 65 74 73 2e 0a 20  g new tickets.. 
1d60: 20 73 74 79 6c 65 5f 66 6f 6f 74 65 72 28 29 3b   style_footer();
1d70: 0a 7d 0a 23 65 6e 64 69 66 0a                    .}.#endif.