Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libpp/ppcontext.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1986-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Glenn Fowler
23
* AT&T Research
24
*
25
* preprocessor context switch
26
*
27
* args op return
28
* (0,0) free current context 0
29
* (0,1) save current context current
30
* (p,0) free context p 0
31
* (p,1) make p current context previous
32
*/
33
34
#include "pplib.h"
35
36
void*
37
ppcontext(void* context, int flags)
38
{
39
struct ppcontext* np = (struct ppcontext*)context;
40
struct ppcontext* op;
41
42
if (flags & 01)
43
{
44
if (!(op = pp.context)) op = pp.context = newof(0, struct ppcontext, 1, 0);
45
memcpy(op, _PP_CONTEXT_BASE_, sizeof(struct ppcontext));
46
}
47
else
48
{
49
if (!(op = np)) op = (struct ppcontext*)_PP_CONTEXT_BASE_;
50
if (op->filtab) hashfree(op->filtab);
51
if (op->prdtab) hashfree(op->prdtab);
52
if (op->symtab) hashfree(op->symtab);
53
if (op->date) free(op->date);
54
if (op->time) free(op->time);
55
if (np)
56
{
57
free(np);
58
np = 0;
59
}
60
memzero(op, sizeof(struct ppcontext));
61
op = 0;
62
}
63
if (np) memcpy(_PP_CONTEXT_BASE_, np, sizeof(struct ppcontext));
64
return((void*)op);
65
}
66
67