Category : C Source Code
Archive   : ECSTR.ZIP
Filename : STRNLEN.C

Output of file : STRNLEN.C contained in archive : ECSTR.ZIP
/* File : strnlen.c
Author : Richard A. O'Keefe.
Updated: 10 April 1984
Defines: strnlen()

strnlen(src, len)
returns the number of characters up to the first NUL in src, or len,
whichever is smaller. This is the same as strnend(src,len)-src.

Beware: the VaxAsm version only works for 0 <= len < 65535.

#include "strings.h"

#if VaxAsm

int strnlen(src, len)
char *src;
int len;
asm("locc $0,8(ap),*4(ap)");
asm("subl3 4(ap),r1,r0");

#else ~VaxAsm

int strnlen(s, n)
register char *s;
register int n;
register int L;

for (L = 0; --n >= 0 && *s++; L++) ;
return L;

#endif VaxAsm

  3 Responses to “Category : C Source Code
Archive   : ECSTR.ZIP
Filename : STRNLEN.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: