@cryptotaxi247 / netdata-1 / commits / 994980f9e

renaming of typedefs for portability

Costa Tsaousis committed Dec 20, 2016 at 20:55 UTC 994980f9ea8710957e667cfe42f9e01ae93c8c44
1 file changed +111 -111
src/registry.c
+111 -111
@@ -114,7 +114,7 @@ struct url {
114 uint16_t len; // the length of the URL in bytes
115 char url[1]; // the URL - dynamically allocated to more size
116 };
117 -typedef struct url URL;
117 +typedef struct url ND_URL;
118
119
120 // ----------------------------------------------------------------------------
@@ -122,7 +122,7 @@ typedef struct url URL;
122
123 // For each MACHINE-URL pair we keep this
124 struct machine_url {
125 - URL *url; // de-duplicated URL
125 + ND_URL *url; // de-duplicated URL
126 // DICTIONARY *persons; // dictionary of PERSON *
127
128 uint8_t flags;
@@ -130,7 +130,7 @@ struct machine_url {
130 uint32_t last_t; // the last time we saw this
131 uint32_t usages; // how many times this has been accessed
132 };
133 -typedef struct machine_url MACHINE_URL;
133 +typedef struct machine_url ND_MACHINE_URL;
134
135 // A machine
136 struct machine {
@@ -144,7 +144,7 @@ struct machine {
144 uint32_t last_t; // the last time we saw this
145 uint32_t usages; // how many times this has been accessed
146 };
147 -typedef struct machine MACHINE;
147 +typedef struct machine ND_MACHINE;
148
149
150 // ----------------------------------------------------------------------------
@@ -152,8 +152,8 @@ typedef struct machine MACHINE;
152
153 // for each PERSON-URL pair we keep this
154 struct person_url {
155 - URL *url; // de-duplicated URL
156 - MACHINE *machine; // link the MACHINE of this URL
155 + ND_URL *url; // de-duplicated URL
156 + ND_MACHINE *machine; // link the MACHINE of this URL
157
158 uint8_t flags;
159 uint32_t first_t; // the first time we saw this
@@ -163,7 +163,7 @@ struct person_url {
163 char name[1]; // the name of the URL, as known by the user
164 // dynamically allocated to fit properly
165 };
166 -typedef struct person_url PERSON_URL;
166 +typedef struct person_url ND_PERSON_URL;
167
168 // A person
169 struct person {
@@ -175,7 +175,7 @@ struct person {
175 uint32_t last_t; // the last time we saw this
176 uint32_t usages; // how many times this has been accessed
177 };
178 -typedef struct person PERSON;
178 +typedef struct person ND_PERSON;
179
180
181 // ----------------------------------------------------------------------------
@@ -209,12 +209,12 @@ static inline void registry_urls_unlock(void) {
209 // updating a person's urls.
210 // however, to save the memory required for keeping a
211 // mutex (40 bytes) per person, we do...
212 -static inline void registry_person_urls_lock(PERSON *p) {
212 +static inline void registry_person_urls_lock(ND_PERSON *p) {
213 (void)p;
214 pthread_mutex_lock(&registry.person_urls_lock);
215 }
216
217 -static inline void registry_person_urls_unlock(PERSON *p) {
217 +static inline void registry_person_urls_unlock(ND_PERSON *p) {
218 (void)p;
219 pthread_mutex_unlock(&registry.person_urls_lock);
220 }
@@ -223,12 +223,12 @@ static inline void registry_person_urls_unlock(PERSON *p) {
223 // updating a machine's urls.
224 // however, to save the memory required for keeping a
225 // mutex (40 bytes) per machine, we do...
226 -static inline void registry_machine_urls_lock(MACHINE *m) {
226 +static inline void registry_machine_urls_lock(ND_MACHINE *m) {
227 (void)m;
228 pthread_mutex_lock(&registry.machine_urls_lock);
229 }
230
231 -static inline void registry_machine_urls_unlock(MACHINE *m) {
231 +static inline void registry_machine_urls_unlock(ND_MACHINE *m) {
232 (void)m;
233 pthread_mutex_unlock(&registry.machine_urls_lock);
234 }
@@ -306,20 +306,20 @@ static inline char *registry_fix_url(char *url, size_t *len) {
306 // ----------------------------------------------------------------------------
307 // forward definition of functions
308
309 -extern PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url, char *name, time_t when);
310 -extern PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
309 +extern ND_PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url, char *name, time_t when);
310 +extern ND_PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when);
311
312
313 // ----------------------------------------------------------------------------
314 // URL
315
316 -static inline URL *registry_url_allocate_nolock(const char *url, size_t urllen) {
316 +static inline ND_URL *registry_url_allocate_nolock(const char *url, size_t urllen) {
317 // protection from too big URLs
318 if(urllen > registry.max_url_length)
319 urllen = registry.max_url_length;
320
321 - debug(D_REGISTRY, "Registry: registry_url_allocate_nolock('%s'): allocating %zu bytes", url, sizeof(URL) + urllen);
322 - URL *u = mallocz(sizeof(URL) + urllen);
321 + debug(D_REGISTRY, "Registry: registry_url_allocate_nolock('%s'): allocating %zu bytes", url, sizeof(ND_URL) + urllen);
322 + ND_URL *u = mallocz(sizeof(ND_URL) + urllen);
323
324 // a simple strcpy() should do the job
325 // but I prefer to be safe, since the caller specified urllen
@@ -327,18 +327,18 @@ static inline URL *registry_url_allocate_nolock(const char *url, size_t urllen)
327 strncpyz(u->url, url, u->len);
328 u->links = 0;
329
330 - registry.urls_memory += sizeof(URL) + urllen;
330 + registry.urls_memory += sizeof(ND_URL) + urllen;
331
332 debug(D_REGISTRY, "Registry: registry_url_allocate_nolock('%s'): indexing it", url);
333 - dictionary_set(registry.urls, u->url, u, sizeof(URL));
333 + dictionary_set(registry.urls, u->url, u, sizeof(ND_URL));
334
335 return u;
336 }
337
338 -static inline URL *registry_url_get_nolock(const char *url, size_t urllen) {
338 +static inline ND_URL *registry_url_get_nolock(const char *url, size_t urllen) {
339 debug(D_REGISTRY, "Registry: registry_url_get_nolock('%s')", url);
340
341 - URL *u = dictionary_get(registry.urls, url);
341 + ND_URL *u = dictionary_get(registry.urls, url);
342 if(!u) {
343 u = registry_url_allocate_nolock(url, urllen);
344 registry.urls_count++;
@@ -347,24 +347,24 @@ static inline URL *registry_url_get_nolock(const char *url, size_t urllen) {
347 return u;
348 }
349
350 -static inline URL *registry_url_get(const char *url, size_t urllen) {
350 +static inline ND_URL *registry_url_get(const char *url, size_t urllen) {
351 debug(D_REGISTRY, "Registry: registry_url_get('%s')", url);
352
353 registry_urls_lock();
354
355 - URL *u = registry_url_get_nolock(url, urllen);
355 + ND_URL *u = registry_url_get_nolock(url, urllen);
356
357 registry_urls_unlock();
358
359 return u;
360 }
361
362 -static inline void registry_url_link_nolock(URL *u) {
362 +static inline void registry_url_link_nolock(ND_URL *u) {
363 u->links++;
364 debug(D_REGISTRY, "Registry: registry_url_link_nolock('%s'): URL has now %u links", u->url, u->links);
365 }
366
367 -static inline void registry_url_unlink_nolock(URL *u) {
367 +static inline void registry_url_unlink_nolock(ND_URL *u) {
368 u->links--;
369 if(!u->links) {
370 debug(D_REGISTRY, "Registry: registry_url_unlink_nolock('%s'): No more links for this URL", u->url);
@@ -379,15 +379,15 @@ static inline void registry_url_unlink_nolock(URL *u) {
379 // ----------------------------------------------------------------------------
380 // MACHINE
381
382 -static inline MACHINE *registry_machine_find(const char *machine_guid) {
382 +static inline ND_MACHINE *registry_machine_find(const char *machine_guid) {
383 debug(D_REGISTRY, "Registry: registry_machine_find('%s')", machine_guid);
384 return dictionary_get(registry.machines, machine_guid);
385 }
386
387 -static inline MACHINE_URL *registry_machine_url_allocate(MACHINE *m, URL *u, time_t when) {
388 - debug(D_REGISTRY, "registry_machine_link_to_url('%s', '%s'): allocating %zu bytes", m->guid, u->url, sizeof(MACHINE_URL));
387 +static inline ND_MACHINE_URL *registry_machine_url_allocate(ND_MACHINE *m, ND_URL *u, time_t when) {
388 + debug(D_REGISTRY, "registry_machine_link_to_url('%s', '%s'): allocating %zu bytes", m->guid, u->url, sizeof(ND_MACHINE_URL));
389
390 - MACHINE_URL *mu = mallocz(sizeof(MACHINE_URL));
390 + ND_MACHINE_URL *mu = mallocz(sizeof(ND_MACHINE_URL));
391
392 // mu->persons = dictionary_create(DICTIONARY_FLAGS);
393 // dictionary_set(mu->persons, p->guid, p, sizeof(PERSON));
@@ -397,19 +397,19 @@ static inline MACHINE_URL *registry_machine_url_allocate(MACHINE *m, URL *u, tim
397 mu->url = u;
398 mu->flags = REGISTRY_URL_FLAGS_DEFAULT;
399
400 - registry.machines_urls_memory += sizeof(MACHINE_URL);
400 + registry.machines_urls_memory += sizeof(ND_MACHINE_URL);
401
402 debug(D_REGISTRY, "registry_machine_link_to_url('%s', '%s'): indexing URL in machine", m->guid, u->url);
403 - dictionary_set(m->urls, u->url, mu, sizeof(MACHINE_URL));
403 + dictionary_set(m->urls, u->url, mu, sizeof(ND_MACHINE_URL));
404 registry_url_link_nolock(u);
405
406 return mu;
407 }
408
409 -static inline MACHINE *registry_machine_allocate(const char *machine_guid, time_t when) {
410 - debug(D_REGISTRY, "Registry: registry_machine_allocate('%s'): creating new machine, sizeof(MACHINE)=%zu", machine_guid, sizeof(MACHINE));
409 +static inline ND_MACHINE *registry_machine_allocate(const char *machine_guid, time_t when) {
410 + debug(D_REGISTRY, "Registry: registry_machine_allocate('%s'): creating new machine, sizeof(MACHINE)=%zu", machine_guid, sizeof(ND_MACHINE));
411
412 - MACHINE *m = mallocz(sizeof(MACHINE));
412 + ND_MACHINE *m = mallocz(sizeof(ND_MACHINE));
413
414 strncpyz(m->guid, machine_guid, 36);
415
@@ -419,10 +419,10 @@ static inline MACHINE *registry_machine_allocate(const char *machine_guid, time_
419 m->first_t = m->last_t = (uint32_t)when;
420 m->usages = 0;
421
422 - registry.machines_memory += sizeof(MACHINE);
422 + registry.machines_memory += sizeof(ND_MACHINE);
423
424 registry.machines_count++;
425 - dictionary_set(registry.machines, m->guid, m, sizeof(MACHINE));
425 + dictionary_set(registry.machines, m->guid, m, sizeof(ND_MACHINE));
426
427 return m;
428 }
@@ -430,8 +430,8 @@ static inline MACHINE *registry_machine_allocate(const char *machine_guid, time_
430 // 1. validate machine GUID
431 // 2. if it is valid, find it or create it and return it
432 // 3. if it is not valid, return NULL
433 -static inline MACHINE *registry_machine_get(const char *machine_guid, time_t when) {
434 - MACHINE *m = NULL;
433 +static inline ND_MACHINE *registry_machine_get(const char *machine_guid, time_t when) {
434 + ND_MACHINE *m = NULL;
435
436 registry_machines_lock();
437
@@ -456,20 +456,20 @@ static inline MACHINE *registry_machine_get(const char *machine_guid, time_t whe
456 // ----------------------------------------------------------------------------
457 // PERSON
458
459 -static inline PERSON *registry_person_find(const char *person_guid) {
459 +static inline ND_PERSON *registry_person_find(const char *person_guid) {
460 debug(D_REGISTRY, "Registry: registry_person_find('%s')", person_guid);
461 return dictionary_get(registry.persons, person_guid);
462 }
463
464 -static inline PERSON_URL *registry_person_url_allocate(PERSON *p, MACHINE *m, URL *u, char *name, size_t namelen, time_t when) {
464 +static inline ND_PERSON_URL *registry_person_url_allocate(ND_PERSON *p, ND_MACHINE *m, ND_URL *u, char *name, size_t namelen, time_t when) {
465 // protection from too big names
466 if(namelen > registry.max_name_length)
467 namelen = registry.max_name_length;
468
469 debug(D_REGISTRY, "registry_person_url_allocate('%s', '%s', '%s'): allocating %zu bytes", p->guid, m->guid, u->url,
470 - sizeof(PERSON_URL) + namelen);
470 + sizeof(ND_PERSON_URL) + namelen);
471
472 - PERSON_URL *pu = mallocz(sizeof(PERSON_URL) + namelen);
472 + ND_PERSON_URL *pu = mallocz(sizeof(ND_PERSON_URL) + namelen);
473
474 // a simple strcpy() should do the job
475 // but I prefer to be safe, since the caller specified urllen
@@ -482,22 +482,22 @@ static inline PERSON_URL *registry_person_url_allocate(PERSON *p, MACHINE *m, UR
482 pu->flags = REGISTRY_URL_FLAGS_DEFAULT;
483 m->links++;
484
485 - registry.persons_urls_memory += sizeof(PERSON_URL) + namelen;
485 + registry.persons_urls_memory += sizeof(ND_PERSON_URL) + namelen;
486
487 debug(D_REGISTRY, "registry_person_url_allocate('%s', '%s', '%s'): indexing URL in person", p->guid, m->guid, u->url);
488 - dictionary_set(p->urls, u->url, pu, sizeof(PERSON_URL));
488 + dictionary_set(p->urls, u->url, pu, sizeof(ND_PERSON_URL));
489 registry_url_link_nolock(u);
490
491 return pu;
492 }
493
494 -static inline PERSON_URL *registry_person_url_reallocate(PERSON *p, MACHINE *m, URL *u, char *name, size_t namelen, time_t when, PERSON_URL *pu) {
494 +static inline ND_PERSON_URL *registry_person_url_reallocate(ND_PERSON *p, ND_MACHINE *m, ND_URL *u, char *name, size_t namelen, time_t when, ND_PERSON_URL *pu) {
495 // this function is needed to change the name of a PERSON_URL
496
497 debug(D_REGISTRY, "registry_person_url_reallocate('%s', '%s', '%s'): allocating %zu bytes", p->guid, m->guid, u->url,
498 - sizeof(PERSON_URL) + namelen);
498 + sizeof(ND_PERSON_URL) + namelen);
499
500 - PERSON_URL *tpu = registry_person_url_allocate(p, m, u, name, namelen, when);
500 + ND_PERSON_URL *tpu = registry_person_url_allocate(p, m, u, name, namelen, when);
501 tpu->first_t = pu->first_t;
502 tpu->last_t = pu->last_t;
503 tpu->usages = pu->usages;
@@ -505,7 +505,7 @@ static inline PERSON_URL *registry_person_url_reallocate(PERSON *p, MACHINE *m,
505 // ok, these are a hack - since the registry_person_url_allocate() is
506 // adding these, we have to subtract them
507 tpu->machine->links--;
508 - registry.persons_urls_memory -= sizeof(PERSON_URL) + strlen(pu->name);
508 + registry.persons_urls_memory -= sizeof(ND_PERSON_URL) + strlen(pu->name);
509 registry_url_unlink_nolock(u);
510
511 freez(pu);
@@ -513,12 +513,12 @@ static inline PERSON_URL *registry_person_url_reallocate(PERSON *p, MACHINE *m,
513 return tpu;
514 }
515
516 -static inline PERSON *registry_person_allocate(const char *person_guid, time_t when) {
517 - PERSON *p = NULL;
516 +static inline ND_PERSON *registry_person_allocate(const char *person_guid, time_t when) {
517 + ND_PERSON *p = NULL;
518
519 - debug(D_REGISTRY, "Registry: registry_person_allocate('%s'): allocating new person, sizeof(PERSON)=%zu", (person_guid)?person_guid:"", sizeof(PERSON));
519 + debug(D_REGISTRY, "Registry: registry_person_allocate('%s'): allocating new person, sizeof(PERSON)=%zu", (person_guid)?person_guid:"", sizeof(ND_PERSON));
520
521 - p = mallocz(sizeof(PERSON));
521 + p = mallocz(sizeof(ND_PERSON));
522
523 if(!person_guid) {
524 for (; ;) {
@@ -544,10 +544,10 @@ static inline PERSON *registry_person_allocate(const char *person_guid, time_t w
544 p->first_t = p->last_t = when;
545 p->usages = 0;
546
547 - registry.persons_memory += sizeof(PERSON);
547 + registry.persons_memory += sizeof(ND_PERSON);
548
549 registry.persons_count++;
550 - dictionary_set(registry.persons, p->guid, p, sizeof(PERSON));
550 + dictionary_set(registry.persons, p->guid, p, sizeof(ND_PERSON));
551
552 return p;
553 }
@@ -557,8 +557,8 @@ static inline PERSON *registry_person_allocate(const char *person_guid, time_t w
557 // 2. if it is valid, find it
558 // 3. if it is not valid, create a new one
559 // 4. return it
560 -static inline PERSON *registry_person_get(const char *person_guid, time_t when) {
561 - PERSON *p = NULL;
560 +static inline ND_PERSON *registry_person_get(const char *person_guid, time_t when) {
561 + ND_PERSON *p = NULL;
562
563 registry_persons_lock();
564
@@ -583,12 +583,12 @@ static inline PERSON *registry_person_get(const char *person_guid, time_t when)
583 // ----------------------------------------------------------------------------
584 // LINKING OF OBJECTS
585
586 -static inline PERSON_URL *registry_person_link_to_url(PERSON *p, MACHINE *m, URL *u, char *name, size_t namelen, time_t when) {
586 +static inline ND_PERSON_URL *registry_person_link_to_url(ND_PERSON *p, ND_MACHINE *m, ND_URL *u, char *name, size_t namelen, time_t when) {
587 debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): searching for URL in person", p->guid, m->guid, u->url);
588
589 registry_person_urls_lock(p);
590
591 - PERSON_URL *pu = dictionary_get(p->urls, u->url);
591 + ND_PERSON_URL *pu = dictionary_get(p->urls, u->url);
592 if(!pu) {
593 debug(D_REGISTRY, "registry_person_link_to_url('%s', '%s', '%s'): not found", p->guid, m->guid, u->url);
594 pu = registry_person_url_allocate(p, m, u, name, namelen, when);
@@ -600,7 +600,7 @@ static inline PERSON_URL *registry_person_link_to_url(PERSON *p, MACHINE *m, URL
600 if(likely(pu->last_t < (uint32_t)when)) pu->last_t = when;
601
602 if(pu->machine != m) {
603 - MACHINE_URL *mu = dictionary_get(pu->machine->urls, u->url);
603 + ND_MACHINE_URL *mu = dictionary_get(pu->machine->urls, u->url);
604 if(mu) {
605 info("registry_person_link_to_url('%s', '%s', '%s'): URL switched machines (old was '%s') - expiring it from previous machine.",
606 p->guid, m->guid, u->url, pu->machine->guid);
@@ -634,12 +634,12 @@ static inline PERSON_URL *registry_person_link_to_url(PERSON *p, MACHINE *m, URL
634 return pu;
635 }
636
637 -static inline MACHINE_URL *registry_machine_link_to_url(PERSON *p, MACHINE *m, URL *u, time_t when) {
637 +static inline ND_MACHINE_URL *registry_machine_link_to_url(ND_PERSON *p, ND_MACHINE *m, ND_URL *u, time_t when) {
638 debug(D_REGISTRY, "registry_machine_link_to_url('%s', '%s', '%s'): searching for URL in machine", p->guid, m->guid, u->url);
639
640 registry_machine_urls_lock(m);
641
642 - MACHINE_URL *mu = dictionary_get(m->urls, u->url);
642 + ND_MACHINE_URL *mu = dictionary_get(m->urls, u->url);
643 if(!mu) {
644 debug(D_REGISTRY, "registry_machine_link_to_url('%s', '%s', '%s'): not found", p->guid, m->guid, u->url);
645 mu = registry_machine_url_allocate(m, u, when);
@@ -675,7 +675,7 @@ static inline int registry_should_save_db(void) {
675 return registry.log_count > registry.save_registry_every_entries;
676 }
677
678 -static inline void registry_log(const char action, PERSON *p, MACHINE *m, URL *u, char *name) {
678 +static inline void registry_log(const char action, ND_PERSON *p, ND_MACHINE *m, ND_URL *u, char *name) {
679 if(likely(registry.log_fp)) {
680 // we lock only if the file is open
681 // to allow replaying the log at registry_log_load()
@@ -789,7 +789,7 @@ int registry_log_load(void) {
789
790 // make sure the person exists
791 // without this, a new person guid will be created
792 - PERSON *p = registry_person_find(person_guid);
792 + ND_PERSON *p = registry_person_find(person_guid);
793 if(!p) p = registry_person_allocate(person_guid, when);
794
795 if(s[0] == 'A')
@@ -819,10 +819,10 @@ int registry_log_load(void) {
819 // ----------------------------------------------------------------------------
820 // REGISTRY REQUESTS
821
822 -PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url, char *name, time_t when) {
822 +ND_PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url, char *name, time_t when) {
823 debug(D_REGISTRY, "registry_request_access('%s', '%s', '%s'): NEW REQUEST", (person_guid)?person_guid:"", machine_guid, url);
824
825 - MACHINE *m = registry_machine_get(machine_guid, when);
825 + ND_MACHINE *m = registry_machine_get(machine_guid, when);
826 if(!m) return NULL;
827
828 // make sure the name is valid
@@ -832,8 +832,8 @@ PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url
832 size_t urllen;
833 url = registry_fix_url(url, &urllen);
834
835 - URL *u = registry_url_get(url, urllen);
836 - PERSON *p = registry_person_get(person_guid, when);
835 + ND_URL *u = registry_url_get(url, urllen);
836 + ND_PERSON *p = registry_person_get(person_guid, when);
837
838 registry_person_link_to_url(p, m, u, name, namelen, when);
839 registry_machine_link_to_url(p, m, u, when);
@@ -845,7 +845,7 @@ PERSON *registry_request_access(char *person_guid, char *machine_guid, char *url
845 }
846
847 // verify the person, the machine and the URL exist in our DB
848 -PERSON_URL *registry_verify_request(char *person_guid, char *machine_guid, char *url, PERSON **pp, MACHINE **mm) {
848 +ND_PERSON_URL *registry_verify_request(char *person_guid, char *machine_guid, char *url, ND_PERSON **pp, ND_MACHINE **mm) {
849 char pbuf[36 + 1], mbuf[36 + 1];
850
851 if(!person_guid || !*person_guid || !machine_guid || !*machine_guid || !url || !*url) {
@@ -871,7 +871,7 @@ PERSON_URL *registry_verify_request(char *person_guid, char *machine_guid, char
871 machine_guid = mbuf;
872
873 // make sure the machine exists
874 - MACHINE *m = registry_machine_find(machine_guid);
874 + ND_MACHINE *m = registry_machine_find(machine_guid);
875 if(!m) {
876 info("Registry Request Verification: machine not found, person: '%s', machine '%s', url '%s'", person_guid, machine_guid, url);
877 return NULL;
@@ -879,14 +879,14 @@ PERSON_URL *registry_verify_request(char *person_guid, char *machine_guid, char
879 if(mm) *mm = m;
880
881 // make sure the person exist
882 - PERSON *p = registry_person_find(person_guid);
882 + ND_PERSON *p = registry_person_find(person_guid);
883 if(!p) {
884 info("Registry Request Verification: person not found, person: '%s', machine '%s', url '%s'", person_guid, machine_guid, url);
885 return NULL;
886 }
887 if(pp) *pp = p;
888
889 - PERSON_URL *pu = dictionary_get(p->urls, url);
889 + ND_PERSON_URL *pu = dictionary_get(p->urls, url);
890 if(!pu) {
891 info("Registry Request Verification: URL not found for person, person: '%s', machine '%s', url '%s'", person_guid, machine_guid, url);
892 return NULL;
@@ -894,12 +894,12 @@ PERSON_URL *registry_verify_request(char *person_guid, char *machine_guid, char
894 return pu;
895 }
896
897 -PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when) {
897 +ND_PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url, char *delete_url, time_t when) {
898 (void)when;
899
900 - PERSON *p = NULL;
901 - MACHINE *m = NULL;
902 - PERSON_URL *pu = registry_verify_request(person_guid, machine_guid, url, &p, &m);
900 + ND_PERSON *p = NULL;
901 + ND_MACHINE *m = NULL;
902 + ND_PERSON_URL *pu = registry_verify_request(person_guid, machine_guid, url, &p, &m);
903 if(!pu || !p || !m) return NULL;
904
905 // normalize the url
@@ -913,7 +913,7 @@ PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url
913
914 registry_person_urls_lock(p);
915
916 - PERSON_URL *dpu = dictionary_get(p->urls, delete_url);
916 + ND_PERSON_URL *dpu = dictionary_get(p->urls, delete_url);
917 if(!dpu) {
918 info("Registry Delete Request: URL not found for person: '%s', machine '%s', url '%s', delete url '%s'", p->guid, m->guid, pu->url->url, delete_url);
919 registry_person_urls_unlock(p);
@@ -933,14 +933,14 @@ PERSON *registry_request_delete(char *person_guid, char *machine_guid, char *url
933
934 // a structure to pass to the dictionary_get_all() callback handler
935 struct machine_request_callback_data {
936 - MACHINE *find_this_machine;
937 - PERSON_URL *result;
936 + ND_MACHINE *find_this_machine;
937 + ND_PERSON_URL *result;
938 };
939
940 // the callback function
941 // this will be run for every PERSON_URL of this PERSON
942 int machine_request_callback(void *entry, void *data) {
943 - PERSON_URL *mypu = (PERSON_URL *)entry;
943 + ND_PERSON_URL *mypu = (ND_PERSON_URL *)entry;
944 struct machine_request_callback_data *myrdata = (struct machine_request_callback_data *)data;
945
946 if(mypu->machine == myrdata->find_this_machine) {
@@ -951,14 +951,14 @@ int machine_request_callback(void *entry, void *data) {
951 return 0; // continue
952 }
953
954 -MACHINE *registry_request_machine(char *person_guid, char *machine_guid, char *url, char *request_machine, time_t when) {
954 +ND_MACHINE *registry_request_machine(char *person_guid, char *machine_guid, char *url, char *request_machine, time_t when) {
955 (void)when;
956
957 char mbuf[36 + 1];
958
959 - PERSON *p = NULL;
960 - MACHINE *m = NULL;
961 - PERSON_URL *pu = registry_verify_request(person_guid, machine_guid, url, &p, &m);
959 + ND_PERSON *p = NULL;
960 + ND_MACHINE *m = NULL;
961 + ND_PERSON_URL *pu = registry_verify_request(person_guid, machine_guid, url, &p, &m);
962 if(!pu || !p || !m) return NULL;
963
964 // make sure the machine GUID is valid
@@ -1020,7 +1020,7 @@ void registry_set_cookie(struct web_client *w, const char *guid) {
1020 snprintfz(w->cookie2, COOKIE_MAX, NETDATA_REGISTRY_COOKIE_NAME "=%s; Domain=%s; Expires=%s", guid, registry.registry_domain, edate);
1021 }
1022
1023 -static inline void registry_set_person_cookie(struct web_client *w, PERSON *p) {
1023 +static inline void registry_set_person_cookie(struct web_client *w, ND_PERSON *p) {
1024 registry_set_cookie(w, p->guid);
1025 }
1026
@@ -1057,15 +1057,15 @@ static inline int registry_json_disabled(struct web_client *w, const char *actio
1057
1058 // structure used be the callbacks below
1059 struct registry_json_walk_person_urls_callback {
1060 - PERSON *p;
1061 - MACHINE *m;
1060 + ND_PERSON *p;
1061 + ND_MACHINE *m;
1062 struct web_client *w;
1063 int count;
1064 };
1065
1066 // callback for rendering PERSON_URLs
1067 static inline int registry_json_person_url_callback(void *entry, void *data) {
1068 - PERSON_URL *pu = (PERSON_URL *)entry;
1068 + ND_PERSON_URL *pu = (ND_PERSON_URL *)entry;
1069 struct registry_json_walk_person_urls_callback *c = (struct registry_json_walk_person_urls_callback *)data;
1070 struct web_client *w = c->w;
1071
@@ -1080,10 +1080,10 @@ static inline int registry_json_person_url_callback(void *entry, void *data) {
1080
1081 // callback for rendering MACHINE_URLs
1082 static inline int registry_json_machine_url_callback(void *entry, void *data) {
1083 - MACHINE_URL *mu = (MACHINE_URL *)entry;
1083 + ND_MACHINE_URL *mu = (ND_MACHINE_URL *)entry;
1084 struct registry_json_walk_person_urls_callback *c = (struct registry_json_walk_person_urls_callback *)data;
1085 struct web_client *w = c->w;
1086 - MACHINE *m = c->m;
1086 + ND_MACHINE *m = c->m;
1087
1088 if(unlikely(c->count++))
1089 buffer_strcat(w->response.data, ",");
@@ -1100,7 +1100,7 @@ int registry_request_access_json(struct web_client *w, char *person_guid, char *
1100 if(!registry.enabled)
1101 return registry_json_disabled(w, "access");
1102
1103 - PERSON *p = registry_request_access(person_guid, machine_guid, url, name, when);
1103 + ND_PERSON *p = registry_request_access(person_guid, machine_guid, url, name, when);
1104 if(!p) {
1105 registry_json_header(w, "access", REGISTRY_STATUS_FAILED);
1106 registry_json_footer(w);
@@ -1127,7 +1127,7 @@ int registry_request_delete_json(struct web_client *w, char *person_guid, char *
1127 if(!registry.enabled)
1128 return registry_json_disabled(w, "delete");
1129
1130 - PERSON *p = registry_request_delete(person_guid, machine_guid, url, delete_url, when);
1130 + ND_PERSON *p = registry_request_delete(person_guid, machine_guid, url, delete_url, when);
1131 if(!p) {
1132 registry_json_header(w, "delete", REGISTRY_STATUS_FAILED);
1133 registry_json_footer(w);
@@ -1145,7 +1145,7 @@ int registry_request_search_json(struct web_client *w, char *person_guid, char *
1145 if(!registry.enabled)
1146 return registry_json_disabled(w, "search");
1147
1148 - MACHINE *m = registry_request_machine(person_guid, machine_guid, url, request_machine, when);
1148 + ND_MACHINE *m = registry_request_machine(person_guid, machine_guid, url, request_machine, when);
1149 if(!m) {
1150 registry_json_header(w, "search", REGISTRY_STATUS_FAILED);
1151 registry_json_footer(w);
@@ -1165,14 +1165,14 @@ int registry_request_search_json(struct web_client *w, char *person_guid, char *
1165
1166 // structure used be the callbacks below
1167 struct registry_person_url_callback_verify_machine_exists_data {
1168 - MACHINE *m;
1168 + ND_MACHINE *m;
1169 int count;
1170 };
1171
1172 int registry_person_url_callback_verify_machine_exists(void *entry, void *data) {
1173 struct registry_person_url_callback_verify_machine_exists_data *d = (struct registry_person_url_callback_verify_machine_exists_data *)data;
1174 - PERSON_URL *pu = (PERSON_URL *)entry;
1175 - MACHINE *m = d->m;
1174 + ND_PERSON_URL *pu = (ND_PERSON_URL *)entry;
1175 + ND_MACHINE *m = d->m;
1176
1177 if(pu->machine == m)
1178 d->count++;
@@ -1188,21 +1188,21 @@ int registry_request_switch_json(struct web_client *w, char *person_guid, char *
1188 if(!registry.enabled)
1189 return registry_json_disabled(w, "switch");
1190
1191 - PERSON *op = registry_person_find(person_guid);
1191 + ND_PERSON *op = registry_person_find(person_guid);
1192 if(!op) {
1193 registry_json_header(w, "switch", REGISTRY_STATUS_FAILED);
1194 registry_json_footer(w);
1195 return 430;
1196 }
1197
1198 - PERSON *np = registry_person_find(new_person_guid);
1198 + ND_PERSON *np = registry_person_find(new_person_guid);
1199 if(!np) {
1200 registry_json_header(w, "switch", REGISTRY_STATUS_FAILED);
1201 registry_json_footer(w);
1202 return 431;
1203 }
1204
1205 - MACHINE *m = registry_machine_find(machine_guid);
1205 + ND_MACHINE *m = registry_machine_find(machine_guid);
1206 if(!m) {
1207 registry_json_header(w, "switch", REGISTRY_STATUS_FAILED);
1208 registry_json_footer(w);
@@ -1311,7 +1311,7 @@ char *registry_get_this_machine_guid(void) {
1311 // REGISTRY LOAD/SAVE
1312
1313 int registry_machine_save_url(void *entry, void *file) {
1314 - MACHINE_URL *mu = entry;
1314 + ND_MACHINE_URL *mu = entry;
1315 FILE *fp = file;
1316
1317 debug(D_REGISTRY, "Registry: registry_machine_save_url('%s')", mu->url->url);
@@ -1330,7 +1330,7 @@ int registry_machine_save_url(void *entry, void *file) {
1330 }
1331
1332 int registry_machine_save(void *entry, void *file) {
1333 - MACHINE *m = entry;
1333 + ND_MACHINE *m = entry;
1334 FILE *fp = file;
1335
1336 debug(D_REGISTRY, "Registry: registry_machine_save('%s')", m->guid);
@@ -1354,7 +1354,7 @@ int registry_machine_save(void *entry, void *file) {
1354 }
1355
1356 static inline int registry_person_save_url(void *entry, void *file) {
1357 - PERSON_URL *pu = entry;
1357 + ND_PERSON_URL *pu = entry;
1358 FILE *fp = file;
1359
1360 debug(D_REGISTRY, "Registry: registry_person_save_url('%s')", pu->url->url);
@@ -1375,7 +1375,7 @@ static inline int registry_person_save_url(void *entry, void *file) {
1375 }
1376
1377 static inline int registry_person_save(void *entry, void *file) {
1378 - PERSON *p = entry;
1378 + ND_PERSON *p = entry;
1379 FILE *fp = file;
1380
1381 debug(D_REGISTRY, "Registry: registry_person_save('%s')", p->guid);
@@ -1512,9 +1512,9 @@ int registry_save(void) {
1512
1513 static inline size_t registry_load(void) {
1514 char *s, buf[4096 + 1];
1515 - PERSON *p = NULL;
1516 - MACHINE *m = NULL;
1517 - URL *u = NULL;
1515 + ND_PERSON *p = NULL;
1516 + ND_MACHINE *m = NULL;
1517 + ND_URL *u = NULL;
1518 size_t line = 0;
1519
1520 debug(D_REGISTRY, "Registry: loading active db from: '%s'", registry.db_filename);
@@ -1605,7 +1605,7 @@ static inline size_t registry_load(void) {
1605 m = registry_machine_find(&s[32]);
1606 if(!m) m = registry_machine_allocate(&s[32], first_t);
1607
1608 - PERSON_URL *pu = registry_person_url_allocate(p, m, u, &s[69], strlen(&s[69]), first_t);
1608 + ND_PERSON_URL *pu = registry_person_url_allocate(p, m, u, &s[69], strlen(&s[69]), first_t);
1609 pu->last_t = strtoul(&s[11], NULL, 16);
1610 pu->usages = strtoul(&s[20], NULL, 16);
1611 pu->flags = strtoul(&s[29], NULL, 16);
@@ -1628,7 +1628,7 @@ static inline size_t registry_load(void) {
1628 // u = registry_url_allocate_nolock(&s[32], strlen(&s[32]));
1629 u = registry_url_get_nolock(&s[32], strlen(&s[32]));
1630
1631 - MACHINE_URL *mu = registry_machine_url_allocate(m, u, strtoul(&s[2], NULL, 16));
1631 + ND_MACHINE_URL *mu = registry_machine_url_allocate(m, u, strtoul(&s[2], NULL, 16));
1632 mu->last_t = strtoul(&s[11], NULL, 16);
1633 mu->usages = strtoul(&s[20], NULL, 16);
1634 mu->flags = strtoul(&s[29], NULL, 16);
@@ -1740,12 +1740,12 @@ void registry_free(void) {
1740 // since the dictionaries use memory we allocated
1741
1742 while(registry.persons->values_index.root) {
1743 - PERSON *p = ((NAME_VALUE *)registry.persons->values_index.root)->value;
1743 + ND_PERSON *p = ((NAME_VALUE *)registry.persons->values_index.root)->value;
1744
1745 // fprintf(stderr, "\nPERSON: '%s', first: %u, last: %u, usages: %u\n", p->guid, p->first_t, p->last_t, p->usages);
1746
1747 while(p->urls->values_index.root) {
1748 - PERSON_URL *pu = ((NAME_VALUE *)p->urls->values_index.root)->value;
1748 + ND_PERSON_URL *pu = ((NAME_VALUE *)p->urls->values_index.root)->value;
1749
1750 // fprintf(stderr, "\tURL: '%s', first: %u, last: %u, usages: %u, flags: 0x%02x\n", pu->url->url, pu->first_t, pu->last_t, pu->usages, pu->flags);
1751
@@ -1770,12 +1770,12 @@ void registry_free(void) {
1770 }
1771
1772 while(registry.machines->values_index.root) {
1773 - MACHINE *m = ((NAME_VALUE *)registry.machines->values_index.root)->value;
1773 + ND_MACHINE *m = ((NAME_VALUE *)registry.machines->values_index.root)->value;
1774
1775 // fprintf(stderr, "\nMACHINE: '%s', first: %u, last: %u, usages: %u\n", m->guid, m->first_t, m->last_t, m->usages);
1776
1777 while(m->urls->values_index.root) {
1778 - MACHINE_URL *mu = ((NAME_VALUE *)m->urls->values_index.root)->value;
1778 + ND_MACHINE_URL *mu = ((NAME_VALUE *)m->urls->values_index.root)->value;
1779
1780 // fprintf(stderr, "\tURL: '%s', first: %u, last: %u, usages: %u, flags: 0x%02x\n", mu->url->url, mu->first_t, mu->last_t, mu->usages, mu->flags);
1781