예제 #1
0
int cbparse_entry_devtype(void *pArg, const char *p) {
  int rc = 0;
  PARSE_ENTRY_DATA_T *pEntryData = (PARSE_ENTRY_DATA_T *) pArg;

  //fprintf(stderr, "entry '%s'\n", p);

  if(!strncasecmp(p, DEVFILE_KEY_DEVICE, strlen(DEVFILE_KEY_DEVICE))) {

    if((p = strutil_skip_key(p, strlen(DEVFILE_KEY_DEVICE)))) {
      p = avc_dequote(p, NULL, 0);
      strncpy(pEntryData->devname, p, sizeof(pEntryData->devname) - 1);
      pEntryData->flags |= PARSE_FLAG_HAVE_DEVNAME; 
    }

  } else if(!strncasecmp(p, DEVFILE_KEY_METHODS, strlen(DEVFILE_KEY_METHODS))) {

    if((p = strutil_skip_key(p, strlen(DEVFILE_KEY_METHODS)))) {
      p = avc_dequote(p, NULL, 0);

      if(strutil_parse_csv(cbparse_entry_devtype_method, pEntryData, p) < 0) {
        LOG(X_WARNING("Failed to parse device type method(s) '%s'"), p);
      }
      //fprintf(stderr, "%s %d %d %d %d\n", pEntryData->devname, pEntryData->methods[0], pEntryData->methods[1], pEntryData->methods[2], pEntryData->methods[3]);

      pEntryData->flags |= PARSE_FLAG_HAVE_METHOD; 
    }

  } else if(!strncasecmp(p, DEVFILE_KEY_METHOD, strlen(DEVFILE_KEY_METHOD))) {

    if((p = strutil_skip_key(p, strlen(DEVFILE_KEY_METHOD)))) {
      p = avc_dequote(p, NULL, 0);

      pEntryData->methods[0] = devtype_methodfromstr(p);
      pEntryData->flags |= PARSE_FLAG_HAVE_METHOD; 
    }

  } else if(!strncasecmp(p, DEVFILE_KEY_TYPE, strlen(DEVFILE_KEY_TYPE))) {

    if((p = strutil_skip_key(p, strlen(DEVFILE_KEY_TYPE)))) {
      p = avc_dequote(p, NULL, 0);
      pEntryData->devtype = devtype_typefromstr(p);
      pEntryData->flags |= PARSE_FLAG_HAVE_DEVTYPE; 
    }

  } else if(!strncasecmp(p, DEVFILE_KEY_MATCH, strlen(DEVFILE_KEY_MATCH))) {

    if((p = strutil_skip_key(p, strlen(DEVFILE_KEY_MATCH)))) {
      p = avc_dequote(p, NULL, 0);
      strncpy(pEntryData->strmatch, p, sizeof(pEntryData->strmatch) - 1);
      pEntryData->flags |= PARSE_FLAG_HAVE_MATCH; 
    }

  }

  return rc;
}
예제 #2
0
int cbparse_entry_devtype_method(void *pArg, const char *p) {
  int rc = 0;
  PARSE_ENTRY_DATA_T *pEntryData = (PARSE_ENTRY_DATA_T *) pArg;

  if(pEntryData->numMethods < STREAM_DEVICE_METHODS_MAX) {
    pEntryData->methods[pEntryData->numMethods++] = devtype_methodfromstr(p);
    rc = 1;
  }

  return rc;
}
예제 #3
0
int cbparse_methods_csv(void *pArg, const char *p) {
  PARSE_ENTRY_DATA_T *pEntryData = (PARSE_ENTRY_DATA_T *) pArg;
  STREAM_METHOD_T method;
  int rc = 0;

  if((method = devtype_methodfromstr(p)) > STREAM_METHOD_UNKNOWN && method < STREAM_METHOD_MAX) {
    pEntryData->methodBits = devtype_method_getbits(method);
  }
  //LOG(X_DEBUG("PARSE_METHODS_CSV: %d, p:'%s', methodBits: 0x%x"), method, p, pEntryData->methodBits);

  return rc;
}