MCPcopy Create free account
hub / github.com/NetHack/NetHack / choose_soundlib

Function choose_soundlib

src/sounds.c:1808–1858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1806
1807#if 0
1808staticfn void
1809choose_soundlib(const char *s)
1810{
1811 int i;
1812 char *tmps = 0;
1813
1814 for (i = 1; soundlib_choices[i].sndprocs; i++) {
1815 if (!strcmpi(s, soundlib_choices[i].sndprocs->soundname)) {
1816 assign_soundlib(i);
1817 return;
1818 }
1819 }
1820 assign_soundlib((int) soundlib_nosound);
1821
1822 /* The code below here mimics that in windows.c error handling
1823 for choosing Window type */
1824
1825 /* 50: arbitrary, no real soundlib names are anywhere near that long;
1826 used to prevent potential raw_printf() overflow if user supplies a
1827 very long string (on the order of 1200 chars) on the command line
1828 (config file options can't get that big; they're truncated at 1023) */
1829#define SOUNDLIB_NAME_MAXLEN 50
1830 if (strlen(s) >= SOUNDLIB_NAME_MAXLEN) {
1831 tmps = (char *) alloc(SOUNDLIB_NAME_MAXLEN);
1832 (void) strncpy(tmps, s, SOUNDLIB_NAME_MAXLEN - 1);
1833 tmps[SOUNDLIB_NAME_MAXLEN - 1] = '\0';
1834 s = tmps;
1835 }
1836#undef SOUNDLIB_NAME_MAXLEN
1837
1838 if (!soundlib_choices[1].sndprocs) {
1839 config_error_add(
1840 "Soundlib type %s not recognized. The only choice is: %s",
1841 s, soundlib_choices[0].sndprocs->soundname);
1842 } else {
1843 char buf[BUFSZ];
1844 boolean first = TRUE;
1845
1846 buf[0] = '\0';
1847 for (i = 0; soundlib_choices[i].sndprocs; i++) {
1848 Sprintf(eos(buf), "%s%s",
1849 first ? "" : ", ",
1850 soundlib_choices[i].sndprocs->soundname);
1851 first = FALSE;
1852 }
1853 config_error_add("Soundlib type %s not recognized. Choices are: %s",
1854 s, buf);
1855 }
1856 if (tmps)
1857 free((genericptr_t) tmps) /*, tmps = 0*/ ;
1858}
1859#endif
1860
1861/* copy up to maxlen-1 characters; 'dest' must be able to hold maxlen;

Callers

nothing calls this directly

Calls 4

assign_soundlibFunction · 0.85
config_error_addFunction · 0.85
eosFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected