<commit_before>package main

import "fmt"
import "net"
import "os"
import "bytes"

const BLOCK_SIZE = 512

const (
  OCTET = "octet"
  NETASCII = "netascii"
)

const (
  RRQ uint16 = 1  + iota
  WRQ
  DATA
  ACK
  ERROR
)

var ERRORS = [...] string {
  "Not defined, see error message (if any).",
  "File not found.",
  "Access violation.",
  "Disk full or allocation exceeded.",
  "Illegal TFTP operation.",
  "Unknown transfer ID.",
  "File already exists.",
  "No such user.",
}

func Bytes2UInt16 (value []byte) uint16 {
  var a uint16 = uint16 (value [0] & 0xff) << 8
  var b uint16 = uint16 (value [1] & 0xff)
  return a + b
}

func Int2Bytes (value uint16) (retVal []byte) {
  retVal = []byte {uint8 (value >> 8), uint8 (value & 0xff)}
  return
}

func HandleRRQ (buffer []byte, conn *net.UDPConn, tid *net.UDPAddr) {
  var foo = bytes.Split (buffer [2:], []byte {0x00})
  var filename string = string (foo [0])
  var mode string = string (foo [1])

  if _, err := os.Stat (filename); err == nil {
    var fileBuffer []byte

    if mode == OCTET {
      fileBuffer = make ([]byte, BLOCK_SIZE)
    } else if mode == NETASCII {
      panic ("Modo aún no soportado!!")
    } else {
      panic ("Modo desconocido!!")
    }

    file, err := os.Open (filename)<commit_msg>Corrrect Int2Bytes function<commit_after>package main

import "fmt"
import "net"
import "os"
import "bytes"

const BLOCK_SIZE = 512

const (
  OCTET = "octet"
  NETASCII = "netascii"
)

const (
  RRQ uint16 = 1  + iota
  WRQ
  DATA
  ACK
  ERROR
)

var ERRORS = [...] string {
  "Not defined, see error message (if any).",
  "File not found.",
  "Access violation.",
  "Disk full or allocation exceeded.",
  "Illegal TFTP operation.",
  "Unknown transfer ID.",
  "File already exists.",
  "No such user.",
}

func Bytes2UInt16 (value []byte) uint16 {
  var a uint16 = uint16 (value [0] & 0xff) << 8
  var b uint16 = uint16 (value [1] & 0xff)
  return a + b
}

func Int2Bytes (value uint16) (retVal []byte) {
  retVal = []byte {byte (value >> 8), byte (value & 0xff)}
  return
}

func HandleRRQ (buffer []byte, conn *net.UDPConn, tid *net.UDPAddr) {
  var foo = bytes.Split (buffer [2:], []byte {0x00})
  var filename string = string (foo [0])
  var mode string = string (foo [1])

  if _, err := os.Stat (filename); err == nil {
    var fileBuffer []byte

    if mode == OCTET {
      fileBuffer = make ([]byte, BLOCK_SIZE)
    } else if mode == NETASCII {
      panic ("Modo aún no soportado!!")
    } else {
      panic ("Modo desconocido!!")
    }

    file, err := os.Open (filename)
{'fraction_non_alphanumeric': 0.14676034348165495, 'fraction_numerical': 0.02849336455893833, 'mean_word_length': 3.0109546165884193, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5120093', 'n_tokens_mistral': 973, 'n_tokens_neox': 917, 'n_words': 315}