• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

RemapPluginInfo.cc

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #include "RemapPluginInfo.h"
00025 
00026 remap_plugin_info::remap_plugin_info(char *_path)
00027   :  next(0), path(NULL), path_size(0), dlh(NULL), fp_tsremap_init(NULL), fp_tsremap_done(NULL), fp_tsremap_new_instance(NULL),
00028      fp_tsremap_delete_instance(NULL), fp_tsremap_do_remap(NULL), fp_tsremap_os_response(NULL) 
00029 {
00030   // coverity did not see ats_free
00031   // coverity[ctor_dtor_leak]
00032   if (_path && likely((path = ats_strdup(_path)) > 0))
00033     path_size = strlen(path);
00034 }
00035 
00036 remap_plugin_info::~remap_plugin_info()
00037 {
00038   ats_free(path);
00039   if (dlh)
00040     dlclose(dlh);
00041 }
00042 
00043 
00044 //
00045 // Find a plugin by path from our linked list
00046 //
00047 remap_plugin_info *
00048 remap_plugin_info::find_by_path(char *_path)
00049 {
00050   int _path_size = 0;
00051   remap_plugin_info *pi = 0;
00052 
00053   if (likely(_path && (_path_size = strlen(_path)) > 0)) {
00054     for (pi = this; pi; pi = pi->next) {
00055       if (pi->path && pi->path_size == _path_size && !strcmp(pi->path, _path))
00056         break;
00057     }
00058   }
00059 
00060   return pi;
00061 }
00062 
00063 
00064 //
00065 // Add a plugin to the linked list
00066 //
00067 void
00068 remap_plugin_info::add_to_list(remap_plugin_info * pi)
00069 {
00070   remap_plugin_info *p = this;
00071 
00072   if (likely(pi)) {
00073     while (p->next)
00074       p = p->next;
00075 
00076     p->next = pi;
00077     pi->next = NULL;
00078   }
00079 }
00080 
00081 
00082 //
00083 // Remove and delete all plugins from a list, including ourselves.
00084 //
00085 void
00086 remap_plugin_info::delete_my_list()
00087 {
00088   remap_plugin_info *p = this->next;
00089 
00090   while (p) {
00091     remap_plugin_info *tmp = p;
00092 
00093     p = p->next;
00094     delete tmp;
00095   }
00096 
00097   delete this;
00098 }

Generated by  doxygen 1.7.1