/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1986-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20/*21* Glenn Fowler22* AT&T Research23*24* preprocessor context switch25*26* args op return27* (0,0) free current context 028* (0,1) save current context current29* (p,0) free context p 030* (p,1) make p current context previous31*/3233#include "pplib.h"3435void*36ppcontext(void* context, int flags)37{38struct ppcontext* np = (struct ppcontext*)context;39struct ppcontext* op;4041if (flags & 01)42{43if (!(op = pp.context)) op = pp.context = newof(0, struct ppcontext, 1, 0);44memcpy(op, _PP_CONTEXT_BASE_, sizeof(struct ppcontext));45}46else47{48if (!(op = np)) op = (struct ppcontext*)_PP_CONTEXT_BASE_;49if (op->filtab) hashfree(op->filtab);50if (op->prdtab) hashfree(op->prdtab);51if (op->symtab) hashfree(op->symtab);52if (op->date) free(op->date);53if (op->time) free(op->time);54if (np)55{56free(np);57np = 0;58}59memzero(op, sizeof(struct ppcontext));60op = 0;61}62if (np) memcpy(_PP_CONTEXT_BASE_, np, sizeof(struct ppcontext));63return((void*)op);64}656667