Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "CaptureFactory_private.h"
00025
00026 #include <stdlib.h>
00027
00028 namespace alvar {
00029
00030 void CaptureFactoryPrivate::setupPluginPaths()
00031 {
00032
00033 const int bufferSize = 4096;
00034 char applicationBuffer[bufferSize];
00035 int count = readlink("/proc/self/exe", applicationBuffer, bufferSize);
00036 if (count != 0 && count < bufferSize) {
00037 std::string applicationPath(applicationBuffer, count);
00038 applicationPath = std::string(applicationPath, 0, applicationPath.find_last_of("/"));
00039 mPluginPaths.push_back(applicationPath);
00040 mPluginPaths.push_back(applicationPath + "/alvarplugins");
00041 }
00042
00043
00044 parseEnvironmentVariable(std::string("ALVAR_LIBRARY_PATH"));
00045
00046
00047 parseEnvironmentVariable(std::string("ALVAR_PLUGIN_PATH"));
00048 }
00049
00050 void CaptureFactoryPrivate::parseEnvironmentVariable(const std::string &variable)
00051 {
00052
00053 char *buffer;
00054 std::string path("");
00055 buffer = getenv(variable.data());
00056 if (buffer) {
00057 path = std::string(buffer);
00058 }
00059
00060
00061 char delimitor = ':';
00062 if (!path.empty()) {
00063 std::string::size_type start = 0;
00064 std::string::size_type end = 0;
00065 while ((end = path.find_first_of(delimitor, start)) != std::string::npos) {
00066 std::string tmp(path, start, end - start);
00067 if (!tmp.empty()) {
00068 mPluginPaths.push_back(tmp);
00069 }
00070 start = end + 1;
00071 }
00072 if (start != path.size()) {
00073 std::string tmp(path, start, std::string::npos);
00074 if (!tmp.empty()) {
00075 mPluginPaths.push_back(tmp);
00076 }
00077 }
00078 }
00079 }
00080
00081 std::string CaptureFactoryPrivate::pluginPrefix()
00082 {
00083 return std::string("lib");
00084 }
00085
00086 std::string CaptureFactoryPrivate::pluginExtension()
00087 {
00088 return std::string("so");
00089 }
00090
00091 }