@@ -786,24 +786,35 @@ static int parse_data_file(TYPE_FD arg_upsfd)
786786
787787 if (now < next_update )
788788 {
789- upsdebugx (1 , "leaving (paused)..." );
789+ upsdebugx (1 , "%s: leaving (paused)..." , __func__ );
790790 return 1 ;
791791 }
792792
793793 /* initialise everything, to loop back at the beginning of the file */
794794 if (ctx == NULL )
795795 {
796+ upsdebugx (2 , "%s: (re-)initialize PCONF context" , __func__ );
796797 ctx = (PCONF_CTX_t * )xmalloc (sizeof (PCONF_CTX_t ));
798+ if (!ctx ) {
799+ upsdebugx (1 , "%s: failed to malloc()" , __func__ );
800+ return 1 ;
801+ }
797802
803+ upsdebugx (5 , "%s: call prepare_filepath()" , __func__ );
798804 prepare_filepath (fn , sizeof (fn ));
805+
806+ upsdebugx (5 , "%s: got '%s', call pconf_init()" , __func__ , fn );
799807 pconf_init (ctx , upsconf_err );
800808
809+ upsdebugx (5 , "%s: call pconf_file_begin()" , __func__ );
801810 if (!pconf_file_begin (ctx , fn ))
802811 fatalx (EXIT_FAILURE , "Can't open dummy-ups definition file %s: %s" ,
803812 fn , ctx -> errmsg );
804813
805814 /* we need this for parsing alarm instructions later */
815+ upsdebugx (5 , "%s: call status_init()" , __func__ );
806816 status_init (); /* in case no ups.status does it */
817+ upsdebugx (5 , "%s: call alarm_init()" , __func__ );
807818 alarm_init (); /* reset alarms at start of parsing */
808819 }
809820
@@ -812,6 +823,7 @@ static int parse_data_file(TYPE_FD arg_upsfd)
812823 next_update = -1 ;
813824
814825 /* Now start or continue parsing... */
826+ upsdebugx (3 , "%s: proceed parsing PCONF context" , __func__ );
815827 while (pconf_file_next (ctx ))
816828 {
817829 if (pconf_parse_error (ctx ))
@@ -822,6 +834,10 @@ static int parse_data_file(TYPE_FD arg_upsfd)
822834 }
823835
824836 /* Check if we have something to process */
837+ upsdebugx (4 , "%s: %s:%d: numargs:%d token:%s" ,
838+ __func__ , fn , ctx -> linenum , ctx -> numargs ,
839+ (ctx -> numargs < 1 ? "<null>" : ctx -> arglist [0 ])
840+ );
825841 if (ctx -> numargs < 1 )
826842 continue ;
827843
@@ -920,9 +936,12 @@ static int parse_data_file(TYPE_FD arg_upsfd)
920936 /* Cleanup parseconf if there is no pending action */
921937 if (next_update == -1 )
922938 {
939+ upsdebugx (3 , "%s: clean up PCONF context: no pending action" , __func__ );
923940 pconf_finish (ctx );
924941 free (ctx );
925942 ctx = NULL ;
926943 }
944+
945+ upsdebugx (3 , "%s: leaving (finished)" , __func__ );
927946 return 1 ;
928947}
0 commit comments