| 1 |
/* File: tabledefio.c (formerly known as sprddef.c) |
| 2 |
* Author: Jean Thierry-Mieg ([email protected]) |
| 3 |
* Copyright (C) J Thierry-Mieg and R Durbin, 1992 |
| 4 |
* ------------------------------------------------------------------- |
| 5 |
* Acedb is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU General Public License |
| 7 |
* as published by the Free Software Foundation; either version 2 |
| 8 |
* of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, write to the Free Software |
| 17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 |
* or see the on-line version at http://www.gnu.org/copyleft/gpl.txt |
| 19 |
* ------------------------------------------------------------------- |
| 20 |
* This file is part of the ACEDB genome database package, written by |
| 21 |
* Richard Durbin (MRC LMB, UK) [email protected], and |
| 22 |
* Jean Thierry-Mieg (CRBM du CNRS, France) [email protected] |
| 23 |
* |
| 24 |
* Description: |
| 25 |
Read write to disk |
| 26 |
and or |
| 27 |
Get Save in object |
| 28 |
a table definition |
| 29 |
* Exported functions: |
| 30 |
* HISTORY: |
| 31 |
* Last edited: Apr 6 16:16 2001 (edgrif) |
| 32 |
* * Jun 14 15:52 1999 (fw): cleaned up I/O handling of |
| 33 |
* param char sequences \% and %%1 etc.. |
| 34 |
* Created: Fri Dec 11 13:53:37 1992 (mieg) |
| 35 |
*------------------------------------------------------------------- |
| 36 |
*/ |
| 37 |
|
| 38 |
/* $Id: tabledefio.c,v 1.14 2001/04/06 16:32:21 edgrif Exp $ */ |
| 39 |
|
| 40 |
#include "acedb.h" |
| 41 |
#include "aceio.h" |
| 42 |
#include "lex.h" |
| 43 |
#include "java.h" |
| 44 |
#include "dump.h" |
| 45 |
#include "whooks/systags.h" |
| 46 |
#include "whooks/tags.h" |
| 47 |
#include "whooks/sysclass.h" |
| 48 |
#include "spread_.h" |
| 49 |
|
| 50 |
/*****************************************************/ |
| 51 |
|
| 52 |
static void convertCondBufferIn (char *to_buf, char *from_buf, |
| 53 |
int to_max); |
| 54 |
static char *convertCondBufferOut (char *from_buf); |
| 55 |
|
| 56 |
/*****************************************************/ |
| 57 |
/******* Input Output of the definitions *************/ |
| 58 |
|
| 59 |
FREEOPT presenceChoice[] = { |
| 60 |
{3,"Presence options"}, |
| 61 |
{VAL_IS_OPTIONAL, "Optional"}, |
| 62 |
{VAL_IS_REQUIRED, "Mandatory"}, |
| 63 |
{VAL_MUST_BE_NULL, "Null"} |
| 64 |
} ; |
| 65 |
|
| 66 |
FREEOPT extendChoice[] = { |
| 67 |
{2,"Extend options"}, |
| 68 |
{COLEXTEND_RIGHT_OF, "Right_of"}, |
| 69 |
{COLEXTEND_FROM, "From"} |
| 70 |
} ; |
| 71 |
|
| 72 |
FREEOPT hideChoice[] = { |
| 73 |
{2,"Hide options"}, |
| 74 |
{TRUE, "Hidden"}, |
| 75 |
{FALSE, "Visible"} |
| 76 |
} ; |
| 77 |
|
| 78 |
/**********/ |
| 79 |
|
| 80 |
static FREEOPT showOpts[] = { |
| 81 |
{6, "Show options"}, |
| 82 |
{1, "MIN"}, |
| 83 |
{2, "MAX"}, |
| 84 |
{3, "Average"}, |
| 85 |
{4, "Variance"}, |
| 86 |
{5, "Sum"}, |
| 87 |
{6, "Count"} |
| 88 |
} ; |
| 89 |
|
| 90 |
/****************************************************************** |
| 91 |
************************* public functions *********************** |
| 92 |
******************************************************************/ |
| 93 |
|
| 94 |
void spreadDumpDefinitions (SPREAD spread, ACEOUT dump_out) |
| 95 |
/* write out complete table_maker spreadsheet definition */ |
| 96 |
{ |
| 97 |
char *cp ; |
| 98 |
|
| 99 |
aceOutPrint (dump_out, "// Spread sheet definition for the ACeDB software \n") ; |
| 100 |
aceOutPrint (dump_out, "// User: %s\n", getLogin(TRUE)) ; |
| 101 |
aceOutPrint (dump_out, "// Date: %s\n\n", timeShow (timeNow())) ; |
| 102 |
aceOutPrint (dump_out, "// %%n (%%%%n in the graphic) are parameter to be given on the command line in tace\n") ; |
| 103 |
aceOutPrint (dump_out, "// or by default by the Parameters given in this file\n") ; |
| 104 |
aceOutPrint (dump_out, "// \\%%n (%%n in the graphic) are substituted by the value of column n at run time\n") ; |
| 105 |
aceOutPrint (dump_out, "// Line starting with // are ignored, starting with # are comments\n\n") ; |
| 106 |
|
| 107 |
if (stackExists(spread->comments)) |
| 108 |
{ stackCursor(spread->comments, 0) ; |
| 109 |
while ((cp = stackNextText(spread->comments))) |
| 110 |
aceOutPrint (dump_out, "# %s", cp) ; |
| 111 |
} |
| 112 |
|
| 113 |
if (strlen(spread->titleBuffer) > 0) |
| 114 |
aceOutPrint (dump_out, "Title %s\n\n", spread->titleBuffer) ; |
| 115 |
if (strlen(spread->paramBuffer) > 0) |
| 116 |
aceOutPrint (dump_out, "Parameters %s\n\n", spread->paramBuffer); |
| 117 |
if (spread->sortColonne) |
| 118 |
aceOutPrint (dump_out, "Sortcolumn %d\n\n", spread->sortColonne) ; |
| 119 |
if (spread->precompute) |
| 120 |
aceOutPrint (dump_out, "Precompute\n\n") ; |
| 121 |
|
| 122 |
spreadDumpColonneDefinitions (dump_out, spread->colonnes) ; |
| 123 |
aceOutPrint (dump_out, " \n\n// End of these definitions\n") ; |
| 124 |
|
| 125 |
return; |
| 126 |
} /* spreadDumpDefinitions */ |
| 127 |
|
| 128 |
/******************************************************/ |
| 129 |
|
| 130 |
void spreadColSetPresence(SPREAD spread, int colNum, KEY presence) |
| 131 |
/* the key refers to the FREEOPT presenceChoice */ |
| 132 |
{ |
| 133 |
COL *col = arrayp(spread->colonnes, colNum, COL); |
| 134 |
SpPresenceType oldValue = col->presence; |
| 135 |
|
| 136 |
if (oldValue != (SpPresenceType)presence) |
| 137 |
{ |
| 138 |
col->presence = (SpPresenceType)presence; |
| 139 |
col->optionalp = freekey2text(col->presence, presenceChoice) ; |
| 140 |
spread->isModified = TRUE; |
| 141 |
} |
| 142 |
|
| 143 |
return; |
| 144 |
} /* spreadColSetPresence */ |
| 145 |
|
| 146 |
void spreadColCyclePresence(SPREAD spread, int colNum) |
| 147 |
{ |
| 148 |
COL *col = arrayp(spread->colonnes, colNum, COL); |
| 149 |
KEY newValue = (col->presence+1) % presenceChoice->key ; |
| 150 |
|
| 151 |
spreadColSetPresence(spread, colNum, newValue); |
| 152 |
|
| 153 |
return; |
| 154 |
} /* spreadColCyclePresence */ |
| 155 |
|
| 156 |
/************************************************************/ |
| 157 |
|
| 158 |
void spreadColSetExtend(SPREAD spread, int colNum, KEY extend) |
| 159 |
/* the key refers to the FREEOPT extendChoice */ |
| 160 |
{ |
| 161 |
COL *col = arrayp(spread->colonnes, colNum, COL); |
| 162 |
SpExtendType oldValue = col->extend; |
| 163 |
|
| 164 |
if (oldValue != (SpExtendType)extend) |
| 165 |
{ |
| 166 |
col->extend = (SpExtendType)extend; |
| 167 |
col->extendp = freekey2text(col->extend, extendChoice) ; |
| 168 |
spread->isModified = TRUE; |
| 169 |
} |
| 170 |
|
| 171 |
return; |
| 172 |
} /* spreadColSetExtend */ |
| 173 |
|
| 174 |
void spreadColCycleExtend(SPREAD spread, int colNum) |
| 175 |
{ |
| 176 |
COL *col = arrayp(spread->colonnes, colNum, COL); |
| 177 |
KEY newValue = (col->extend+1) % extendChoice->key ; |
| 178 |
|
| 179 |
spreadColSetExtend(spread, colNum, newValue); |
| 180 |
|
| 181 |
return; |
| 182 |
} /* spreadColCycleExtend */ |
| 183 |
|
| 184 |
/************************************************************/ |
| 185 |
|
| 186 |
void spreadColSetHidden(SPREAD spread, int colNum, KEY hidden) |
| 187 |
/* the key refers to the FREEOPT hideChoice */ |
| 188 |
{ |
| 189 |
COL *col = arrayp(spread->colonnes, colNum, COL); |
| 190 |
BOOL oldValue = col->hidden; |
| 191 |
|
| 192 |
if (oldValue != (BOOL)hidden) |
| 193 |
{ |
| 194 |
col->hidden = (BOOL)hidden; |
| 195 |
col->hiddenp = freekey2text(col->hidden, hideChoice) ; |
| 196 |
spread->isModified = TRUE; |
| 197 |
} |
| 198 |
|
| 199 |
return; |
| 200 |
} /* spreadColSetHidden */ |
| 201 |
|
| 202 |
void spreadColCycleHidden(SPREAD spread, int colNum) |
| 203 |
{ |
| 204 |
COL *col = arrayp(spread->colonnes, colNum, COL); |
| 205 |
KEY newValue = (col->hidden+1) % hideChoice->key ; |
| 206 |
|
| 207 |
spreadColSetHidden(spread, colNum, newValue); |
| 208 |
|
| 209 |
return; |
| 210 |
} /* spreadColCycleHidden */ |
| 211 |
|
| 212 |
|
| 213 |
/****************************************************************** |
| 214 |
*********************** protected functions ********************** |
| 215 |
******************************************************************/ |
| 216 |
|
| 217 |
void spreadDumpColonneDefinitions (ACEOUT dump_out, Array colonnes) |
| 218 |
/* print all colonne definitions into the dump_out */ |
| 219 |
{ |
| 220 |
int j , maxCol; |
| 221 |
COL *c ; |
| 222 |
|
| 223 |
maxCol = arrayMax(colonnes) ; |
| 224 |
for(j = 0 ; j < maxCol; j++) |
| 225 |
{ c = arrp(colonnes,j, COL) ; |
| 226 |
if (!c->type) |
| 227 |
continue ; |
| 228 |
|
| 229 |
aceOutPrint (dump_out, "Colonne %d \n", j + 1) ; |
| 230 |
if (*c->headerBuffer) |
| 231 |
aceOutPrint (dump_out, "Subtitle %s \n", c->headerBuffer) ; |
| 232 |
|
| 233 |
aceOutPrint (dump_out, "Width %d \n", c->width) ; |
| 234 |
aceOutPrint (dump_out, "%s \n",freekey2text(c->presence, presenceChoice)) ; |
| 235 |
aceOutPrint (dump_out, "%s \n",freekey2text(c->hidden, hideChoice)) ; |
| 236 |
if (c->typep) |
| 237 |
aceOutPrint (dump_out, "%s \n",c->typep) ; |
| 238 |
if ((c->type == 'k') && c->classe) |
| 239 |
aceOutPrint (dump_out, "Class %s \n",name(c->classe)) ; |
| 240 |
if ((c->type == 'K') && c->classe) |
| 241 |
aceOutPrint (dump_out, "Next_Key %s \n", name(c->classe)) ; |
| 242 |
if (c->type == 'c') |
| 243 |
aceOutPrint (dump_out, "Count \n") ; |
| 244 |
if (c->showType != SHOW_ALL) |
| 245 |
aceOutPrint (dump_out, "Extract %s\n", freekey2text (c->showType, showOpts)) ; |
| 246 |
aceOutPrint (dump_out, "%s %d \n", freekey2text(c->extend, extendChoice), c->from); |
| 247 |
|
| 248 |
if (c->tagp && *c->tagp) aceOutPrint (dump_out, "Tag %s \n",c->tagp) ; |
| 249 |
if (strlen(c->conditionBuffer) > 0) |
| 250 |
{ |
| 251 |
aceOutPrint (dump_out, "Condition ") ; |
| 252 |
|
| 253 |
aceOutPrint (dump_out, "%s", convertCondBufferOut(c->conditionBuffer)); |
| 254 |
aceOutPrint (dump_out, "\n") ; |
| 255 |
} |
| 256 |
aceOutPrint (dump_out, " \n") ; |
| 257 |
} |
| 258 |
|
| 259 |
return; |
| 260 |
} /* spreadDumpColonneDefinitions */ |
| 261 |
|
| 262 |
/************************************************************/ |
| 263 |
|
| 264 |
static FREEOPT spreadReadMenu[] = |
| 265 |
{ |
| 266 |
{45, "Spread Definitions"}, |
| 267 |
{'#', "#"}, |
| 268 |
{'a', "Table"}, /* first line if from object */ |
| 269 |
{'T', "Title"}, |
| 270 |
{'P', "Parameters"}, |
| 271 |
{'s', "Subtitle"}, |
| 272 |
{'c', "Colonne"}, |
| 273 |
{'r', "From"}, |
| 274 |
{'R', "Right_of"}, |
| 275 |
{'g', "Tag"}, |
| 276 |
{'v', "Visible"}, |
| 277 |
{'h', "Hidden"}, |
| 278 |
{'o', "Optional"}, |
| 279 |
{'m', "Mandatory"}, |
| 280 |
{'N', "Null"}, |
| 281 |
{'C', "Condition"}, |
| 282 |
{'k', "Class"}, |
| 283 |
{'k', "A_Class"}, |
| 284 |
{'i', "Integer"}, |
| 285 |
{'i', "An_Int"}, |
| 286 |
{'f', "Float"}, |
| 287 |
{'f', "A_Float"}, |
| 288 |
{'d', "Date"}, |
| 289 |
{'d', "A_Date"}, |
| 290 |
{'t', "Text"}, |
| 291 |
{'t', "A_Text"}, |
| 292 |
{'b', "Boolean"}, |
| 293 |
{'B', "Show_Tag"}, |
| 294 |
{'n', "Next_Tag"}, |
| 295 |
{'K', "Next_Key"}, |
| 296 |
{'S', "Sortcolumn"}, |
| 297 |
{'E', "Extract"}, |
| 298 |
{'w', "Width"}, |
| 299 |
{'M', "FlipMap"}, |
| 300 |
{'L', "Type"}, |
| 301 |
{'L', "Presence"}, |
| 302 |
{'L', "Visibility"}, |
| 303 |
{'L', "Origin"}, |
| 304 |
{'1', "All"}, |
| 305 |
{'2', "Min"}, |
| 306 |
{'3', "Max"}, |
| 307 |
{'4', "Average"}, |
| 308 |
{'5', "Variance"}, |
| 309 |
{'6', "Sum"}, |
| 310 |
{'7', "Count"}, |
| 311 |
{'U', "Precompute"} |
| 312 |
} ; |
| 313 |
|
| 314 |
/************************************************************/ |
| 315 |
|
| 316 |
BOOL spreadSaveDefInObj (SPREAD spread, KEY tableKey) |
| 317 |
{ |
| 318 |
Stack s = 0 ; |
| 319 |
int ii, j , maxCol ; char *cp ; |
| 320 |
COL *c ; |
| 321 |
KEY tag ; |
| 322 |
char buf[2] ; |
| 323 |
OBJ tableObj ; |
| 324 |
|
| 325 |
buf[1] = 0 ; /* used in stackCat */ |
| 326 |
if (class(tableKey) != _VTable) |
| 327 |
return FALSE ; |
| 328 |
|
| 329 |
if (!(tableObj = bsUpdate(tableKey))) |
| 330 |
return FALSE ; |
| 331 |
|
| 332 |
while (bsGoto (tableObj, 0), bsGetKeyTags (tableObj, _bsRight, 0)) |
| 333 |
bsRemove (tableObj) ; |
| 334 |
|
| 335 |
if (stackExists(spread->comments)) |
| 336 |
{ |
| 337 |
stackCursor(spread->comments, 0) ; |
| 338 |
while((cp = stackNextText(spread->comments))) |
| 339 |
bsAddData (tableObj, _Comment, _Text, cp) ; |
| 340 |
} |
| 341 |
|
| 342 |
if (strlen(spread->titleBuffer) > 0) |
| 343 |
bsAddData (tableObj, _Title, _Text, spread->titleBuffer) ; |
| 344 |
|
| 345 |
lexaddkey ("Precompute", &tag, 0) ; |
| 346 |
if (spread->precompute) |
| 347 |
bsAddTag (tableObj, tag) ; |
| 348 |
|
| 349 |
lexaddkey ("Sortcolumn", &tag, 0) ; |
| 350 |
if (spread->sortColonne) |
| 351 |
bsAddData (tableObj, tag, _Int, &spread->sortColonne) ; |
| 352 |
|
| 353 |
lexaddkey ("Parameters", &tag, 0) ; |
| 354 |
if (strlen(spread->paramBuffer) > 0) |
| 355 |
bsAddData (tableObj, tag, _Text, spread->paramBuffer) ; |
| 356 |
|
| 357 |
maxCol = arrayMax(spread->colonnes) ; |
| 358 |
for(j = 0 ; j < maxCol; j++) |
| 359 |
{ c = arrp(spread->colonnes,j, COL) ; |
| 360 |
if (!c->type) |
| 361 |
continue ; |
| 362 |
|
| 363 |
ii = j + 1 ; |
| 364 |
lexaddkey ("Colonne", &tag, 0) ; |
| 365 |
bsAddData (tableObj, tag, _Int, &ii) ; |
| 366 |
bsPushObj(tableObj) ; |
| 367 |
|
| 368 |
if (c->headerBuffer && strlen(c->headerBuffer) > 0) |
| 369 |
bsAddData (tableObj, str2tag("Subtitle"), _Text, c->headerBuffer); |
| 370 |
|
| 371 |
lexaddkey ("Right_of", &tag, 0) ; |
| 372 |
if (c->extend == COLEXTEND_FROM) |
| 373 |
bsAddData (tableObj, _From, _Int, &c->from) ; |
| 374 |
else |
| 375 |
bsAddData (tableObj, tag, _Int, &c->from) ; |
| 376 |
|
| 377 |
lexaddkey ("Tag", &tag, 0) ; |
| 378 |
if (c->tagp && *c->tagp) |
| 379 |
bsAddData (tableObj, tag, _Text, c->tagp) ; |
| 380 |
|
| 381 |
if (c->hidden) |
| 382 |
bsAddTag (tableObj, _Hidden) ; |
| 383 |
else |
| 384 |
bsAddTag (tableObj, _Visible) ; |
| 385 |
lexaddkey ("Width", &tag, 0) ; |
| 386 |
bsAddData (tableObj, tag, _Int, &c->width) ; |
| 387 |
|
| 388 |
switch (c->presence) |
| 389 |
{ |
| 390 |
case VAL_MUST_BE_NULL: |
| 391 |
lexaddkey ("Null", &tag, 0) ; |
| 392 |
bsAddTag (tableObj, tag) ; |
| 393 |
break ; |
| 394 |
case VAL_IS_OPTIONAL: |
| 395 |
lexaddkey ("Optional", &tag, 0) ; |
| 396 |
bsAddTag (tableObj, tag) ; |
| 397 |
break ; |
| 398 |
case VAL_IS_REQUIRED: |
| 399 |
lexaddkey ("Mandatory", &tag, 0) ; |
| 400 |
bsAddTag (tableObj, tag) ; |
| 401 |
break ; |
| 402 |
} |
| 403 |
|
| 404 |
if (strlen(c->conditionBuffer) > 0) |
| 405 |
{ |
| 406 |
lexaddkey ("Condition", &tag, 0) ; |
| 407 |
|
| 408 |
cp = convertCondBufferOut(c->conditionBuffer); |
| 409 |
bsAddData (tableObj, tag, _Text, cp) ; |
| 410 |
} |
| 411 |
|
| 412 |
switch (c->type) |
| 413 |
{ |
| 414 |
case 'k': |
| 415 |
lexaddkey ("A_Class", &tag, 0) ; |
| 416 |
if (c->classe) |
| 417 |
bsAddData (tableObj, tag, _Text, name(c->classe)) ; |
| 418 |
break ; |
| 419 |
case 'K': |
| 420 |
lexaddkey ("Next_Key", &tag, 0) ; |
| 421 |
if (c->classe) |
| 422 |
bsAddData (tableObj, tag, _Text, name(c->classe)) ; |
| 423 |
break ; |
| 424 |
case 'i': |
| 425 |
lexaddkey ("An_Int", &tag, 0) ; |
| 426 |
bsAddTag (tableObj,tag) ; |
| 427 |
break ; |
| 428 |
case 'f': |
| 429 |
lexaddkey ("A_Float", &tag, 0) ; |
| 430 |
bsAddTag (tableObj,tag) ; |
| 431 |
break ; |
| 432 |
case 't': |
| 433 |
lexaddkey ("A_Text", &tag, 0) ; |
| 434 |
bsAddTag (tableObj,tag) ; |
| 435 |
break ; |
| 436 |
case 'd': |
| 437 |
lexaddkey ("A_Date", &tag, 0) ; |
| 438 |
bsAddTag (tableObj,tag) ; |
| 439 |
break ; |
| 440 |
case 'b': |
| 441 |
lexaddkey ("Boolean", &tag, 0) ; |
| 442 |
bsAddTag (tableObj,tag) ; |
| 443 |
break ; |
| 444 |
case 'B': |
| 445 |
lexaddkey ("Show_Tag", &tag, 0) ; |
| 446 |
bsAddTag (tableObj,tag) ; |
| 447 |
break ; |
| 448 |
case 'n': |
| 449 |
lexaddkey ("Next_Tag", &tag, 0) ; |
| 450 |
bsAddTag (tableObj,tag) ; |
| 451 |
break ; |
| 452 |
case 'c': |
| 453 |
lexaddkey ("Count", &tag, 0) ; |
| 454 |
bsAddTag (tableObj,tag) ; |
| 455 |
break ; |
| 456 |
} |
| 457 |
|
| 458 |
switch (c->type) |
| 459 |
{ |
| 460 |
case 'c': |
| 461 |
switch (c->realType) |
| 462 |
{ |
| 463 |
case 'k': |
| 464 |
lexaddkey ("A_Class", &tag, 0) ; |
| 465 |
if (c->classe) |
| 466 |
bsAddData (tableObj, tag, _Text, name(c->classe)) ; |
| 467 |
break ; |
| 468 |
case 'i': |
| 469 |
lexaddkey ("An_Int", &tag, 0) ; |
| 470 |
bsAddTag (tableObj,tag) ; |
| 471 |
break ; |
| 472 |
case 'f': |
| 473 |
lexaddkey ("A_Float", &tag, 0) ; |
| 474 |
bsAddTag (tableObj,tag) ; |
| 475 |
break ; |
| 476 |
case 't': |
| 477 |
lexaddkey ("A_Text", &tag, 0) ; |
| 478 |
bsAddTag (tableObj,tag) ; |
| 479 |
break ; |
| 480 |
case 'd': |
| 481 |
lexaddkey ("A_Date", &tag, 0) ; |
| 482 |
bsAddTag (tableObj,tag) ; |
| 483 |
break ; |
| 484 |
case 'b': |
| 485 |
lexaddkey ("Boolean", &tag, 0) ; |
| 486 |
bsAddTag (tableObj,tag) ; |
| 487 |
break ; |
| 488 |
} |
| 489 |
default: |
| 490 |
break ; |
| 491 |
} |
| 492 |
|
| 493 |
switch (c->showType) |
| 494 |
{ |
| 495 |
case SHOW_ALL: /* this is the default */ |
| 496 |
break ; |
| 497 |
case SHOW_MIN: |
| 498 |
bsAddTag (tableObj, _Min) ; |
| 499 |
break ; |
| 500 |
case SHOW_MAX: |
| 501 |
bsAddTag (tableObj, _Max) ; |
| 502 |
break ; |
| 503 |
case SHOW_SUM: |
| 504 |
lexaddkey ("Sum", &tag, 0) ; |
| 505 |
bsAddTag (tableObj,tag) ; |
| 506 |
break ; |
| 507 |
case SHOW_AVG: |
| 508 |
lexaddkey ("Average", &tag, 0) ; |
| 509 |
bsAddTag (tableObj,tag) ; |
| 510 |
break ; |
| 511 |
case SHOW_VAR: |
| 512 |
lexaddkey ("Variance", &tag, 0) ; |
| 513 |
bsAddTag (tableObj,tag) ; |
| 514 |
break ; |
| 515 |
} |
| 516 |
|
| 517 |
bsGoto (tableObj, 0) ; |
| 518 |
} |
| 519 |
|
| 520 |
bsSave (tableObj) ; |
| 521 |
stackDestroy (s) ; |
| 522 |
|
| 523 |
return TRUE ; |
| 524 |
} /* spreadSaveDefInObj */ |
| 525 |
|
| 526 |
/******************************************************/ |
| 527 |
|
| 528 |
BOOL spreadReadDef (SPREAD spread, ACEIN def_io, char *inParams, |
| 529 |
BOOL isReadFromObj) |
| 530 |
/* spreadReadDef - parse definitions into existing spread struct |
| 531 |
* existing defs are overwritten |
| 532 |
* PARAMETERS: |
| 533 |
* the definitions are read from the ACEIN def_io |
| 534 |
* the user-supplied parameters are inParams, which will be |
| 535 |
* combined with the parameters stored in the object itself |
| 536 |
* if NULL - the defs are parsed literally |
| 537 |
* if valid string - parameter substitution is performed |
| 538 |
* the boolean isReadFromObj tells whether the def_io |
| 539 |
* input was created from an object. |
| 540 |
* |
| 541 |
* RETURNS: |
| 542 |
* TRUE - is no syntax error etc. was encountered |
| 543 |
* FALSE - if there was some error, the validity of the data in |
| 544 |
* spread is now undefined */ |
| 545 |
{ |
| 546 |
int i; |
| 547 |
KEY option ; |
| 548 |
char *cp, *card ; |
| 549 |
COL *c=0 ; |
| 550 |
BOOL firstCol = TRUE, shift = TRUE ; |
| 551 |
BOOL ret = TRUE ; /*mhmp 26.11.98 */ |
| 552 |
Stack s1 = 0, paramStack = 0 ; |
| 553 |
ACEIN parse_io = NULL; |
| 554 |
char parse_special[24]; |
| 555 |
|
| 556 |
tableDestroy(spread->values); |
| 557 |
spreadDestroyColonnes (spread->colonnes); |
| 558 |
spread->colonnes = arrayCreate(8, COL) ; |
| 559 |
|
| 560 |
spread->comments = stackReCreate(spread->comments, 120) ; |
| 561 |
spread->sortColonne = 1 ; /* default */ |
| 562 |
memset (spread->titleBuffer, 0, 60) ; |
| 563 |
memset (spread->paramBuffer, 0, 180) ; |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
/* the paramStack contains multiple characters parameters, |
| 568 |
* when the free-package reads them, it'll use freeword to |
| 569 |
* parse them in - this behaviour will strip basically unprotect |
| 570 |
* the values, so in order for the protected values to be |
| 571 |
* substituted into the query, we need to freeprotect every |
| 572 |
* param-value TWICE - this is because of an inconsistency in the |
| 573 |
* free-package which would be too volatile to change, so |
| 574 |
* we work around it here this way */ |
| 575 |
paramStack = stackCreate(200) ; |
| 576 |
if (inParams && strlen(inParams) > 0) |
| 577 |
/* should be freeprotected (quoted) already |
| 578 |
* is protected here again */ |
| 579 |
catText(paramStack, freeprotect(inParams)) ; |
| 580 |
|
| 581 |
if (inParams == NULL) /* don't substitute params */ |
| 582 |
strcpy (parse_special, "\n\t/@\\"); /* exclude % */ |
| 583 |
else |
| 584 |
strcpy (parse_special, "\n\t/@%\\"); /* include % */ |
| 585 |
|
| 586 |
/* first parsing pass - |
| 587 |
* (1) extract parameters which are stored with the definitions, |
| 588 |
* so we can add those to the passed parameter |
| 589 |
* (2) build up text-stack 's1' containing the verbatim definitions */ |
| 590 |
s1 = stackCreate (2000) ; |
| 591 |
aceInSpecial (def_io,"\n/\\") ; |
| 592 |
while ((card = aceInCard(def_io))) |
| 593 |
{ |
| 594 |
cp = aceInPos(def_io) ; |
| 595 |
if (cp && *cp) |
| 596 |
catText (s1, cp) ; |
| 597 |
catText (s1, "\n") ; |
| 598 |
if (aceInKey (def_io, &option, spreadReadMenu)) |
| 599 |
{ |
| 600 |
if (option == 'P') /* only interested in embedded parameters */ |
| 601 |
{ |
| 602 |
cp = aceInPos(def_io); |
| 603 |
if (cp && strlen(cp) > 0) |
| 604 |
{ |
| 605 |
char *param_word; |
| 606 |
ACEIN param_io; |
| 607 |
|
| 608 |
if (isReadFromObj) |
| 609 |
cp = freeunprotect(cp) ; |
| 610 |
|
| 611 |
/* add a list doubly freeprotected |
| 612 |
* parameters onto the stack */ |
| 613 |
param_io = aceInCreateFromText(cp, "", 0); |
| 614 |
aceInSpecial (param_io,"\n/\\") ; |
| 615 |
aceInCard(param_io); |
| 616 |
while ((param_word = aceInWord(param_io))) |
| 617 |
{ |
| 618 |
catText (paramStack, " ") ; |
| 619 |
|
| 620 |
param_word = freeprotect(freeprotect(param_word)); |
| 621 |
catText (paramStack, param_word); |
| 622 |
} |
| 623 |
aceInDestroy(param_io); |
| 624 |
} |
| 625 |
} |
| 626 |
} |
| 627 |
else if (aceInWord(def_io)) |
| 628 |
/* we didn't match any of the options, but there still |
| 629 |
* is more to be read, so this will be an error then */ |
| 630 |
{ |
| 631 |
ret = FALSE ; |
| 632 |
goto fin ; |
| 633 |
} |
| 634 |
} |
| 635 |
|
| 636 |
/* second parsing pass - |
| 637 |
* parse the definitions from the stack that we've just built-up */ |
| 638 |
|
| 639 |
parse_io = aceInCreateFromText(stackText (s1,0), stackText (paramStack,0), 0); |
| 640 |
aceInSpecial (parse_io, parse_special); |
| 641 |
|
| 642 |
while ((card = aceInCard(parse_io))) |
| 643 |
{ |
| 644 |
lao: |
| 645 |
if (aceInKey (parse_io, &option, spreadReadMenu)) |
| 646 |
switch (option) |
| 647 |
{ |
| 648 |
case '#': |
| 649 |
pushText(spread->comments, aceInPos(parse_io)) ; |
| 650 |
break ; |
| 651 |
case 'U': /* "Precompute" */ |
| 652 |
spread->precompute = TRUE ; |
| 653 |
break ; |
| 654 |
case 'c': /* "Colonne" */ |
| 655 |
if (aceInInt(parse_io, &i)) |
| 656 |
{ |
| 657 |
if (firstCol && i == 0) |
| 658 |
shift = FALSE ; /* because in acedb.1.x i saved i, now i+1 */ |
| 659 |
if (shift) |
| 660 |
i-- ; |
| 661 |
|
| 662 |
c = arrayp(spread->colonnes,i, COL) ; |
| 663 |
if (!c->from) |
| 664 |
c = spreadColInit(spread, i); |
| 665 |
|
| 666 |
if (isReadFromObj) |
| 667 |
goto lao ; /* loop on the inside of the def */ |
| 668 |
} |
| 669 |
break ; |
| 670 |
case 'E': /* Extract */ |
| 671 |
if (c && aceInKey (parse_io, &option, showOpts) && option >= 1 && option <= 6) |
| 672 |
{ |
| 673 |
if (option < 6) |
| 674 |
c->showType = (SpShowType) ( option ) ; |
| 675 |
else |
| 676 |
c->type = 'c' ; |
| 677 |
c->nonLocal = TRUE ; |
| 678 |
c->typep = freekey2text(option, showOpts) ; |
| 679 |
} |
| 680 |
break ; |
| 681 |
case 'w': /* "Width" */ |
| 682 |
if (c && aceInInt(parse_io, &i)) |
| 683 |
c->width = i ; |
| 684 |
break ; |
| 685 |
case 'N': /* "Null" */ |
| 686 |
if (c) |
| 687 |
spreadColSetPresence(spread, c->colonne, VAL_MUST_BE_NULL); |
| 688 |
break ; |
| 689 |
case 'o': /* "Optional" */ |
| 690 |
if (c) |
| 691 |
spreadColSetPresence(spread, c->colonne, VAL_IS_OPTIONAL); |
| 692 |
break ; |
| 693 |
case 'm': /* "Mandatory" */ |
| 694 |
if (c) |
| 695 |
spreadColSetPresence(spread, c->colonne, VAL_IS_REQUIRED) ; |
| 696 |
break ; |
| 697 |
case 'M': /* "FlipMap" */ |
| 698 |
if (c) |
| 699 |
c->flipped = TRUE ; |
| 700 |
break ; |
| 701 |
case 'v': /* "Visible" */ |
| 702 |
if (c) |
| 703 |
spreadColSetHidden(spread, c->colonne, FALSE); |
| 704 |
break ; |
| 705 |
|
| 706 |
case 'h': /* "Hidden" */ |
| 707 |
if (c) |
| 708 |
spreadColSetHidden(spread, c->colonne, TRUE); |
| 709 |
break ; |
| 710 |
|
| 711 |
case 'i': /* "Integer" or "An_Int" */ |
| 712 |
case 'f': /* "Float" or "A_Float" */ |
| 713 |
case 'd': /* "Date" or "A_Date" */ |
| 714 |
case 't': /* "Text" or "A_Text" */ |
| 715 |
if (c) |
| 716 |
{ |
| 717 |
c->type = c->realType = option ; |
| 718 |
c->nonLocal = FALSE ; |
| 719 |
} |
| 720 |
break ; |
| 721 |
|
| 722 |
case 'k': /* "Class" or "A_Class" */ |
| 723 |
case 'K': /* "Next_Key" */ |
| 724 |
if (c) |
| 725 |
{ |
| 726 |
c->type = c->realType = option ; |
| 727 |
c->nonLocal = FALSE ; |
| 728 |
if ((cp = aceInPos(parse_io)) && *cp) |
| 729 |
{ |
| 730 |
if (isReadFromObj) |
| 731 |
cp = freeunprotect(cp) ; |
| 732 |
lexword2key(cp, &c->classe,_VClass) ; |
| 733 |
} |
| 734 |
} |
| 735 |
break ; |
| 736 |
|
| 737 |
case 'b': /* "Boolean" */ |
| 738 |
case 'B': /* "Show_Tag" */ |
| 739 |
case 'n': /* "Next_Tag" */ |
| 740 |
if (c) |
| 741 |
{ |
| 742 |
if (option == 'B') option = 'b' ; |
| 743 |
c->type = option ; |
| 744 |
c->realType = 'b' ; |
| 745 |
c->classe = _VSystem ; |
| 746 |
c->nonLocal = FALSE ; |
| 747 |
} |
| 748 |
break ; |
| 749 |
|
| 750 |
case 'r': /* "From" */ |
| 751 |
if (c) |
| 752 |
{ |
| 753 |
spreadColSetExtend(spread, c->colonne, COLEXTEND_FROM) ; |
| 754 |
if (aceInInt(parse_io, &i)) |
| 755 |
c->from = i ; |
| 756 |
} |
| 757 |
break ; |
| 758 |
|
| 759 |
case 'R': /* "Right_of" */ |
| 760 |
if (c) |
| 761 |
{ |
| 762 |
spreadColSetExtend(spread, c->colonne, COLEXTEND_RIGHT_OF); |
| 763 |
if (aceInInt(parse_io,&i)) |
| 764 |
c->from = i ; |
| 765 |
} |
| 766 |
break ; |
| 767 |
case 'g': /* "Tag" */ |
| 768 |
if (c && (cp = aceInPos(parse_io)) && *cp) |
| 769 |
{ |
| 770 |
c->tagStack = stackReCreate(c->tagStack, 30) ; |
| 771 |
if (isReadFromObj) |
| 772 |
cp = freeunprotect(cp) ; |
| 773 |
pushText(c->tagStack, cp) ; |
| 774 |
c->tagp = stackText(c->tagStack, 0) ; |
| 775 |
} |
| 776 |
break ; |
| 777 |
|
| 778 |
case 'C': /* "Condition" */ |
| 779 |
if (c && (cp = aceInPos(parse_io)) && *cp) |
| 780 |
{ |
| 781 |
char *cond_text = strnew(cp, 0); |
| 782 |
|
| 783 |
if (isReadFromObj) |
| 784 |
{ |
| 785 |
char *tmp_buf = NULL ; |
| 786 |
ACEIN cond_io = NULL ; |
| 787 |
|
| 788 |
/* row-params conditions are stored as \%<n>, |
| 789 |
* for storage in ace-format (in an object) |
| 790 |
* they've been freeprotected with quotes, |
| 791 |
* so here we could get "\%1 > \%2", which looks |
| 792 |
* like \"\\%1 > \\%2\" in c-style escaping. */ |
| 793 |
/* NOTE that to ensure that convertCondBufer does the */ |
| 794 |
/* right thing, we need to only remove the quotes, not */ |
| 795 |
/* the \\ !!! */ |
| 796 |
cond_io = aceInCreateFromText(cond_text, NULL, 0); |
| 797 |
aceInSpecial (cond_io, parse_special); |
| 798 |
aceInCard(cond_io); |
| 799 |
tmp_buf = aceInPos(cond_io) ; |
| 800 |
tmp_buf = strnew(aceInUnprotectQuote(cond_io, tmp_buf), 0) ; |
| 801 |
aceInDestroy(cond_io); |
| 802 |
|
| 803 |
convertCondBufferIn(c->conditionBuffer, tmp_buf, 360); |
| 804 |
messfree (tmp_buf); |
| 805 |
} |
| 806 |
else |
| 807 |
convertCondBufferIn(c->conditionBuffer, cond_text, 360); |
| 808 |
|
| 809 |
messfree(cond_text); |
| 810 |
} |
| 811 |
break ; |
| 812 |
|
| 813 |
case 's': /* "Subtitle" */ |
| 814 |
if (c && (cp = aceInPos(parse_io)) && *cp) |
| 815 |
{ |
| 816 |
if (isReadFromObj) |
| 817 |
cp = freeunprotect(cp) ; |
| 818 |
strncpy(c->headerBuffer, cp, 59) ; |
| 819 |
} |
| 820 |
break ; |
| 821 |
|
| 822 |
case 'T': /* "Title" */ |
| 823 |
if ((cp = aceInPos(parse_io)) && *cp) |
| 824 |
{ |
| 825 |
if (isReadFromObj) |
| 826 |
cp = freeunprotect(cp) ; |
| 827 |
strncpy(spread->titleBuffer, cp, 59) ; |
| 828 |
} |
| 829 |
break ; |
| 830 |
|
| 831 |
case 'S': /* "Sortcolumn" */ |
| 832 |
aceInInt (parse_io, &spread->sortColonne) ; |
| 833 |
break ; |
| 834 |
case 'L': /* "Type", |
| 835 |
"Presence", |
| 836 |
"Visibility", |
| 837 |
"Origin" */ |
| 838 |
/* intermediate tags, loop */ |
| 839 |
goto lao ; |
| 840 |
break ; |
| 841 |
case 'P': /* "Parameters" */ |
| 842 |
if ((cp = aceInPos(parse_io)) && *cp) |
| 843 |
{ |
| 844 |
if (isReadFromObj) |
| 845 |
cp = freeunprotect(cp) ; |
| 846 |
strncpy(spread->paramBuffer, cp, 179) ; |
| 847 |
} |
| 848 |
break ; |
| 849 |
case 'a': /* "Table" */ |
| 850 |
/* hopefully isReadFromObj = TRUE */ |
| 851 |
break ; |
| 852 |
|
| 853 |
case '1': /* "All" */ |
| 854 |
if (c) |
| 855 |
{ |
| 856 |
c->showType = SHOW_ALL ; |
| 857 |
c->nonLocal = FALSE ; |
| 858 |
} |
| 859 |
break ; |
| 860 |
|
| 861 |
case '2': /* "Min" */ |
| 862 |
if (c) |
| 863 |
{ |
| 864 |
c->showType = SHOW_MIN ; |
| 865 |
c->nonLocal = TRUE ; |
| 866 |
} |
| 867 |
break ; |
| 868 |
|
| 869 |
case '3': /* "Max" */ |
| 870 |
if (c) |
| 871 |
{ |
| 872 |
c->showType = SHOW_MAX ; |
| 873 |
c->nonLocal = TRUE ; |
| 874 |
} |
| 875 |
break ; |
| 876 |
|
| 877 |
case '4': /* "Average" */ |
| 878 |
if (c) |
| 879 |
{ |
| 880 |
c->showType = SHOW_AVG ; |
| 881 |
c->nonLocal = TRUE ; |
| 882 |
} |
| 883 |
break ; |
| 884 |
|
| 885 |
case '5': /* Variance" */ |
| 886 |
if (c) |
| 887 |
{ |
| 888 |
c->showType = SHOW_VAR ; |
| 889 |
c->nonLocal = TRUE ; |
| 890 |
} |
| 891 |
break ; |
| 892 |
|
| 893 |
case '6': /* "Sum" */ |
| 894 |
if (c) |
| 895 |
{ |
| 896 |
c->showType = SHOW_SUM ; |
| 897 |
c->nonLocal = TRUE ; |
| 898 |
} |
| 899 |
break ; |
| 900 |
|
| 901 |
case '7': /* Count" */ |
| 902 |
if (c) |
| 903 |
{ |
| 904 |
c->type = 'c' ; c->showType = SHOW_ALL ; |
| 905 |
c->nonLocal = TRUE ; |
| 906 |
} |
| 907 |
break ; |
| 908 |
default: |
| 909 |
messcrash ("spreadReadDef() - unknown option") ; |
| 910 |
} |
| 911 |
else if (aceInWord(parse_io)) |
| 912 |
{ |
| 913 |
ret = FALSE; |
| 914 |
goto fin ; |
| 915 |
} |
| 916 |
} |
| 917 |
|
| 918 |
fin: |
| 919 |
|
| 920 |
if (parse_io) |
| 921 |
aceInDestroy (parse_io); |
| 922 |
|
| 923 |
stackDestroy (paramStack) ; |
| 924 |
stackDestroy (s1) ; |
| 925 |
|
| 926 |
spread->isModified = FALSE ; |
| 927 |
|
| 928 |
if (ret && |
| 929 |
(spread->sortColonne < 0 || |
| 930 |
spread->sortColonne > arrayMax(spread->colonnes))) |
| 931 |
{ |
| 932 |
/* ---- inconvienient to output error here ------- |
| 933 |
* |
| 934 |
* messerror("sort-column %d out of range 0-%d", |
| 935 |
* spread->sortColonne, arrayMax(spread->colonnes)); |
| 936 |
*/ |
| 937 |
spread->sortColonne = 0; /* default order, sort left->right */ |
| 938 |
} |
| 939 |
|
| 940 |
return ret ; |
| 941 |
} /* spreadReadDef */ |
| 942 |
|
| 943 |
|
| 944 |
Stack getDefinitionFromObj (KEY tableKey) |
| 945 |
/* read from the object 'tableKey' in class _VTable |
| 946 |
* and print the definitions onto a stack. |
| 947 |
* the parameters that are from the object are combined |
| 948 |
* with the parameters passed into the functions (parms) |
| 949 |
* and returned in a newly allocated string newParams |
| 950 |
* |
| 951 |
* RETURNS a text-stack with the definitions */ |
| 952 |
{ |
| 953 |
char *zq ; |
| 954 |
char oneCharBuf[2]; |
| 955 |
ACEOUT dump_out; |
| 956 |
Stack dump_stack = 0, defStack = 0 ; |
| 957 |
|
| 958 |
if (class(tableKey) != _VTable) |
| 959 |
return NULL ; |
| 960 |
|
| 961 |
|
| 962 |
dump_stack = stackCreate (1000) ; |
| 963 |
dump_out = aceOutCreateToStack (dump_stack, 0); |
| 964 |
dumpKeyBeautifully (dump_out, tableKey, 'a', 0); |
| 965 |
aceOutDestroy (dump_out); |
| 966 |
|
| 967 |
/* when the parameter sequences |
| 968 |
* % (command param) and \% (row param) are read back from an object |
| 969 |
* which was dumped in ace-style into the database, |
| 970 |
* they come back as \% and \\\% respectively, so we convert back : |
| 971 |
* \% -> % |
| 972 |
* \\\% -> \% |
| 973 |
* just as if they had come from a file */ |
| 974 |
zq = stackText(dump_stack,0) ; |
| 975 |
oneCharBuf[1] = '\0'; |
| 976 |
defStack = stackCreate(1000); |
| 977 |
while (*zq) |
| 978 |
{ |
| 979 |
if (strncmp(zq,"\\\\\\%",4) == 0) /* \\% literally */ |
| 980 |
{ |
| 981 |
zq +=4 ; |
| 982 |
catText(defStack, "\\%"); /* \% literally */ |
| 983 |
} |
| 984 |
else if (strncmp(zq,"\\%", 2) == 0) /* \% literally */ |
| 985 |
{ |
| 986 |
zq += 2; |
| 987 |
catText(defStack, "%"); |
| 988 |
} |
| 989 |
else |
| 990 |
{ |
| 991 |
oneCharBuf[0] = *zq; |
| 992 |
catText(defStack, oneCharBuf); |
| 993 |
zq++ ; |
| 994 |
} |
| 995 |
} |
| 996 |
stackDestroy (dump_stack) ; |
| 997 |
|
| 998 |
return defStack ; |
| 999 |
} /* getDefinitionFromObj */ |
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
/****************************************************************** |
| 1004 |
************************ private functions *********************** |
| 1005 |
******************************************************************/ |
| 1006 |
|
| 1007 |
/* convert when loading from file into memory |
| 1008 |
* \% -> % (row condition params) |
| 1009 |
* % -> %% (command line params) |
| 1010 |
* Also, we try to get rid of lots of '\\' that appear due to |
| 1011 |
* some problem in the free stuff which means that stuff gets |
| 1012 |
* double quoted to protect it. I hope this is correct, the aquila |
| 1013 |
* results for the "tables" tests seem to be correct now. |
| 1014 |
*/ |
| 1015 |
static void convertCondBufferIn (char *to_buf, char *from_buf, |
| 1016 |
int to_max) |
| 1017 |
{ |
| 1018 |
int to_pos = 0; |
| 1019 |
char *from_p = from_buf; |
| 1020 |
|
| 1021 |
while (to_pos < to_max && *from_p != '\0') |
| 1022 |
{ |
| 1023 |
if (*from_p == '\\' && *(from_p + 1) == '%') |
| 1024 |
{ |
| 1025 |
/* unprotect the \% char -> % */ |
| 1026 |
from_p++ ; |
| 1027 |
} |
| 1028 |
else if (*from_p == '\\') |
| 1029 |
{ |
| 1030 |
/* try to strip out the \\ junk... */ |
| 1031 |
from_p++ ; |
| 1032 |
} |
| 1033 |
else if (*from_p == '%') |
| 1034 |
{ |
| 1035 |
/* double the single % char -> %% */ |
| 1036 |
to_buf[to_pos++] = '%'; |
| 1037 |
} |
| 1038 |
|
| 1039 |
to_buf[to_pos++] = *from_p ; |
| 1040 |
from_p++ ; |
| 1041 |
} |
| 1042 |
to_buf[to_pos] = '\0' ; |
| 1043 |
|
| 1044 |
return; |
| 1045 |
} /* convertCondBufferIn */ |
| 1046 |
|
| 1047 |
static char *convertCondBufferOut (char *from_buf) |
| 1048 |
/* convert when writing memory into file/object |
| 1049 |
* % -> \% (row condition params) |
| 1050 |
* %% -> % (command line params) |
| 1051 |
*/ |
| 1052 |
{ |
| 1053 |
static char *out_buf = 0; |
| 1054 |
char *from_p = from_buf; |
| 1055 |
char *out_p; |
| 1056 |
|
| 1057 |
if (out_buf) messfree(out_buf); |
| 1058 |
|
| 1059 |
out_buf = (char*)messalloc(strlen(from_buf) * 2 + 1); |
| 1060 |
out_p = out_buf; |
| 1061 |
|
| 1062 |
while (*from_p) |
| 1063 |
{ |
| 1064 |
if (*from_p == '%') |
| 1065 |
{ |
| 1066 |
if (*(from_p + 1) == '%') |
| 1067 |
from_p++; /* skip one % to export %% as % */ |
| 1068 |
else |
| 1069 |
{ |
| 1070 |
*out_p = '\\'; |
| 1071 |
out_p++; |
| 1072 |
} |
| 1073 |
} |
| 1074 |
*out_p++ = *from_p++; |
| 1075 |
} |
| 1076 |
|
| 1077 |
return out_buf; |
| 1078 |
} /* convertCondBufferOut */ |
| 1079 |
|
| 1080 |
/******************************************************/ |