Exemplo n.º 1
0
/* deletes a service comment */
int delete_service_comment(unsigned long comment_id) {
	int result = OK;

	/* delete the comment from memory */
	result = delete_comment(SERVICE_COMMENT, comment_id);

	return result;
	}
Exemplo n.º 2
0
/* deletes a host comment */
int delete_host_comment(unsigned long comment_id) {
	int result = OK;

	/* delete the comment from memory */
	result = delete_comment(HOST_COMMENT, comment_id);

	return result;
	}
Exemplo n.º 3
0
Comics *modify_comment(Comics *comics, char* comment){
	if(comics->comment){
		delete_comment(comics);
		comics->comment = (char*)malloc(sizeof(char));
		strcpy(comics->comment, comment);
	}
	else{
		comics->comment = (char*)malloc(sizeof(char));
		strcpy(comics->comment, comment);
	}
	return comics;
}
Exemplo n.º 4
0
/* checks for an expired comment (and removes it) */
int check_for_expired_comment(unsigned long comment_id) {
	nagios_comment *temp_comment = NULL;

	/* check all comments */
	for(temp_comment = comment_list; temp_comment != NULL; temp_comment = temp_comment->next) {

		/* delete the now expired comment */
		if(temp_comment->comment_id == comment_id && temp_comment->expires == TRUE && temp_comment->expire_time < time(NULL)) {
			delete_comment(temp_comment->comment_type, comment_id);
			break;
			}
		}

	return OK;
	}
Exemplo n.º 5
0
/* deletes all non-persistent acknowledgement comments for a particular service */
int delete_service_acknowledgement_comments(service *svc) {
	int result = OK;
	nagios_comment *temp_comment = NULL;
	nagios_comment *next_comment = NULL;

	if(svc == NULL)
		return ERROR;

	/* delete comments from memory */
	for(temp_comment = comment_list; temp_comment != NULL; temp_comment = next_comment) {
		next_comment = temp_comment->next;
		if(temp_comment->comment_type == SERVICE_COMMENT && !strcmp(temp_comment->host_name, svc->host_name) && !strcmp(temp_comment->service_description, svc->description)  && temp_comment->entry_type == ACKNOWLEDGEMENT_COMMENT && temp_comment->persistent == FALSE)
			delete_comment(SERVICE_COMMENT, temp_comment->comment_id);
		}

	return result;
	}
Exemplo n.º 6
0
/* deletes all comments for a particular service */
int delete_all_service_comments(char *host_name, char *svc_description) {
	int result = OK;
	nagios_comment *temp_comment = NULL;
	nagios_comment *next_comment = NULL;

	if(host_name == NULL || svc_description == NULL)
		return ERROR;

	/* delete service comments from memory */
	for(temp_comment = comment_list; temp_comment != NULL; temp_comment = next_comment) {
		next_comment = temp_comment->next;
		if(temp_comment->comment_type == SERVICE_COMMENT && !strcmp(temp_comment->host_name, host_name) && !strcmp(temp_comment->service_description, svc_description))
			delete_comment(SERVICE_COMMENT, temp_comment->comment_id);
		}

	return result;
	}
Exemplo n.º 7
0
/* deletes all comments for a particular host */
int delete_all_host_comments(char *host_name) {
	int result = OK;
	nagios_comment *temp_comment = NULL;
	nagios_comment *next_comment = NULL;

	if(host_name == NULL)
		return ERROR;

	/* delete host comments from memory */
	for(temp_comment = get_first_comment_by_host(host_name); temp_comment != NULL; temp_comment = next_comment) {
		next_comment = get_next_comment_by_host(host_name, temp_comment);
		if(temp_comment->comment_type == HOST_COMMENT)
			delete_comment(HOST_COMMENT, temp_comment->comment_id);
		}

	return result;
	}
Exemplo n.º 8
0
/* deletes all non-persistent acknowledgement comments for a particular host */
int delete_host_acknowledgement_comments(host *hst) {
	int result = OK;
	nagios_comment *temp_comment = NULL;
	nagios_comment *next_comment = NULL;

	if(hst == NULL)
		return ERROR;

	/* delete comments from memory */
	temp_comment = get_first_comment_by_host(hst->name);
	while (temp_comment) {
		next_comment = get_next_comment_by_host(hst->name, temp_comment);
		if(temp_comment->comment_type == HOST_COMMENT && temp_comment->entry_type == ACKNOWLEDGEMENT_COMMENT && temp_comment->persistent == FALSE) {
			delete_comment(HOST_COMMENT, temp_comment->comment_id);
			}
		temp_comment = next_comment;
		}

	return result;
	}
Exemplo n.º 9
0
t_opc	*scd_bld2(char **tmp, t_htb *opcs, t_htb *lbls, t_chp *chp)
{
  if (tmp == NULL || opcs == NULL || lbls == NULL || chp == NULL)
    return (NULL);
  return (build_opc(delete_comment(tmp), opcs, lbls, chp));
}
Exemplo n.º 10
0
void read_parameter_file ( char *filename )
{
     FILE *f;
     char buffer[MAXPARAMLINELENGTH+1];
     char *buf2;
     int buf2size;
     int line = 0;
     int errors = 0;
     int including = 1;
      int flag;
     int buflen, buf2len;
     int cont;

     /** open it. **/
     f = fopen ( filename, "r" );
     if ( f == NULL )
	  fprintf( stderr ,  "\ncan't open parameter file \"%s\".",
		 filename );

     /** lines are read into buffer.  they are appended to buf2 until a
       line which is not continued is hit, then buf2 is parsed and the
       parameter added. **/

     /* initial allocation of buf2. */
     buf2 = (char *)malloc ( MAXPARAMLINELENGTH * sizeof ( char ) );
     buf2size = MAXPARAMLINELENGTH;
     buf2[0] = 0;
     buf2len = 0;
     cont = 0;

     while ( fgets ( buffer, MAXPARAMLINELENGTH, f ) != NULL )
     {
	  ++line;

	  /* remove comments, skip line if it's blank after comment
	     removal. */
	  if ( delete_comment ( buffer ) )
	       continue;

	  /* is this line continued?  (is the last nonwhitespace character
	     a backslash?) */
	  cont = check_continuation ( buffer );

	  /** make buf2 bigger if necessary. **/
	  buflen = strlen ( buffer );
	  while ( buf2len + buflen > buf2size + 10 )
	  {
	       buf2size += MAXPARAMLINELENGTH;
	       buf2 = (char *)realloc ( buf2, buf2size * sizeof ( char ) );
	  }

	  /** tack the current line onto buf2. **/
	  strcat ( buf2, buffer );
	  buf2len += buflen;

	  /** if this line is not continued further, then parse buf2. and
	   add the parameter. **/
	  if ( !cont )
	  {
	       if ( parse_one_parameter ( buf2 ))
	       {
		    errors = 1;
		    fprintf( stderr ,  "\n%s line %d: syntax error.",
			   filename, line );
	       }

	       /** reset buf2 as empty. **/
	       buf2len = 0;
	       buf2[0] = 0;
	  }
     }

     /* close file. */
     fclose ( f );

     /** if the last line was continued, and nothing followed it, that's
       an error. **/
     if ( buf2len != 0 )
     {
	  errors = 1;
	   fprintf( stderr ,  "\nunexpected EOF." );
     }

     /** if any errors occurred during parsing, stop now. **/
     if ( errors )
     {
	 fprintf( stderr ,
		 "\nsome syntax errors occurred parsing \"%s\".", filename );
	 free( buf2 );
	 exit(1);
    }

     free ( buf2 );

}