commit 0a664f7464332f0f4e2dc441a0635dbcf2fa9b5e
parent abd97ee5a0ab6ef7776fcf602f4a368e261d00ab
Author: cfillion <cfillion@users.noreply.github.com>
Date: Fri, 2 Jun 2017 19:03:40 -0400
api: create GetEntryInfo function
Diffstat:
3 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/src/api.cpp b/src/api.cpp
@@ -154,6 +154,45 @@ DEFINE_API(int, CompareVersions, ((const char*, ver1))((const char*, ver2))
return a.compare(b);
});
+DEFINE_API(void, FreeEntry, ((PackageEntry*, entry)), R"(
+ Free resources allocated for the given package entry.
+)", {
+ if(s_entries.count(entry)) {
+ s_entries.erase(entry);
+ delete entry;
+ }
+});
+
+DEFINE_API(void, GetEntryInfo, ((PackageEntry*, entry))
+ ((char*, repoOut))((int, repoOut_sz))((char*, catOut))((int, catOut_sz))
+ ((char*, pkgOut))((int, pkgOut_sz))((char*, descOut))((int, descOut_sz))
+ ((int*, typeOut))((char*, verOut))((int, verOut_sz))
+ ((char*, authorOut))((int, authorOut_sz))((bool*, pinnedOut)), R"(
+ Get the repository name, category, package name, package description, package type, the currently installed version, author name and pinned status of the given package entry.
+
+ type: 1=script, 2=extension, 3=effect, 4=data, 5=theme, 6=langpack, 7=webinterface
+)", {
+ if(!s_entries.count(entry))
+ return;
+
+ if(repoOut)
+ snprintf(repoOut, repoOut_sz, "%s", entry->remote.c_str());
+ if(catOut)
+ snprintf(catOut, catOut_sz, "%s", entry->category.c_str());
+ if(pkgOut)
+ snprintf(pkgOut, pkgOut_sz, "%s", entry->package.c_str());
+ if(descOut)
+ snprintf(descOut, descOut_sz, "%s", entry->description.c_str());
+ if(typeOut)
+ *typeOut = (int)entry->type;
+ if(verOut)
+ snprintf(verOut, verOut_sz, "%s", entry->version.toString().c_str());
+ if(authorOut)
+ snprintf(authorOut, authorOut_sz, "%s", entry->author.c_str());
+ if(pinnedOut)
+ *pinnedOut = entry->pinned;
+});
+
DEFINE_API(PackageEntry*, GetOwner, ((const char*, fn))((char*, errorOut))((int, errorOut_sz)), R"(
Returns the package entry owning the given file.
Delete the returned object from memory after use with <a href="#ReaPack_FreeEntry">ReaPack_FreeEntry</a>.
@@ -187,12 +226,3 @@ DEFINE_API(PackageEntry*, GetOwner, ((const char*, fn))((char*, errorOut))((int,
return nullptr;
}
});
-
-DEFINE_API(void, FreeEntry, ((PackageEntry*, entry)), R"(
- Free resources allocated for the given package entry.
-)", {
- if(s_entries.count(entry)) {
- s_entries.erase(entry);
- delete entry;
- }
-});
diff --git a/src/api.hpp b/src/api.hpp
@@ -49,6 +49,7 @@ namespace API {
extern APIFunc AboutRepository;
extern APIFunc CompareVersions;
extern APIFunc FreeEntry;
+ extern APIFunc GetEntryInfo;
extern APIFunc GetOwner;
};
diff --git a/src/main.cpp b/src/main.cpp
@@ -164,6 +164,7 @@ static void setupAPI()
reapack->setupAPI(&API::AboutRepository);
reapack->setupAPI(&API::CompareVersions);
reapack->setupAPI(&API::FreeEntry);
+ reapack->setupAPI(&API::GetEntryInfo);
reapack->setupAPI(&API::GetOwner);
}