Exemple #1
0
 static HSPToken *expectUUID(HSP *sp, HSPToken *tok, char *uuid)
 {
   HSPToken *t = tok;
   t = t->nxt;
   if(t == NULL || parseUUID(t->str, uuid) == NO) {
     parseError(sp, tok, "expected UUID", "");
     return NULL;
   }
   return t;
 }
Exemple #2
0
  int submitCreate(void *magic, char *line)
  {
    EVMod *mod = (EVMod *)magic;
    HSP_mod_OVS *mdata = (HSP_mod_OVS *)mod->data;
    char *uuid = stripQuotes(line, SFVS_QUOTES);
    if(!uuid)
      return NO;
    if(my_strlen(uuid) < 32)
      return NO;
    char binUUID[16];
    if(parseUUID(uuid, binUUID) == NO)
      return NO;

    setStr(&mdata->sflowUUID, uuid);
    return YES;
  }
Exemple #3
0
/**
 * Reads the file to extract saved GUID (UUID) to dsIndex mappings
 * and populates the GuidStore structure. **guidStore is updated to point
 * to the head of the list.
 * Any lines in the file that cannot be parsed or contain invalid entries
 * are discarded.
 */
void readGuidStore(FILE *file, WCHAR *fileName, GuidStore **guidStore, uint32_t *maxIndex)
{
	if (file == NULL) {
		return;
	}
	CHAR line[GUID_STORE_MAX_LINELEN+1];
	rewind(file);
	uint32_t lineNo = 0;
	while (fgets(line, GUID_STORE_MAX_LINELEN, file)) {
		lineNo++;
		CHAR *p = line;
		// comments start with '#'
		p[strcspn(p, "#")] = '\0';
		// should just have two tokens, so check for 3
		uint32_t tokc = 0;
		CHAR *tokv[3];
		for (uint32_t i = 0; i < 3; i++) {
			size_t len;
			p += strspn(p, GUID_STORE_SEPARATORS);
			if ((len = strcspn(p, GUID_STORE_SEPARATORS)) == 0){
				break;
			}
			tokv[tokc++] = p;
			p += len;
			if (*p != '\0') {
				*p++ = '\0';
			}
		}
		// expect UUID=int
		CHAR uuid[16];
		long dsIndex;
		if (tokc != 2 || !parseUUID(tokv[0], uuid) || (dsIndex = strtol(tokv[1], NULL, 0)) < 1) {
			myLog(LOG_ERR, "readGuidStore: bad line %u %s in %S", lineNo, line, fileName);
		} else {
			*guidStore = newGuidStore(*guidStore, uuid, dsIndex);
			if ((*guidStore)->dsIndex > *maxIndex) {
				*maxIndex = (*guidStore)->dsIndex;
			}
		}
	}
}