src/lib/lex.c
LEX *lex_open_buf(LEX *lf, const char *buffer, LEX_ERROR_HANDLER *scan_error)

{
   LEX *nf;

   Dmsg0(400, "Open config buffer\n");
   nf = (LEX *)malloc(sizeof(LEX));
   if (lf) {
      memcpy(nf, lf, sizeof(LEX));
      memset(lf, 0, sizeof(LEX));
      lf->next = nf;                  /* if have lf, push it behind new one */
      lf->options = nf->options;      /* preserve user options */
      /*
       * preserve err_type to prevent bacula exiting on 'reload'
       * if config is invalid. Fixes bug #877
       */
      lf->err_type = nf->err_type;
   } else {
      lf = nf;                        /* start new packet */
      memset(lf, 0, sizeof(LEX));
      lex_set_error_handler_error_type(lf, M_ERROR_TERM);
   }
   if (scan_error) {
      lf->scan_error = scan_error;
   } else {
      lex_set_default_error_handler(lf);
   }
   lf->fd = NULL;
   lf->bpipe = NULL;
   lf->fname = NULL;
   lf->line = get_memory(5000);
   pm_strcpy(lf->line, buffer);
   pm_strcat(lf->line, "");
   lf->state = lex_none;
   lf->ch = 0;
   lf->str = get_memory(5000);
   return lf;
}
/*
 * Open a configuration in memory buffer. We push the
 * state of the current file (lf) so that we
 * can do includes.  This is a bit of a hammer.
 * Instead of passing back the pointer to the
 * new packet, I simply replace the contents
 * of the caller's packet with the new packet,
 * and link the contents of the old packet into
 * the next field.
 *
 */
Open a configuration in memory buffer. We push the
state of the current file (lf) so that we
can do includes.  This is a bit of a hammer.
Instead of passing back the pointer to the
new packet, I simply replace the contents
of the caller's packet with the new packet,
and link the contents of the old packet into
the next field.
Open a configuration in memory buffer . We push the state of the current file ( lf ) so that we can do includes . This is a bit of a hammer . Instead of passing back the pointer to the new packet I simply replace the contents of the caller ' s packet with the new packet and link the contents of the old packet into the next field .
LEX *lex_open_buf(LEX *lf, const char *buffer, LEX_ERROR_HANDLER *scan_error)
{
   LEX *nf;
   Dmsg0(400, "Open config buffer\n");
   nf = (LEX *)malloc(sizeof(LEX));
   if (lf) {
      memcpy(nf, lf, sizeof(LEX));
      memset(lf, 0, sizeof(LEX));
      lf->next = nf;                  
      lf->options = nf->options;      
      lf->err_type = nf->err_type;
   } else {
      lf = nf;                        
      memset(lf, 0, sizeof(LEX));
      lex_set_error_handler_error_type(lf, M_ERROR_TERM);
   }
   if (scan_error) {
      lf->scan_error = scan_error;
   } else {
      lex_set_default_error_handler(lf);
   }
   lf->fd = NULL;
   lf->bpipe = NULL;
   lf->fname = NULL;
   lf->line = get_memory(5000);
   pm_strcpy(lf->line, buffer);
   pm_strcat(lf->line, "");
   lf->state = lex_none;
   lf->ch = 0;
   lf->str = get_memory(5000);
   return lf;
}
LEX * lex_open_buf ( LEX * lf , const char * buffer , LEX_ERROR_HANDLER * scan_error ) { LEX * nf ; Dmsg0 ( 400 , " \n " ) ; nf = ( LEX * ) malloc ( sizeof ( LEX ) ) ; if ( lf ) { memcpy ( nf , lf , sizeof ( LEX ) ) ; memset ( lf , 0 , sizeof ( LEX ) ) ; lf -> next = nf ; lf -> options = nf -> options ; lf -> err_type = nf -> err_type ; } else { lf = nf ; memset ( lf , 0 , sizeof ( LEX ) ) ; lex_set_error_handler_error_type ( lf , M_ERROR_TERM ) ; } if ( scan_error ) { lf -> scan_error = scan_error ; } else { lex_set_default_error_handler ( lf ) ; } lf -> fd = NULL ; lf -> bpipe = NULL ; lf -> fname = NULL ; lf -> line = get_memory ( 5000 ) ; pm_strcpy ( lf -> line , buffer ) ; pm_strcat ( lf -> line , " " ) ; lf -> state = lex_none ; lf -> ch = 0 ; lf -> str = get_memory ( 5000 ) ; return lf ; }
Open a configuration in memory buffer.
Open a configuration in memory buffer .
/* if have lf, push it behind new one */ /* preserve user options */ /*
       * preserve err_type to prevent bacula exiting on 'reload'
       * if config is invalid. Fixes bug #877
       */ /* start new packet */