8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / libpp / common / ppcontext.c
blobf87a2fff3348f1783e8b77a05b9335b06b780651
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1986-2009 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * *
19 ***********************************************************************/
20 #pragma prototyped
22 * Glenn Fowler
23 * AT&T Research
25 * preprocessor context switch
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
34 #include "pplib.h"
36 void*
37 ppcontext(void* context, int flags)
39 struct ppcontext* np = (struct ppcontext*)context;
40 struct ppcontext* op;
42 if (flags & 01)
44 if (!(op = pp.context)) op = pp.context = newof(0, struct ppcontext, 1, 0);
45 memcpy(op, _PP_CONTEXT_BASE_, sizeof(struct ppcontext));
47 else
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)
57 free(np);
58 np = 0;
60 memzero(op, sizeof(struct ppcontext));
61 op = 0;
63 if (np) memcpy(_PP_CONTEXT_BASE_, np, sizeof(struct ppcontext));
64 return((void*)op);