コード例 #1
0
void getToken(void)
{
	skipBlanks();
	tokenp = tokenString;
	switch (calcCharCode(curChar))
	{
	case CHR_LETTER:
		getWord();
		break;
	case CHR_DIGIT:
		getNumber();
		break;
	case CHR_DQUOTE:
		getString();
		break;
	case CHR_EOF:
		curToken = TKN_EOF;
		break;
	default:
		getSpecial();
		break;
	}
	if (blockFlag)
		crunchToken();
}
コード例 #2
0
ファイル: Move.cpp プロジェクト: rianneogi/Blitzkrieg
bool Move::isEquivalent(Move const& m) const
{
	if(m.getTo()==getTo() && m.getFrom()==getFrom() && m.getSpecial()==getSpecial())
	{
		return true;
	}
	return false;
}
コード例 #3
0
ファイル: scene.cpp プロジェクト: CACamargo/project-obj
void Scene::receiveUseRequest(){
    if(getSpecial() != "chest"){
        QVariant verdict("There's nothing to use here.");
        sendUseVerdict(verdict);
    }
    else{
        relayUseRequest();
    }
}
コード例 #4
0
ファイル: scene.cpp プロジェクト: CACamargo/project-obj
void Scene::receiveTalkRequest(){
    if(getSpecial() != "old man"){
        QVariant verdict("There's no one here to talk to.");
        sendTalkVerdict(verdict);
    }
    else{
        relayTalkRequest();
    }
}
コード例 #5
0
ファイル: KangarooChannel.cpp プロジェクト: caomw/mobot
KangarooStatus KangarooChannel::get(KangarooGetType type, KangarooGetFlags flags)
{
  KangarooTimeout timeout(commandTimeout());
  
  KangarooStatus initialStatus;
  if (getInitialSequenceCodeIfNecessary(timeout, initialStatus)) { return initialStatus; }
  
  return getSpecial(type, flags, timeout);
}
コード例 #6
0
ファイル: Move.cpp プロジェクト: rianneogi/Blitzkrieg
string Move::toString() const
{
	string s = "";
	int i = getSpecial();
	if(i==PIECE_QUEEN) s="Q";
	else if(i==PIECE_KNIGHT) s="N";
	else if(i==PIECE_ROOK) s="R";
	else if(i==PIECE_BISHOP) s="B";
	return (Int2Sq(getFrom()) + Int2Sq(getTo()) + s);
}
コード例 #7
0
ファイル: KangarooChannel.cpp プロジェクト: caomw/mobot
// We return a status only if there is an error.
boolean KangarooChannel::getInitialSequenceCodeIfNecessary(const KangarooTimeout& timeout, KangarooStatus& status)
{
    if (_monitoredSequenceCodeIsReady) { return false; }
    status = getSpecial(KANGAROO_GETP, KANGAROO_GET_SEQUENCE_CODE, timeout);
    if (status.error() < 0) { return true; }

    _monitoredSequenceCode = status.sequenceCode();
    _monitoredSequenceCodeIsReady = true;
    return false;
}
コード例 #8
0
ファイル: isdnbill.c プロジェクト: marschap/isdn4k-utils
static char *beautify(char *num)
{
  auto char   s[BUFSIZ], sx[BUFSIZ], sy[BUFSIZ];
  auto TELNUM number;
  static char res[BUFSIZ];


  if (*num)
    normalizeNumber(num, &number, TN_ALL);
  else {
    sprintf(res, "%*s", -COUNTRYLEN, "UNKNOWN");
    return(res);
  } /* else */

  if (*number.msn)
    sprintf(sx, "%s%s%s", number.area, (*number.area ? "/" : ""), number.msn);
  else
    strcpy(sx, number.area);

  if (*number.country && strcmp(number.country, mycountry))
    sprintf(s, "%s %s", number.country, sx);
  else
    sprintf(s, "%s%s", (*number.country ? "0" : ""), sx);

  *sy = 0;

  if (getSpecial(num))
    sprintf(sy, "%s", getSpecialName(num));
  else {
    if (*number.country && strcmp(number.country, mycountry))
      sprintf(sy, "%s", number.scountry);
    else if (*number.scountry && strcmp(number.country, mycountry))
      sprintf(sy, "%s", number.scountry);

    if (*number.sarea) {
      if (*sy)
        strcat(sy, ", ");

      strcat(sy, number.sarea);

    } /* if */

    if (!*sy)
      sprintf(sy, "???");
  } /* else */


  sprintf(sx, "%s, %s", s, sy);
  sprintf(res, "%*s", -COUNTRYLEN, sx);
  res[COUNTRYLEN] = 0; /* clipping */

  return(res);
} /* beautify */
コード例 #9
0
// End of Queue routines
// -------------------------------------------------------------------
void Scanner::nextTokenInternal()
{
    // check if a token has been pushed back into the token stream, if so use it first
    // I think I should get rid of this code, use queue methods instead
    if (previousToken.tokenCode != CodeTypes::tEmptyToken)
    {
        ftoken = previousToken.tokenCode;
        tokenString = previousToken.tokenString;
        tokenDouble = previousToken.tokenDouble;
        tokenInteger = previousToken.tokenInteger;
        previousToken.tokenCode = CodeTypes::tEmptyToken;
        return;
    }

    // Check if there is anything in the token queue, if so get the item
    // from the queue and exit. If not, read as normal from the stream.
    // Checking the queue before reading from the stream can be turned off and on
    // by setting the FromQueue Flag.
    if(FromQueue)
    {
        if(!IsQueueEmpty())
        {
            getTokenFromQueue();
            return;
        }
    }

    skipBlanks();
    tokenString = "";

    TCharCode::TCharCode code = FCharTable[fch];
    switch(code)
    {
        case TCharCode::cLETTER:
        case TCharCode::cUNDERSCORE:
            getWord();
            break;
        case TCharCode::cDIGIT:
            getNumber();
            break;
        case TCharCode::cDOUBLEQUOTE:
            getString();
            break;
        case TCharCode::cETX:
            ftoken = CodeTypes::tEndOfStreamToken;
            break;
        default:
            getSpecial();
            break;
    }
}
コード例 #10
0
ファイル: Move.cpp プロジェクト: rianneogi/Blitzkrieg
bool Move::operator<(Move const& m) const
{
	int sp = getSpecial();
	int msp = m.getSpecial();
	if(sp==PIECE_KNIGHT || sp==PIECE_ROOK || sp==PIECE_BISHOP || msp==PIECE_QUEEN || msp==PIECE_KING || msp==PIECE_PAWN)
	{
		return true;
	}
	else if(sp==PIECE_QUEEN || sp==PIECE_KING || sp==PIECE_PAWN || msp==PIECE_KNIGHT || msp==PIECE_ROOK || msp==PIECE_BISHOP)
	{
		return false;
	}
	int c = getCapturedPiece();
	int mc = m.getCapturedPiece();
	int cap = CapturedPiecePriority[c];
	int mcap = CapturedPiecePriority[mc];
	if(cap<mcap)
	{
		return true;
	}
	else if(cap>mcap)
	{
		return false;
	}
	else
	{
		int mov = MovingPiecePriority[c][getMovingPiece()];
		int mmov = MovingPiecePriority[mc][m.getMovingPiece()];
		if(mov<mmov)
		{
			return true;
		}
		else if(mmov>mov)
		{
			return false;
		}
		else
		{
			if(ToPriority[getTo()]<ToPriority[m.getTo()])
			{
				return true;
			}
			else
				return false;
		}
	}
	return false;
}
コード例 #11
0
ファイル: ChrsGrid.cpp プロジェクト: demon90s/CharCrush
void ChrsGrid::crushLastChr()
{
	//得到消除后,应该生成的特殊类型
	int special_type = getSpecial(m_SelectedChrs.size() - 1);

	auto last_chr = m_SelectedChrs.back();
	if (special_type != 0)
	{
		auto new_chr = createAChr(last_chr->getX(), last_chr->getY());
		new_chr->setSpecial(special_type);
		m_ChrsBox[last_chr->getX()][last_chr->getY()] = new_chr;

		//进入动作,完成后在添加新元素,开始掉落
		new_chr->setScale(0.01);
		auto scalebigger = ScaleTo::create(0.1, 1.2);
		auto scalesmaller = ScaleTo::create(0.2, 1);
		auto call = CallFunc::create([this]() {
			//清空临时已选汉字集合, 更改主界面的letter label的显示
			m_SelectedChrs.clear();	
			getGameScene()->setLetterLabel(getStringFromChrs(&m_SelectedChrs), false);

			//根据阵列空余添加新汉字元素至新汉字盒子,位于顶部,等待掉落
			addNewChrs();

			//使汉字掉落,同时开启掉落状态捕捉函数,掉落完后判断步数是否结束
			dropChrs();
			schedule(schedule_selector(ChrsGrid::onChrsDropping), 0.1);
		});
		auto action = Sequence::create(scalebigger, scalesmaller, call, nullptr);
		new_chr->runAction(action);
	}
	else
	{
		//清空临时已选汉字集合, 更改主界面的letter label的显示
		m_SelectedChrs.clear();	
		getGameScene()->setLetterLabel(getStringFromChrs(&m_SelectedChrs), false);

		//根据阵列空余添加新汉字元素至新汉字盒子,位于顶部,等待掉落
		addNewChrs();

		//使汉字掉落,同时开启掉落状态捕捉函数,掉落完后判断步数是否结束
		dropChrs();
		schedule(schedule_selector(ChrsGrid::onChrsDropping), 0.1);
	}
}
コード例 #12
0
ファイル: Scanner.cpp プロジェクト: CSE220Team21/Lab5
Token* Scanner::getToken()
{
    char ch = '\0'; //This can be the current character you are examining during scanning.
    char token_string[MAX_TOKEN_STRING_LENGTH] = {'\0'}; //Store your token here as you build it.
    char *token_ptr = token_string; //write some code to point this to the beginning of token_string
    Token *new_token;
    
/*    new_token->setType(NO_TYPE);          */
    //1.  Skip past all of the blanks
    if (line_ptr == NULL)
    {
        line_ptr = source_line;
    }
    skipBlanks(source_line);
    ch = *line_ptr;
    
    //2.  figure out which case you are dealing with LETTER, DIGIT, QUOTE, EOF, or special, by examining ch
    switch (char_table[ch])
    {//3.  Call the appropriate function to deal with the cases in 2.
        case LETTER:
        	new_token = new Identifier();
            getWord(token_string, token_ptr, new_token);
            break;
        case DIGIT:
            new_token = getNumber(token_string, token_ptr);
            break;
        case QUOTE:
        	new_token = new EpicQuotes();
            getString(token_string, token_ptr, new_token);
            break;
        case EOF_CODE:
        	new_token = new Token();
            new_token->setCode(END_OF_FILE);
            break;
        default:
        	new_token = new Token();
            getSpecial(token_string, token_ptr, new_token);
            break;
    }
    
    return new_token; //What should be returned here?
}
コード例 #13
0
ファイル: Scanner.cpp プロジェクト: rgonza26/Lab5
Token* Scanner::getToken()
{
    char ch = '\0'; //This can be the current character you are examining during scanning.
    char token_string[MAX_TOKEN_STRING_LENGTH] = {'\0'}; //Store your token here as you build it.
    char *token_ptr = token_string; //write some code to point this to the beginning of token_string
    //Token *new_token = new Token();	//old remove
    
    //new_token->setType(NO_TYPE);	//old remove
    //1.  Skip past all of the blanks
    if (line_ptr == NULL)
    {
        line_ptr = source_line;
    }
    skipBlanks(source_line);
    ch = *line_ptr;
    
    //2.  figure out which case you are dealing with LETTER, DIGIT, QUOTE, EOF, or special, by examining ch
    switch (char_table[ch])
    {//3.  Call the appropriate function to deal with the cases in 2.
        case LETTER:
            return getWord(token_string, token_ptr);
            break;
        case DIGIT:
            return getNumber(token_string, token_ptr);
            break;
        case QUOTE:
            return getString(token_string, token_ptr);
            break;
        case EOF_CODE:
			{
				String* new_eof_token = new String();
				new_eof_token->setCode(END_OF_FILE);
				return new_eof_token;
				break;
			}
        default:
            return getSpecial(token_string, token_ptr);
            break;
    }
	assert(!"error: invalid token type");
}
コード例 #14
0
ファイル: KangarooChannel.cpp プロジェクト: caomw/mobot
// Wait for a response, to ensure the packet was received at all.
// Internally generated errors (like timeouts) have negative numbers, so we pass them along.
// For any received error, we've failed to update if the sequence codes don't match.
boolean KangarooChannel::updateMonitoredResult(const KangarooTimeout& timeout,
                                               boolean acceptRepliesWithStartupSequenceCode)
{
  _monitoredGetResult = getSpecial(_monitoredGetType, _monitoredGetFlags, timeout);
  
  if (_monitoredGetResult.error() < 0)
  {
    return true;
  }
  
  if (_monitoredGetResult.sequenceCode() == _monitoredSequenceCode)
  {
    return true;
  }
  
  if (_monitoredGetResult.sequenceCode() == 0 && acceptRepliesWithStartupSequenceCode)
  {
    return true;
  }
  
  return false;
}
コード例 #15
0
ファイル: isdnbill.c プロジェクト: marschap/isdn4k-utils
static void findrate()
{
  auto RATE  Rate;
  auto char *version;


  clearRate(&Rate);
  Rate.start  = c.connect;
  Rate.now    = c.connect + c.duration;
  Rate.prefix = pnum2prefix(c.provider, c.connect);

  Rate.src[0] = number[CALLING].country;
  Rate.src[1] = number[CALLING].area;
  Rate.src[2] = number[CALLING].msn;

  Rate.dst[0] = number[CALLED].country;
  Rate.dst[1] = number[CALLED].area;
  Rate.dst[2] = number[CALLED].msn;

  if (getRate(&Rate, &version) != UNKNOWN) {
    c.zone = Rate.z;

    if (!c.zone && (*number[CALLED].country && strcmp(number[CALLED].country, mycountry)))
      c.zone = AUSLAND;
    else if (getSpecial(c.num[CALLED]))
      c.zone = SONDERRUFNUMMERN;
    else if (c.zone == UNKNOWN)
      c.zone = ELSEWHERE;

    c.compute = Rate.Charge;
  }
  else {
    c.zone = ELSEWHERE;
    c.compute = c.pay;
    sprintf(c.error, " ??? %s", version);
  } /* else */

  zonesum[SUBTOTAL][c.zone].ncalls++;
} /* findrate */
コード例 #16
0
ファイル: isdnbill.c プロジェクト: marschap/isdn4k-utils
static void justify(char *fromnum, char *tonum, TELNUM number)
{
  register char *p1, *p2;
  auto     char  s[BUFSIZ], sx[BUFSIZ], sy[BUFSIZ];


  /* AK:16-Dec-99                                                     */
  /* Hier ist noch ein Bug in normalizeNumber(), Leo!                 */
  /* Bei Sonderrufnummern landet die komplette Nummer in number.area, */
  /* wobei die letzten 2 Digits abgeschnitten sind (fehlen) 	      */

  if (!*number.msn) {
    strcpy(number.msn, c.dialout ? tonum : fromnum);
    *number.area = 0;
  } /* if */

  p1 = numtonam(c.dialout ? CALLED : CALLING, 1);

  if (*number.msn)
    sprintf(sx, "%s%s%s", number.area, (*number.area ? "/" : ""), number.msn);
  else
    strcpy(sx, number.area);

  if (*number.country && strcmp(number.country, mycountry))
    sprintf(s, "%s %s", number.country, sx);
  else
    sprintf(s, "%s%s", (*number.country ? "0" : ""), sx);

  p2 = msnsum[SUBTOTAL][c.si1][c.ihome].alias;

  printf("%12s %s %-21s",
    p2 ? p2 : fromnum,
    (c.dialout ? "->" : "<-"),
    p1 ? clip(p1, 20) : s);

  *s = 0;

  if (*tonum && getSpecial(tonum))
    sprintf(s, "%s", getSpecialName(tonum));
  else {
    if (*number.country && strcmp(number.country, mycountry))
      sprintf(s, "%s", number.scountry);
    else if (*number.scountry && strcmp(number.country, mycountry))
      sprintf(s, "%s", number.scountry);

    if (*number.sarea) {
      if (*s)
        strcat(s, ", ");

      strcat(s, number.sarea);

      if (c.dialout) {
        sprintf(sy, ",%d", c.zone);
        strcat(s, sy);
      } /* if */
    } /* if */

    if (!*s && *tonum)
      sprintf(s, "???");
  } /* else */

  s[COUNTRYLEN] = 0; /* clipping */

  sprintf(c.country, "%-*s", COUNTRYLEN, s);
} /* justify */
コード例 #17
0
ファイル: xml.c プロジェクト: BIllli/mget
static void parseXML(const char *dir, XML_CONTEXT *context)
{
	const char *tok;
	char directory[256] = "";
	size_t pos = 0;

	if (!(context->hints & XML_HINT_HTML)) {
		pos = strlcpy(directory, dir, sizeof(directory));
		if (pos >= sizeof(directory)) pos = sizeof(directory) - 1;
	}

	do {
		getContent(context, directory);
		if (context->token_len)
			debug_printf("%s=%.*s\n", directory, (int)context->token_len, context->token);

		if (!(tok = getToken(context))) return;
		// debug_printf("A Token '%.*s'\n", (int)context->token_len, context->token);

		if (context->token_len == 1 && *tok == '<') {
			// get element name and add it to directory
			int flags = XML_FLG_BEGIN;

			if (!(tok = getToken(context))) return;
			// debug_printf("A2 Token '%.*s'\n", (int)context->token_len, context->token);

			if (!(context->hints & XML_HINT_HTML)) {
				if (!pos || directory[pos - 1] != '/')
					snprintf(&directory[pos], sizeof(directory) - pos, "/%.*s", (int)context->token_len, tok);
				else
					snprintf(&directory[pos], sizeof(directory) - pos, "%.*s", (int)context->token_len, tok);
			} else {
				// snprintf(directory, sizeof(directory), "%.*s", (int)context->token_len, tok);
				if (context->token_len < sizeof(directory)) {
					strncpy(directory, tok, context->token_len);
					directory[context->token_len] = 0;
				} else {
					strncpy(directory, tok, sizeof(directory) - 1);
					directory[sizeof(directory) - 1] = 0;
				}
			}

			while ((tok = getToken(context))) {
				// debug_printf("C Token %.*s\n", (int)context->token_len, context->token);
				if (context->token_len == 2 && !strncmp(tok, "/>", 2)) {
					if (context->callback)
						context->callback(context->user_ctx, flags | XML_FLG_END, directory, NULL, NULL, 0, 0);
					break; // stay in this level
				} else if (context->token_len == 1 && *tok == '>') {
					if (context->callback)
						context->callback(context->user_ctx, flags | XML_FLG_CLOSE, directory, NULL, NULL, 0, 0);
					if (context->hints & XML_HINT_HTML) {
						if (!mget_strcasecmp_ascii(directory, "script")) {
							// special HTML <script> content parsing
							// see http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#the-script-element
							// 4.3.1.2 Restrictions for contents of script elements
							debug_printf("*** need special <script> handling\n");
							getScriptContent(context);
							if (context->token_len)
								debug_printf("%s=%.*s\n", directory, (int)context->token_len, context->token);
						}
					} else
						parseXML(directory, context); // descend one level
					break;
				} else {
//					snprintf(attribute, sizeof(attribute), "%.*s", (int)context->token_len, tok);
					char attribute[context->token_len + 1];
					strncpy(attribute, tok, context->token_len);
					attribute[context->token_len] = 0;

					if (getValue(context) == 0) return;
					if (context->token_len) {
						debug_printf("%s/@%s=%.*s\n", directory, attribute, (int)context->token_len, context->token);
						if (context->callback)
							context->callback(context->user_ctx, flags | XML_FLG_ATTRIBUTE, directory, attribute, context->token, context->token_len, context->token - context->buf);
					} else {
						debug_printf("%s/@%s\n", directory, attribute);
						if (context->callback)
							context->callback(context->user_ctx, flags | XML_FLG_ATTRIBUTE, directory, attribute, NULL, 0, 0);
					}
					flags = 0;
				}
			}
			directory[pos] = 0;
		} else if (context->token_len == 2) {
			if (!strncmp(tok, "</", 2)) {
				// ascend one level
				// cleanup - get name and '>'
				if (!(tok = getToken(context))) return;
				// debug_printf("X Token %s\n",tok);
				if (context->callback) {
					if (!(context->hints & XML_HINT_HTML))
						context->callback(context->user_ctx, XML_FLG_END, directory, NULL, NULL, 0, 0);
					else {
						char tag[context->token_len + 1]; // we need to \0 terminate tok
						memcpy(tag, tok, context->token_len);
						tag[context->token_len] = 0;
						context->callback(context->user_ctx, XML_FLG_END, tag, NULL, NULL, 0, 0);
					}
				}
				if (!(tok = getToken(context))) return;
				// debug_printf("Y Token %s\n",tok);
				if (!(context->hints & XML_HINT_HTML))
					return;
				else
					continue;
			} else if (!strncmp(tok, "<?", 2)) { // special info - ignore
				getProcessing(context);
				debug_printf("%s=<?%.*s?>\n", directory, (int)context->token_len, context->token);
				continue;
			} else if (!strncmp(tok, "<!", 2)) {
				getSpecial(context);
				debug_printf("%s=<!%.*s>\n", directory, (int)context->token_len, context->token);
			}
		} else if (context->token_len == 4 && !strncmp(tok, "<!--", 4)) { // comment - ignore
			getComment(context);
			debug_printf("%s=<!--%.*s-->\n", directory, (int)context->token_len, context->token);
			continue;
		}
	} while (tok);
}
コード例 #18
0
ファイル: isdnbill.c プロジェクト: marschap/isdn4k-utils
int main(int argc, char *argv[], char *envp[])
{
  register char    *pl, *pr, *p, x;
#ifdef AK
  auto     FILE    *f = fopen("/www/log/isdn.log", "r");
#else
  auto     FILE    *f = fopen("/var/log/isdn.log", "r");
#endif
  auto     char     s[BUFSIZ], sx[BUFSIZ];
  auto     int      i, l, col, day, lday = UNKNOWN, month, lmonth = UNKNOWN;
  auto     double   dur;
  auto     char    *version;
  auto     char    *myname = basename(argv[0]);
  auto     int      opt, go, s0, indent;
  auto	   time_t   now;
  auto 	   struct   tm *tm;


  if (f != (FILE *)NULL) {

    while ((opt = getopt(argc, argv, options)) != EOF)
      switch (opt) {
        case 'n' : onlynumbers++;
                   break;

        case 'v' : verbose = atoi(optarg);
                   break;

        case 'V' : print_version(myname);
                   exit(0);

        case 'i' : showincoming++;
                   break;

        case 'o' : showoutgoing++;
                   break;

        case 'e' : showerrors++;
                   break;

        case 'a' : showincoming = showoutgoing = showerrors = 1;
                   break;

        case 'N' : strcpy(onlythis, optarg);
                   break;

        case 'm' : netto++;
             	   break;

        case 'f' : force++;
             	   break;

        case 't' : onlytoday++;
             	   break;

        case 'I' : onlyInternal++;
             	   break;

        case 'E' : onlyExternal++;
             	   break;

        case '?' : printf(usage, argv[0], argv[0], options);
                   return(1);
      } /* switch */

    if (!showincoming && !showoutgoing && !showerrors) {
      printf("This makes no sense! You must specify -i, -o or -e\n");
      printf("\t-a    -> alle Verbindungen anzeigen i.e. \"-ioe\"\n");
      printf("\t      -> show all connections\n");
      printf("\t-e    -> nichtzustandegekommene Verbindungen anzeigen\n");
      printf("\t      -> show incomplete calls\n");
      printf("\t-f    -> Verbindungsentgeld _immer_ neu berechnen\n");
      printf("\t      -> recalculate costs _always_\n");
      printf("\t-i    -> reinkommende Verbindungen anzeigen\n");
      printf("\t      -> show incoming calls\n");
      printf("\t-m    -> ohne MwSt anzeigen\n");
      printf("\t      -> prices without VAT\n");
      printf("\t-n    -> _nicht_ anstelle Rufnummern Alias-Bezeichnungen anzeigen\n");
      printf("\t      -> do _not_ replace numbers with aliases\n");
      printf("\t-o    -> rausgehende Verbindungen anzeigen\n");
      printf("\t      -> show outgoing calls\n");
      printf("\t-t    -> nur die heutigen Verbindungen anzeigen\n");
      printf("\t      -> show only current connections\n");
      printf("\t-vn   -> Verbose Level\n");
      printf("\t-Nnnn -> nur Verbindungen mit _dieser_ Rufnummer anzeigen\n");
      printf("\t      -> show only calls with the specified number\n");
      printf("\t-I    -> nur Verbindungen am Internen S0-Bus anzeigen\n");
      printf("\t      -> show only calls on the internal S0 bus\n");
      printf("\t-E    -> nur Verbindungen am Externen S0-Bus anzeigen\n");
      printf("\t      -> show only calls on the external S0 bus\n");
      printf("\t-V    -> Version anzeigen\n");
      printf("\t      -> show version\n");

      return(1);
    } /* if */

    *home = 0;

    interns0 = 3;

    set_print_fct_for_tools(print_in_modules);

    if (!readconfig(myname)) {

      initHoliday(holifile, &version);

      if (verbose)
        fprintf(stderr, "%s\n", version);

      initDest(destfile, &version);

      if (verbose)
        fprintf(stderr, "%s\n", version);

      initRate(rateconf, ratefile, zonefile, &version);

      if (verbose)
        fprintf(stderr, "%s\n", version);

      memset(&msnsum, 0, sizeof(msnsum));
      memset(&provsum, 0, sizeof(provsum));
      memset(&zonesum, 0, sizeof(zonesum));

      partner[0] = (PARTNER *)calloc(knowns, sizeof(PARTNER));
      partner[1] = (PARTNER *)calloc(knowns, sizeof(PARTNER));

      time(&now);
      tm = localtime(&now);
      tm->tm_sec = tm->tm_min = tm->tm_hour = 0;
      now = mktime(tm);

      while (fgets(s, BUFSIZ, f)) {
        pl = s;
        col = 0;

        memset(&c, 0, sizeof(c));

        while ((pr = strchr(pl, '|'))) {
          memcpy(sx, pl, (l = (pr - pl)));
          sx[l] = 0;
          pl = pr + 1;

          switch (col++) {
            case  0 :                               break;

            case  1 : deb(sx);
                      strcpy(c.num[CALLING], sx);
                      break;

            case  2 : deb(sx);
                      strcpy(c.num[CALLED], sx);
                      break;

            case  3 : dur = atoi(sx);               break;

            case  4 : c.duration = atol(sx) / 100;
                      break;

            case  5 : c.connect = atol(sx);         break;
            case  6 : c.units = atoi(sx);           break;
            case  7 : c.dialout = *sx == 'O';       break;
            case  8 : c.cause = atoi(sx);           break;
            case  9 : c.ibytes = atoi(sx);          break;
            case 10 : c.obytes = atoi(sx);          break;
            case 11 : strcpy(c.version, sx);        break;
            case 12 : c.si1 = atoi(sx);             break;
            case 13 : c.si2 = atoi(sx);             break;
            case 14 : c.currency_factor = atof(sx); break;
            case 15 : strcpy(c.currency, sx);       break;
            case 16 : c.pay = atof(sx);             break;
            case 17 : c.provider = atoi(sx);        break;
            case 18 :                               break;
          } /* switch */

        } /* while */


        /* Repair wrong entries from older (or current?) isdnlog-versions ... */

        if (abs((int)dur - (int)c.duration) > 1) {
          if (verbose)
            fprintf(stderr, "REPAIR: Duration %f -> %f\n", c.duration, dur);

          c.duration = dur;
        } /* if */

        if (!memcmp(c.num[CALLED], "+4910", 5)) {
          p = c.num[CALLED] + 7;
          x = *p;
          *p = 0;

          c.provider = atoi(c.num[CALLED] + 5);

          *p = x;

          if (strlen(c.num[CALLED]) > 7)
            memmove(c.num[CALLED] + 3, c.num[CALLED] + 8, strlen(c.num[CALLED]) - 7);

          if (verbose)
            fprintf(stderr, "REPAIR: Provider=%d\n", c.provider);
        } /* if */

        if (!c.provider || (c.provider == UNKNOWN)) {
          if (verbose)
            fprintf(stderr, "REPAIR: Provider %d -> %d\n", c.provider, preselect);

          c.provider = preselect;
        } /* if */

        if (c.dialout && (strlen(c.num[CALLED]) > 3) && !getSpecial(c.num[CALLED])) {
          sprintf(s, "0%s", c.num[CALLED] + 3);

          if (getSpecial(s)) {
            if (verbose)
              fprintf(stderr, "REPAIR: Callee %s -> %s\n", c.num[CALLED], s);

            strcpy(c.num[CALLED], s);
          } /* if */
        } /* if */

        if (!c.dialout && (strlen(c.num[CALLING]) > 3) && !getSpecial(c.num[CALLING])) {
          sprintf(s, "0%s", c.num[CALLING] + 3);

          if (getSpecial(s)) {
            if (verbose)
              fprintf(stderr, "REPAIR: Caller %s -> %s\n", c.num[CALLING], s);

            strcpy(c.num[CALLING], s);
          } /* if */
        } /* if */


        go = 0;

        if (showoutgoing && c.dialout && c.duration)
          go++;

        if (showincoming && !c.dialout && c.duration)
          go++;

        if (showerrors && !c.duration)
          go++;

        if (*onlythis && strstr(c.num[CALLING], onlythis) == NULL &&
           	      	 strstr(c.num[CALLED], onlythis) == NULL)
          go = 0;

        if (onlytoday && c.connect < now)
          go = 0;

        s0 = 0; /* Externer S0 */

        if (c.dialout && (strlen(c.num[CALLING]) < interns0))
          s0 = 1; /* Interner S0-Bus */

        if (!c.dialout && (strlen(c.num[CALLED]) < interns0))
          s0 = 1; /* Interner S0-Bus */

        if (onlyInternal && !s0)
          go = 0;

        if (onlyExternal && s0)
          go = 0;


        if (go) {
          when(s, &day, &month);

          if (lmonth == UNKNOWN)
            lmonth = month;
          else if (month != lmonth) {
            total(SUBTOTAL);
            lmonth = month;
          } /* if */

          if (lday == UNKNOWN)
            lday = day;
          else if (day != lday) {
            printf("\n");
            lday = day;
          } /* else */

          printf("%s%s ", s, timestr(c.duration));

	  if (*c.num[CALLING])
            normalizeNumber(c.num[CALLING], &number[CALLING], TN_ALL);
          else {
	    memset(&number[CALLING], 0, sizeof(TELNUM));
            strcpy(number[CALLING].msn, "UNKNOWN");
          } /* else */

	  if (*c.num[CALLED])
            normalizeNumber(c.num[CALLED], &number[CALLED], TN_ALL);
          else {
	    memset(&number[CALLED], 0, sizeof(TELNUM));
            strcpy(number[CALLED].msn, "UNKNOWN");
          } /* else */

          findme();

          indent = 11 + strlen(c.currency);

          if (c.dialout) {

            findrate();

            msnsum[SUBTOTAL][c.si1][c.ihome].ncalls++;

            justify(number[CALLING].msn, c.num[CALLED], number[CALLED]);

            provsum[SUBTOTAL][c.provider].ncalls++;

            strcpy(s, getProvider(pnum2prefix(c.provider, c.connect)));
            s[PROVLEN] = 0;

            if (c.provider < 100)
              sprintf(c.sprovider, "  010%02d:%-*s", c.provider, PROVLEN, s);
            else if (c.provider < 200)
              sprintf(c.sprovider, "0100%03d:%-*s", c.provider - 100, PROVLEN, s);
            else
              sprintf(c.sprovider, "01900%02d:%-*s", c.provider - 200, PROVLEN, s);


            if (c.duration) {

#if 0 // Berechnung, um wieviel es mit AktivPlus der DTAG billiger waere -- stimmt irgendwie eh nicht mehr ...

              if ((preselect == DTAG) && ((c.zone == 1) || (c.zone == 2))) {
                auto struct tm *tm = localtime(&c.connect);
                auto int        takte;
                auto double     price;


                takte = (c.duration + 59) / 60;

                if ((tm->tm_wday > 0) && (tm->tm_wday < 5)) {   /* Wochentag */
                  if ((tm->tm_hour > 8) && (tm->tm_hour < 18))  /* Hauptzeit */
                    price = 0.06;
                  else
                    price = 0.03;
                }
                else                                            /* Wochenende */
                  price = 0.03;

                c.aktiv = takte * price;

                msnsum[SUBTOTAL][c.si1][c.ihome].aktiv += c.aktiv;
                provsum[SUBTOTAL][c.provider].aktiv += c.aktiv;
                zonesum[SUBTOTAL][c.zone].aktiv += c.aktiv;
              } /* if */
#endif

              if (c.pay < 0.0) { /* impossible! */
                c.pay = c.compute;
                c.computed++;
              } /* if */

              if (force || fabs(c.pay - c.compute) > 1.00) {
                c.pay = c.compute;
                c.computed++;
              } /* if */

              if (netto)
                c.pay = c.pay * 100.0 / 116.0;

              if (c.pay)
                printf("%12s%s ", printRate(c.pay), c.computed ? "*" : " ");
              else
                printf("%*s", indent, "");

              printf("%s%s%s", c.country, c.sprovider, c.error);

#if 0
              if (c.aktiv)
                printf(" AktivPlus - %13s", printRate(c.pay - c.aktiv));
#endif

              msnsum[SUBTOTAL][c.si1][c.ihome].pay += c.pay;
              msnsum[SUBTOTAL][c.si1][c.ihome].duration += c.duration;
              msnsum[SUBTOTAL][c.si1][c.ihome].compute += c.compute;
              msnsum[SUBTOTAL][c.si1][c.ihome].ibytes += c.ibytes;
              msnsum[SUBTOTAL][c.si1][c.ihome].obytes += c.obytes;

              provsum[SUBTOTAL][c.provider].pay += c.pay;
              provsum[SUBTOTAL][c.provider].duration += c.duration;
              provsum[SUBTOTAL][c.provider].compute += c.compute;
              provsum[SUBTOTAL][c.provider].ibytes += c.ibytes;
              provsum[SUBTOTAL][c.provider].obytes += c.obytes;

              zonesum[SUBTOTAL][c.zone].pay += c.pay;
              zonesum[SUBTOTAL][c.zone].duration += c.duration;
              zonesum[SUBTOTAL][c.zone].compute += c.compute;
              zonesum[SUBTOTAL][c.zone].ibytes += c.ibytes;
              zonesum[SUBTOTAL][c.zone].obytes += c.obytes;
            }
            else {
              printf("%*s%s%s", indent, "", c.country, c.sprovider);

              if ((c.cause != 0x1f) && /* Normal, unspecified */
                  (c.cause != 0x10))   /* Normal call clearing */
                printf(" %s", qmsg(TYPE_CAUSE, VERSION_EDSS1, c.cause));

              if ((c.cause == 0x22) || /* No circuit/channel available */
                  (c.cause == 0x2a) || /* Switching equipment congestion */
                  (c.cause == 0x2f))   /* Resource unavailable, unspecified */
                provsum[SUBTOTAL][c.provider].failed++;
            } /* else */
          }
          else { /* Dialin: */
            justify(number[CALLED].msn, c.num[CALLING], number[CALLING]);
            printf("%*s%s%s", indent, "", c.country, c.sprovider);
          } /* else */


          if (c.known[OTHER] == UNKNOWN) {
            l = UNKNOWN;

            for (i = 0; i < nunknown[c.dialout]; i++) {
              if (!strcmp(unknown[c.dialout][i].num, c.num[OTHER])) {
                l = i;
                break;
              } /* if */
            } /* for */

            if (l == UNKNOWN) {
              l = nunknown[c.dialout];

              nunknown[c.dialout]++;

              if (!l)
                unknown[c.dialout] = (PARTNER *)malloc(sizeof(PARTNER));
              else
                unknown[c.dialout] = (PARTNER *)realloc(unknown[c.dialout], sizeof(PARTNER) * nunknown[c.dialout]);

              memset(&unknown[c.dialout][l], 0, sizeof(PARTNER));
            } /* if */

            strcpy(unknown[c.dialout][l].num, c.num[OTHER]);

            unknown[c.dialout][l].ihome = c.ihome;
            unknown[c.dialout][l].ncalls++;
            unknown[c.dialout][l].pay += c.pay;
            unknown[c.dialout][l].duration += c.duration;
            unknown[c.dialout][l].compute += c.compute;
            unknown[c.dialout][l].ibytes += c.ibytes;
            unknown[c.dialout][l].obytes += c.obytes;
          }
          else {
            strcpy(partner[c.dialout][c.known[OTHER]].num, c.num[OTHER]);
            partner[c.dialout][c.known[OTHER]].ncalls++;
            partner[c.dialout][c.known[OTHER]].pay += c.pay;
            partner[c.dialout][c.known[OTHER]].duration += c.duration;
            partner[c.dialout][c.known[OTHER]].compute += c.compute;
            partner[c.dialout][c.known[OTHER]].ibytes += c.ibytes;
            partner[c.dialout][c.known[OTHER]].obytes += c.obytes;
          } /* else */

          printf("\n");

        } /* if */
      } /* while */

      fclose(f);
      total(SUBTOTAL);

      if (!onlytoday)
        total(TOTAL);

      showpartner();

    }
    else
      fprintf(stderr, "%s: Can't read configuration file(s)\n", myname);
  }
  else
    fprintf(stderr, "%s: Can't open \"isdn.log\" file\n", myname);

  return(0);
} /* isdnbill */