- if (!(*dlopened = dlopen(ptr, RTLD_LAZY|RTLD_LOCAL))) {
- data->error(data, NULL, PSI_WARNING, "Could not open library '%s': %s.",
- data->psi.file.ln, dlerror());
- return 0;
+
+ return true;
+}
+
+bool psi_decl_file_validate(struct psi_data *dst, struct psi_data *src)
+{
+ size_t i = 0;
+ char *libname;
+ void *dlopened;
+
+ while (psi_plist_get(src->file.libnames, i++, &libname)) {
+ if (!validate_lib(dst, libname, &dlopened)) {
+ return false;
+ }
+
+ dst->file.libnames = psi_plist_add(dst->file.libnames, &libname);
+ dst->file.dlopened = psi_plist_add(dst->file.dlopened, &dlopened);
+ }
+
+ if (src->file.filename) {
+ dst->file.filename = zend_string_copy(src->file.filename);
+ }
+ return true;
+}
+
+void psi_libs_free(void **dlopened) {
+ if (*dlopened) {
+ dlclose(*dlopened);
+ }
+}
+
+void psi_names_free(char **name) {
+ if (*name) {
+ free(*name);