コード例 #1
0
void CLink::Load(CProfINIFile & SavePF)
  {
  if (1)
    return;
  
  CString Line, V;
  Line=SavePF.RdStr("Links", m_sTag, "");
  if (Line.GetLength()>0)
    {
    int iStart=0;
    int lLink = SafeAtoL(Line.Tokenize(",", iStart));
    //int lDbg  = SafeAtoL(Line.Tokenize(",", iStart));
    int lHold = SafeAtoL(Line.Tokenize(",", iStart));
    V=Line.Tokenize("'", iStart);
    
    //m_bSltDbgOn=lDbg!=0;
    m_State.m_bHold=lHold!=0;

    CFullValue FV(OPC_QUALITY_GOOD);
    StringToVariant(Type(), V, FV, false);
    gs_SlotMngr.AppendChange(eCSD_File, -1, eCSD_Link, m_lLink, -1/*gs_SlotMngr.GetTransactionID()*/, FV, NULL, true);
    }
  };
コード例 #2
0
ファイル: pgntags.c プロジェクト: zbrad/xboard-1
/* Parse PGN tags; returns 0 for success or error number
 */
int
ParsePGNTag (char *tag, GameInfo *gameInfo)
{
    char *name, *value, *p, *oldTags;
    int len;
    int success;

    name = tag;
    while (!isalpha(*name) && !isdigit(*name)) {
	name++;
    }
    p = name;
    while (*p != ' ' && *p != '\t' && *p != '\n') {
	p++;
    }
    *p = NULLCHAR;
    value = strchr(p + 1, '"') + 1;
    p = strrchr(value, '"');
    *p = NULLCHAR;

    if (StrCaseCmp(name, "Event") == 0) {
	success = StrSavePtr(value, &gameInfo->event) != NULL;
    } else if (StrCaseCmp(name, "Site") == 0) {
	success = StrSavePtr(value, &gameInfo->site) != NULL;
    } else if (StrCaseCmp(name, "Date") == 0) {
	success = StrSavePtr(value, &gameInfo->date) != NULL;
    } else if (StrCaseCmp(name, "Round") == 0) {
	success = StrSavePtr(value, &gameInfo->round) != NULL;
    } else if (StrCaseCmp(name, "White") == 0) {
	success = StrSavePtr(value, &gameInfo->white) != NULL;
    } else if (StrCaseCmp(name, "Black") == 0) {
	success = StrSavePtr(value, &gameInfo->black) != NULL;
    }
    /* Fold together the various ways of denoting White/Black rating */
    else if ((StrCaseCmp(name, "WhiteElo")==0) ||
	     (StrCaseCmp(name, "WhiteUSCF")==0) ) {
      success = TRUE;
      gameInfo->whiteRating = atoi( value );
    } else if ((StrCaseCmp(name, "BlackElo")==0) ||
	       (StrCaseCmp(name, "BlackUSCF")==0)) {
      success = TRUE;
      gameInfo->blackRating = atoi( value );
    }
    else if (StrCaseCmp(name, "Result") == 0) {
	if (strcmp(value, "1-0") == 0)
	    gameInfo->result = WhiteWins;
	else if (strcmp(value, "0-1") == 0)
	    gameInfo->result = BlackWins;
	else if (strcmp(value, "1/2-1/2") == 0)
	    gameInfo->result = GameIsDrawn;
	else
	    gameInfo->result = GameUnfinished;
	success = TRUE;
    } else if (StrCaseCmp(name, "TimeControl") == 0) {
//	int tc, mps, inc = -1;
//	if(sscanf(value, "%d/%d", &mps, &tc) == 2 || )
	success = StrSavePtr(value, &gameInfo->timeControl) != NULL;
    } else if (StrCaseCmp(name, "FEN") == 0) {
	success = StrSavePtr(value, &gameInfo->fen) != NULL;
    } else if (StrCaseCmp(name, "SetUp") == 0) {
	/* ignore on input; presence of FEN governs */
	success = TRUE;
    } else if (StrCaseCmp(name, "Variant") == 0) {
        /* xboard-defined extension */
	success = StrSavePtr(value, &gameInfo->variantName) != NULL;
        if(*value && strcmp(value, engineVariant)) // keep current engine-defined variant if it matches
            gameInfo->variant = StringToVariant(value);
    } else if (StrCaseCmp(name, "VariantMen") == 0) {
        /* for now ignore this tag, as we have no method yet */
        /* for assigning the pieces to XBoard pictograms     */
        success = TRUE;
    } else if (StrCaseCmp(name, PGN_OUT_OF_BOOK) == 0) {
        /* [AS] Out of book annotation */
        success = StrSavePtr(value, &gameInfo->outOfBook) != NULL;
    } else {
	if (gameInfo->extraTags == NULL) {
	    oldTags = "";
	} else {
	    oldTags = gameInfo->extraTags;
	}
	/* Buffer size includes 7 bytes of space for [ ""]\n\0 */
	len = strlen(oldTags) + strlen(value) + strlen(name) + 7;
	if ((p = (char *) malloc(len))  !=  NULL) {
	    sprintf(p, "%s[%s \"%s\"]\n", oldTags, name, value);
	    if (gameInfo->extraTags != NULL) free(gameInfo->extraTags);
	    gameInfo->extraTags = p;
	    success = TRUE;
	} else {
	    success = FALSE;
	}
    }
    return(success ? 0 : ENOMEM);
}