Skip to content

Commit

Permalink
Consent taggging support added
Browse files Browse the repository at this point in the history
Signed-off-by: Ulf Bjorkengren <[email protected]>
  • Loading branch information
Ulf Bjorkengren committed Dec 5, 2023
1 parent 90c3d95 commit 000e748
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
29 changes: 17 additions & 12 deletions binary/c_parser/cparserlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,27 @@ char* nodeTypeToString(nodeTypes_t type) {
}

uint8_t validateToUint8(char* validate) {
if (strcmp(validate, "write-only") == 0) {
return 1;
uint8_t validation = 0;
if (strstr(validate, "write-only") != NULL) {
validation = 1;
} else if (strstr(validate, "read-write") != NULL) {
validation = 2;
}
if (strcmp(validate, "read-write") == 0) {
return 2;
if (strstr(validate, "consent") != NULL) {
validation += 10;
}
return 0;
return validation;
}

char* validateToString(uint8_t validate) {
if (validate == 1) {
return "write-only";
void validateToString(uint8_t validate, char *validation) {
if (validate%10 == 1) {
strcpy(validation, "write-only");
} else if (validate%10 == 2) {
strcpy(validation, "read-write");
}
if (validate == 2) {
return "read-write";
if (validate/10 == 1) {
strcat(validation, "+consent");
}
return "";
}

void pushPathSegment(char* name, SearchContext_t* context) {
Expand Down Expand Up @@ -487,7 +491,8 @@ void writeNode(struct node_t* node) {
fwrite(node->defaultAllowed, sizeof(char)*node->defaultLen, 1, treeFp);
}

char* validate = validateToString(node->validate);
char validate[10+1+7+1]; // access control + consent data
validateToString(node->validate, (char*)&validate);
int validateLen = strlen(validate);
fwrite(&validateLen, sizeof(uint8_t), 1, treeFp);
if (validateLen > 0) {
Expand Down
32 changes: 21 additions & 11 deletions binary/go_parser/datamodel/datamodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

package datamodel

import "fmt"
import (
"fmt"
"strings"
)

type NodeTypes_t uint8

Expand Down Expand Up @@ -65,13 +68,16 @@ func StringToNodetype(nodeType string) uint8 {
}

func ValidateToInt(validate string) uint8 {
if (validate == "write-only") {
return 1
validation := (uint8)(0)
if strings.Contains(validate, "write-only") {
validation = 1
} else if strings.Contains(validate, "read-write") {
validation = 2
}
if (validate == "read-write") {
return 2
if strings.Contains(validate, "consent") {
validation += 10
}
return 0
return validation
}

func NodetypeToString(nodeType NodeTypes_t) string {
Expand Down Expand Up @@ -99,11 +105,15 @@ func NodetypeToString(nodeType NodeTypes_t) string {


func ValidateToString(validate uint8) string {
if (validate == 1) {
return "write-only"
var validation string
if (validate%10 == 1) {
validation = "write-only"
}
if (validate == 2) {
return "read-write"
if (validate%10 == 2) {
validation = "read-write"
}
return ""
if (validate/10 == 1) {
validation = "+consent"
}
return validation
}

0 comments on commit 000e748

Please sign in to comment.