diff --git a/rtmp/rtmp.go b/rtmp/rtmp.go index 06ba4789..135687c9 100644 --- a/rtmp/rtmp.go +++ b/rtmp/rtmp.go @@ -593,6 +593,27 @@ func C_RTMP_SetupURL(r *C.RTMP, u string) int32 { return 1 } +// int RTMP_ParseURL(const char *url, int *protocol, AVal *host, unsigned int *port, +// AVal *playpath, AVal *app); +// parseurl.c +33 +func C_RTMP_ParseURL(url *byte, protocol *int32, host *C.AVal, port *uint32, + playpath *C.AVal, app *C.AVal) { + + var p, end, col, ques, slash *byte + + // RTMP_Log(RTMP_LOGDEBUG, "Parsing..."); + + *protocol = RTMP_PROTOCOL_RTMP + *port = 0 + playpath.av_len = 0 + playpath.av_val = nil + app.av_len = 0 + app.av_val = nil + + p = str + +} + // void SocksSetup(RTMP *r, C.AVal* sockshost); // rtmp.c +410 func C_SocksSetup(r *C.RTMP, sockshost *C.AVal) { @@ -2353,6 +2374,42 @@ func strchr(str *byte, val byte) *byte { return nil } +// Porting: http://www.ai.mit.edu/projects/im/cam8/cam8/working/CAMlib/tcl/compat/strstr.c +func strstr(str *byte, substring *byte) *byte { + var a, b *byte + /* First scan quickly through the two strings looking for a + * single-character match. When it's found, then compare the + * rest of the substring. + */ + + b = substring + if *b == 0 { + return str + } + + for *str != 0 { + str = (*byte)(incBytePtr(unsafe.Pointer(str), 1)) + if *str != *b { + continue + } + a = str + for { + if *b == 0 { + return str + } + tmp1 := a + a = (*byte)(incBytePtr(unsafe.Pointer(a), 1)) + tmp2 := b + b = (*byte)(incBytePtr(unsafe.Pointer(b), 1)) + if *tmp1 != *tmp2 { + break + } + } + b = substring + } + return nil +} + // Creates mem of the size noOfBytes. returns as unsafe pointer func allocate(nOfBytes uintptr) unsafe.Pointer { mem := make([]byte, int(nOfBytes))