/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-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* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped2223#include <ast.h>2425#if !_UWIN2627void _STUB_stdfun(){}2829#else3031#include <ast_windows.h>32#include <uwin.h>33#include <dlfcn.h>34#include "FEATURE/uwin"3536#if _lib___iob_func37#define IOB ((char*)__iob_func())38#elif _lib___p__iob39#define IOB ((char*)__p__iob())40#elif _dat__iob41#define IOB ((char*)_iob)42#else43#define IOB ((char*)_p__iob())44#endif4546#define IOBMAX (512*32)4748#include "stdhdr.h"4950int51_stdfun(Sfio_t* f, Funvec_t* vp)52{53static char* iob;54static int init;55static void* bp;56static void* np;5758if (!iob && !(iob = IOB))59return 0;60if (f && ((char*)f < iob || (char*)f > iob+IOBMAX))61return 0;62if (!vp->vec[1])63{64if (!init)65{66init = 1;67bp = dlopen("/usr/bin/stdio.dll", 0);68}69if (bp && (vp->vec[1] = (Fun_f)dlsym(bp, vp->name)))70return 1;71if (!np && !(np = dlopen("/sys/msvcrt.dll", 0)))72return -1;73if (!(vp->vec[1] = (Fun_f)dlsym(np, vp->name)))74return -1;75}76return 1;77}7879#endif808182