Back to index

lshw  02.16
Defines | Functions | Variables
version.cc File Reference
#include "version.h"
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
#include <sys/types.h>

Go to the source code of this file.

Defines

#define PACKETSZ   512

Functions

const char * getpackageversion ()
static char * txtquery (const char *name, const char *domain, unsigned int *ttl)
const char * checkupdates ()

Variables

static char versiontag [] = "@(#) $URL: https://ezix.org/source/packages/lshw/releases/B.02.16/src/core/version.cc $ >"

Define Documentation

#define PACKETSZ   512

Definition at line 22 of file version.cc.


Function Documentation

const char* checkupdates ( )

Definition at line 111 of file version.cc.

{
  static char *latest = NULL;

  if(!latest)
    latest = txtquery(PACKAGE, "ezix.org", NULL);

  return latest;
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* getpackageversion ( )

Definition at line 28 of file version.cc.

{
  static char * result = NULL;
  char * lastslash = NULL;

  if(result)
    return result;

  lastslash = strrchr(versiontag, '/');
  if(lastslash)
    *lastslash = '\0';      // cut the basename off

  lastslash = strrchr(versiontag, '/');
  if(lastslash)
    *lastslash = '\0';  // cut the basename off

  lastslash = strrchr(versiontag, '/');
  if(lastslash)
    *lastslash = '\0';  // cut the basename off

  lastslash = strrchr(versiontag, '/');
  if(lastslash)
    result = lastslash+1;
  else
    return "unknown";

  return result;
}

Here is the caller graph for this function:

static char* txtquery ( const char *  name,
const char *  domain,
unsigned int *  ttl 
) [static]

Definition at line 57 of file version.cc.

{
  unsigned char answer[PACKETSZ], *pt;
  char host[128], *txt;
  int len, exp, cttl, size, txtlen, type;

  if(res_init() < 0)
    return NULL;

  memset(answer, 0, PACKETSZ);
  if((len = res_querydomain(name, domain, C_IN, T_TXT, answer, PACKETSZ)) < 0)
    return NULL;

  pt = answer + sizeof(HEADER);

  if((exp = dn_expand(answer, answer + len, pt, host, sizeof(host))) < 0)
    return NULL;

  pt += exp;

  GETSHORT(type, pt);
  if(type != T_TXT)
    return NULL;

  pt += INT16SZ; /* class */

  if((exp = dn_expand(answer, answer + len, pt, host, sizeof(host))) < 0)
    return NULL;

  pt += exp;
  GETSHORT(type, pt);
  if(type != T_TXT)
    return NULL;

  pt += INT16SZ; /* class */
  GETLONG(cttl, pt);
  if(ttl)
    *ttl = cttl;
  GETSHORT(size, pt);
  txtlen = *pt;

  if(txtlen >= size || !txtlen)
    return NULL;

  if(!(txt = (char*)malloc(txtlen + 1)))
    return NULL;

  pt++;
  strncpy(txt, (char*)pt, txtlen);
  txt[txtlen] = 0;

  return txt;
}

Here is the caller graph for this function:


Variable Documentation

char versiontag[] = "@(#) $URL: https://ezix.org/source/packages/lshw/releases/B.02.16/src/core/version.cc $ >" [static]

Definition at line 26 of file version.cc.