{"id":280,"date":"2007-06-23T09:22:34","date_gmt":"2007-06-23T07:22:34","guid":{"rendered":"https:\/\/alax.info\/blog\/280"},"modified":"2007-06-23T09:27:19","modified_gmt":"2007-06-23T07:27:19","slug":"howto-use-replace-in-files-to-automatically-convert-oui-list-into-cc-header-file","status":"publish","type":"post","link":"https:\/\/alax.info\/blog\/280","title":{"rendered":"HOWTO: Use Replace In Files to automatically convert OUI list into C\/C++ header file"},"content":{"rendered":"<p><a href=\"http:\/\/standards.ieee.org\/regauth\/oui\/index.shtml\">IEEE OUI and Company_id Assignments<\/a> is a list of manufacturers and corresponding codes which are used in MAC addresses and protocol identifiers:<\/p>\n<blockquote><p>The three-octet OUI can be used to generate Universal LAN MAC addresses and Protocol Identifiers per ANSI\/IEEE Std 802 for use in Local and Metropolitan Area Network applications.<\/p>\n<p>If your firm manufactures or plans to manufacture products using ISO\/IEC 8802 standards, you should apply to IEEE for your firm&#8217;s OUI. The Institute of Electrical and Electronics Engineers, Inc. has been designated by the ISO Council to act as the registration authority for the implementation of International Standards in the ISO\/IEC 8802 series. This is the one world-wide source of registered OUIs. <\/p><\/blockquote>\n<p>The full list is located at <a href=\"http:\/\/standards.ieee.org\/regauth\/oui\/oui.txt\">http:\/\/standards.ieee.org\/regauth\/oui\/oui.txt<\/a>.<\/p>\n<p><a href=\"https:\/\/alax.info\/blog\/category\/utilities\/replace-in-files\/\">Alax.Info Replace In Files<\/a> can be used to process the file to create a C\/C++ compatible header file of the following format:<\/p>\n<blockquote><p><strong>{ 0x00, 0x11, 0xDF, &#8220;Arecont Systems&#8221; },<\/strong><br \/>\n\/\/0011DF     (base 16)\t\tArecont Systems<br \/>\n\/\/\t\t\t\t177 N Church Ave suite 1010<br \/>\n\/\/\t\t\t\tTucson Arizona 85701<br \/>\n\/\/\t\t\t\tUNITED STATES<\/p>\n<p><strong>{ 0x00, 0x11, 0xE0, &#8220;U-MEDIA Communications, Inc.&#8221; },<\/strong><br \/>\n\/\/0011E0     (base 16)\t\tU-MEDIA Communications, Inc.<br \/>\n\/\/\t\t\t\t9F, No.1, Jin-Shan 7th St.<br \/>\n\/\/\t\t\t\tHsinchu  300<br \/>\n\/\/\t\t\t\tTAIWAN, REPUBLIC OF CHINA<\/p>\n<p><strong>{ 0x00, 0x11, 0xE1, &#8220;BEKO Electronics Co.&#8221; },<\/strong><br \/>\n\/\/0011E1     (base 16)\t\tBEKO Electronics Co.<br \/>\n\/\/\t\t\t\tBeylikduzu Mevkii Buyukcekmece<br \/>\n\/\/\t\t\t\tIstanbul  34901<br \/>\n\/\/\t\t\t\tTURKEY\n<\/p><\/blockquote>\n<p><!--more--><br \/>\nBelow is the JavaScript file contents which perform the processing being invoked by console script host:<\/p>\n<p><code>WScript.Echo(\"Script Name: \" + WScript.ScriptFullName);<br \/>\nBasePath = WScript.ScriptFullName.replace(\/^(.+)\\\\[^\\\\]+$\/i, \"$1\");<br \/>\nFileSystemObject = WScript.CreateObject(\"Scripting.FileSystemObject\");<br \/>\nWScript.Echo(\"Base Path: \" + BasePath);<\/code><\/p>\n<p><code>TextFile = FileSystemObject.OpenTextFile(BasePath + \"\\\\oui.txt\", 1, false, -2); \/\/ ForReading, TristateUseDefault<br \/>\nMemoryText = WScript.CreateObject(\"AlaxInfo.ReplaceInFiles.MemoryText\");<br \/>\nMemoryText.Text = TextFile.ReadAll();<\/code><\/p>\n<p><code>ReplaceText = WScript.CreateObject(\"AlaxInfo.ReplaceInFiles.ReplaceText\");<br \/>\nReplaceText.GlobalMatch = true;<br \/>\nReplaceText.RegularExpressions = true;<br \/>\nReplaceText.IgnoreCase = true;<br \/>\nReplaceText.Multiline = true;<br \/>\nReplaceText.FindPatterns =<br \/>\n  \"\\\"\" + \"^{[0-9A-F][0-9A-F]}\\\\-{[0-9A-F][0-9A-F]}\\\\-{[0-9A-F][0-9A-F]}\\\\b+\\\\(hex\\\\)\\\\b+{.+?}$\" + \"\\\"\" + \",\" +<br \/>\n  \"\\\"\" + \"^{[^\\\\{].+}$\" + \"\\\"\" + \",\" +<br \/>\n  \"\";<br \/>\nReplaceText.ReplacePatterns =<br \/>\n  \"\\\"\" + \"{ 0x\\\\1, 0x\\\\2, 0x\\\\3, \\\"\\\"\\\\4\\\"\\\" },\" + \"\\\"\" + \",\" +<br \/>\n  \"\\\"\" + \"\/\/\\\\1\" + \"\\\"\" + \",\" +<br \/>\n  \"\";<br \/>\nReplaceText.Replace(MemoryText);<\/code><\/p>\n<p><code>HeaderFile = FileSystemObject.CreateTextFile(BasePath + \"\\\\oui.txt.h\", true, false);<br \/>\nHeaderFile.Write(MemoryText.Text);<\/code><\/p>\n<p><a href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2007\/06\/oui.js\">The script<\/a> converts <b>oui.txt<\/b> into <b><a href=\"https:\/\/alax.info\/blog\/wp-content\/uploads\/2007\/06\/ouitxth.zip\">oui.txt.h<\/a><\/b> file which can be then included into source code as follows:<\/p>\n<p><code>static const struct { BYTE n0, n1, n2; LPCSTR pszName; } g_pMap[] =<br \/>\n{<br \/>\n#include \"oui.txt.h\"<br \/>\n};<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>IEEE OUI and Company_id Assignments is a list of manufacturers and corresponding codes which are used in MAC addresses and protocol identifiers: The three-octet OUI can be used to generate Universal LAN MAC addresses and Protocol Identifiers per ANSI\/IEEE Std 802 for use in Local and Metropolitan Area Network applications. If your firm manufactures or&hellip; <\/p>\n<p><a class=\"moretag\" href=\"https:\/\/alax.info\/blog\/280\">Read the full article<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,18,21],"tags":[],"class_list":["post-280","post","type-post","status-publish","format-standard","hentry","category-atl","category-replace-in-files","category-seriously"],"_links":{"self":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/comments?post=280"}],"version-history":[{"count":0,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/posts\/280\/revisions"}],"wp:attachment":[{"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/media?parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/categories?post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alax.info\/blog\/wp-json\/wp\/v2\/tags?post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}