SCANC(9)
π SCANC β the kernel dev manual page, bestie edition β¨
okay so real talk: this is scanc from the Kernel Developer's Manual (section 9, obvi β kernel-land π§). it's a tiny little function with main character energy, and honestly? she ate. let's get into it π
β¨ NAME β¨
scanc β literally just uses a byte string as a lookup table index. that's the whole vibe. no cap π
πΈ SYNOPSIS πΈ
#include <lib/libkern/libkern.h>
int
scanc(u_int size, const u_char *cp, const u_char table[], int mask);
look at her. iconic signature. four args, one dream π
π¦ DESCRIPTION π¦
so here's the tea β: scanc() scans the byte string cp, and the length of that string is size. simple enough, right?
then β and this is the fun part β a character in the string gets used as an index into the 256-byte table. like, every byte in your string is basically pointing at a lil spot in the table. iykyk π«Ά
the scan stops when either of these happens:
- a bitwise-AND of the byte from the
tableandmaskisn't zero π₯ - or the string is exhausted (you ran out of characters, bestie, it's over π)
that's it. that's the whole scan. no notes π
β RETURN VALUES β
scanc() returns the length of the rest of the string β including the character that made the scan stop. yes, she's included, she's part of the count, don't do her dirty π
and if scanc() exhausted the string? it returns 0. zero. nada. the scan found nothing and honestly same π
π HISTORY π
scanc() emulates a VAX instruction with the same name. retro! vintage! a whole ancestor! we respect the lineage π§β¨
π friendly lil reminder: the details up there are load-bearing β the256-byte table, theint-typed mask, the "including the stopping character" bit β so don't skip 'em, bestie π«Ά
kisses, this was SCANC(9) from the Debian crew, dated April 24, 2013 β slay forever, periodt π
β¨
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c)2011,2013 YAMAMOTO Takashi
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms