FreeBSD Bugzilla – Attachment 212875 Details for
Bug 245156
audio/pulseaudio: parse /dev/sndstat correctly to get device name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Testcase
testcase.c (text/plain), 1.06 KB, created by
lightside
on 2020-03-30 23:52:50 UTC
(
hide
)
Description:
Testcase
Filename:
MIME Type:
Creator:
lightside
Created:
2020-03-30 23:52:50 UTC
Size:
1.06 KB
patch
obsolete
>/* > cc -o testcase testcase.c && ./testcase >*/ > >#include <stdio.h> >#include <string.h> > >int main() { > const char *line = "pcm4: <Realtek (0x1168) (Rear Analog 5.1/2.0)> (play/rec) default"; > int device; > > if (sscanf(line, "%*[a-z]%i: ", &device) != 1) > return 0; > { > char *k = strchr(line, ':'); > if (!k) > return 0; > const size_t klen = strlen(line) - strlen(k) + 1; > char nameunit[klen + 1]; > nameunit[klen] = '\0'; > strncpy(nameunit, line, klen); > k++; > k += strspn(k, " <"); > const char *e = strrchr(k, '>'); > > if (!e) > return 0; > > const size_t len = strlen(k) - strlen(e); > char desc[len + 1]; > desc[len] = '\0'; > strncpy(desc, k, len); > printf("%s %s\n", nameunit, desc); > /* pcm4: Realtek (0x1168) (Rear Analog 5.1/2.0) */ > } > { > char *k = strrchr(line, '>'); > > if (!k) > return 0; > > const size_t len = strlen(line) - strlen(k) + 1; > char desc[len + 1]; > desc[len] = '\0'; > strncpy(desc, line, len); > > printf("%s\n", desc); > /* pcm4: <Realtek (0x1168) (Rear Analog 5.1/2.0)> */ > } > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 245156
:
212817
|
212838
|
212854
|
212855
|
212875
|
212876
|
212877
|
212878
|
213004
|
213005
|
213006
|
213025
|
213026
|
213050
|
213051
|
213052
|
228663
|
228708