ctucx.git: nimjpg

parse jpg file header

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
import streams

template debug*(x: varargs[untyped]) =
  if not defined(release):
    echo(x)

template error*(x: varargs[untyped]) =
  echo(x)
  quit(1)

# These are shim functions to make a Stream usable like an AyncFile
# This is so we can use the multisync macro

proc read*(stream: Stream, length: int): string =
  return stream.readStr(length)

proc getFilePos*(stream: Stream): int64 =
  return int64(stream.getPosition())

proc setFilePos*(stream: Stream, position: int64) =
  stream.setPosition(int(position))

proc readBuffer*(stream: Stream, buffer: pointer, length: int): int =
  return stream.readData(buffer, length)