Introduce macro constants for Rhizome service names

Use "MeshMS1" instead of "MeshMS"... version 2 won't be far away
This commit is contained in:
Andrew Bettison 2012-05-20 16:07:22 +09:30
parent 189ecee4b9
commit e6575cb369
3 changed files with 14 additions and 7 deletions

View File

@ -1102,18 +1102,18 @@ int app_rhizome_add_file(int argc, const char *const *argv, struct command_line_
return WHY("Manifest struct could not be allocated -- not added to rhizome");
}
/* Fill in a few missing manifest fields, to make it easier to use when adding new files:
- the default service is "file"
- the current time for "date"
- if service is "file", then the payload file's basename for "name"
- the default service is FILE
- use the current time for "date"
- if service is file, then use the payload file's basename for "name"
*/
const char *service = rhizome_manifest_get(m, "service", NULL, 0);
if (service == NULL) {
rhizome_manifest_set(m, "service", (service = "file"));
rhizome_manifest_set(m, "service", (service = RHIZOME_SERVICE_FILE));
}
if (rhizome_manifest_get(m, "date", NULL, 0) == NULL) {
rhizome_manifest_set_ll(m, "date", gettime_ms());
}
if (strcasecmp("file", service) == 0) {
if (strcasecmp(RHIZOME_SERVICE_FILE, service) == 0) {
if (rhizome_manifest_get(m, "name", NULL, 0) == NULL) {
const char *name = strrchr(filepath, '/');
name = name ? name + 1 : filepath;

View File

@ -152,11 +152,11 @@ int rhizome_add_manifest(rhizome_manifest *m_in,
return WHY("Manifest missing 'service' field");
if (rhizome_manifest_get_ll(m_in, "date") == -1)
return WHY("Manifest missing 'date' field");
if (strcasecmp(service, "file") == 0) {
if (strcasecmp(service, RHIZOME_SERVICE_FILE) == 0) {
const char *name = rhizome_manifest_get(m_in, "name", NULL, 0);
if (name == NULL || !name[0])
return WHY("Manifest missing 'name' field");
} else if (strcasecmp(service, "MeshMS") == 0) {
} else if (strcasecmp(service, RHIZOME_SERVICE_MESHMS) == 0) {
const char *sender = rhizome_manifest_get(m_in, "sender", NULL, 0);
const char *recipient = rhizome_manifest_get(m_in, "recipient", NULL, 0);
if (sender == NULL || sender[0])

View File

@ -153,6 +153,13 @@ typedef struct rhizome_manifest {
} rhizome_manifest;
/* Supported service identifiers. These go in the 'service' field of every
* manifest, and indicate which application must be used to process the bundle
* after it is received by Rhizome.
*/
#define RHIZOME_SERVICE_FILE "file"
#define RHIZOME_SERVICE_MESHMS "MeshMS1"
extern long long rhizome_space;
const char *rhizome_datastore_path();
int rhizome_set_datastore_path(const char *path);