source: src-qt4/pc-sounddetect/parse_sound.c @ 6f64d7c1

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 6f64d7c1 was 6f64d7c1, checked in by Ken Moore <ken@…>, 5 months ago

Another fix for pc-sounddetect to fix compilation on 10.x, this should at least make the warning much more negligible.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 * ----------------------------------------------------------------------------
3 * "THE BEER-WARE LICENSE" (Revision 42):
4 * <cneirabustos@gmail.com> wrote this file. As long as you retain this notice you
5 * can do whatever you want with this stuff. If we meet some day, and you think
6 * this stuff is worth it, you can buy me a beer in return,carlos neira bustos
7 * ----------------------------------------------------------------------------
8 */ 
9
10#include <libxml/xmlmemory.h>
11#include <libxml/parser.h>
12#include <string.h>
13
14const char* GetKo(xmlDocPtr doc, xmlNodePtr cur, char* chip_id); 
15const char*  parse_Sound_CardXML(char *docname, char* Vendor_Name, char* chip_id ) ;
16
17
18
19/* cnb 2008-01-01
20    we get the kernel module to load according to search keys(vendor,chipid)
21 */
22
23const char* GetKo(xmlDocPtr doc, xmlNodePtr cur, char* chip_id) {
24
25        xmlChar *key;
26        static char tempkey[16];
27        cur = cur->xmlChildrenNode ;
28        while (cur!= NULL) {
29
30                    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
31                    snprintf(tempkey,sizeof tempkey ,"%s",(char*)key);
32
33                    if(!memcmp(tempkey,chip_id,strlen(tempkey))) { 
34                        xmlFree(key);
35                        const char *name = cur->name;
36                        return name;
37                    }
38                    cur = cur->next;
39        }
40        xmlFree(key);
41        return "UNKNOWN";
42
43}
44
45/* cnb 2008-01-01
46   "validate" the xml and parse the soundcards.xml , searching with keys vendor
47   and chip_id
48 */
49const char* parse_Sound_CardXML(char *docname, char* Vendor_Name, char* chip_id ) 
50{
51
52        xmlDocPtr doc;
53        xmlNodePtr cur;
54        static char kernelmodule[16];
55
56        doc = xmlParseFile(docname);
57        sprintf(kernelmodule,"%s","UNKNOWN");
58       
59        if (doc == NULL ) {
60                fprintf(stderr,"/usr/local/share/pcbsd/pc-sounddetect/soundcards.xml not found!\n");
61                return kernelmodule;
62        }
63       
64        cur = xmlDocGetRootElement(doc);
65       
66        if (cur == NULL) {
67                fprintf(stderr,"empty document\n");
68                xmlFreeDoc(doc);
69                return kernelmodule;
70        }
71       
72        if (xmlStrcmp(cur->name, (const xmlChar *) "SoundCard_vendors")) {
73                fprintf(stderr,"This xml does not have information about sound cards ");
74                xmlFreeDoc(doc);
75                return kernelmodule;
76        }
77        cur = cur->xmlChildrenNode;
78        while (cur!= NULL) 
79        {           
80                if ((!xmlStrcmp(cur->name, (const xmlChar *)Vendor_Name))){
81                    snprintf(kernelmodule,sizeof kernelmodule,"%s",GetKo(doc, cur,chip_id));
82                        xmlFreeDoc(doc);
83                        return kernelmodule;
84                }
85                 
86                cur = cur->next;
87        }
88        xmlFreeDoc(doc);
89        return kernelmodule;
90 }
Note: See TracBrowser for help on using the repository browser.