⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mlib.c

📁 GNU libtool 是一个通用库支持脚本
💻 C
字号:
/* main.c -- mlib library   Copyright (C) 2002 Free Software Foundation, Inc.   Originally by greg Eisenhauer <eisen at cc.gatech.edu>   Extracted from mdemo.c   This file is part of GNU Libtool.This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301USA. */#include "foo.h"#include "ltdl.h"#include <stdio.h>inttest_dl (filename)  char *filename;{  lt_dlhandle handle;	  const lt_dlinfo *info;  int (*pfoo1)() = 0;  int (*pfoo2)() = 0;  int (*phello)() = 0;  int *pnothing = 0;  int ret = 0;  handle = lt_dlopen(filename);  if (!handle) {    fprintf (stderr, "can't open the module %s!\n", filename);    fprintf (stderr, "error was: %s\n", lt_dlerror());    return 1;  }  info = lt_dlgetinfo(handle);  if (!info) {    fprintf (stderr, "can't get module info: %s\n", lt_dlerror());    return 1;  }  if (info->name) {    printf ("module name: %s\n", info->name);  } else {    printf ("module is not a libtool module\n");  }  printf ("module filename: %s\n", info->filename);  printf ("module reference count: %i\n", info->ref_count);    phello = (int(*)())lt_dlsym(handle, "hello");    if (phello)    {      int value = (*phello) ();            printf ("hello returned: %i\n", value);      if (value == HELLO_RET)        printf("hello is ok!\n");    }  else    {      fprintf (stderr, "did not find the `hello' function\n");      fprintf (stderr, "error was: %s\n", lt_dlerror());      ret = 1;    }  pnothing = (int*)lt_dlsym(handle, "nothing");    /* Try assigning to the nothing variable. */  if (pnothing)    *pnothing = 1;  else    {      fprintf (stderr, "did not find the `nothing' variable\n");      fprintf (stderr, "error was: %s\n", lt_dlerror());      ret = 1;    }  pfoo1 = (int(*)())lt_dlsym(handle, "foo1");    /* Just call the functions and check return values. */  if (pfoo1)    {      if ((*pfoo1) () == FOO_RET)        printf("foo1 is ok!\n");      else	ret = 1;    }  else {    pfoo2 = (int(*)())lt_dlsym(handle, "foo2");      if (pfoo2)      {        if ((*pfoo2) () == FOO_RET)          printf("foo2 is ok!\n");        else ret = 1;      }    else      {        fprintf (stderr, "did not find any of the `foo' functions\n");        fprintf (stderr, "error was: %s\n", lt_dlerror());        ret = 1;      }  }  lt_dlclose(handle);  return ret;}int mlib_func(argc, argv)int argc;char **argv;{  int ret = 0;  int i;  /*   * Would be nice if this somehow worked for libraries, not just executables.   * LTDL_SET_PRELOADED_SYMBOLS();   */  if (lt_dlinit() != 0) {    fprintf (stderr, "error during initialization: %s\n", lt_dlerror());    return 1;  }  for (i = 1; i < argc; i++)    if (test_dl(argv[i]))       ret = 1;  lt_dlexit();  return ret;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -