// File: DoubleString[P]RtConverter/src/Rtklib/stream.cpp
// Function: bamboo::strclose(bamboo::stream_t*)
extern void strclose(stream_t *stream)
	{
		tracet(3, "strclose: type=%d mode=%d\n", stream->type, stream->mode);

		strlock(stream);

		if (stream->port) {
			switch (stream->type) {
			case STR_SERIAL: closeserial((serial_t *)stream->port); break;
			case STR_FILE: closefile((file_t   *)stream->port); break;
			case STR_TCPSVR: closetcpsvr((tcpsvr_t *)stream->port); break;
			case STR_TCPCLI: closetcpcli((tcpcli_t *)stream->port); break;
			case STR_NTRIPSVR: closentrip((ntrip_t  *)stream->port); break;
			case STR_NTRIPCLI: closentrip((ntrip_t  *)stream->port); break;
			case STR_NTRIPC_S: closentripc((ntripc_t *)stream->port); break;
			case STR_NTRIPC_C: closentripc((ntripc_t *)stream->port); break;
			case STR_UDPSVR: closeudpsvr((udp_t    *)stream->port); break;
			case STR_UDPCLI: closeudpcli((udp_t    *)stream->port); break;
			case STR_MEMBUF: closemembuf((membuf_t *)stream->port); break;
			case STR_FTP: closeftp((ftp_t    *)stream->port); break;
			case STR_HTTP: closeftp((ftp_t    *)stream->port); break;
			case STR_VRSCONCLI: closevrsconcli((vrscon_cli_t*)stream->port); break;
			case STR_VRSCONSVR: closevrsconsvr((vrscon_svr_t*)stream->port); break;
			}
		}
		else {
			trace(2, "no port to close stream: type=%d\n", stream->type);
		}
		stream->type = 0;
		stream->mode = 0;
		stream->state = 0;
		stream->inr = stream->outr = 0;
		stream->path[0] = '\0';
		stream->msg[0] = '\0';
		stream->port = NULL;

		strunlock(stream);
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %edx
movq -0x8(%rbp), %rax
movl 0x4(%rax), %ecx
movl $0x3, %edi
leaq 0x29e35(%rip), %rsi     # 0xc8b7a
movb $0x0, %al
callq 0x95890
movq -0x8(%rbp), %rdi
callq 0x9ef00
movq -0x8(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x9ee82
movq -0x8(%rbp), %rax
movl (%rax), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x10(%rbp)
subl $0xf, %eax
ja 0x9ee80
movq -0x10(%rbp), %rax
leaq 0x29c0a(%rip), %rcx     # 0xc8990
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9ef20
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9ef80
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9efd0
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f070
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f0c0
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f0c0
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f110
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f110
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f170
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f1c0
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f210
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f250
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f250
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f290
jmp 0x9ee80
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9f2c0
jmp 0x9ee9b
movq -0x8(%rbp), %rax
movl (%rax), %edx
movl $0x2, %edi
leaq 0x29d01(%rip), %rsi     # 0xc8b95
movb $0x0, %al
callq 0x8b980
movq -0x8(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x4(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x8(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x18(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x10(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x60(%rax)
movq -0x8(%rbp), %rax
movb $0x0, 0x460(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x58(%rax)
movq -0x8(%rbp), %rdi
callq 0x9f2f0
addq $0x10, %rsp
popq %rbp
retq
nop