Example #1
0
 void IdsaAppender::_append(const LoggingEvent& event) {
     IDSA_EVENT *idsaEvent;
     
     idsaEvent = idsa_event(_idsaConnection);
     
     if (idsaEvent){
         
         idsa_name(idsaEvent,(char *)event.categoryName.c_str());
         idsa_scheme(idsaEvent,"log4cpp");
         
         idsa_add_integer(idsaEvent, "priority", event.priority);
         idsa_add_string(idsaEvent, "ndc", (char *)event.ndc.c_str());
         idsa_add_string(idsaEvent, "message", 
                         (char*)event.message.c_str());
         
         idsa_log(_idsaConnection,idsaEvent);
         // idsa_log does its own deallocation */
     }
 }
Example #2
0
File: sparse.c Project: hsiboy/ida
int parse_extra(IDSA_EVENT * evt, char *service, char *message)
{
  char *end;
  char label[IDSA_M_NAME];
  char prefix[IDSA_M_NAME];
  char value[IDSA_M_LONG];
  int state;
  int j, i, ls, le, vs, ve, sc, tc;
  int result;

  state = LOOK_LABEL;
  ls = le = 0;
  vs = ve = 0;
  i = 0;
  result = 0;

  end = "";

  sc = strlen(service);
  if (sc > IDSA_M_NAME / 2) {
    sc = IDSA_M_NAME / 2;
  }
  strncpy(prefix, service, sc);
  prefix[sc] = '.';
  sc++;
  prefix[sc] = '\0';

  while (state != LOOK_END) {
    switch (state) {
    case LOOK_LABEL:
      if (message[i] == '\0') {
	state = LOOK_END;
      } else if (message[i] == '=') {
	if (le > ls) {
	  tc = le - ls;
	  if (message[ls] == '.') {
	    if (tc >= IDSA_M_NAME) {
	      tc = IDSA_M_NAME - 1;
	    }
	    strncpy(label, message + ls, tc);
	    label[tc] = '\0';
	  } else {
	    strncpy(label, prefix, sc);
	    if (tc >= (IDSA_M_NAME - sc)) {
	      tc = IDSA_M_NAME - (sc + 1);
	    }
	    strncpy(label + sc, message + ls, tc);
	    label[tc + sc] = '\0';
	  }

#ifdef TRACE
	  fprintf(stderr, __FUNCTION__ ": got label <%s> starting at %d\n", label, ls);
#endif

	  i++;
	  if (message[i] == '\0') {
	    state = LOOK_END;
	  } else {
	    switch (message[i]) {
	    case '<':
	      i++;
	      end = ">";
	      break;
	    case '(':
	      i++;
	      end = ")";
	      break;
	    case '[':
	      i++;
	      end = "]";
	      break;
	    case '"':
	      i++;
	      end = "\"";
	      break;
	    case '\'':
	      i++;
	      end = "'";
	      break;
	    case '`':
	      i++;
	      end = "`'";
	      break;
	    default:
	      end = " \t";
	      break;
	    }
	    ve = vs = i;
	    state = LOOK_VALUE;
	  }
	} else {
	  i++;
	  ls = le = i;
	}
      } else if (isspace(message[i])) {
	i++;
	ls = le = i;
      } else {
	i++;
	le = i;
      }
      break;
    case LOOK_VALUE:
      for (j = 0; (end[j] != '\0') && (end[j] != message[i]); j++);
      if (end[j] == message[i]) {
	if (ve > vs) {
	  tc = ve - vs;
	  if (tc >= IDSA_M_LONG) {
	    tc = IDSA_M_LONG - 1;
	  }
	  strncpy(value, message + vs, tc);
	  value[tc] = '\0';

	  result += idsa_add_string(evt, label, value);
	}

	if (message[i] == '\0') {
	  state = LOOK_END;
	} else {
	  state = LOOK_LABEL;
	  i++;
	  ls = le = i;
	}
      } else {
	i++;
	ve = i;
      }
      break;
    }
  }

  return result;
}