diff options
author | mrwastl <mrwastl@users.sourceforge.net> | 2012-03-06 21:21:29 +0100 |
---|---|---|
committer | mrwastl <mrwastl@users.sourceforge.net> | 2012-03-06 21:21:29 +0100 |
commit | 542edc8b0c5f7fb9d0309484e2697c594a049fe7 (patch) | |
tree | bb7b47326eb3b654af529051a977e5116a6f65ce | |
parent | 1072d6d8f8ad989d7ea02d573adcdf63c3a336ce (diff) | |
download | graphlcd-base-542edc8b0c5f7fb9d0309484e2697c594a049fe7.tar.gz graphlcd-base-542edc8b0c5f7fb9d0309484e2697c594a049fe7.tar.bz2 |
more flexible including of serdisplib in dlopen()
-rw-r--r-- | glcddrivers/serdisp.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/glcddrivers/serdisp.c b/glcddrivers/serdisp.c index 8c29ede..8b46bcb 100644 --- a/glcddrivers/serdisp.c +++ b/glcddrivers/serdisp.c @@ -7,7 +7,7 @@ * This file is released under the GNU General Public License. Refer * to the COPYING file distributed with this package. * - * (c) 2003-2011 Wolfgang Astleitner <mrwastl AT users.sourceforge.net> + * (c) 2003-2012 Wolfgang Astleitner <mrwastl AT users.sourceforge.net> */ #include <stdio.h> @@ -61,10 +61,27 @@ int cDriverSerDisp::Init(void) std::string optionstring = ""; std::string wiringstring; + int chk_major = 0; + std::string libname = ""; // dynamically load serdisplib using dlopen() & co. + sdhnd = NULL; + chk_major = 3; // max major version to check + + while ( ! sdhnd && chk_major > 0) { + libname = "libserdisp.so."; + libname.push_back (chk_major + '0'); + sdhnd = dlopen(libname.c_str(), RTLD_LAZY); + if (!sdhnd) { // try /usr/local/lib + libname.insert(0, "/usr/local/lib/"); + sdhnd = dlopen(libname.c_str(), RTLD_LAZY); + } + chk_major --; + } - sdhnd = dlopen("libserdisp.so", RTLD_LAZY); + if (!sdhnd) { // try libserdisp.so without major version + sdhnd = dlopen("libserdisp.so", RTLD_LAZY); + } if (!sdhnd) { // try /usr/local/lib sdhnd = dlopen("/usr/local/lib/libserdisp.so", RTLD_LAZY); } |