1*4887Schin /*********************************************************************** 2*4887Schin * * 3*4887Schin * This software is part of the ast package * 4*4887Schin * Copyright (c) 1985-2007 AT&T Knowledge Ventures * 5*4887Schin * and is licensed under the * 6*4887Schin * Common Public License, Version 1.0 * 7*4887Schin * by AT&T Knowledge Ventures * 8*4887Schin * * 9*4887Schin * A copy of the License is available at * 10*4887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 11*4887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 12*4887Schin * * 13*4887Schin * Information and Software Systems Research * 14*4887Schin * AT&T Research * 15*4887Schin * Florham Park NJ * 16*4887Schin * * 17*4887Schin * Glenn Fowler <gsf@research.att.com> * 18*4887Schin * David Korn <dgk@research.att.com> * 19*4887Schin * Phong Vo <kpv@research.att.com> * 20*4887Schin * * 21*4887Schin ***********************************************************************/ 22*4887Schin #pragma prototyped 23*4887Schin /* 24*4887Schin * Glenn Fowler 25*4887Schin * AT&T Bell Laboratories 26*4887Schin * 27*4887Schin * 3d fs operations 28*4887Schin * only active for non-shared 3d library 29*4887Schin */ 30*4887Schin 31*4887Schin #include <ast.h> 32*4887Schin #include <fs3d.h> 33*4887Schin 34*4887Schin int 35*4887Schin fs3d(register int op) 36*4887Schin { 37*4887Schin register int cur; 38*4887Schin register char* v; 39*4887Schin char val[sizeof(FS3D_off) + 8]; 40*4887Schin 41*4887Schin static int fsview; 42*4887Schin static char on[] = FS3D_on; 43*4887Schin static char off[] = FS3D_off; 44*4887Schin 45*4887Schin if (fsview < 0) return(0); 46*4887Schin 47*4887Schin /* 48*4887Schin * get the current setting 49*4887Schin */ 50*4887Schin 51*4887Schin if (!fsview && mount("", "", 0, NiL)) 52*4887Schin goto nope; 53*4887Schin if (FS3D_op(op) == FS3D_OP_INIT && mount(FS3D_init, NiL, FS3D_VIEW, NiL)) 54*4887Schin goto nope; 55*4887Schin if (mount(on, val, FS3D_VIEW|FS3D_GET|FS3D_SIZE(sizeof(val)), NiL)) 56*4887Schin goto nope; 57*4887Schin if (v = strchr(val, ' ')) v++; 58*4887Schin else v = val; 59*4887Schin if (!strcmp(v, on)) 60*4887Schin cur = FS3D_ON; 61*4887Schin else if (!strncmp(v, off, sizeof(off) - 1) && v[sizeof(off)] == '=') 62*4887Schin cur = FS3D_LIMIT((int)strtol(v + sizeof(off) + 1, NiL, 0)); 63*4887Schin else cur = FS3D_OFF; 64*4887Schin if (cur != op) 65*4887Schin { 66*4887Schin switch (FS3D_op(op)) 67*4887Schin { 68*4887Schin case FS3D_OP_OFF: 69*4887Schin v = off; 70*4887Schin break; 71*4887Schin case FS3D_OP_ON: 72*4887Schin v = on; 73*4887Schin break; 74*4887Schin case FS3D_OP_LIMIT: 75*4887Schin sfsprintf(val, sizeof(val), "%s=%d", off, FS3D_arg(op)); 76*4887Schin v = val; 77*4887Schin break; 78*4887Schin default: 79*4887Schin v = 0; 80*4887Schin break; 81*4887Schin } 82*4887Schin if (v && mount(v, NiL, FS3D_VIEW, NiL)) 83*4887Schin goto nope; 84*4887Schin } 85*4887Schin fsview = 1; 86*4887Schin return(cur); 87*4887Schin nope: 88*4887Schin fsview = -1; 89*4887Schin return(0); 90*4887Schin } 91