Преглед на файлове

style: adopt naming convention

v0lp3 преди 4 години
родител
ревизия
858fd45513
променени са 2 файла, в които са добавени 17 реда и са изтрити 17 реда
  1. 14 14
      src/backend.go
  2. 3 3
      src/utils.go

+ 14 - 14
src/backend.go

@@ -21,20 +21,20 @@ func Scan(brotherIP string, brotherPort int, resolution int, color string, adf b
 
 	defer socket.Close()
 
-	width, heigth := SendRequest(socket, resolution, color, adf)
+	width, heigth := sendRequest(socket, resolution, color, adf)
 
-	bytes := GetScanBytes(socket)
+	bytes := getScanBytes(socket)
 
-	return RemoveHeaders(bytes), width, heigth
+	return removeHeaders(bytes), width, heigth
 }
 
-func SendRequest(socket net.Conn, resolution int, _mode string, adf bool) (int, int) {
+func sendRequest(socket net.Conn, resolution int, _mode string, adf bool) (int, int) {
 
-	mode, compression := GetCompressionMode(_mode)
+	mode, compression := getCompressionMode(_mode)
 
 	log.Println("Reading scanner status...")
 
-	status := ReadPacket(socket)[:7]
+	status := readPacket(socket)[:7]
 
 	if status != "+OK 200" {
 		HandleError(fmt.Errorf("invalid reply from scanner: %s", status))
@@ -43,17 +43,17 @@ func SendRequest(socket net.Conn, resolution int, _mode string, adf bool) (int,
 	log.Println("Leasing options...")
 
 	request := []byte(fmt.Sprintf("\x1bI\nR=%d,%d\nM=%s\n\x80", resolution, resolution, mode))
-	SendPacket(socket, request)
+	sendPacket(socket, request)
 
-	offer := ReadPacket(socket)
+	offer := readPacket(socket)
 
 	if !adf {
 		log.Println("Disabling automatic document feeder (ADF)")
 
 		request = []byte("\x1bD\nADF\n\x80")
-		SendPacket(socket, request)
+		sendPacket(socket, request)
 
-		ReadPacket(socket)
+		readPacket(socket)
 	}
 
 	log.Println("Sending scan request...")
@@ -67,14 +67,14 @@ func SendRequest(socket net.Conn, resolution int, _mode string, adf bool) (int,
 	requestFormat := "\x1bX\nR=%v,%v\nM=%s\nC=%s\nJ=MID\nB=50\nN=50\nA=0,0,%v,%v\n\x80"
 
 	request = []byte(fmt.Sprintf(requestFormat, offerOptions[1], offerOptions[1], mode, compression, width, height))
-	SendPacket(socket, request)
+	sendPacket(socket, request)
 
 	log.Println("Scanning started...")
 
 	return width, height
 }
 
-func GetScanBytes(socket net.Conn) []byte {
+func getScanBytes(socket net.Conn) []byte {
 	log.Println("Getting packets...")
 
 	packet := make([]byte, 2048)
@@ -106,7 +106,7 @@ func SaveImage(data []byte, width int, height int, name string, color string) {
 
 	log.Println("Saving image...")
 
-	_, compression := GetCompressionMode(color)
+	_, compression := getCompressionMode(color)
 
 	if compression != "JPEG" {
 
@@ -134,7 +134,7 @@ func SaveImage(data []byte, width int, height int, name string, color string) {
 	}
 }
 
-func RemoveHeaders(scan []byte) []byte {
+func removeHeaders(scan []byte) []byte {
 	log.Println("Removing headers from bytes...")
 
 	const headerLen int = 12

+ 3 - 3
src/utils.go

@@ -7,12 +7,12 @@ import (
 	"os"
 )
 
-func SendPacket(socket net.Conn, packet []byte) {
+func sendPacket(socket net.Conn, packet []byte) {
 	_, err := socket.Write(packet)
 	HandleError(err)
 }
 
-func ReadPacket(socket net.Conn) string {
+func readPacket(socket net.Conn) string {
 	reply := make([]byte, 64)
 
 	_, err := socket.Read(reply)
@@ -29,7 +29,7 @@ func HandleError(err error) {
 	}
 }
 
-func GetCompressionMode(_mode string) (string, string) {
+func getCompressionMode(_mode string) (string, string) {
 
 	if _mode == "GRAY64" {
 		return _mode, "NONE"