- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 - 56
 - 57
 - 58
 
                        UINT32 GetHostName(char *hostName, UINT32 hostNameBufSize)
{
        if (hostName == NULL ){
                OSALTRACE(OSAL_ERROR, ("Error: Input parameter hostName(null)."));
                return -1;
        }
        FILE *fp = NULL;
        static char buffer[512];
        char tag[64];
        // hope this size will be OK for one line to read from the fileOB
        char line[1000];
        char *linep=line;
        int buffSize = sizeof(buffer);
        int found = 0;
        fp = fopen("/etc/resolv.conf", "r");
        if ( fp == NULL)
        {
                OSALTRACE(OSAL_ERROR, ("failed to open resolver config file."));
                return -1;
        }
        while ( ((*linep=getc(fp)) != EOF) && !found )
        {
                if (*linep++ == '\n')
                {
                        *linep = '\0';
                        sscanf(line, "%s %s", tag, buffer);
                        if (tag[0] && (!strcmp(tag, "search") || !strcmp(tag, "domain") ) ) {
                                found = 1;
                                break;
                        }
                        linep = line;
                }
        }
        fclose(fp);
        if ( found )
        {
                strcpy(hostName,buffer);
                OSALTRACE(OSAL_DEBUG, ("DHCP domain is  %s.", buffer));
        }
        else
        {
                OSALTRACE(OSAL_ERROR, ("Could not find dhcp domain in resolv.conf."));
                return -1;
        }
        return !found;
}
                                     
        
            Intel WiMAX Network Service, не какая-то пионерская поделка...