From 1cf41fb16f8a0ea06fa0dd8cabadc8a3e3610dc6 Mon Sep 17 00:00:00 2001 From: schmirl Date: Fri, 18 Sep 2009 10:41:41 +0000 Subject: - cleaned up common.h / common.c - dropped cStreamdevMenuSetupPage --- common.c | 137 +-------------------------------------------------------------- 1 file changed, 2 insertions(+), 135 deletions(-) (limited to 'common.c') diff --git a/common.c b/common.c index cd19d75..279e909 100644 --- a/common.c +++ b/common.c @@ -1,5 +1,5 @@ /* - * $Id: common.c,v 1.10 2009/06/19 06:32:38 schmirl Exp $ + * $Id: common.c,v 1.11 2009/09/18 10:41:41 schmirl Exp $ */ #include @@ -12,140 +12,7 @@ using namespace std; const char *VERSION = "0.5.0-pre"; -const char *StreamTypes[st_Count] = { - "TS", - "PES", - "PS", - "ES", - "Extern", - "", // used internally only -}; - -const char *SuspendModes[sm_Count] = { - trNOOP("Offer suspend mode"), - trNOOP("Always suspended"), - trNOOP("Never suspended") -}; - -const char IpCharacters[] = "0123456789."; - -char *GetNextLine(char *String, uint Length, uint &Offset) { - char *last, *first; - - first = String + Offset; - for (last = first; last < String + Length; ++last) { - if (*last == '\012') { - if (*(last - 1) == '\015') - *(last - 1) = '\0'; - - *last++ = '\0'; - Dprintf("IN: |%s|\n", first); - Offset = last - String; - return first; - } - } - return NULL; -} - -const cChannel *ChannelFromString(const char *String, int *Apid) { - const cChannel *channel = NULL; - char *string = strdup(String); - char *ptr, *end; - int apididx = 0; - - if ((ptr = strrchr(string, '+')) != NULL) { - *(ptr++) = '\0'; - apididx = strtoul(ptr, &end, 10); - Dprintf("found apididx: %d\n", apididx); - } - - if (isnumber(string)) { - int temp = strtol(String, NULL, 10); - if (temp >= 1 && temp <= Channels.MaxNumber()) - channel = Channels.GetByNumber(temp); - } else { - channel = Channels.GetByChannelID(tChannelID::FromString(string)); - - if (channel == NULL) { - int i = 1; - while ((channel = Channels.GetByNumber(i, 1)) != NULL) { - if (String == channel->Name()) - break; - - i = channel->Number() + 1; - } - } - } - - if (channel != NULL && apididx > 0) { - int apid = 0, index = 1; - - for (int i = 0; channel->Apid(i) != 0; ++i, ++index) { - if (index == apididx) { - apid = channel->Apid(i); - break; - } - } - - if (apid == 0) { - for (int i = 0; channel->Dpid(i) != 0; ++i, ++index) { - if (index == apididx) { - apid = channel->Dpid(i); - break; - } - } - } - - if (Apid != NULL) - *Apid = apid; - } - - free(string); - return channel; -} - -void cStreamdevMenuSetupPage::AddCategory(const char *Title) { - char *buffer = NULL; - - asprintf(&buffer, "--- %s -------------------------------------------------" - "---------------", Title ); - - cOsdItem *item = new cOsdItem(buffer); - free(buffer); - item->SetSelectable(false); - Add(item); -} - -void cStreamdevMenuSetupPage::AddBoolEdit(const char *Title, int &Value) { - Add(new cMenuEditBoolItem(Title, &Value)); -} - -void cStreamdevMenuSetupPage::AddIpEdit(const char *Title, char *Value) { - Add(new cMenuEditIpItem(Title, Value)); -} - -void cStreamdevMenuSetupPage::AddShortEdit(const char *Title, int &Value) { - AddRangeEdit(Title, Value, 0, 65535); -} - -void cStreamdevMenuSetupPage::AddRangeEdit(const char *Title, int &Value, - int Min, int Max) { - Add(new cMenuEditIntItem(Title, &Value, Min, Max)); -} - -void cStreamdevMenuSetupPage::AddSuspEdit(const char *Title, int &Value) { - static const char *SuspendModesTR[sm_Count] = { NULL }; - - if (SuspendModesTR[0] == NULL) { - for (int i = 0; i < sm_Count; ++i) - SuspendModesTR[i] = tr(SuspendModes[i]); - } - - Add(new cMenuEditStraItem(Title, &Value, sm_Count, SuspendModesTR)); -} -void cStreamdevMenuSetupPage::AddTypeEdit(const char *Title, int &Value) { - Add(new cMenuEditStraItem(Title, &Value, st_CountSetup, StreamTypes)); -} +const char cMenuEditIpItem::IpCharacters[] = "0123456789."; cMenuEditIpItem::cMenuEditIpItem(const char *Name, char *Value): cMenuEditItem(Name) { -- cgit v1.2.3