14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*8462SApril.Chin@Sun.COM * Copyright (c) 1985-2008 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 7*8462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * Phong Vo <kpv@research.att.com> * 204887Schin * * 214887Schin ***********************************************************************/ 224887Schin #pragma prototyped 234887Schin /* 244887Schin * Glenn Fowler 254887Schin * AT&T Bell Laboratories 264887Schin * 274887Schin * 3d fs operations 284887Schin * only active for non-shared 3d library 294887Schin */ 304887Schin 314887Schin #include <ast.h> 324887Schin #include <fs3d.h> 334887Schin 344887Schin int 354887Schin fs3d(register int op) 364887Schin { 374887Schin register int cur; 384887Schin register char* v; 394887Schin char val[sizeof(FS3D_off) + 8]; 404887Schin 414887Schin static int fsview; 424887Schin static char on[] = FS3D_on; 434887Schin static char off[] = FS3D_off; 444887Schin 45*8462SApril.Chin@Sun.COM if (fsview < 0) 46*8462SApril.Chin@Sun.COM return 0; 474887Schin 484887Schin /* 494887Schin * get the current setting 504887Schin */ 514887Schin 52*8462SApril.Chin@Sun.COM if (!fsview && (!getenv("LD_PRELOAD") || mount("", "", 0, NiL))) 534887Schin goto nope; 544887Schin if (FS3D_op(op) == FS3D_OP_INIT && mount(FS3D_init, NiL, FS3D_VIEW, NiL)) 554887Schin goto nope; 564887Schin if (mount(on, val, FS3D_VIEW|FS3D_GET|FS3D_SIZE(sizeof(val)), NiL)) 574887Schin goto nope; 58*8462SApril.Chin@Sun.COM if (v = strchr(val, ' ')) 59*8462SApril.Chin@Sun.COM v++; 60*8462SApril.Chin@Sun.COM else 61*8462SApril.Chin@Sun.COM v = val; 624887Schin if (!strcmp(v, on)) 634887Schin cur = FS3D_ON; 644887Schin else if (!strncmp(v, off, sizeof(off) - 1) && v[sizeof(off)] == '=') 654887Schin cur = FS3D_LIMIT((int)strtol(v + sizeof(off) + 1, NiL, 0)); 66*8462SApril.Chin@Sun.COM else 67*8462SApril.Chin@Sun.COM cur = FS3D_OFF; 684887Schin if (cur != op) 694887Schin { 704887Schin switch (FS3D_op(op)) 714887Schin { 724887Schin case FS3D_OP_OFF: 734887Schin v = off; 744887Schin break; 754887Schin case FS3D_OP_ON: 764887Schin v = on; 774887Schin break; 784887Schin case FS3D_OP_LIMIT: 794887Schin sfsprintf(val, sizeof(val), "%s=%d", off, FS3D_arg(op)); 804887Schin v = val; 814887Schin break; 824887Schin default: 834887Schin v = 0; 844887Schin break; 854887Schin } 864887Schin if (v && mount(v, NiL, FS3D_VIEW, NiL)) 874887Schin goto nope; 884887Schin } 894887Schin fsview = 1; 90*8462SApril.Chin@Sun.COM return cur; 914887Schin nope: 924887Schin fsview = -1; 93*8462SApril.Chin@Sun.COM return 0; 944887Schin } 95