Example #1
0
/***********************************************
#  Sub-Routines / Functions Definitions
##
# This is the actual Body
##
***********************************************/
func main() {
	// This is the main program which calls in everything else.
	caller := "Automaton :: Main ::"

	log.Notelog("Welcome to Automaton", &caller)
	log.Deblog("Development Starting oh yeah !!", 3, &caller)

	/*
	   it := "Hello, Hello"
	   hit := sha512.New()
	   io.WriteString(hit,it)
	   fmt.Printf("% x", hit.Sum(nil))
	   log.DebugL("hello", "debug", 1, "main")
	   log.DebugL("hello", "debug", 3, "main")
	   log.DebugL("Oh Noes ... ", "error", 3, "main")
	*/

	//func It (message string, logtype string, loglev int, caller string)
	//func Read_cfg (cfg_type *string, cfg_file *string, cfg_handle *string)

	filen := "/home/vdopey/example.txt"
	filet := "cfgpars"
	fileh := ""
	filehandler.Read_cfg(filet, &filen, fileh)

}
Example #2
0
func Read_cfg(cfg_type string, cfg_file *string, cfg_handle string) {
	caller := "filehandler :: read_cfg"
	switch cfg_type {
	case "cfgpars":
		fcon := read_file(cfg_file)
		//patmatch := "(\\w+)=(\".+?\"|\'.+?\'|.+)\\s*(#.*|)"
		// patmatch := "(\\w+)[=](\\w+)"
		wshmatch := "[;]*[#]*(\\s)*[#]."
		varmatch := "(\\w+)=(\".+?\"|'.+?'|.+)(\\s*)(#.*|)"
		wshpat, err := regexp.Compile(wshmatch)
		if err != nil {
			logger.Errlog(&err, 1, &caller)
		}
		varpat, err := regexp.Compile(varmatch)
		if err != nil {
			logger.Errlog(&err, 1, &caller)
		}

		fmt.Println(wshpat.String())
		fmt.Println(varpat.String())

		for i := 0; i < len(fcon); i++ {
			switch {
			case varpat.MatchString(fcon[i]):
				logger.Deblog("Printing and saving: "+fcon[i], 1, &caller)
				variables := strings.SplitAfter(fcon[i], "=")
				for i := 0; i < len(variables); i++ {
					logger.Deblog("Variable currently: "+variables[i], 1, &caller)
				}
			case wshpat.MatchString(fcon[i]):
				// skipping the matched pattern
			default:
				logger.Deblog("Hit Default value currently: "+fcon[i], 1, &caller)
			}
		}

		/*
		   if match,err := regexp.MatchString("^[#]+",fcon[i]); match {
		     if err != nil {
		       logger.Errlog (&err,1,&caller)
		     }
		     logger.Deblog("skipping the matched line: "+fcon[i],1,&caller)
		   } else if match,err := regexp.MatchString("^(\\s)+",fcon[i]); match {
		     if err != nil {
		       logger.Errlog (&err,1,&caller)
		     }
		     logger.Deblog("skipping the matched line: "+fcon[i],1,&caller)
		   } else if match := pattern.MatchString(fcon[i]); match {
		       if err != nil {
		         logger.Errlog (&err,1,&caller)
		       }
		     logger.Deblog("skipping the patmatch matched line: "+fcon[i],1,&caller)
		   } else if match,err := regexp.MatchString("^$",fcon[i]); match {
		     if err != nil {
		       logger.Errlog (&err,1,&caller)
		     }
		     logger.Deblog("skipping the matched line: "+fcon[i],1,&caller)
		   } else {
		     logger.Deblog("Printing and saving: "+fcon[i],1,&caller)
		     variables := strings.SplitAfter(fcon[i], "=")
		     for i := 0; i < len(variables);i++ {
		       logger.Deblog("Variable currently: "+variables[i],1,&caller)
		     }
		   }
		*/
	case "genericpars":
	case "rulespars":
	case "passpars":
	case "shadpars":
	case "grouppars":
	case "userpars":
	case "mailpars":
		switch cfg_handle {
		case "generic":
		case "alert":
		default:
		}
	default:
	}
}