github.com/iDigitalFlame/xmt@v0.5.1/c2/profile.go (about)

     1  // Copyright (C) 2020 - 2023 iDigitalFlame
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU General Public License as published by
     5  // the Free Software Foundation, either version 3 of the License, or
     6  // any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU General Public License
    14  // along with this program.  If not, see <https://www.gnu.org/licenses/>.
    15  //
    16  
    17  package c2
    18  
    19  import "github.com/iDigitalFlame/xmt/c2/cfg"
    20  
    21  // ProfileParser is a package level constant to be used when performing Profile
    22  // loads from a raw binary source. This function will take the resulting byte
    23  // array and Marshal it into a working Profile interface.
    24  //
    25  // This function starts out as nil, which in case the "c2/cfg" binary profile
    26  // parser will be used.
    27  //
    28  // This is used to apply custom profiles to be used. Custom profiles can be Marshaled
    29  // by exposing the 'MarshalBinary() ([]byte, error)' function.
    30  var ProfileParser func(b []byte) (cfg.Profile, error)
    31  
    32  func parseProfile(b []byte) (cfg.Profile, error) {
    33  	if ProfileParser == nil {
    34  		return cfg.Raw(b)
    35  	}
    36  	return ProfileParser(b)
    37  }