SASC
DVBSoftCAM

cSource Class Reference

#include <sources.h>

Inheritance diagram for cSource:

List of all members.

Public Types

enum  eSourceType {
  stNone = 0x0000, stCable = 0x4000, stSat = 0x8000, stTerr = 0xC000,
  st_Mask = 0xC000, st_Neg = 0x0800, st_Pos = 0x07FF
}

Public Member Functions

 cSource (void)
 ~cSource ()
int Code (void) const
const char * Description (void) const
bool Parse (const char *s)

Static Public Member Functions

static cString ToString (int Code)
static int FromString (const char *s)
static int FromData (eSourceType SourceType, int Position=0, bool East=false)
static bool IsCable (int Code)
static bool IsSat (int Code)
static bool IsTerr (int Code)

Detailed Description

Definition at line 15 of file sources.h.


Member Enumeration Documentation

Enumerator:
stNone 
stCable 
stSat 
stTerr 
st_Mask 
st_Neg 
st_Pos 

Definition at line 17 of file sources.h.

                   {
    stNone  = 0x0000,
    stCable = 0x4000,
    stSat   = 0x8000,
    stTerr  = 0xC000,
    st_Mask = 0xC000,
    st_Neg  = 0x0800,
    st_Pos  = 0x07FF,
    };

Constructor & Destructor Documentation

cSource::cSource ( void  )
cSource::~cSource ( )

Member Function Documentation

int cSource::Code ( void  ) const [inline]

Definition at line 32 of file sources.h.

{ return code; }
const char* cSource::Description ( void  ) const [inline]

Definition at line 33 of file sources.h.

{ return description; }
static int cSource::FromData ( eSourceType  SourceType,
int  Position = 0,
bool  East = false 
) [static]
int cSource::FromString ( const char *  s) [static]

Definition at line 436 of file compat.c.

References esyslog, st_Neg, stCable, stNone, stSat, and stTerr.

Referenced by main(), and cPlainKeyConstCw::Parse().

{
  int type = stNone;
  switch (toupper(*s)) {
    case 'C': type = stCable; break;
    case 'S': type = stSat;   break;
    case 'T': type = stTerr;  break;
    case '0' ... '9': type = *s - '0'; break; // backward compatibility
    default: esyslog("ERROR: unknown source key '%c'", *s);
             return stNone;
    }
  int code = type;
  if (type == stSat) {
     int pos = 0;
     bool dot = false;
     bool neg = false;
     while (*++s) {
           switch (toupper(*s)) {
             case '0' ... '9': pos *= 10;
                               pos += *s - '0';
                               break;
             case '.':         dot = true;
                               break;
             case 'E':         neg = true; // fall through to 'W'
             case 'W':         if (!dot)
                                  pos *= 10;
                               break;
             default: esyslog("ERROR: unknown source character '%c'", *s);
                      return stNone;
             }
           }
     if (neg)
        pos |= st_Neg;
     code |= pos;
     }
  return code;
}
static bool cSource::IsCable ( int  Code) [inline, static]

Definition at line 38 of file sources.h.

References st_Mask, and stCable.

{ return (Code & st_Mask) == stCable; }
static bool cSource::IsSat ( int  Code) [inline, static]

Definition at line 39 of file sources.h.

References st_Mask, and stSat.

Referenced by cPlainKeyConstCw::Parse().

{ return (Code & st_Mask) == stSat; }
static bool cSource::IsTerr ( int  Code) [inline, static]

Definition at line 40 of file sources.h.

References st_Mask, and stTerr.

{ return (Code & st_Mask) == stTerr; }
bool cSource::Parse ( const char *  s)
cString cSource::ToString ( int  Code) [static]

Definition at line 416 of file compat.c.

References st_Mask, st_Neg, stCable, stSat, and stTerr.

Referenced by cValidityRange::Print(), cPlainKeyConstCw::PrintKeyNr(), and cCam::Tune().

{
  char buffer[16];
  char *q = buffer;
  switch (Code & st_Mask) {
    case stCable: *q++ = 'C'; break;
    case stSat:   *q++ = 'S';
                  {
                    int pos = Code & ~st_Mask;
                    q += snprintf(q, sizeof(buffer) - 2, "%u.%u", (pos & ~st_Neg) / 10, (pos & ~st_Neg) % 10); // can't simply use "%g" here since the silly 'locale' messes up the decimal point
                    *q++ = (Code & st_Neg) ? 'E' : 'W';
                  }
                  break;
    case stTerr:  *q++ = 'T'; break;
    default:      *q++ = Code + '0'; // backward compatibility
    }
  *q = 0;
  return buffer;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines