drivers/accessibility/speakup/utils.h
Source file repositories/reference/linux-study-clean/drivers/accessibility/speakup/utils.h
File Facts
- System
- Linux kernel
- Corpus path
drivers/accessibility/speakup/utils.h- Extension
.h- Size
- 2089 bytes
- Lines
- 103
- Domain
- Driver Families
- Bucket
- drivers/accessibility
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.h
Detected Declarations
struct st_keyfunction open_inputfunction oops
Annotated Snippet
struct st_key {
char *name;
struct st_key *next;
int value, shift;
};
struct st_key key_table[MAXKEYS];
struct st_key *extra_keys = key_table+HASHSIZE;
char *def_name, *def_val;
FILE *infile;
int lc;
char filename[256];
static inline void open_input(const char *dir_name, const char *name)
{
if (dir_name)
snprintf(filename, sizeof(filename), "%s/%s", dir_name, name);
else
snprintf(filename, sizeof(filename), "%s", name);
infile = fopen(filename, "r");
if (infile == 0) {
fprintf(stderr, "can't open %s\n", filename);
exit(1);
}
lc = 0;
}
static inline int oops(const char *msg, const char *info)
{
if (info == NULL)
info = "";
fprintf(stderr, "error: file %s line %d\n", filename, lc);
fprintf(stderr, "%s %s\n", msg, info);
exit(1);
}
static inline struct st_key *hash_name(char *name)
{
unsigned char *pn = (unsigned char *)name;
int hash = 0;
while (*pn) {
hash = (hash * 17) & 0xfffffff;
if (isupper(*pn))
*pn = tolower(*pn);
hash += (int)*pn;
pn++;
}
hash %= HASHSIZE;
return &key_table[hash];
}
static inline struct st_key *find_key(char *name)
{
struct st_key *this = hash_name(name);
while (this) {
if (this->name && !strcmp(name, this->name))
return this;
this = this->next;
}
return this;
}
static inline struct st_key *add_key(char *name, int value, int shift)
{
struct st_key *this = hash_name(name);
if (extra_keys-key_table >= MAXKEYS)
oops("out of key table space, enlarge MAXKEYS", NULL);
if (this->name != NULL) {
while (this->next) {
if (!strcmp(name, this->name))
oops("attempt to add duplicate key", name);
this = this->next;
}
this->next = extra_keys++;
this = this->next;
}
this->name = strdup(name);
this->value = value;
this->shift = shift;
return this;
}
Annotation
- Immediate include surface: `stdio.h`.
- Detected declarations: `struct st_key`, `function open_input`, `function oops`.
- Atlas domain: Driver Families / drivers/accessibility.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.