View Source

[modwtcl]
apreq.h
dist/
libapreq1/
mod_wtcl.c
mod_wtcl.h
setupExclude.txt
util/
win.def
win.mak
wt1.1/
WtAppTable.c
WtAppTable.h
WtBasicCmds.c
WtBasicCmds.h
WtClientRequest.c
WtClientRequest.h
WtCollection.c
WtCollection.h
WtCollectionCmds.c
WtCollectionCmds.h
WtContext.c
WtContext.h
WtContextEvents.c
WtContextEvents.h
WtCookie.c
WtCookie.h
WtDbSession.c
WtDbSession.h
WtExecute.c
WtExecute.h
WtHtmlEntities.c
WtHtmlEntities.h
WtInitCmds.c
WtInitCmds.h
WtMtTable.c
WtMtTable.h
WtMultiTable.c
WtMultiTable.h
WtOS.h
WtProcSession.c
WtProcSession.h
WtResponse.c
WtResponse.h
WtServerCmds.c
WtServerCmds.h
WtSession.c
WtSession.h
WtSettings.c
WtSettings.h
WtTable.c
WtTable.h
WtTableCmds.c
WtTableCmds.h
WtTableUtil.c
WtTableUtil.h
WtUpload.c
WtUpload.h
WtUtil.c
WtUtil.h
WtWebErrors.c
WtWebErrors.h
WtWindows.h
File: / archive / modwtcl / WtAppTable.c

Lines Size Modified Created Owner MIME Types
619 15,812 2010/05/09 04:04:16 2011/06/13 15:35:15 BUILTIN\Administrators text/x-csrc

0001
/*
0002
 * Copyright 2001 Alex Boverman and the original authors.
0003
 * 
0004
 * Licensed under the Apache License, Version 2.0 (the "License");
0005
 * you may not use this file except in compliance with the License.
0006
 * You may obtain a copy of the License at
0007
 * 
0008
 *      http://www.apache.org/licenses/LICENSE-2.0
0009
 * 
0010
 * Unless required by applicable law or agreed to in writing, software
0011
 * distributed under the License is distributed on an "AS IS" BASIS,
0012
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013
 * See the License for the specific language governing permissions and
0014
 * limitations under the License.
0015
 */
0016
0017
#include "WtOS.h"
0018
#include "WtAppTable.h"
0019
#include "WtTableCmds.h"
0020
#include "WtTableUtil.h"
0021
#include "WtUtil.h"
0022
#include "WtMtTable.h"
0023
#include "WtTable.h"
0024
0025
WtAppTableSet wtAppTables;
0026
0027
void WtInitAppTableSet(WtAppTableSet *set)
0028
{
0029
  Tcl_InitObjHashTable(&set->tables);
0030
  set->lock = NULL;
0031
  set->seqId = 0;
0032
}
0033
0034
/* Open an app table */
0035
0036
Tcl_Obj *WtOpenAppTable(WtAppTableSet *set, Tcl_Obj *id,
0037
    Tcl_Interp *interp, int *created)
0038
{
0039
  int ok = 1;
0040
  Tcl_HashEntry *ent;
0041
  Tcl_Obj *tbl = NULL;
0042
  WtAppTable *at;
0043
0044
  Tcl_MutexLock(&set->lock);
0045
0046
  *created = 0;
0047
  ent = Tcl_CreateHashEntry(&set->tables, (char *)id,
0048
    created);
0049
0050
  if (!ent) {
0051
    ok = 0;
0052
    Tcl_MutexUnlock(&set->lock);
0053
  } else {
0054
    if (!*created) {
0055
      tbl = (Tcl_Obj *)Tcl_GetHashValue(ent);
0056
    } else {
0057
      if (tbl = WtNewAppTableObj()) {
0058
        Tcl_IncrRefCount(tbl);
0059
        Tcl_SetHashValue(ent, tbl);
0060
      } else {
0061
        Tcl_DeleteHashEntry(ent);
0062
        *created = 0;
0063
        ok = 0;
0064
      }
0065
    }
0066
0067
    if (ok) {
0068
      Tcl_IncrRefCount(tbl);
0069
    }
0070
0071
    Tcl_MutexUnlock(&set->lock);
0072
0073
    if (ok) {
0074
      at = WtAppTableRep(tbl);
0075
      at->accessTime = time(NULL);
0076
    }
0077
  }
0078
0079
  return tbl;
0080
}
0081
0082
/* Close an app table */
0083
0084
int WtCloseAppTable(Tcl_Obj *tbl)
0085
{
0086
  Tcl_DecrRefCount(tbl);
0087
  return 1;
0088
}
0089
0090
/* Delete an app table */
0091
0092
int WtDeleteAppTable(WtAppTableSet *set, Tcl_Obj *id, Tcl_Interp *interp)
0093
{
0094
  int ok = 1;
0095
  Tcl_Obj *tbl;
0096
  Tcl_HashEntry *ent;
0097
0098
  Tcl_MutexLock(&set->lock);
0099
0100
  ent = Tcl_FindHashEntry(&set->tables, (char *)id);
0101
0102
  if (ent) {
0103
    tbl = (Tcl_Obj *)Tcl_GetHashValue(ent);
0104
    if (tbl) {
0105
      Tcl_DecrRefCount(tbl);
0106
    }
0107
    Tcl_DeleteHashEntry(ent);
0108
  }
0109
0110
  Tcl_MutexUnlock(&set->lock);
0111
0112
  return ok;
0113
}
0114
0115
/* Helper to manage table objects */
0116
0117
WtTableCmdStatus WtAppTableCmdHelper(ClientData clientData,
0118
    Tcl_Interp *interp, int objc, Tcl_Obj *const objv[],
0119
    int *tclRet, int readOnly, int appendUsage)
0120
{
0121
  int status = WT_TBL_CMD_DONE, ret = TCL_ERROR, error = 0, created = 0;
0122
  WtContext *w;
0123
  char *subCmd, idStr[128];
0124
  Tcl_Obj *tbl = NULL, *mt, *obj, *key, *val;
0125
0126
  w = WtGetAssocContext(interp);
0127
0128
  if (objc < 2) {
0129
    if (appendUsage) {
0130
      WtAppTableCmdUsageError(interp, objv[0], readOnly);
0131
    }
0132
0133
    *tclRet = TCL_ERROR;
0134
0135
    return WT_TBL_CMD_MISSING;
0136
  }
0137
0138
  subCmd = WtToString(objv[1]);
0139
0140
  if (!strcmp(subCmd, "open")) {
0141
0142
    /* open command */
0143
0144
    if (objc == 2 || objc == 3) {
0145
      if (objc == 2) {
0146
        Tcl_MutexLock(&wtAppTables.lock);
0147
        snprintf(idStr, sizeof(idStr), "appTable-%lu", wtAppTables.seqId++);
0148
        Tcl_MutexUnlock(&wtAppTables.lock);
0149
        obj = WtNewString(idStr);
0150
        Tcl_IncrRefCount(obj);
0151
      } else {
0152
        obj = objv[2];
0153
      }
0154
      if (tbl = WtOpenAppTable(&wtAppTables, obj, interp, &created)) {
0155
        Tcl_SetObjResult(interp, WtNewString(Tcl_GetString(obj)));
0156
        ret = TCL_OK;
0157
      }
0158
      if (objc == 2) {
0159
        Tcl_DecrRefCount(obj);
0160
      }
0161
    } else {
0162
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0163
        WtToString(objv[0]), " ", WtToString(objv[1]), " ?id?",
0164
        NULL);
0165
    }
0166
0167
  } else if (!strcmp(subCmd, "count")) {
0168
0169
    /* count command */
0170
0171
    if (objc != 3) {
0172
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0173
        WtToString(objv[0]), " ", WtToString(objv[1]), " tableId", NULL);
0174
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0175
      Tcl_SetObjResult(interp, Tcl_NewIntObj(WtMtTableSize(mt)));
0176
      ret = TCL_OK;
0177
    }
0178
0179
  } else if (!strcmp(subCmd, "has")) {
0180
0181
    /* has command */
0182
0183
    if (objc != 4) {
0184
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0185
        WtToString(objv[0]), " ", WtToString(objv[1]), " ",
0186
        " table key", NULL);
0187
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0188
      Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
0189
        WtMtTableHas(mt, objv[3])));
0190
      ret = TCL_OK;
0191
    }
0192
0193
  } else if (!strcmp(subCmd, "keys")) {
0194
0195
    /* keys command */
0196
0197
    if (objc != 3) {
0198
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0199
        WtToString(objv[0]), " ", WtToString(objv[1]), " tableId", NULL);
0200
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0201
      if (WtMtTableKeys(mt, &obj, interp)) {
0202
        Tcl_SetObjResult(interp, obj);
0203
        ret = TCL_OK;
0204
      }
0205
    }
0206
0207
  } else if (!strcmp(subCmd, "values")) {
0208
0209
    /* values command */
0210
0211
    if (objc != 3) {
0212
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0213
        WtToString(objv[0]), " ", WtToString(objv[1]), " tableId", NULL);
0214
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0215
      if (WtMtTableValues(mt, &obj, interp)) {
0216
        Tcl_SetObjResult(interp, obj);
0217
        ret = TCL_OK;
0218
      }
0219
    }
0220
0221
  } else if (!strcmp(subCmd, "get")) {
0222
0223
    /* get command */
0224
0225
    if (objc < 4 || objc > 5) {
0226
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0227
        WtToString(objv[0]), " ",
0228
        WtToString(objv[1]), " table key ?defaultValue?", NULL);
0229
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0230
      obj = WtMtTableGet(mt, objv[3]);
0231
      if (obj) {
0232
        Tcl_SetObjResult(interp, obj);
0233
        ret = TCL_OK;
0234
      } else if (objc > 4) {
0235
        Tcl_SetObjResult(interp, objv[4]);
0236
        ret = TCL_OK;
0237
      } else {
0238
        Tcl_AppendResult(interp, "No entry with key \"",
0239
          WtToString(objv[3]), "\" found.", NULL);
0240
      }
0241
    }
0242
0243
  } else if (!strcmp(subCmd, "set") && !readOnly) {
0244
0245
    /* set command */
0246
0247
    if (objc != 5) {
0248
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0249
        WtToString(objv[0]), " ", WtToString(objv[1]),
0250
        " table key value", NULL);
0251
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0252
      WtMtTableSet(mt, objv[3], objv[4]);
0253
      Tcl_SetObjResult(interp, objv[4]);
0254
      ret = TCL_OK;
0255
    }
0256
0257
  } else if (!strcmp(subCmd, "setDefault") && !readOnly) {
0258
0259
    /* setDefault command */
0260
0261
    if (objc != 5) {
0262
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0263
        WtToString(objv[0]), " ", WtToString(objv[1]), " ",
0264
        " table key value", NULL);
0265
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0266
      if (obj = WtMtTableGet(mt, objv[3])) {
0267
        Tcl_SetObjResult(interp, obj);
0268
      } else {
0269
        WtMtTableSet(mt, objv[3], objv[4]);
0270
        Tcl_SetObjResult(interp, objv[4]);
0271
      }
0272
      ret = TCL_OK;
0273
    }
0274
0275
  } else if (!strcmp(subCmd, "lappend") && !readOnly) {
0276
0277
    /* lappend command */
0278
0279
    if (objc != 5) {
0280
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0281
        WtToString(objv[0]), " ", WtToString(objv[1]),
0282
        " table key value", NULL);
0283
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0284
      key = Tcl_DuplicateObj(objv[3]);
0285
      Tcl_IncrRefCount(key);
0286
      val = Tcl_DuplicateObj(objv[4]);
0287
      Tcl_IncrRefCount(val);
0288
      WtMtTableLock(mt);
0289
0290
      if (WtTableAppendToList(WtMtTableRep(mt)->tbl, key, val, &obj,
0291
          interp)) {
0292
        Tcl_SetObjResult(interp, Tcl_DuplicateObj(obj));
0293
        ret = TCL_OK;
0294
      }
0295
0296
      WtMtTableUnlock(mt);
0297
      Tcl_DecrRefCount(key);
0298
      Tcl_DecrRefCount(val);
0299
    }
0300
0301
  } else if (!strcmp(subCmd, "remove") && !readOnly) {
0302
0303
    /* remove command */
0304
0305
    if (objc != 4) {
0306
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0307
        WtToString(objv[0]), " ", WtToString(objv[1]), " table key", NULL);
0308
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0309
      WtMtTableRemove(mt, objv[3]);
0310
      ret = TCL_OK;
0311
    }
0312
0313
  } else if (!strcmp(subCmd, "removeList") && !readOnly) {
0314
0315
    /* removeList command */
0316
0317
    if (objc != 4) {
0318
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0319
        WtToString(objv[0]), " ", WtToString(objv[1]), " table list", NULL);
0320
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0321
      if (WtMtTableRemoveList(mt, objv[3], interp)) {
0322
        ret = TCL_OK;
0323
      }
0324
    }
0325
0326
  } else if (!strcmp(subCmd, "items")) {
0327
0328
    /* items command */
0329
0330
    if (objc != 3) {
0331
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0332
        WtToString(objv[0]), " ", WtToString(objv[1]), " tableId", NULL);
0333
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0334
      WtMtTableLock(mt);
0335
      Tcl_SetObjResult(interp, Tcl_DuplicateObj(WtMtTableRep(mt)->tbl));
0336
      WtMtTableUnlock(mt);
0337
      ret = TCL_OK;
0338
    }
0339
0340
  } else if (!strcmp(subCmd, "list")) {
0341
0342
    /* list command */
0343
0344
    if (objc != 3) {
0345
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0346
        WtToString(objv[0]), " ", WtToString(objv[1]),
0347
        " tableId", NULL);
0348
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0349
      WtMtTableLock(mt);
0350
      if (obj = WtTableToList(WtMtTableRep(mt)->tbl, 0, interp)) {
0351
        Tcl_SetObjResult(interp, Tcl_DuplicateObj(obj));
0352
        ret = TCL_OK;
0353
      }
0354
      WtMtTableUnlock(mt);
0355
    }
0356
0357
  } else if (!strcmp(subCmd, "array")) {
0358
0359
    /* array command */
0360
0361
    if (objc != 4) {
0362
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0363
        WtToString(objv[0]), " ", WtToString(objv[1]),
0364
        " table arrayName", NULL);
0365
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0366
      WtMtTableLock(mt);
0367
      if (WtTableToArray(interp, WtMtTableRep(mt)->tbl, objv[3], 0)) {
0368
        ret = TCL_OK;
0369
      }
0370
      WtMtTableUnlock(mt);
0371
    }
0372
0373
  } else if (!strcmp(subCmd, "copy")) {
0374
0375
    /* copy command */
0376
0377
    if (objc != 3) {
0378
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0379
        WtToString(objv[0]), " ", WtToString(objv[1]), " tableId", NULL);
0380
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0381
      WtMtTableLock(mt);
0382
      if (obj = Tcl_DuplicateObj(WtMtTableRep(mt)->tbl)) {
0383
        Tcl_SetObjResult(interp, obj);
0384
        ret = TCL_OK;
0385
      }
0386
      WtMtTableUnlock(mt);
0387
    }
0388
0389
  } else if (!strcmp(subCmd, "clear") && !readOnly) {
0390
0391
    /* clear command */
0392
0393
    if (objc != 3) {
0394
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0395
        WtToString(objv[0]), " ", WtToString(objv[1]), " tableId", NULL);
0396
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0397
      WtMtTableClear(mt);
0398
      ret = TCL_OK;
0399
    }
0400
0401
  } else if (!strcmp(subCmd, "delete") && !readOnly) {
0402
0403
    /* delete command */
0404
0405
    if (objc != 3) {
0406
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0407
        WtToString(objv[0]), " ", WtToString(objv[1]), " tableId", NULL);
0408
    } else if (WtDeleteAppTable(&wtAppTables, objv[2], interp)) {
0409
      ret = TCL_OK;
0410
    }
0411
0412
  } else if (!strcmp(subCmd, "importVars")) {
0413
0414
    /* importVars command */
0415
0416
    if (objc != 3) {
0417
      Tcl_AppendResult(interp, wtBadUsagePrefix,
0418
        WtToString(objv[0]), " ", WtToString(objv[1]), " tableId", NULL);
0419
    } else if (mt = WtAppTableCmdGetStorage(objv[2], &tbl, interp)) {
0420
      WtMtTableLock(mt);
0421
      if (WtImportTableVars(tbl, interp)) {
0422
        ret = TCL_OK;
0423
      }
0424
      WtMtTableUnlock(mt);
0425
    }
0426
0427
  } else {
0428
0429
    /* unknown command */
0430
0431
    status = WT_TBL_CMD_NOT_FOUND;
0432
0433
    if (appendUsage) {
0434
      WtAppTableCmdUsageError(interp, objv[0], readOnly);
0435
    }
0436
0437
  }
0438
0439
  if (tbl && !WtCloseAppTable(tbl)) {
0440
    ret = TCL_ERROR;
0441
  }
0442
0443
  *tclRet = ret;
0444
0445
  return status;
0446
}
0447
0448
void WtAppTableCmdUsageError(Tcl_Interp *interp, Tcl_Obj *cmd, int readOnly)
0449
{
0450
  Tcl_Obj *interpRes = Tcl_GetObjResult(interp);
0451
  Tcl_AppendResult(interp, wtBadUsagePrefix2, NULL);
0452
  WtAppTableCmdAppendUsage(interp, cmd, readOnly);
0453
}
0454
0455
void WtAppTableCmdAppendUsage(Tcl_Interp *interp, Tcl_Obj *cmd, int readOnly)
0456
{
0457
  Tcl_Obj *res = Tcl_GetObjResult(interp);
0458
  char *cmdStr = WtToString(cmd);
0459
0460
  if (readOnly) {
0461
    Tcl_AppendStringsToObj(res,
0462
      cmdStr, " open ?tableId?\n",
0463
      cmdStr, " count tableId\n",
0464
      cmdStr, " has tableId key\n",
0465
      cmdStr, " keys tableId\n",
0466
      cmdStr, " values tableId\n",
0467
      cmdStr, " get tableId key ?defaultValue?\n",
0468
      cmdStr, " items tableId\n",
0469
      cmdStr, " list tableId\n",
0470
      cmdStr, " array tableId arrayName\n",
0471
      cmdStr, " copy tableId\n",
0472
      cmdStr, " importVars tableId\n",
0473
      NULL);
0474
  } else {
0475
    Tcl_AppendStringsToObj(res,
0476
      cmdStr, " open ?tableId?\n",
0477
      cmdStr, " count tableId\n",
0478
      cmdStr, " has tableId key\n",
0479
      cmdStr, " keys tableId\n",
0480
      cmdStr, " values tableId\n",
0481
      cmdStr, " get tableId key ?defaultValue?\n",
0482
      cmdStr, " set tableId key value\n",
0483
      cmdStr, " setDefault tableId key value\n",
0484
      cmdStr, " append tableId key value\n",
0485
      cmdStr, " add tableId key value\n",
0486
      cmdStr, " remove tableId key\n",
0487
      cmdStr, " removeList tableId keys\n",
0488
      cmdStr, " items tableId\n",
0489
      cmdStr, " list tableId\n",
0490
      cmdStr, " array tableId arrayName\n",
0491
      cmdStr, " copy tableId\n",
0492
      cmdStr, " importVars tableId\n",
0493
      cmdStr, " clear tableId\n",
0494
      cmdStr, " delete tableId\n",
0495
      NULL);
0496
  }
0497
}
0498
0499
int WtAppTableCmd(ClientData clientData, Tcl_Interp *interp,
0500
    int objc, Tcl_Obj *const objv[])
0501
{
0502
  int ret;
0503
  WtAppTableCmdHelper(clientData, interp, objc, objv, &ret, 0, 1);
0504
  return ret;
0505
}
0506
0507
/* Get the app table referenced by the command */
0508
0509
Tcl_Obj *WtAppTableCmdGetTarget(Tcl_Obj *id, Tcl_Interp *interp)
0510
{
0511
  int created;
0512
  return WtOpenAppTable(&wtAppTables, id, interp, &created);
0513
}
0514
0515
/* Get an app table's storage object */
0516
0517
Tcl_Obj *WtAppTableCmdGetStorage(Tcl_Obj *id, Tcl_Obj **tbl,
0518
    Tcl_Interp *interp)
0519
{
0520
  WtAppTable *at;
0521
  Tcl_Obj *mt = NULL;
0522
  int created;
0523
0524
  *tbl = WtOpenAppTable(&wtAppTables, id, interp, &created);
0525
0526
  if (*tbl) {
0527
    at = WtAppTableRep(*tbl);
0528
    mt = at->sharedTable;
0529
  }
0530
0531
  return mt;
0532
}
0533
0534
/* App table object */
0535
0536
/* Create */
0537
0538
Tcl_Obj *WtNewAppTableObj()
0539
{
0540
  Tcl_Obj *obj;
0541
0542
  WtAppTable *at = (WtAppTable *)ckalloc(sizeof(WtAppTable));
0543
  at->sharedTable = WtNewMtTableObj();
0544
0545
  obj = Tcl_NewObj();
0546
  obj->internalRep.twoPtrValue.ptr1 = at;
0547
  obj->internalRep.twoPtrValue.ptr2 = NULL;
0548
  obj->typePtr = &WtAppTableType;
0549
  Tcl_InvalidateStringRep(obj);
0550
  return obj;
0551
}
0552
0553
/* Copy */
0554
0555
static void WtAppTableDup(Tcl_Obj *src, Tcl_Obj *dst)
0556
{
0557
  WtAppTable *srcRep = WtAppTableRep(src);
0558
  WtAppTable *dstRep = (WtAppTable *)ckalloc(
0559
    sizeof(WtAppTable));
0560
0561
  if (srcRep->sharedTable) {
0562
    dstRep->sharedTable = Tcl_DuplicateObj(dstRep->sharedTable);
0563
    Tcl_IncrRefCount(dstRep->sharedTable);
0564
  } else {
0565
    dstRep->sharedTable = NULL;
0566
  }
0567
0568
  dst->internalRep.twoPtrValue.ptr1 = dstRep;
0569
  dst->internalRep.twoPtrValue.ptr2 = NULL;
0570
  dst->typePtr = &WtAppTableType;
0571
  Tcl_InvalidateStringRep(dst);
0572
}
0573
0574
/* Update the string rep */
0575
0576
static void WtAppTableUpdateString(Tcl_Obj *obj)
0577
{
0578
  WtUpdateProtectedObjString(obj);
0579
}
0580
0581
/* Convert */
0582
0583
static int WtAppTableSetFromAny(Tcl_Interp *interp, Tcl_Obj *obj)
0584
{
0585
  return WtSetProtectedObjFromAny(interp, obj, &WtAppTableType);
0586
}
0587
0588
/* Free */
0589
0590
static void WtAppTableFree(Tcl_Obj *obj)
0591
{
0592
  WtAppTable *at = WtAppTableRep(obj);
0593
  if (at->sharedTable) {
0594
    Tcl_DecrRefCount(at->sharedTable);
0595
    at->sharedTable = NULL;
0596
  }
0597
  ckfree((char *)(at));
0598
}
0599
0600
WtAppTable *WtAppTableRep(Tcl_Obj *obj)
0601
{
0602
  return (WtAppTable *)obj->internalRep.twoPtrValue.ptr1;
0603
}
0604
0605
/* Process session type */
0606
0607
struct Tcl_ObjType WtAppTableType =
0608
{
0609
  "appTable",
0610
  WtAppTableFree,
0611
  WtAppTableDup,
0612
  WtAppTableUpdateString,
0613
  WtAppTableSetFromAny
0614
};
0615
0616
void WtInitAppTableCommands(Tcl_Interp *interp)
0617
{
0618
  Tcl_CreateObjCommand(interp, "appTable", WtAppTableCmd, NULL, NULL);
0619
}