/*
 * Licensed to Open Source Radio Access Network(OS-RAN) Alliance and OAI
 * Software Alliance under one or more contributor license agreements. The
 * initial OpenXG series projects are derided from OAI projects, the files from
 * OAI projects are all in compliance with OAI Public License, Version 1.1.
 * codes and files developed from OpenXG projects and from OS-RAN Alliance
 * are all under OS-RAN licenses; you may not use this file except in compliance
 * with the license.  You may get a copy of the license at:
 *	http://www.openxg.org.cn/?falu_69.html
 * For more information about OpenXG, please contact:
 * contact@openxg.org.cn
 */


#ifndef _PRINT_BUFFER_H
#define _PRINT_BUFFER_H

#include <string>

#include "iostream"
#include "logger.hpp"
using namespace std;

void print_buffer(const string app, const string commit, uint8_t *buf,
                  int len) {
  if (!app.compare("ausf_server")) cout << commit.c_str() << endl;
  Logger::ausf_server().debug(commit.c_str());

  for (int i = 0; i < len; i++) printf("%x ", buf[i]);
  printf("\n");
}

void hexStr2Byte(const char *src, unsigned char *dest, int len) {
  short i;
  unsigned char hBy, lBy;
  for (i = 0; i < len; i += 2) {
    hBy = toupper(src[i]);
    lBy = toupper(src[i + 1]);
    if (hBy > 0x39)
      hBy -= 0x37;
    else
      hBy -= 0x30;
    if (lBy > 0x39)
      lBy -= 0x37;
    else
      lBy -= 0x30;
    dest[i / 2] = (hBy << 4) | lBy;
  }
}

#endif
