VOID ToggleModuleDisabled( BlankerPrefs *Prefs ) { struct FileInfoBlock *Blk; BPTR BlankerLock; BYTE Path[108]; strcpy( Path, Prefs->bp_Dir ); AddPart( Path, Prefs->bp_Blanker, 108 ); if( BlankerLock = Lock( Path, ACCESS_READ )) { if( Blk = AllocDosObject( DOS_FIB, 0L )) { if( Examine( BlankerLock, Blk )) { if( Stricmp( Blk->fib_Comment, "Disabled" )) SetComment( Path, "Disabled" ); else SetComment( Path, "" ); } FreeDosObject( DOS_FIB, Blk ); } UnLock( BlankerLock ); } }
static void gui_download_window_done(struct gui_download_window *dw) { struct dlnode *dln,*dln2 = NULL; struct browser_window *bw; bool queuedl = false; if(!dw) return; bw = dw->bw; if((nsoption_bool(download_notify)) && (dw->result == AMINS_DLOAD_OK)) { Notify(ami_gui_get_app_id(), APPNOTIFY_Title, messages_get("amiDownloadComplete"), APPNOTIFY_PubScreenName, "FRONT", APPNOTIFY_BackMsg, dw->fname, APPNOTIFY_CloseOnDC, TRUE, APPNOTIFY_Text, dw->fname, TAG_DONE); } download_context_destroy(dw->ctx); if((dln = dw->dln)) { dln2 = (struct dlnode *)GetSucc((struct Node *)dln); if((dln!=dln2) && (dln2)) queuedl = true; free(dln->filename); Remove((struct Node *)dln); FreeVec(dln); } FClose(dw->fh); SetComment(dw->fname, dw->url); downloads_in_progress--; DisposeObject(dw->objects[OID_MAIN]); DelObject(dw->node); if(queuedl) { nsurl *url; if (nsurl_create(dln2->node.ln_Name, &url) != NSERROR_OK) { amiga_warn_user("NoMemory", 0); } else { browser_window_navigate(bw, url, NULL, BW_NAVIGATE_DOWNLOAD, NULL, NULL, NULL); nsurl_unref(url); } } ami_try_quit(); /* In case the only window open was this download */ }
nserror gui_window_save_link(struct gui_window *g, nsurl *url, const char *title) { char fname[1024]; STRPTR openurlstring,linkname; struct DiskObject *dobj = NULL; linkname = ASPrintf("Link_to_%s",FilePart(nsurl_access(url))); if(AslRequestTags(savereq, ASLFR_Window, g->shared->win, ASLFR_SleepWindow, TRUE, ASLFR_TitleText,messages_get("NetSurf"), ASLFR_Screen,scrn, ASLFR_InitialFile,linkname, TAG_DONE)) { strlcpy(fname, savereq->fr_Drawer, 1024); AddPart(fname,savereq->fr_File,1024); ami_set_pointer(g->shared, GUI_POINTER_WAIT, false); if(ami_download_check_overwrite(fname, g->shared->win, 0)) { BPTR fh; if((fh = FOpen(fname,MODE_NEWFILE,0))) { /* \todo Should be URLOpen on OS4.1 */ openurlstring = ASPrintf("openurl \"%s\"\n",nsurl_access(url)); FWrite(fh,openurlstring,1,strlen(openurlstring)); FClose(fh); FreeVec(openurlstring); SetComment(fname, nsurl_access(url)); dobj = GetIconTags(NULL,ICONGETA_GetDefaultName,"url", ICONGETA_GetDefaultType,WBPROJECT, TAG_DONE); dobj->do_DefaultTool = "IconX"; PutIconTags(fname,dobj, ICONPUTA_NotifyWorkbench,TRUE, TAG_DONE); FreeDiskObject(dobj); } FreeVec(linkname); } ami_reset_pointer(g->shared); } return NSERROR_OK; }
void KVIdentificationResult::Reset() { // Reset to initial values SetIDType(""); SetComment(""); IDattempted = kFALSE; IDOK = kFALSE; IDcode = -1; Zident = kFALSE; Aident = kFALSE; IDquality = -1; Z = -1; A = -1; PID = -1.0; deltaEpedestal = deltaEpedestal_UNKNOWN; }
void LFGPlayerState::Clear() { rolesMask = LFG_ROLE_MASK_NONE; update = true; m_state = LFG_STATE_NONE; m_flags = LFG_MEMBER_FLAG_NONE | LFG_MEMBER_FLAG_CHARINFO | LFG_MEMBER_FLAG_COMMENT | LFG_MEMBER_FLAG_UNK1 | LFG_MEMBER_FLAG_GROUP | LFG_MEMBER_FLAG_UNK2 | LFG_MEMBER_FLAG_UNK3 | LFG_MEMBER_FLAG_BIND; m_DungeonsList.clear(); m_LockMap.clear(); SetComment("<no comment>"); }
DWORD CTag_Ape::MakeTag(const char *szFileName) { // ID3v1をバックアップ DWORD dwWin32errorCode = _LoadId3Tag(szFileName); if(dwWin32errorCode != ERROR_SUCCESS) { return dwWin32errorCode; } // 現存タグを削除 m_comments.clear(); dwWin32errorCode = _DelTag(szFileName); if(dwWin32errorCode != ERROR_SUCCESS) { return dwWin32errorCode; } // Apeタグを保存 CString strDefaultName = getFileName(CString(szFileName)); SetComment(CTag_Ape::APE_TAG_FIELD_TITLE,strDefaultName); dwWin32errorCode = _SaveApeTagV2(szFileName); if(dwWin32errorCode != ERROR_SUCCESS) { return dwWin32errorCode; } // Id3v1タグを復元 if(m_bHasId3tag && !m_bDoNotSaveId3v1) { _SaveId3TagV1(szFileName); } return ERROR_SUCCESS; }
void AsmInc (const char* Filename, char CommentStart, int IgnoreUnknown) /* Read an assembler include file */ { char Buf[1024]; char* L; const char* Comment; unsigned Line; unsigned Len; long Val; unsigned DVal; int Sign; unsigned Base; unsigned Digits; StrBuf Ident = STATIC_STRBUF_INITIALIZER; /* Try to open the file for reading */ FILE* F = fopen (Filename, "r"); if (F == 0) { Error ("Cannot open asm include file \"%s\": %s", Filename, strerror (errno)); } /* Read line by line, check for NAME = VALUE lines */ Line = 0; while ((L = fgets (Buf, sizeof (Buf), F)) != 0) { /* One more line read */ ++Line; /* Ignore leading white space */ while (IsBlank (*L)) { ++L; } /* Remove trailing whitespace */ Len = strlen (L); while (Len > 0 && IsSpace (L[Len-1])) { --Len; } L[Len] = '\0'; /* If the line is empty or starts with a comment char, ignore it */ if (*L == '\0' || *L == CommentStart) { continue; } /* Read an identifier */ SB_Clear (&Ident); if (IsAlpha (*L) || *L == '_') { SB_AppendChar (&Ident, *L++); while (IsAlNum (*L) || *L == '_') { SB_AppendChar (&Ident, *L++); } SB_Terminate (&Ident); } else { if (!IgnoreUnknown) { Error ("%s(%u): Syntax error", Filename, Line); } continue; } /* Ignore white space */ L = SkipWhitespace (L); /* Check for := or = */ if (*L == '=') { ++L; } else if (*L == ':' && *++L == '=') { ++L; } else { if (!IgnoreUnknown) { Error ("%s(%u): Missing `='", Filename, Line); } continue; } /* Allow white space once again */ L = SkipWhitespace (L); /* A number follows. Read the sign. */ if (*L == '-') { Sign = -1; ++L; } else { Sign = 1; if (*L == '+') { ++L; } } /* Determine the base of the number. Allow $ and % as prefixes for * hex and binary numbers respectively. */ if (*L == '$') { Base = 16; ++L; } else if (*L == '%') { Base = 2; ++L; } else { Base = 10; } /* Decode the number */ Digits = 0; Val = 0; while (IsXDigit (*L) && (DVal = DigitVal (*L)) < Base) { Val = (Val * Base) + DVal; ++Digits; ++L; } /* Must have at least one digit */ if (Digits == 0) { if (!IgnoreUnknown) { Error ("%s(%u): Error in number format", Filename, Line); } continue; } /* Skip whitespace again */ L = SkipWhitespace (L); /* Check for a comment */ if (*L == CommentStart) { Comment = SkipWhitespace (L+1); if (*Comment == '\0') { Comment = 0; } } else { Comment = 0; } /* Check for a comment character or end of line */ if (*L != CommentStart && *L != '\0') { if (!IgnoreUnknown) { Error ("%s(%u): Trailing garbage", Filename, Line); } continue; } /* Apply the sign */ Val *= Sign; /* Define the symbol and the comment */ AddExtLabel (Val, SB_GetConstBuf (&Ident)); SetComment (Val, Comment); } /* Delete the string buffer contents */ SB_Done (&Ident); /* Close the include file ignoring errors (we were just reading). */ (void) fclose (F); }
wxString TagEntry::FormatComment() { if(m_isCommentForamtted) return m_formattedComment; m_isCommentForamtted = true; m_formattedComment.Clear(); // Send the plugins an event requesting tooltip for this tag if(IsMethod()) { if(IsConstructor()) m_formattedComment << wxT("<b>[Constructor]</b>\n"); else if(IsDestructor()) m_formattedComment << wxT("<b>[Destructor]</b>\n"); TagEntryPtr p(new TagEntry(*this)); m_formattedComment << wxT("<code>") << TagsManagerST::Get()->FormatFunction(p, FunctionFormat_WithVirtual | FunctionFormat_Arg_Per_Line) << wxT("</code>\n"); m_formattedComment.Replace(GetName(), wxT("<b>") + GetName() + wxT("</b>")); } else if(IsClass()) { m_formattedComment << wxT("<b>Kind:</b> "); m_formattedComment << GetKind() << "\n"; if(GetInheritsAsString().IsEmpty() == false) { m_formattedComment << wxT("<b>Inherits:</b> "); m_formattedComment << GetInheritsAsString() << wxT("\n"); } } else if(IsMacro() || IsTypedef() || IsContainer() || GetKind() == wxT("member") || GetKind() == wxT("variable")) { m_formattedComment << wxT("<b>Kind:</b> "); m_formattedComment << GetKind() << "\n"; m_formattedComment << wxT("<b>Match Pattern:</b> "); // Prettify the match pattern wxString matchPattern(GetPattern()); matchPattern.Trim().Trim(false); if(matchPattern.StartsWith(wxT("/^"))) { matchPattern.Replace(wxT("/^"), wxT("")); } if(matchPattern.EndsWith(wxT("$/"))) { matchPattern.Replace(wxT("$/"), wxT("")); } matchPattern.Replace(wxT("\t"), wxT(" ")); while(matchPattern.Replace(wxT(" "), wxT(" "))) { } matchPattern.Trim().Trim(false); // BUG#3082954: limit the size of the 'match pattern' to a reasonable size (200 chars) matchPattern = TagsManagerST::Get()->WrapLines(matchPattern); matchPattern.Replace(GetName(), wxT("<b>") + GetName() + wxT("</b>")); m_formattedComment << wxT("<code>") << matchPattern << wxT("</code>\n"); } // Add comment section wxString tagComment; if(!GetFile().IsEmpty()) { CommentParseResult comments; ::ParseComments(GetFile().mb_str(wxConvUTF8).data(), comments); // search for comment in the current line, the line above it and 2 above it // use the first match we got for(size_t i = 0; i < 3; i++) { wxString comment = comments.getCommentForLine(GetLine()-i); if(!comment.IsEmpty()) { SetComment(comment); break; } } } if(!GetComment().IsEmpty()) { wxString theComment; theComment = GetComment(); theComment = TagsManagerST::Get()->WrapLines(theComment); theComment.Trim(false); wxString tagComment = wxString::Format(wxT("%s\n"), theComment.c_str()); if(m_formattedComment.IsEmpty() == false) { m_formattedComment.Trim().Trim(false); m_formattedComment << wxT("\n<hr>"); } m_formattedComment << tagComment; } // Update all "doxy" comments and surround them with <green> tags static wxRegEx reDoxyParam("([@\\\\]{1}param)[ \t]+([_a-z][a-z0-9_]*)?", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyBrief("([@\\\\]{1}(brief|details))[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyThrow("([@\\\\]{1}(throw|throws))[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyReturn("([@\\\\]{1}(return|retval|returns))[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyToDo("([@\\\\]{1}todo)[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDoxyRemark("([@\\\\]{1}(remarks|remark))[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reDate("([@\\\\]{1}date)[ \t]*", wxRE_DEFAULT | wxRE_ICASE); static wxRegEx reFN("([@\\\\]{1}fn)[ \t]*", wxRE_DEFAULT | wxRE_ICASE); if(reDoxyParam.IsValid() && reDoxyParam.Matches(m_formattedComment)) { reDoxyParam.ReplaceAll(&m_formattedComment, "\n<b>Parameter</b>\n<i>\\2</i>"); } if(reDoxyBrief.IsValid() && reDoxyBrief.Matches(m_formattedComment)) { reDoxyBrief.ReplaceAll(&m_formattedComment, ""); } if(reDoxyThrow.IsValid() && reDoxyThrow.Matches(m_formattedComment)) { reDoxyThrow.ReplaceAll(&m_formattedComment, "\n<b>Throws</b>\n"); } if(reDoxyReturn.IsValid() && reDoxyReturn.Matches(m_formattedComment)) { reDoxyReturn.ReplaceAll(&m_formattedComment, "\n<b>Returns</b>\n"); } if(reDoxyToDo.IsValid() && reDoxyToDo.Matches(m_formattedComment)) { reDoxyToDo.ReplaceAll(&m_formattedComment, "\n<b>TODO</b>\n"); } if(reDoxyRemark.IsValid() && reDoxyRemark.Matches(m_formattedComment)) { reDoxyRemark.ReplaceAll(&m_formattedComment, "\n "); } if(reDate.IsValid() && reDate.Matches(m_formattedComment)) { reDate.ReplaceAll(&m_formattedComment, "<b>Date</b> "); } if(reFN.IsValid() && reFN.Matches(m_formattedComment)) { size_t fnStart, fnLen, fnEnd; if(reFN.GetMatch(&fnStart, &fnLen)) { fnEnd = m_formattedComment.find('\n', fnStart); if(fnEnd != wxString::npos) { // remove the string from fnStart -> fnEnd (including ther terminating \n) m_formattedComment.Remove(fnStart, (fnEnd - fnStart) + 1); } } } // if nothing to display skip this m_formattedComment.Trim().Trim(false); return m_formattedComment; }
DWORD CTag_Ape::_LoadApeTagV2(HANDLE hFile) { DWORD dwRet; DWORD dwWin32errorCode = ERROR_SUCCESS; // ID3TAGを探す SetFilePointer(hFile,-sizeof(ID3_TAG),NULL,FILE_END); if(!ReadFile(hFile,&m_id3tag,sizeof(m_id3tag),&dwRet,NULL) || (dwRet != sizeof(m_id3tag))) { dwWin32errorCode = GetLastError(); CloseHandle(hFile); return dwWin32errorCode; } BOOL bId3v1 = FALSE; // ID3TAGの正当性をチェック if((m_id3tag.TagHeader[0] == 'T') && (m_id3tag.TagHeader[1] == 'A') && (m_id3tag.TagHeader[2] == 'G')) { bId3v1 = TRUE; } DWORD rawFieldBytes = m_footer.size - ((m_footer.flags&APE_FLAG_TAG_HAS_HEADER)?sizeof(APE_TAG_FOOTER):0); char *pRawTag = (char *)malloc(rawFieldBytes); // ヘッダの先頭に移動 SetFilePointer(hFile,-m_footer.size-(bId3v1?128:0),NULL,FILE_END); // ヘッダをバッファに取り込む if(!ReadFile(hFile,pRawTag,rawFieldBytes,&dwRet,NULL) || (dwRet != rawFieldBytes)) { dwWin32errorCode = GetLastError(); CloseHandle(hFile); return dwWin32errorCode; } // 各フィールドの取り込み int rawTagOffset = 0; int i; for(i=0; i<m_footer.fields; i++) { if(rawFieldBytes < 4+4+1) { // バッファオーバーフロー free(pRawTag); CloseHandle(hFile); return -1; } // フィールドサイズ DWORD fieldValueSize = *(DWORD *)&pRawTag[rawTagOffset]; if(fieldValueSize > rawFieldBytes) { free(pRawTag); CloseHandle(hFile); return -1; } rawTagOffset += 4; // フィールドフラグ int fieldFlags = *(int *)&pRawTag[rawTagOffset]; rawTagOffset += 4; // フィールド名 char nameBuffer[256]; strncpy(nameBuffer,&pRawTag[rawTagOffset],min(sizeof(nameBuffer)-1,rawFieldBytes-rawTagOffset)); nameBuffer[255] = '\0'; rawTagOffset += strlen(nameBuffer) + 1; if((fieldFlags & APE_FLAG_TEXTINFO_MASK) != APE_FLAG_TEXTINFO_UTF8) { // UTF8文字列でないときはスキップ rawTagOffset += fieldValueSize; continue; } // 値 if(rawFieldBytes < rawTagOffset) { // バッファオーバーフロー free(pRawTag); CloseHandle(hFile); return -1; } char *pFieldBuffer = (char *)malloc(fieldValueSize+1); memcpy(pFieldBuffer,&pRawTag[rawTagOffset],fieldValueSize); pFieldBuffer[fieldValueSize] = '\0'; // UTF-8->SJIS CString str = Utf8toSjis(pFieldBuffer,fieldValueSize); rawTagOffset += fieldValueSize; SetComment(nameBuffer,str); TRACE("APE:%s:%s\n",nameBuffer,pFieldBuffer); free(pFieldBuffer); } free(pRawTag); return ERROR_SUCCESS; }
BOOL IniFile::ReadFileA() { USES_CONVERSION; FILE *f = fopen(T2A(m_szPath), "rt"); if (!f) return FALSE; char szLine[MAX_FGETS_LINE]; char szKey[MAX_KEY]; LPSTR lpszSub, lpszSub2; szKey[0] = '\0'; while (fgets(szLine, MAX_FGETS_LINE-1, f)) { if (szLine[strlen(szLine) - 1] == '\r') szLine[strlen(szLine) - 1] = '\0'; if (szLine[strlen(szLine) - 1] == '\n') szLine[strlen(szLine) - 1] = '\0'; if (strlen(szLine)) { if (!isprint(szLine[0])) { fclose(f); return FALSE; } switch (szLine[0]) { case '[': lpszSub = strchr(szLine, ']'); if (lpszSub) { lpszSub[0] = '\0'; strcpy(szKey, szLine+1); AddKeyName(A2T(szKey)); } break; case ';': case '#': SetComment(A2T(szLine+1)); break; default: lpszSub = strchr(szLine, '='); if (lpszSub) { lpszSub2 = lpszSub; if (lpszSub2[0] == ' ') { while (lpszSub2[0] == ' ') lpszSub2--; lpszSub2++; } lpszSub2[0] = '\0'; while (lpszSub[0] == ' ') lpszSub++; lpszSub++; SetValueS(A2T(szKey), A2T(szLine), A2T(lpszSub)); } break; } } } fclose(f); return m_dqKeys.empty() ? FALSE : TRUE; }
// // further: \r\n까지 검색하여 길이 구해 line 버퍼수 결정 // BOOL IniFile::ReadFileW() { USES_CONVERSION; FILE *f = _tfopen(m_szPath, _T("rb")); if (!f) return FALSE; LPWSTR lpwszLine; WCHAR wszLine[MAX_FGETS_LINE] = {0}; fread(wszLine, 2, 1, f); if (wszLine[0] != 0xFEFF) { fclose(f); return FALSE; } size_t nLen; size_t nRead; WCHAR szKey[MAX_KEY]; LPWSTR lpwszSub, lpwszSub2; szKey[0] = L'\0'; while (1) { nLen = 0; while (1) { nRead = fread(wszLine+nLen, sizeof(WCHAR), 1, f); if (nRead > 0) nLen++; if (nLen >= 1 && wszLine[nLen-1] == L'\n') { wszLine[nLen-1] = L'\0'; nLen--; if (nLen >= 1 && wszLine[nLen-1] == L'\r') { wszLine[nLen-1] = L'\0'; nLen--; } break; } if (nRead <= 0) break; } lpwszLine = (LPWSTR)wszLine; if (wcslen(lpwszLine)) { switch (lpwszLine[0]) { case L'[': lpwszSub = wcsrchr(lpwszLine, L']'); // ex) [c:\[123]] if (lpwszSub) { lpwszSub[0] = _T('\0'); wcscpy(szKey, lpwszLine+1); AddKeyName(W2T(szKey)); } break; case L';': case L'#': SetComment(W2T(lpwszLine+1)); break; default: lpwszSub = wcschr(lpwszLine, L'='); if (lpwszSub) { lpwszSub2 = lpwszSub; if (lpwszSub2[0] == L' ') { while (lpwszSub2[0] == L' ') lpwszSub2--; lpwszSub2++; } lpwszSub2[0] = L'\0'; while (lpwszSub[0] == L' ') lpwszSub++; lpwszSub++; SetValueS(W2T(szKey), W2T(lpwszLine), W2T(lpwszSub)); } break; } } if (nRead <= 0) break; } fclose(f); return m_dqKeys.empty() ? FALSE : TRUE; }
void ami_file_save(int type, char *fname, struct Window *win, struct hlcache_handle *object, struct hlcache_handle *favicon, struct browser_window *bw) { BPTR lock, fh; const char *source_data; ULONG source_size; struct bitmap *bm; ami_update_pointer(win, GUI_POINTER_WAIT); if(ami_download_check_overwrite(fname, win, 0)) { switch(type) { case AMINS_SAVE_SOURCE: if((source_data = content_get_source_data(object, &source_size))) { BPTR fh; if(fh = FOpen(fname, MODE_NEWFILE,0)) { FWrite(fh, source_data, 1, source_size); FClose(fh); } } break; case AMINS_SAVE_TEXT: save_as_text(object, fname); break; case AMINS_SAVE_COMPLETE: if(lock = CreateDir(fname)) { UnLock(lock); save_complete(object, fname, ami_file_set_type); amiga_icon_superimpose_favicon(fname, favicon, NULL); } break; case AMINS_SAVE_PDF: #ifdef WITH_PDF_EXPORT if(save_as_pdf(object, fname)) amiga_icon_superimpose_favicon(fname, favicon, "pdf"); #endif break; case AMINS_SAVE_IFF: if((bm = content_get_bitmap(object))) { bm->url = (char *)nsurl_access(hlcache_handle_get_url(object)); bm->title = (char *)content_get_title(object); bitmap_save(bm, fname, 0); } #ifdef WITH_NS_SVG else if(ami_mime_compare(object, "svg") == true) { ami_save_svg(object, fname); } #endif break; case AMINS_SAVE_SELECTION: if(source_data = browser_window_get_selection(bw)) { if(fh = FOpen(fname, MODE_NEWFILE,0)) { FWrite(fh, source_data, 1, strlen(source_data)); FClose(fh); } free((void *)source_data); } break; } if(object) SetComment(fname, nsurl_access(hlcache_handle_get_url(object))); } ami_update_pointer(win, GUI_POINTER_DEFAULT); }
static void RangeSection (void) /* Parse a range section */ { static const IdentTok RangeDefs[] = { { "COMMENT", INFOTOK_COMMENT }, { "END", INFOTOK_END }, { "NAME", INFOTOK_NAME }, { "START", INFOTOK_START }, { "TYPE", INFOTOK_TYPE }, }; static const IdentTok TypeDefs[] = { { "ADDRTABLE", INFOTOK_ADDRTAB }, { "BYTETABLE", INFOTOK_BYTETAB }, { "CODE", INFOTOK_CODE }, { "DBYTETABLE", INFOTOK_DBYTETAB }, { "DWORDTABLE", INFOTOK_DWORDTAB }, { "RTSTABLE", INFOTOK_RTSTAB }, { "SKIP", INFOTOK_SKIP }, { "TEXTTABLE", INFOTOK_TEXTTAB }, { "WORDTABLE", INFOTOK_WORDTAB }, }; /* Which values did we get? */ enum { tNone = 0x00, tStart = 0x01, tEnd = 0x02, tType = 0x04, tName = 0x08, tComment= 0x10, tNeeded = (tStart | tEnd | tType) }; unsigned Attributes = tNone; /* Locals - initialize to avoid gcc warnings */ unsigned Start = 0; unsigned End = 0; unsigned char Type = 0; char* Name = 0; char* Comment = 0; unsigned MemberSize = 0; /* Skip the token */ InfoNextTok (); /* Expect the opening curly brace */ InfoConsumeLCurly (); /* Look for section tokens */ while (InfoTok != INFOTOK_RCURLY) { /* Convert to special token */ InfoSpecialToken (RangeDefs, ENTRY_COUNT (RangeDefs), "Range attribute"); /* Look at the token */ switch (InfoTok) { case INFOTOK_COMMENT: AddAttr ("COMMENT", &Attributes, tComment); InfoNextTok (); InfoAssureStr (); if (InfoSVal[0] == '\0') { InfoError ("Comment may not be empty"); } Comment = xstrdup (InfoSVal); Attributes |= tComment; InfoNextTok (); break; case INFOTOK_END: AddAttr ("END", &Attributes, tEnd); InfoNextTok (); InfoAssureInt (); InfoRangeCheck (0x0000, 0xFFFF); End = InfoIVal; InfoNextTok (); break; case INFOTOK_NAME: AddAttr ("NAME", &Attributes, tName); InfoNextTok (); InfoAssureStr (); if (InfoSVal[0] == '\0') { InfoError ("Name may not be empty"); } Name = xstrdup (InfoSVal); Attributes |= tName; InfoNextTok (); break; case INFOTOK_START: AddAttr ("START", &Attributes, tStart); InfoNextTok (); InfoAssureInt (); InfoRangeCheck (0x0000, 0xFFFF); Start = InfoIVal; InfoNextTok (); break; case INFOTOK_TYPE: AddAttr ("TYPE", &Attributes, tType); InfoNextTok (); InfoSpecialToken (TypeDefs, ENTRY_COUNT (TypeDefs), "TYPE"); switch (InfoTok) { case INFOTOK_ADDRTAB: Type = atAddrTab; MemberSize = 2; break; case INFOTOK_BYTETAB: Type = atByteTab; MemberSize = 1; break; case INFOTOK_CODE: Type = atCode; MemberSize = 1; break; case INFOTOK_DBYTETAB: Type = atDByteTab; MemberSize = 2; break; case INFOTOK_DWORDTAB: Type = atDWordTab; MemberSize = 4; break; case INFOTOK_RTSTAB: Type = atRtsTab; MemberSize = 2; break; case INFOTOK_SKIP: Type = atSkip; MemberSize = 1; break; case INFOTOK_TEXTTAB: Type = atTextTab; MemberSize = 1; break; case INFOTOK_WORDTAB: Type = atWordTab; MemberSize = 2; break; } InfoNextTok (); break; default: Internal ("Unexpected token: %u", InfoTok); } /* Directive is followed by a semicolon */ InfoConsumeSemi (); } /* Did we get all required values? */ if ((Attributes & tNeeded) != tNeeded) { InfoError ("Required values missing from this section"); } /* Start must be less than end */ if (Start > End) { InfoError ("Start value must not be greater than end value"); } /* Check the granularity */ if (((End - Start + 1) % MemberSize) != 0) { InfoError ("Type of range needs a granularity of %u", MemberSize); } /* Set the range */ MarkRange (Start, End, Type); /* Do we have a label? */ if (Attributes & tName) { /* Define a label for the table */ AddExtLabel (Start, Name); /* Set the comment if we have one */ if (Comment) { SetComment (Start, Comment); } /* Delete name and comment */ xfree (Name); xfree (Comment); } /* Consume the closing brace */ InfoConsumeRCurly (); }
static void LabelSection (void) /* Parse a label section */ { static const IdentTok LabelDefs[] = { { "COMMENT", INFOTOK_COMMENT }, { "ADDR", INFOTOK_ADDR }, { "NAME", INFOTOK_NAME }, { "SIZE", INFOTOK_SIZE }, }; /* Locals - initialize to avoid gcc warnings */ char* Name = 0; char* Comment = 0; long Value = -1; long Size = -1; /* Skip the token */ InfoNextTok (); /* Expect the opening curly brace */ InfoConsumeLCurly (); /* Look for section tokens */ while (InfoTok != INFOTOK_RCURLY) { /* Convert to special token */ InfoSpecialToken (LabelDefs, ENTRY_COUNT (LabelDefs), "Label attribute"); /* Look at the token */ switch (InfoTok) { case INFOTOK_ADDR: InfoNextTok (); if (Value >= 0) { InfoError ("Value already given"); } InfoAssureInt (); InfoRangeCheck (0, 0xFFFF); Value = InfoIVal; InfoNextTok (); break; case INFOTOK_COMMENT: InfoNextTok (); if (Comment) { InfoError ("Comment already given"); } InfoAssureStr (); if (InfoSVal[0] == '\0') { InfoError ("Comment may not be empty"); } Comment = xstrdup (InfoSVal); InfoNextTok (); break; case INFOTOK_NAME: InfoNextTok (); if (Name) { InfoError ("Name already given"); } InfoAssureStr (); Name = xstrdup (InfoSVal); InfoNextTok (); break; case INFOTOK_SIZE: InfoNextTok (); if (Size >= 0) { InfoError ("Size already given"); } InfoAssureInt (); InfoRangeCheck (1, 0x10000); Size = InfoIVal; InfoNextTok (); break; default: Internal ("Unexpected token: %u", InfoTok); } /* Directive is followed by a semicolon */ InfoConsumeSemi (); } /* Did we get the necessary data */ if (Name == 0) { InfoError ("Label name is missing"); } if (Name[0] == '\0' && Size > 1) { InfoError ("Unnamed labels must not have a size > 1"); } if (Value < 0) { InfoError ("Label value is missing"); } if (Size < 0) { /* Use default */ Size = 1; } if (Value + Size > 0x10000) { InfoError ("Invalid size (address out of range)"); } if (HaveLabel ((unsigned) Value)) { InfoError ("Label for address $%04lX already defined", Value); } /* Define the label(s) */ if (Name[0] == '\0') { /* Size has already beed checked */ AddUnnamedLabel (Value); } else { AddExtLabelRange ((unsigned) Value, Name, Size); } /* Define the comment */ if (Comment) { SetComment (Value, Comment); } /* Delete the dynamically allocated memory for Name and Comment */ xfree (Name); xfree (Comment); /* Consume the closing brace */ InfoConsumeRCurly (); }
void CComment::Init(LPCTSTR comment) { m_next = NULL; m_comment = NULL; SetComment(comment); }